faux_vox / bank_types.h

Full commit
/* Programmable switches
 Bank0/Bank1 selects changes between two switch banks for the other 4 switches
 So really 8 programmable switches on the board
 Each switch has two possible behaviours
 Momentary operation (provide a code for when pressed and when released)
 Toggle operation (provide a code for each time pressed/ released)
 Codes can be any valid MIDI message, except SysEx messages
 Messages are either 1, 2 or 3 bytes long
 First byte starts with a 1 in the MSB, data bytes have 0 in the MSB
 After first byte, use a 1 in the MSB as a 'stop' bit for the word.
 If the first byte starts with a 0 in the MSB, the switch function is disabled.
 All messages are stored in a 3 byte array, with FF's used as terminators for 'missing' bytes.
 Switch structure {
 int toggle_not_immediate; // 1= toggle 0=immediate
 byte [3] state0_message = { 00, 0xFF, 0xFF };  // 0 in first byte MSB is disabled
 byte [3] state1_message = { 00, 0xFF, 0xFF };  // 1 in second or third byte MSB indicates byte is not sent (for shorter messages)
 In toggle mode: After a switch is pressed, send the next state message. Nothing is sent on release.
 In immediate mode: After a switch is pressed, send the state1 message. Send the state0 message on release.
 Switches structure {
 switch structure * [4] switch; 
 Bank structure {
 switches * [2] bank;

// Types etc need to be in a seperate header file so they can be used in other functions because of the way the IDE generates function prototypes and orders the derived code.
// 'You need to put type definition inside a separate header file, as the function prototypes that are generated by the IDE are inserted above the typedef
// (but below pre-processor directives like #include).  This header can be another tab in your sketch; use the right facing arrow in the upper right of the IDE.'

const int TOGGLE = 1;
const int IMMEDIATE = 0;
const int LED_OFFSET = 2;
const int MAX_BANKS = 2;
const int MAX_SWITCHES = 4;
const int MAX_STATES = 2;
const int MIDI_MESSAGE_LENGTH = 3;
const int MIDI_DEVICE_ID = 0x78;

const int MIDI_BAUD_RATE=31250;
const int FASTEST_BAUD_RATE=115200;

const int MIDI_SYSEX_LENGTH = 5;

const int ERROR_LED = 6;

enum {OFF=0, INFO, DEBUG, TRACE} debug_levels_e;
typedef enum {STATE0=0, STATE1=1} switch_state_e;

const int DEBUG_LEVEL = OFF;
typedef struct {
  int toggle_not_immediate;
  switch_state_e state;

} switch_t;

typedef struct {
  switch_t switches[MAX_SWITCHES];

typedef struct {
  switches_t bank[MAX_BANKS];