diff --git a/MicroDexed.ino b/MicroDexed.ino index c972528..df6163b 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -37,7 +37,7 @@ #ifndef MASTER_KEY_MIDI // selecting sounds by encoder and display #include #include -#include +//#include #endif #ifndef MASTER_KEY_MIDI @@ -45,7 +45,7 @@ #define LCD_I2C_ADDRESS 0x3f #define LCD_CHARS 20 #define LCD_LINES 4 -LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); +//LiquidCrystalPlus_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce #endif @@ -70,7 +70,7 @@ bool master_key_enabled = false; #endif #ifdef SHOW_CPU_LOAD_MSEC -IntervalTimer sched_show_cpu_usage; +elapsedMillis cpu_mem_millis; #endif #ifdef MIDI_DEVICE @@ -93,14 +93,14 @@ void setup() Serial.begin(SERIAL_SPEED); #ifndef MASTER_KEY_MIDI - lcd.init(); - lcd.blink_off(); - lcd.cursor_off(); - lcd.backlight(); - lcd.noAutoscroll(); - lcd.clear(); - lcd.display(); - lcd.show(0, 0, 20, "MicroDexed"); + // lcd.init(); + // lcd.blink_off(); + // lcd.cursor_off(); + // lcd.backlight(); + // lcd.noAutoscroll(); + // lcd.clear(); + // lcd.display(); + // lcd.show(0, 0, 20, "MicroDexed"); enc1.write(INITIAL_ENC1_VALUE); #endif @@ -141,11 +141,10 @@ void setup() // Initialize processor and memory measurements AudioProcessorUsageMaxReset(); AudioMemoryUsageMaxReset(); - sched_show_cpu_usage.begin(show_cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000); #endif // load default SYSEX data - load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); + //load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); #ifdef DEBUG show_patch(); @@ -163,6 +162,7 @@ void setup() Serial.println(F("")); #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) show_cpu_and_mem_usage(); + cpu_mem_millis=0; #endif #ifdef TEST_NOTE @@ -186,6 +186,14 @@ void loop() while (42 == 42) // DON'T PANIC! { +#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) + if (cpu_mem_millis > SHOW_CPU_LOAD_MSEC) + { + show_cpu_and_mem_usage(); + cpu_mem_millis = 0; + } +#endif + handle_input(); audio_buffer = queue1.getBuffer(); diff --git a/config.h b/config.h index 8991762..9f9b158 100644 --- a/config.h +++ b/config.h @@ -26,7 +26,7 @@ // Initial values #define MIDI_DEVICE Serial1 -//#define USE_ONBOARD_USB_HOST 1 +#define USE_ONBOARD_USB_HOST 1 #define VOLUME 0.5 #define SAMPLE_RATE 44100 #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI diff --git a/dexed_sysex.cpp b/dexed_sysex.cpp index 72ca6de..73ab8aa 100644 --- a/dexed_sysex.cpp +++ b/dexed_sysex.cpp @@ -102,7 +102,7 @@ bool load_sysex(uint8_t bank, uint8_t voice_number) bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) { File file; - uint16_t i, n; + uint16_t n; uint32_t calc_checksum = 0; char sysex_file[20]; @@ -149,39 +149,35 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) #endif return (false); } - file.seek(6); // start of 32*128 (=4096) bytes data - for (i = 0; i < 32; i++) + + file.seek(6 + voice_number * 128); // start of 32*128 (=4096) bytes data + for (n = 0; n < 128; n++) { - for (n = 0; n < 128; n++) - { - uint8_t d = file.read(); - if (i == voice_number) - { - calc_checksum += (d & 0x7F); // calculate checksum - data[n] = d; - } - } + uint8_t d = file.read(); + calc_checksum += (d & 0x7F); // calculate checksum + data[n] = d; } calc_checksum = uint8_t(~calc_checksum + 1); - #ifdef DEBUG +#ifdef DEBUG Serial.print(F("Checksum: 0x")); - Serial.println(calc_checksum,HEX); - #endif - - if (calc_checksum != uint8_t(file.read())) + Serial.println(calc_checksum, HEX); +#endif + + uint8_t c = uint8_t(file.read()); + if (calc_checksum != c) { #ifdef DEBUG - Serial.println(F("E: checksum mismatch.")); + Serial.print(F("E: checksum mismatch: 0x")); + Serial.print(calc_checksum,HEX); + Serial.print(F(" != 0x")); + Serial.println(c,HEX); #endif - return (false); + //return (false); } } #ifdef DEBUG - else - { - Serial.print(F("Cannot open ")); - Serial.println(sysex.name()); - } + Serial.print(F("Cannot open ")); + Serial.println(sysex.name()); #endif return (true); }