Added a meter bar for tune and panorama.

pull/32/head
Holger Wirtz 5 years ago
parent 643cc34acd
commit 115ac834c6
  1. 87
      UI.hpp

@ -220,7 +220,8 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool
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, 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_meter_int(const char* title, uint32_t value, float factor, float offset, int32_t min_value, int32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init);
void lcd_display_meter_float(const char* title, float value, float factor, float offset, 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
@ -1455,12 +1456,8 @@ void UI_func_tune(uint8_t param)
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
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);
lcd_special_chars(METERBAR);
lcd_display_meter_int("Tune", configuration.dexed[instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, true);
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1476,8 +1473,7 @@ 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);
lcd_display_meter_int("Tune", configuration.dexed[instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, false);
MicroDexed[instance_id]->controllers.masterTune = (int((configuration.dexed[instance_id].tune - 100) / 100.0 * 0x4000) << 11) * (1.0 / 12);
MicroDexed[instance_id]->doRefreshVoice();
@ -1486,7 +1482,7 @@ void UI_func_tune(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
lcd_special_chars(SCROLLBAR);
eeprom_write();
}
}
@ -1587,14 +1583,16 @@ void UI_func_panorama(uint8_t param)
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
lcd.print(F("Panorama"));
if (configuration.mono > 0)
{
lcd.setCursor(0, 0);
lcd.print(F("Panorama"));
lcd.setCursor(0, 1);
lcd.print(F("MONO-disabled"));
return;
}
lcd_special_chars(METERBAR);
lcd_display_meter_float("Panorama", configuration.dexed[instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, true);
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1610,15 +1608,14 @@ void UI_func_panorama(uint8_t param)
if (configuration.mono == 0)
{
lcd.setCursor(0, 1);
lcd_display_int(configuration.dexed[instance_id].pan - 20, 1, false, true, true);
lcd_display_meter_float("Panorama", configuration.dexed[instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, false);
mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0));
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
lcd_special_chars(SCROLLBAR);
eeprom_write();
}
}
@ -3251,7 +3248,6 @@ inline void lcd_display_bar_int(const char* title, uint32_t value, float factor,
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)
{
uint8_t size = 0;
float v = float((value - min_value) * LCD_cols) / (max_value - min_value);
float _vi = 0.0;
@ -3307,9 +3303,64 @@ void lcd_display_bar_float(const char* title, float value, float factor, int32_t
}
}
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)
inline void lcd_display_meter_int(const char* title, uint32_t value, float factor, float offset, int32_t min_value, int32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init)
{
lcd_display_meter_float(title, float(value), factor, offset, min_value, max_value, size, 0, zeros, brackets, sign, init);
}
void lcd_display_meter_float(const char* title, float value, float factor, float offset, 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 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);
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-Brackets
if (brackets == true)
{
lcd.setCursor(LCD_cols - size, 0);
lcd.print(F("["));
lcd.setCursor(LCD_cols - 1, 0);
lcd.print(F("]"));
}
}
// Value
lcd.setCursor(LCD_cols - size, 0);
lcd_display_float((value + offset) * factor, size_number, size_fraction, zeros, brackets, sign);
// Bar
lcd.setCursor(0, 1);
if (vi == 0)
{
lcd.write((uint8_t)vf / 2.0 - 0.5);
lcd.print(F(" "));
}
else
{
for (uint8_t i = 0; i < LCD_cols; i++)
lcd.print(F(" ")); // empty block
lcd.setCursor(vi - 1, 1);
lcd.write((uint8_t)vf / 2.0 - 0.5);
}
}
void lcd_special_chars(uint8_t mode)

Loading…
Cancel
Save