Commit 0c7a45ba authored by Jacob Vosmaer's avatar Jacob Vosmaer

Rename midi status sentinel

parent d9c518cf
......@@ -29,11 +29,11 @@ midi_set_channel(uint8_t channel)
midi_channel = channel & 0xf;
}
uint8_t status = MIDI_NO_STATUS;
uint8_t status = MIDI_NUM_STATUSES;
uint16_t data = 0;
static uint8_t parsed_len = 0;
const uint8_t statuses[MIDI_NO_STATUS] = {
const uint8_t statuses[MIDI_NUM_STATUSES] = {
0b1001, // note on
0b1000, // note off
};
......@@ -59,7 +59,7 @@ uint16_t midi_data(void)
uint8_t
midi_available(void)
{
return (status < MIDI_NO_STATUS) && (data_len(status) == parsed_len);
return (status < MIDI_NUM_STATUSES) && (data_len(status) == parsed_len);
}
void
......@@ -70,19 +70,19 @@ midi_parse(uint8_t midi_byte)
return;
}
for (uint8_t i = 0; i < MIDI_NO_STATUS; i++) {
for (uint8_t i = 0; i < MIDI_NUM_STATUSES; i++) {
if (midi_byte == ((statuses[i] << 4) | midi_channel)) {
status = i;
return;
}
}
if (status == MIDI_NO_STATUS) {
if (status == MIDI_NUM_STATUSES) {
return;
}
if (midi_byte & 0x80) {
status = MIDI_NO_STATUS;
status = MIDI_NUM_STATUSES;
data = 0;
return;
}
......
......@@ -6,7 +6,7 @@
enum _statuses {
MIDI_NOTE_ON,
MIDI_NOTE_OFF,
MIDI_NO_STATUS,
MIDI_NUM_STATUSES,
};
uint8_t midi_read();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment