Fixed displaying of blockbar for volume and portamento time.

pull/32/head
Holger Wirtz 5 years ago
parent c01d45f6f4
commit ac896d9685
  1. 204
      UI.hpp

204
UI.hpp

@ -118,7 +118,6 @@ const uint8_t scroll_bar[5][8] = {
{B10001, B10001, B10001, B10001, B10001, B10001, B11111, B11111} // scrollbar bottom {B10001, B10001, B10001, B10001, B10001, B10001, B11111, B11111} // scrollbar bottom
}; };
const uint8_t block_bar[5][8] = { const uint8_t block_bar[5][8] = {
{B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000}, {B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000},
{B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000}, {B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000},
@ -126,6 +125,8 @@ const uint8_t block_bar[5][8] = {
{B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110}, {B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110},
{B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111} {B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111}
}; };
enum { SCROLLBAR, BLOCKBAR };
enum { ENC_R, ENC_L }; enum { ENC_R, ENC_L };
enum { MENU_START, MENU_VOICE, MENU_EDIT, MENU_VOLUME }; enum { MENU_START, MENU_VOICE, MENU_EDIT, MENU_VOLUME };
enum {MENU_VOICE_BANK, MENU_VOICE_SOUND}; enum {MENU_VOICE_BANK, MENU_VOICE_SOUND};
@ -201,6 +202,8 @@ void UI_function_not_enabled(void);
void UI_function_not_implemented(uint8_t param); 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_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_float(float var, uint8_t size_number, uint8_t size_fraction, bool zeros, bool brackets, bool sign);
void lcd_display_bar(const char* title, uint32_t value, uint32_t max_value, bool init);
void lcd_special_chars(uint8_t mode);
// normal menu // normal menu
LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change) LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // normal root menu element (do not change)
@ -234,6 +237,7 @@ uint8_t g_LCDML_CONTROL_prev[NUM_ENCODER] = {0, 0};
#ifdef U8X8_DISPLAY #ifdef U8X8_DISPLAY
const uint8_t * flipped_scroll_bar[5]; const uint8_t * flipped_scroll_bar[5];
const uint8_t * flipped_block_bar[5];
uint8_t * rotTile(const uint8_t * tile) { uint8_t * rotTile(const uint8_t * tile) {
uint8_t * newt = new uint8_t[8]; uint8_t * newt = new uint8_t[8];
@ -268,24 +272,7 @@ void setup_ui(void) {
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print(F("(c)parasiTstudio")); lcd.print(F("(c)parasiTstudio"));
#ifdef I2C_DISPLAY lcd_special_chars(SCROLLBAR);
// set special chars for scrollbar
lcd.createChar(0, (uint8_t*)scroll_bar[0]);
lcd.createChar(1, (uint8_t*)scroll_bar[1]);
lcd.createChar(2, (uint8_t*)scroll_bar[2]);
lcd.createChar(3, (uint8_t*)scroll_bar[3]);
lcd.createChar(4, (uint8_t*)scroll_bar[4]);
// set special chars for volumeba
lcd.createChar(5, (uint8_t*)block_bar[0]);
lcd.createChar(6, (uint8_t*)block_bar[1]);
lcd.createChar(7, (uint8_t*)block_bar[2]);
lcd.createChar(8, (uint8_t*)block_bar[3]);
lcd.createChar(9, (uint8_t*)block_bar[4]);
#else
for (int x = 0; x < 5; x++) {
flipped_scroll_bar[x] = rotTile(scroll_bar[x]);
}
#endif
// LCDMenuLib Setup // LCDMenuLib Setup
LCDML_setup(_LCDML_DISP_cnt); LCDML_setup(_LCDML_DISP_cnt);
@ -306,6 +293,7 @@ void lcdml_menu_control(void)
if (back_from_volume > BACK_FROM_VOLUME_MS && menu_state == MENU_VOLUME) if (back_from_volume > BACK_FROM_VOLUME_MS && menu_state == MENU_VOLUME)
{ {
lcd_special_chars(SCROLLBAR);
UI_func_voice_selection(0); UI_func_voice_selection(0);
return; return;
} }
@ -598,8 +586,8 @@ void encoder_left_up(void)
Serial.println(F("Volume +")); Serial.println(F("Volume +"));
#endif #endif
configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); configuration.vol = constrain(configuration.vol + VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
eeprom_write(); //eeprom_write();
set_volume(configuration.vol, configuration.mono); //set_volume(configuration.vol, configuration.mono);
UI_func_volume(0); UI_func_volume(0);
} }
@ -610,8 +598,8 @@ void encoder_left_down(void)
Serial.println(F("Volume -")); Serial.println(F("Volume -"));
#endif #endif
configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX); configuration.vol = constrain(configuration.vol - VOLUME_ENC_STEPS, VOLUME_MIN, VOLUME_MAX);
eeprom_write(); //eeprom_write();
set_volume(configuration.vol, configuration.mono); //set_volume(configuration.vol, configuration.mono);
UI_func_volume(0); UI_func_volume(0);
} }
@ -2856,9 +2844,8 @@ void UI_func_portamento_time(uint8_t param)
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
// setup function lcd_special_chars(BLOCKBAR);
lcd.setCursor(0, 0); lcd_display_bar("Portam. Time", configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MAX, true);
lcd.print(F("Portam. Time"));
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -2886,14 +2873,18 @@ void UI_func_portamento_time(uint8_t param)
MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time);
} }
/*
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd_display_int(configuration.dexed[instance_id].portamento_time, 2, false, true, false); lcd_display_int(configuration.dexed[instance_id].portamento_time, 2, false, true, false);
*/
lcd_display_bar("Portam. Time", configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MAX, false);
} }
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
// you can here reset some global vars or do nothing // you can here reset some global vars or do nothing
lcd_special_chars(SCROLLBAR);
eeprom_write(); eeprom_write();
} }
} }
@ -3147,83 +3138,24 @@ void UI_func_voice_selection(uint8_t param)
void UI_func_volume(uint8_t param) void UI_func_volume(uint8_t param)
{ {
uint8_t vi, vf;
float _v, _vi;
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("UI_func_volume()")); Serial.println(F("UI_func_volume()"));
#endif #endif
back_from_volume = 0; back_from_volume = 0;
_v = float(configuration.vol * LCD_cols) / 100.0;
vf = uint8_t(modff(_v, &_vi) * 10.0);
vi = uint8_t(_vi);
Serial.print(" ---------------> _v=");
Serial.print(_v, 5);
Serial.print(" ---------------> vi=");
Serial.print(vi);
Serial.print(" ---------------> vf=");
Serial.print(vf);
Serial.println();
_v = float(configuration.vol * LCD_cols) / 100.0;
vf = uint8_t(modff(_v, &_vi) * 10.0);
vi = uint8_t(_vi);
if (menu_state != MENU_VOLUME) if (menu_state != MENU_VOLUME)
{ {
lcd_special_chars(BLOCKBAR);
lcd_display_bar("Volume", configuration.vol, VOLUME_MAX, true);
menu_state = MENU_VOLUME; menu_state = MENU_VOLUME;
lcd.show(0, 0, LCD_cols, "Volume:");
lcd.setCursor(8, 0);
lcd_display_int(configuration.vol, 3, true, false, false);
lcd.setCursor(0, 1);
for (uint8_t i = 0; i < LCD_cols; i++)
{
if (i < uint8_t(vi))
lcd.write((uint8_t)9); // full block
else
lcd.print(F(" "));
}
if (vi == 0 && vf == 0)
{
lcd.setCursor(0, 1);
lcd.write((uint8_t)5);
}
else if (vf > 0)
{
lcd.setCursor(vi, 1);
lcd.write((uint8_t)5 + int(vf / 2));
}
} }
else else
{ lcd_display_bar("Volume", configuration.vol, VOLUME_MAX, false);
lcd.setCursor(8, 0);
lcd_display_int(configuration.vol, 3, true, false, false);
if (vi > 0)
{
lcd.setCursor(vi - 1, 1);
lcd.write((uint8_t)9); // full block
if (vf > 0)
lcd.write((uint8_t)5 + int(vf / 2));
lcd.print(F(" "));
}
else if (vi == 0 && vf == 0)
{
lcd.setCursor(0, 1);
lcd.write((uint8_t)5);
lcd.print(F(" "));
}
}
set_volume(configuration.vol, configuration.mono); set_volume(configuration.vol, configuration.mono);
eeprom_write(); eeprom_write();
} }
void UI_func_load(uint8_t param) void UI_func_load(uint8_t param)
@ -3431,6 +3363,7 @@ void lcd_display_int(int16_t var, uint8_t size, bool zeros, bool brackets, bool
if (brackets == true) if (brackets == true)
lcd.print(F("]")); lcd.print(F("]"));
} }
void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, 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)
{ {
float fraction; float fraction;
@ -3459,5 +3392,96 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo
if (brackets == true) if (brackets == true)
lcd.print(F("]")); lcd.print(F("]"));
} }
void lcd_display_bar(const char* title, uint32_t value, uint32_t max_value, bool init)
{
float _v = float(value * LCD_cols) / max_value;
float _vi;
uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0);
uint8_t vi = uint8_t(_vi);
if (init == true)
{
lcd.show(0, 0, LCD_cols, title);
lcd.setCursor(strlen(title) + 1, 0);
lcd_display_int(value, 3, true, false, false);
lcd.setCursor(0, 1);
for (uint8_t i = 0; i < LCD_cols; i++)
{
if (i < uint8_t(vi))
lcd.write((uint8_t)4); // full block
else
lcd.print(F(" "));
}
if (vi == 0 && uint8_t(vf / 2) == 0)
{
lcd.setCursor(0, 1);
lcd.write((uint8_t)0);
}
else if (vf > 0)
{
lcd.setCursor(vi + 1, 1);
lcd.write((uint8_t)int(vf / 2) - 1);
}
}
else
{
lcd.setCursor(strlen(title) + 1, 0);
lcd_display_int(value, 3, true, false, false);
if (vi > 0)
{
lcd.setCursor(vi - 1, 1);
lcd.write((uint8_t)4); // full block
if (vf > 0)
lcd.write((uint8_t)int(vf / 2) - 1);
lcd.print(F(" "));
}
else if (uint8_t(vf / 2) == 0)
{
lcd.setCursor(0, 1);
lcd.write((uint8_t)0);
lcd.print(F(" "));
}
if (uint8_t(vf / 2) != 0)
{
lcd.setCursor(vi, 1);
lcd.write((uint8_t)int(vf / 2) - 1);
lcd.print(F(" "));
}
}
}
void lcd_special_chars(uint8_t mode)
{
switch (mode)
{
case SCROLLBAR:
// set special chars for scrollbar
for (uint8_t i = 0; i < 5; i++)
{
#ifdef I2C_DISPLAY
lcd.createChar(i, (uint8_t*)scroll_bar[i]);
#else
flipped_scroll_bar[i] = rotTile(scroll_bar[i]);
#endif
}
break;
case BLOCKBAR:
// set special chars for volumebar
for (uint8_t i = 0; i < 5; i++)
{
#ifdef I2C_DISPLAY
lcd.createChar(i, (uint8_t*)block_bar[i]);
#else
flipped_block_bar[i] = rotTile(block_bar[i]);
#endif
}
break;
}
}
#endif #endif
#endif #endif

Loading…
Cancel
Save