Replaced IntervalTimer for showing CPU and MEM usage with

elapsedMillis().
pull/4/head
Holger Wirtz 6 years ago
parent 2c767f78f8
commit fdaeb8b79f
  1. 34
      MicroDexed.ino
  2. 2
      config.h
  3. 42
      dexed_sysex.cpp

@ -37,7 +37,7 @@
#ifndef MASTER_KEY_MIDI // selecting sounds by encoder and display #ifndef MASTER_KEY_MIDI // selecting sounds by encoder and display
#include <Bounce.h> #include <Bounce.h>
#include <Encoder.h> #include <Encoder.h>
#include <LiquidCrystalPlus_I2C.h> //#include <LiquidCrystalPlus_I2C.h>
#endif #endif
#ifndef MASTER_KEY_MIDI #ifndef MASTER_KEY_MIDI
@ -45,7 +45,7 @@
#define LCD_I2C_ADDRESS 0x3f #define LCD_I2C_ADDRESS 0x3f
#define LCD_CHARS 20 #define LCD_CHARS 20
#define LCD_LINES 4 #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); Encoder enc1(ENC1_PIN_A, ENC1_PIN_B);
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
#endif #endif
@ -70,7 +70,7 @@ bool master_key_enabled = false;
#endif #endif
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
IntervalTimer sched_show_cpu_usage; elapsedMillis cpu_mem_millis;
#endif #endif
#ifdef MIDI_DEVICE #ifdef MIDI_DEVICE
@ -93,14 +93,14 @@ void setup()
Serial.begin(SERIAL_SPEED); Serial.begin(SERIAL_SPEED);
#ifndef MASTER_KEY_MIDI #ifndef MASTER_KEY_MIDI
lcd.init(); // lcd.init();
lcd.blink_off(); // lcd.blink_off();
lcd.cursor_off(); // lcd.cursor_off();
lcd.backlight(); // lcd.backlight();
lcd.noAutoscroll(); // lcd.noAutoscroll();
lcd.clear(); // lcd.clear();
lcd.display(); // lcd.display();
lcd.show(0, 0, 20, "MicroDexed"); // lcd.show(0, 0, 20, "MicroDexed");
enc1.write(INITIAL_ENC1_VALUE); enc1.write(INITIAL_ENC1_VALUE);
#endif #endif
@ -141,11 +141,10 @@ void setup()
// Initialize processor and memory measurements // Initialize processor and memory measurements
AudioProcessorUsageMaxReset(); AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset(); AudioMemoryUsageMaxReset();
sched_show_cpu_usage.begin(show_cpu_and_mem_usage, SHOW_CPU_LOAD_MSEC * 1000);
#endif #endif
// load default SYSEX data // load default SYSEX data
load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); //load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR));
#ifdef DEBUG #ifdef DEBUG
show_patch(); show_patch();
@ -163,6 +162,7 @@ void setup()
Serial.println(F("<setup end>")); Serial.println(F("<setup end>"));
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
show_cpu_and_mem_usage(); show_cpu_and_mem_usage();
cpu_mem_millis=0;
#endif #endif
#ifdef TEST_NOTE #ifdef TEST_NOTE
@ -186,6 +186,14 @@ void loop()
while (42 == 42) // DON'T PANIC! 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(); handle_input();
audio_buffer = queue1.getBuffer(); audio_buffer = queue1.getBuffer();

@ -26,7 +26,7 @@
// Initial values // Initial values
#define MIDI_DEVICE Serial1 #define MIDI_DEVICE Serial1
//#define USE_ONBOARD_USB_HOST 1 #define USE_ONBOARD_USB_HOST 1
#define VOLUME 0.5 #define VOLUME 0.5
#define SAMPLE_RATE 44100 #define SAMPLE_RATE 44100
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI

@ -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) bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data)
{ {
File file; File file;
uint16_t i, n; uint16_t n;
uint32_t calc_checksum = 0; uint32_t calc_checksum = 0;
char sysex_file[20]; char sysex_file[20];
@ -149,39 +149,35 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data)
#endif #endif
return (false); 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();
{ calc_checksum += (d & 0x7F); // calculate checksum
uint8_t d = file.read(); data[n] = d;
if (i == voice_number)
{
calc_checksum += (d & 0x7F); // calculate checksum
data[n] = d;
}
}
} }
calc_checksum = uint8_t(~calc_checksum + 1); calc_checksum = uint8_t(~calc_checksum + 1);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Checksum: 0x")); Serial.print(F("Checksum: 0x"));
Serial.println(calc_checksum,HEX); Serial.println(calc_checksum, HEX);
#endif #endif
if (calc_checksum != uint8_t(file.read())) uint8_t c = uint8_t(file.read());
if (calc_checksum != c)
{ {
#ifdef DEBUG #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 #endif
return (false); //return (false);
} }
} }
#ifdef DEBUG #ifdef DEBUG
else Serial.print(F("Cannot open "));
{ Serial.println(sysex.name());
Serial.print(F("Cannot open "));
Serial.println(sysex.name());
}
#endif #endif
return (true); return (true);
} }

Loading…
Cancel
Save