faux_vox / bank_types.h

/* 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.
// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1212169107
// '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;
  char messages[MAX_STATES][MIDI_MESSAGE_LENGTH];

} switch_t;

typedef struct {
  switch_t switches[MAX_SWITCHES];
} 
switches_t;

typedef struct {
  switches_t bank[MAX_BANKS];
} 
banks_t;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.