diff --git a/UI.hpp b/UI.hpp index 0b041c7..01fc3d6 100644 --- a/UI.hpp +++ b/UI.hpp @@ -128,7 +128,15 @@ const uint8_t block_bar[5][8] = { {B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111} }; -enum { SCROLLBAR, BLOCKBAR }; +const uint8_t meter_bar[5][8] = { + {B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000}, + {B01000, B01000, B01000, B01000, B01000, B01000, B01000, B01000}, + {B00100, B00100, B00100, B00100, B00100, B00100, B00100, B00100}, + {B00010, B00010, B00010, B00010, B00010, B00010, B00010, B00010}, + {B00001, B00001, B00001, B00001, B00001, B00001, B00001, B00001} +}; + +enum { SCROLLBAR, BLOCKBAR, METERBAR }; enum { ENC_R, ENC_L }; enum { MENU_START, MENU_VOICE, MENU_EDIT, MENU_VOLUME }; enum {MENU_VOICE_BANK, MENU_VOICE_SOUND}; @@ -210,8 +218,11 @@ void UI_function_not_enabled(void); 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_display_bar_int(const char* title, uint32_t value, float factor, int32_t min_value, int32_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, int32_t min_value, int32_t max_value, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign, bool init); +void lcd_display_meter_float(const char* title, float value, float factor, int32_t min_value, int32_t max_value, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign, bool init); +void lcd_display_bar_int_N(const char* title, uint32_t value, float diff, float factor, int32_t min_value, int32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init); +void lcd_display_bar_float_N(const char* title, float value, float diff, float factor, int32_t min_value, int32_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 @@ -968,9 +979,7 @@ void UI_func_chorus_frequency(uint8_t param) { // setup function 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")); */ + lcd_display_bar_float_N("Chorus Frq.", configuration.chorus_frequency, float(ENCODER[ENC_R].speed()), 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, true); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -988,7 +997,7 @@ 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, 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, false); + lcd_display_bar_float_N("Chorus Frq.", configuration.chorus_frequency, float(ENCODER[ENC_R].speed()), 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); @@ -1158,7 +1167,6 @@ void UI_func_chorus_level(uint8_t param) } } -/* HIER */ void UI_func_delay_time(uint8_t param) { if (LCDML.FUNC_setup()) // ****** SETUP ********* @@ -1430,7 +1438,7 @@ void UI_func_transpose(uint8_t param) 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(); } @@ -3206,11 +3214,11 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo if (size_fraction > 0) { 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); + sprintf(f, "%%+0%d.%df", size_number + size_fraction + 2, size_fraction); + else if (zeros == true && sign == false) + sprintf(f, "%%+0%d.%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); + sprintf(f, "%%+%d.%df", size_number + size_fraction + 2, size_fraction); else if (zeros == false && sign == false) sprintf(f, "%%%d.%df", size_number + size_fraction + 1, size_fraction); @@ -3239,16 +3247,15 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo } 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) + +inline void lcd_display_bar_int(const char* title, uint32_t value, float factor, int32_t min_value, int32_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_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_display_bar_float(const char* title, float value, float factor, int32_t min_value, int32_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; @@ -3261,6 +3268,9 @@ void lcd_display_bar_float(const char* title, float value, float factor, uint32_ else size = size_number + size_fraction + 1; + if (brackets == true) + size += 2; + if (init == true) { // show initial title, value and bar @@ -3331,6 +3341,104 @@ void lcd_display_bar_float(const char* title, float value, float factor, uint32_ } } } +inline void lcd_display_bar_int_N(const char* title, uint32_t value, int16_t diff, float factor, int32_t min_value, int32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init) +{ + lcd_display_bar_float_N(title, float(value), float(diff), factor, min_value, max_value, size, 0, zeros, brackets, sign, init); +} + +void lcd_display_bar_float_N(const char* title, float value, float diff, float factor, int32_t min_value, int32_t max_value, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign, bool init) +{ + uint8_t size = 0; + float value_old = value + diff; + 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); + float v_o = float((value - min_value) * LCD_cols) / (max_value - min_value); + uint8_t vf_o = uint8_t(modff(v, &_vi) * 10.0 + 0.5); + uint8_t vi_o = uint8_t(_vi); + + if (size_fraction == 0) + size = size_number; + else + size = size_number + size_fraction + 1; + + if (brackets == true) + size += 2; + if (sign == true) + size += 1; + + if (init == true) + { + // Title + lcd.setCursor(0, 0); + lcd.print(title); + + // Value + if (brackets == true) + { + lcd.setCursor(LCD_cols - size, 0); + lcd.print(F("[")); + lcd.setCursor(LCD_cols - 1, 0); + lcd.print(F("]")); + } + lcd.setCursor(LCD_cols - size, 0); + lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign); + + // Bar + lcd.setCursor(0, 1); + if (vi == 0) + lcd.write((uint8_t)vf / 2.0); + else + { + for (uint8_t i = 0; i < vi; i++) + lcd.write((uint8_t)4); // full block + if (vi < LCD_cols) + lcd.write((uint8_t)vf / 2.0); + } + } + else + { + // Value + lcd.setCursor(LCD_cols - size, 0); + lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign); + + // Bar + lcd.setCursor(0, 1); + if (vi == 0) + { + if (vf / 2.0 == 0) + lcd.write((uint8_t)0); + else + { + lcd.write((uint8_t)vf / 2.0); + for (uint8_t i = vi; i < LCD_cols; i++) + lcd.print(F(" ")); // empty block + } + } + else + { + for (uint8_t i = 0; i < vi; i++) + lcd.write((uint8_t)4); // full block + if (vi < LCD_cols) + lcd.write((uint8_t)vf / 2.0); + if (vi < LCD_cols - 1) + for (uint8_t i = vi; i < LCD_cols; i++) + lcd.print(F(" ")); // empty block + } + } + + /* + lcd.setCursor(n, 1); + lcd.write((uint8_t)0); // minimal block + cd.write((uint8_t)4); // full block + */ +} + +void lcd_display_meter_float(const char* title, float value, float factor, int32_t min_value, int32_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) { @@ -3355,6 +3463,17 @@ void lcd_special_chars(uint8_t mode) lcd.createChar(i, (uint8_t*)block_bar[i]); #else flipped_block_bar[i] = rotTile(block_bar[i]); +#endif + } + break; + case METERBAR: + // set special chars for volumebar + for (uint8_t i = 0; i < 5; i++) + { +#ifdef I2C_DISPLAY + lcd.createChar(i, (uint8_t*)meter_bar[i]); +#else + flipped_block_bar[i] = rotTile(meter_bar[i]); #endif } break;