|
|
|
@ -68,6 +68,7 @@ bool last_reset_ap_check = false; |
|
|
|
|
looper sched; |
|
|
|
|
bool write_state = false; |
|
|
|
|
uint32_t last_usage = millis(); |
|
|
|
|
bool broadcast_send = false; |
|
|
|
|
|
|
|
|
|
MIDI_CREATE_INSTANCE(HardwareSerial, midi1, MIDI1); |
|
|
|
|
|
|
|
|
@ -199,7 +200,7 @@ void setup() |
|
|
|
|
//sched.addJob(show_midi_state, KRATE_STATE);
|
|
|
|
|
|
|
|
|
|
listDir(SPIFFS, "/", 1); |
|
|
|
|
//read_midistate(1);
|
|
|
|
|
read_midistate(1); |
|
|
|
|
show_midi_state(); |
|
|
|
|
|
|
|
|
|
DEBUG_MSG("<LOOP>\n"); |
|
|
|
@ -220,7 +221,7 @@ void loop() |
|
|
|
|
if (clientIP != tmpIP) |
|
|
|
|
{ |
|
|
|
|
clientIP = tmpIP; |
|
|
|
|
DEBUG_MSG("New connection from: %d.%d.%d.%d\n", clientIP[0],clientIP[1],clientIP[2],clientIP[3]); |
|
|
|
|
DEBUG_MSG("New connection from: %d.%d.%d.%d\n", clientIP[0], clientIP[1], clientIP[2], clientIP[3]); |
|
|
|
|
} |
|
|
|
|
// Check if there are any OSC packets to handle
|
|
|
|
|
udp.read(buffer, size); |
|
|
|
@ -351,6 +352,8 @@ void change_midi_state(uint8_t midichannel, uint8_t cc, uint8_t value) |
|
|
|
|
{ |
|
|
|
|
midistate[(midichannel - 1) * 128 + cc - 1] = int8_t(value); |
|
|
|
|
write_state = true; |
|
|
|
|
lcd.setCursor(LCD_COL - 1, LCD_ROW - 1); |
|
|
|
|
lcd.print("*"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -403,6 +406,8 @@ void write_midistate(uint8_t setup_number) |
|
|
|
|
{ |
|
|
|
|
DEBUG_MSG("Write MIDI state\n"); |
|
|
|
|
|
|
|
|
|
uint32_t t0 = millis(); |
|
|
|
|
|
|
|
|
|
for (uint8_t m = 0; m < 16; m++) |
|
|
|
|
{ |
|
|
|
|
for (uint8_t c = 0; c < 128; c++) |
|
|
|
@ -449,6 +454,13 @@ void write_midistate(uint8_t setup_number) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lcd.setCursor(LCD_COL - 1, LCD_ROW - 1); |
|
|
|
|
lcd.print(" "); |
|
|
|
|
|
|
|
|
|
uint32_t t1 = millis(); |
|
|
|
|
|
|
|
|
|
DEBUG_MSG("T1-T0=%d\n", t1 - t0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void read_midistate(uint8_t setup_number) |
|
|
|
@ -506,7 +518,6 @@ void read_midistate(uint8_t setup_number) |
|
|
|
|
int8_t val = cc.read(); |
|
|
|
|
DEBUG_MSG(" MIDI-Channel %d CC#%d = %d\n", midi_channel + 1, midi_cc + 1, val); |
|
|
|
|
midistate[midi_channel * 128 + midi_cc] = val; |
|
|
|
|
MidiCCToOSC(midi_channel + 1, midi_cc + 1, val); |
|
|
|
|
cc.close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -520,6 +531,27 @@ void read_midistate(uint8_t setup_number) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void broadcast_midistate(void) |
|
|
|
|
{ |
|
|
|
|
uint8_t m, c; |
|
|
|
|
|
|
|
|
|
DEBUG_MSG("Broadcast MIDI state:\n"); |
|
|
|
|
|
|
|
|
|
for (m = 0; m < 16; m++) |
|
|
|
|
{ |
|
|
|
|
DEBUG_MSG("MIDI-Channel %2d\n", m + 1); |
|
|
|
|
for (c = 0; c < 128; c++) |
|
|
|
|
{ |
|
|
|
|
if (midistate[m * 128 + c] >= 0) |
|
|
|
|
{ |
|
|
|
|
DEBUG_MSG("\tCC: %3d = %3d\n", c + 1, midistate[m * 128 + c]); |
|
|
|
|
MidiCCToOSC(m + 1, c + 1, midistate[m * 128 + c]); |
|
|
|
|
MIDI1.sendControlChange(c + 1, midistate[m * 128 + c], m + 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void check_reset_ap_data(void) |
|
|
|
|
{ |
|
|
|
|
if (digitalRead(AP_DATA_RESET_PIN) == HIGH && last_reset_ap_check == true) |
|
|
|
@ -550,8 +582,11 @@ void check_reset_ap_data(void) |
|
|
|
|
|
|
|
|
|
void ping(OSCMessage & msg, int offset) |
|
|
|
|
{ |
|
|
|
|
if (clientIP) |
|
|
|
|
read_midistate(1); |
|
|
|
|
if (clientIP && broadcast_send == false) |
|
|
|
|
{ |
|
|
|
|
broadcast_send = true; |
|
|
|
|
broadcast_midistate(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void listDir(fs::FS & fs, const char * dirname, uint8_t levels) { |
|
|
|
|