to implement MSG_FW_VER add this to compcontrol.c:
- Code: Select all
case MSG_FW_VER:
{
// 2bytes 2bytes <variable>
// [ osID ] [ osVER ] [ os string ]
// os string should not be longer than 32 chars
{
//uint16_t* ptr = reinterpret_cast<uint16_t*>(&(tx_msg_buff[3]));
uint16_t* ptr = (uint16_t*)(tx_msg_buff+3);
*ptr = 101; // osID
++ptr;
*ptr = 101; // version 1.01
}
// this packet is 4 + 4 + 6 bytes = 14
unsigned char* ptr = (tx_msg_buff+(3+4));
//*ptr = { 'd', 'i', 'a', 'g', 'O', 'S' };
for (uint8_t i = 0; i < 6; i++)
{
ptr[i] = "diagOS"[i];
}
tx_msg_buff[0] = MSG_FW_VER;
tx_msg_buff[1] = 0;
tx_msg_buff[2] = 10;
tx_msg_buff[3+10] = calc_CRC8(tx_msg_buff, 3+10);
send_msg(tx_msg_buff, 4+10);
} break;
change "diagOS" to whatever you like (it will be shown in c0nb0x in computer control mode
change also the version - 100 will be shown as "v1.00" in c0nb0x
change the OSID which is the most important thing to c0nb0x, as it doesn't care about the string
this whould be unique, see below
in compcontrol.h
- Code: Select all
enum SERIALMSG
{
MSG_UNUSED = 0, // 0x00 c0nb0x specific, not used by adafruit or sokkos
MSG_PING = 1, // 0x01
MSG_PATT_WR = 16, // 0x10
MSG_PATT_RD = 17, // 0x11
MSG_PATT_LOAD = 18, // 0x12
MSG_PATT_GET = 19, // 0x13
MSG_PATT_PLAY = 20, // 0x14
MSG_PATT_STOP = 21, // 0x15
MSG_PATT = 25, // 0x19
MSG_TRACK_WR = 32, // 0x20
MSG_TRACK_RD = 33, // 0x21
MSG_TRACK_LOAD = 34, // 0x22
MSG_TRACK_GET = 35, // 0x23
MSG_TRACK = 41, // 0x29
MSG_SEQ_START = 48, // 0x30
MSG_SEQ_STOP = 49, // 0x31
MSG_SEQ_GET = 50, // 0x32
MSG_SYNC_SET = 51, // 0x33
MSG_TEMPO_GET = 64, // 0x40
MSG_TEMPO_SET = 65, // 0x41
MSG_TEMPO = 66, // 0x42
MSG_STATUS = 128, // 0x80
// /---------------------------
// extended messages go here (after 128)
// ---------------------------/
MSG_FW_VER = 129, // 0x81
MSG_ISSUPP = 130, // 0x82 "is MSG supported"
MSG_DIAG = 131, // 0x83 all diagnostic stuff will be sub-messages, so i don't waste the numbers here
};
enum STATREPLY
{
STAT_BAD = 0,
STAT_OK = 1,
// ------------------
// EXTENDED go here after 1
// ------------------
STAT_NOTSUP = 3, // "not supported request/feature"
STAT_SUPP = 4, // "supported"
};
OSID: this is mostly important if c0nb0x must have some unique behaviour depending on a given firmware
here are examples:
- if pattern format is different than the stock format (for example n0nx0x which uses 21 bytes, and sokkos 2 which has triplet)
- if there are unique messages for that OS (for example diagOS has a special message designed for reporting buttons and other stuff)
here are the OSIDs currently known to c0nb0x:
- Code: Select all
enum X0X_OSID
{
OSID_UNKNOWN = 0, // unknown, adafruit v1.05 compatible
OSID_ADA105 = 1,
OSID_N0NX0XBETA = 13,
OSID_DIAGFW = 101, // hehe
};
note: n0nx0x itself doesn't implement these new messages (since i wrote it long before c0nb0x) but c0nb0x autodetects it via patternsize=21
so, if you want to implement MSG_FW_VER - pitck a value which isn't already in this list
now, for actual special behaviour of c0nb0x..
your request about showing a few values and being able to automatically update their values (in the app) and also change them via the app.. this is a common thing to digital instruments
you know you can implement these as MIDI CC probably
but besides that, i still see a point about making it exclusive to the app
so here's what i think
first, when c0nb0x connects to the x0x - it already performs a few tests to figure out what the firmware is, and what can it do..
that's where MSG_ISSUPP comes in, with it, c0nb0x can ask the OS if it supports this or that
currently, it hasn't been implemented yet, but the packet structure is known
so, the OS would be asked if it supports "PARAMS" and will return either a status STAT_BAD or a special message MSG_PARAMS with a number - the number of parameters it has
this is so that c0nb0x can (for example) make a list of these params later
now, when any of those params are changed from the OS - a message will have to be sent - MSG_PARAM_CHANGED holding the param index and it's value
i think the param value would be held in an uint8_t
i'm also thinking there should be a way to make some params have a specific number of options, it gets a bit complicated here but don't worry now
see, this then won't be exclusive to your OS, but a standard functionality for any OS which implements the mechanism, and thus, you would be able to change the number of params and their meaning from your OS without having to modify c0nb0x every time
i don't want to delay v1.00 because of these things, as i mentioned, i want to release a stable basic version ASAP and then i'll clean up the code a bit and probably revisit diagOS, and these new messages and features