diff --git a/MicroDexed.ino b/MicroDexed.ino index b0368c2..5efafb6 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1672,8 +1672,9 @@ void show_cpu_and_mem_usage(void) Serial.print(F("|XRUN:")); Serial.print(sum_xrun, DEC); Serial.print(F("|OVERLOAD:")); - Serial.print(sum_overload, DEC); - Serial.print(F("|PEAKR:")); + Serial.println(sum_overload, DEC); + + Serial.print(F("PEAKR:")); Serial.print(peak_r, DEC); Serial.print(F("|PEAKL:")); Serial.print(peak_l, DEC); @@ -1682,7 +1683,8 @@ void show_cpu_and_mem_usage(void) Serial.print(F("|ACTPEAKMD:")); Serial.print(peak_dexed_value, 1); Serial.print(F("|BLOCKSIZE:")); - Serial.print(AUDIO_BLOCK_SAMPLES, DEC); + Serial.println(AUDIO_BLOCK_SAMPLES, DEC); + Serial.print(F("|ACTVOICES:")); for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { diff --git a/UI.hpp b/UI.hpp index 56ebe59..0b041c7 100644 --- a/UI.hpp +++ b/UI.hpp @@ -211,6 +211,7 @@ void UI_function_not_implemented(uint8_t param); void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool sign); void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign); void lcd_display_bar_int(const char* title, uint32_t value, float factor, uint32_t min_value, uint32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init); +void lcd_display_bar_float(const char* title, float value, float factor, uint32_t min_value, uint32_t max_value, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign, bool init); void lcd_special_chars(uint8_t mode); // normal menu @@ -966,10 +967,10 @@ void UI_func_chorus_frequency(uint8_t param) if (LCDML.FUNC_setup()) // ****** SETUP ********* { // setup function - //lcd_special_chars(BLOCKBAR); - //lcd_display_bar_float("Chorus Frq.", configuration.chorus_frequency, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 3, false, false, false, true); - lcd.setCursor(0, 0); - lcd.print(F("Chorus Frequency")); + lcd_special_chars(BLOCKBAR); + lcd_display_bar_float("Chorus Frq.", configuration.chorus_frequency, 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, true); + /* lcd.setCursor(0, 0); + lcd.print(F("Chorus Frequency")); */ } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -987,16 +988,17 @@ void UI_func_chorus_frequency(uint8_t param) chorus_modulator.frequency(configuration.chorus_frequency / 10.0); - //lcd_display_bar_float("Chorus Frq.", configuration.chorus_frequency, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 3, false, false, false, true); - lcd.setCursor(0, 1); - lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, false, true, false); - lcd.print(F(" Hz")); + lcd_display_bar_float("Chorus Frq.", configuration.chorus_frequency, 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, false); + + /*lcd.setCursor(0, 1); + lcd_display_float(configuration.chorus_frequency / 10.0, 2, 1, false, true, false); + lcd.print(F(" Hz"));*/ } } if (LCDML.FUNC_close()) // ****** STABLE END ********* { - //lcd_special_chars(SCROLLBAR); + lcd_special_chars(SCROLLBAR); eeprom_write(); } } @@ -1409,6 +1411,8 @@ void UI_func_transpose(uint8_t param) // setup function lcd.setCursor(0, 0); lcd.print(F("Transpose")); + lcd.setCursor(0, 1); + lcd_display_int(configuration.dexed[instance_id].transpose - 24, 2, true, true, true); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -1424,12 +1428,12 @@ void UI_func_transpose(uint8_t param) else if (LCDML.BT_checkUp()) configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose - ENCODER[ENC_R].speed(), TRANSPOSE_MIN, TRANSPOSE_MAX); + lcd.setCursor(0, 1); + lcd_display_int(configuration.dexed[instance_id].transpose - 24, 2, true, true, true); + MicroDexed[instance_id]->data[DEXED_VOICE_OFFSET + DEXED_TRANSPOSE] = configuration.dexed[instance_id].transpose; MicroDexed[instance_id]->notesOff(); } - - lcd.setCursor(0, 1); - lcd_display_int(configuration.dexed[instance_id].transpose - 24, 1, false, true, true); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1453,6 +1457,8 @@ void UI_func_tune(uint8_t param) lcd.print(F("Tune")); lcd.setCursor(6, 1); lcd.print(F("cent")); + lcd.setCursor(0, 1); + lcd_display_int(configuration.dexed[instance_id].tune - 100, 3, true, true, true); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -1468,12 +1474,12 @@ void UI_func_tune(uint8_t param) else if (LCDML.BT_checkUp()) configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune - ENCODER[ENC_R].speed(), TUNE_MIN, TUNE_MAX); + lcd.setCursor(0, 1); + lcd_display_int(configuration.dexed[instance_id].tune - 100, 3, true, true, true); + MicroDexed[instance_id]->controllers.masterTune = (int((configuration.dexed[instance_id].tune - 100) / 100.0 * 0x4000) << 11) * (1.0 / 12); MicroDexed[instance_id]->doRefreshVoice(); } - - lcd.setCursor(0, 1); - lcd_display_int(configuration.dexed[instance_id].tune - 100, 1, false, true, true); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3189,111 +3195,79 @@ void UI_function_not_implemented(uint8_t param) void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool sign) { - int16_t tmp = 0; - uint16_t p; - bool non_zero_found = false; - - if (size < 1) - return; + lcd_display_float(float(var), size, 0, zeros, brackets, sign); +} - if (brackets == true) - lcd.print(F("[")); +void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign) +{ + char s[LCD_cols + 1]; + char f[LCD_cols + 1]; - if (sign == true) + if (size_fraction > 0) { - size++; - if (var < 0) - { - lcd.print(F("-")); - var = abs(var); - } - else if (var > 0) - lcd.print(F("+")); - else - lcd.print(F(" ")); - } + if (zeros == true && sign == true) + sprintf(f, "%%+%0d.%df", size_number + size_fraction + 1, size_fraction); + else if (zeros == true && sign == true) + sprintf(f, "%%+%0d.%df", size_number + size_fraction + 1, size_fraction); + else if (zeros == false && sign == true) + sprintf(f, "%%+%d.%df", size_number + size_fraction + 1, size_fraction); + else if (zeros == false && sign == false) + sprintf(f, "%%%d.%df", size_number + size_fraction + 1, size_fraction); - if (var == 0 && zeros == false) - { - for (int8_t i = size - 1 ; i > 0; i--) - lcd.print(F(" ")); - lcd.print(F("0")); + sprintf(s, f, var); } else { - for (int8_t i = size - 1 ; i >= 0; i--) - { - p = int(pow(10, i)); - tmp = int(var / p); + if (zeros == true && sign == true) + sprintf(f, "%%+0%dd", size_number + 1); + else if (zeros == true && sign == false) + sprintf(f, "%%%0dd", size_number); + else if (zeros == false && sign == true) + sprintf(f, "%%+%dd", size_number + 1); + else if (zeros == false && sign == false) + sprintf(f, "%%%dd", size_number); - if (tmp == 0) - { - if (zeros == true) - lcd.print(F("0")); - else - { - if (non_zero_found == true) - lcd.print(F("0")); - else - lcd.print(F(" ")); - } - } - else - { - non_zero_found = true; - lcd.print(tmp); - } - var -= (tmp * p); - } + sprintf(s, f, int(var)); } if (brackets == true) - lcd.print(F("]")); -} - -void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign) -{ - float fraction; - float number; - - if (size_number < 1 || size_fraction < 1) - return; - - fraction = modff(var, &number); - - if (brackets == true) - lcd.print(F("[")); - - if (int(number) == 0) { - if (zeros == true) - lcd.print(F("00")); - else - lcd.print(F(" 0")); + char tmp[LCD_cols + 1]; + + strcpy(tmp, s); + sprintf(s, "[%s]", tmp); } - else - lcd_display_int(int(number), size_number, zeros, false, sign); - lcd.print(F(".")); - lcd_display_int(round(fraction * pow(10, size_fraction)), size_fraction, true, false, false); - if (brackets == true) - lcd.print(F("]")); + lcd.print(s); + Serial.println(f); + Serial.println(s); +} + +inline void lcd_display_bar_int(const char* title, uint32_t value, float factor, uint32_t min_value, uint32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init) +{ + lcd_display_bar_float(title, float(value), factor, min_value, max_value, size, 0, zeros, brackets, sign, init); } -void lcd_display_bar_int(const char* title, uint32_t value, float factor, uint32_t min_value, uint32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init) +void lcd_display_bar_float(const char* title, float value, float factor, uint32_t min_value, uint32_t max_value, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign, bool init) { float _v = float((value - min_value) * LCD_cols) / (max_value - min_value); float _vi = 0.0; uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0 + 0.5); uint8_t vi = uint8_t(_vi + 0.5); + uint8_t size = 0; + + if (size_fraction == 0) + size = size_number; + else + size = size_number + size_fraction + 1; if (init == true) { // show initial title, value and bar LCDML.DISP_clear(); lcd.show(0, 0, LCD_cols - 1, title); - lcd.setCursor(LCD_cols - (size + 1) + 1, 0); - lcd_display_int(uint16_t(float(value)*factor + 0.5), size, zeros, brackets, sign); + lcd.setCursor(LCD_cols - size, 0); + lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign); lcd.setCursor(0, 1); if (vi == 0 && uint8_t(vf / 2) == 0) @@ -3323,8 +3297,8 @@ void lcd_display_bar_int(const char* title, uint32_t value, float factor, uint32 // show only changed value and changed part of the bar uint8_t ca = uint8_t (float(LCD_cols - 1) / float(max_value)) + 1; - lcd.setCursor(LCD_cols - (size + 1) + 1, 0); - lcd_display_int(uint16_t(float(value)*factor + 0.5), size, zeros, brackets, sign); + lcd.setCursor(LCD_cols - size, 0); + lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign); if (vi == 0 && uint8_t(vf / 2) == 0) {