Several changes for better displaying the current selected instance.

pull/32/head
Holger Wirtz 5 years ago
parent ddb43bd8e0
commit 15f7bd06ab
  1. 2
      README.md
  2. 236
      UI.hpp
  3. 2
      config.h

@ -12,7 +12,7 @@ MicroDexed is licensed on the GPL v3. The msfa component (acronym for music synt
* Dexed engine by Pascal Gauthier (asb2m10) * Dexed engine by Pascal Gauthier (asb2m10)
* DX Synth engine (as part of Dexed): Raph Levien and the msfa team * DX Synth engine (as part of Dexed): Raph Levien and the msfa team
* PPPlay : Great OPL3 implementation, with documented code :D * PPPlay : Great OPL3 implementation, with documented code :D
* Thierry for extreme testing, discuss about different options and many good suggestions for handling * Thierry: for extreme testing, discussing about different options and many good suggestions for UI handling
## Dexed comes with 3 engine types : ## Dexed comes with 3 engine types :

236
UI.hpp

@ -97,6 +97,7 @@ extern char receive_bank_filename[FILENAME_LEN];
GLOBAL GLOBAL
************************************************************************/ ************************************************************************/
elapsedMillis back_from_volume; elapsedMillis back_from_volume;
uint8_t instance_num[2][8];
#ifdef I2C_DISPLAY #ifdef I2C_DISPLAY
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
@ -139,14 +140,19 @@ const uint8_t meter_bar[5][8] = {
{B00001, B00001, B00001, B00001, B00001, B00001, B00001, B00001} {B00001, B00001, B00001, B00001, B00001, B00001, B00001, B00001}
}; };
const uint8_t inverse_num[4][8] = { const uint8_t inverse_num[2][8] = {
{B11111, B11011, B10011, B11011, B11011, B11011, B10001, B11111},
{B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}
};
/* const uint8_t inverse_num[4][8] = {
{B11111, B11011, B10011, B11011, B11011, B11011, B10001, B11111}, {B11111, B11011, B10011, B11011, B11011, B11011, B10001, B11111},
{B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111},
{B00000, B00100, B01100, B00100, B00100, B00100, B01110, B00000}, {B00000, B00100, B01100, B00100, B00100, B00100, B01110, B00000},
{B00000, B00100, B01010, B00010, B00100, B01000, B01110, B00000} {B00000, B00100, B01010, B00010, B00100, B01000, B01110, B00000}
}; };*/
enum { SCROLLBAR, BLOCKBAR, METERBAR, INVERSE_NUM }; enum { SCROLLBAR, BLOCKBAR, METERBAR };
enum { ENC_R, ENC_L }; enum { ENC_R, ENC_L };
enum {MENU_VOICE_BANK, MENU_VOICE_SOUND}; enum {MENU_VOICE_BANK, MENU_VOICE_SOUND};
uint8_t menu_voice_select = MENU_VOICE_SOUND; uint8_t menu_voice_select = MENU_VOICE_SOUND;
@ -231,6 +237,7 @@ void lcd_display_bar_int(const char* title, uint32_t value, float factor, int32_
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_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_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_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_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_active_instance_number(uint8_t instance_id);
void lcd_special_chars(uint8_t mode); void lcd_special_chars(uint8_t mode);
void eeprom_update_var(uint16_t pos, uint8_t val, const char* val_string); void eeprom_update_var(uint16_t pos, uint8_t val, const char* val_string);
@ -394,9 +401,8 @@ bool menu_init = true;
#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]; const uint8_t * flipped_block_bar[7];
const uint8_t * flipped_meter_bar[5]; const uint8_t * flipped_meter_bar[7];
const uint8_t * flipped_inverse_num[4];
uint8_t * rotTile(const uint8_t * tile) uint8_t * rotTile(const uint8_t * tile)
{ {
@ -1668,17 +1674,30 @@ void UI_func_highest_note(uint8_t param)
void UI_func_sound_intensity(uint8_t param) void UI_func_sound_intensity(uint8_t param)
{ {
uint8_t instance_id = 0; static uint8_t instance_id;
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2) if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
instance_id = 1; instance_id = 1;
else
instance_id = 0;
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
encoderDir[ENC_R].reset(); encoderDir[ENC_R].reset();
lcd_special_chars(BLOCKBAR); lcd_special_chars(BLOCKBAR);
lcd_display_bar_float("Voice Level", float(configuration.dexed[instance_id].sound_intensity), 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, 0, false, false, false, true);
lcd_active_instance_number(instance_id);
lcd_display_bar_int("Voice Level", configuration.dexed[instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, true);
#if NUM_DEXED > 1
lcd_display_bar_int("Voice Level", configuration.dexed[instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, true);
lcd.setCursor(15, 0);
lcd.write(5);
lcd.setCursor(15, 1);
lcd.write(6);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1691,7 +1710,7 @@ void UI_func_sound_intensity(uint8_t param)
configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity - ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity - ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX);
} }
lcd_display_bar_float("Voice Level", float(configuration.dexed[instance_id].sound_intensity), 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, 0, false, false, false, false); lcd_display_bar_int("Voice Level", configuration.dexed[instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, false);
dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX)); dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX));
} }
@ -3305,44 +3324,38 @@ void UI_func_eeprom_reset(uint8_t param)
void UI_func_voice_select(uint8_t param) void UI_func_voice_select(uint8_t param)
{ {
static uint8_t voice_select_instance_id; static uint8_t instance_id;
static uint8_t menu_voice_select = MENU_VOICE_SOUND; static uint8_t menu_voice_select = MENU_VOICE_SOUND;
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
lcd_special_chars(INVERSE_NUM);
encoderDir[ENC_R].reset(); encoderDir[ENC_R].reset();
if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2) if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2)
voice_select_instance_id = 1; instance_id = 1;
else else
voice_select_instance_id = 0; instance_id = 0;
lcd_active_instance_number(instance_id);
char bank_name[BANK_NAME_LEN]; char bank_name[BANK_NAME_LEN];
char voice_name[VOICE_NAME_LEN]; char voice_name[VOICE_NAME_LEN];
if (!get_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, sizeof(bank_name))) if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name)))
strncpy(bank_name, "*ERROR*", sizeof(bank_name)); strncpy(bank_name, "*ERROR*", sizeof(bank_name));
if (!get_voice_by_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, configuration.performance.voice[voice_select_instance_id], voice_name, sizeof(voice_name))) if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name)))
strncpy(voice_name, "*ERROR*", sizeof(voice_name)); strncpy(voice_name, "*ERROR*", sizeof(voice_name));
lcd.show(0, 0, 2, configuration.performance.bank[voice_select_instance_id]); lcd.show(0, 0, 2, configuration.performance.bank[instance_id]);
lcd.show(1, 0, 2, configuration.performance.voice[voice_select_instance_id] + 1); lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1);
lcd.show(0, 4, 10, bank_name); lcd.show(0, 4, 10, bank_name);
lcd.show(1, 4, 10, voice_name); lcd.show(1, 4, 10, voice_name);
#if NUM_DEXED > 1 #if NUM_DEXED > 1
lcd.setCursor(15, 0); lcd.setCursor(15, 0);
if (voice_select_instance_id == 0) lcd.write(5);
lcd.write(voice_select_instance_id);
else
lcd.write(2);
lcd.setCursor(15, 1); lcd.setCursor(15, 1);
if (voice_select_instance_id == 1) lcd.write(6);
lcd.write(voice_select_instance_id);
else
lcd.write(3);
#endif #endif
switch (menu_voice_select) switch (menu_voice_select)
@ -3377,37 +3390,37 @@ void UI_func_voice_select(uint8_t param)
switch (menu_voice_select) switch (menu_voice_select)
{ {
case MENU_VOICE_BANK: case MENU_VOICE_BANK:
memset(g_bank_name[voice_select_instance_id], 0, BANK_NAME_LEN); memset(g_bank_name[instance_id], 0, BANK_NAME_LEN);
bank_tmp = constrain(configuration.performance.bank[voice_select_instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); bank_tmp = constrain(configuration.performance.bank[instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1);
configuration.performance.bank[voice_select_instance_id] = bank_tmp; configuration.performance.bank[instance_id] = bank_tmp;
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(false); change_disp_sd(false);
#endif #endif
load_sd_voice(configuration.performance.bank[voice_select_instance_id], configuration.performance.voice[voice_select_instance_id], voice_select_instance_id); load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(true); change_disp_sd(true);
#endif #endif
break; break;
case MENU_VOICE_SOUND: case MENU_VOICE_SOUND:
memset(g_voice_name[voice_select_instance_id], 0, VOICE_NAME_LEN); memset(g_voice_name[instance_id], 0, VOICE_NAME_LEN);
voice_tmp = configuration.performance.voice[voice_select_instance_id] - ENCODER[ENC_R].speed(); voice_tmp = configuration.performance.voice[instance_id] - ENCODER[ENC_R].speed();
if (voice_tmp < 0 && configuration.performance.bank[voice_select_instance_id] - 1 >= 0) if (voice_tmp < 0 && configuration.performance.bank[instance_id] - 1 >= 0)
{ {
configuration.performance.bank[voice_select_instance_id]--; configuration.performance.bank[instance_id]--;
configuration.performance.bank[voice_select_instance_id] = constrain(configuration.performance.bank[voice_select_instance_id], 0, MAX_BANKS - 1); configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1);
} }
else if (voice_tmp < 0 && configuration.performance.bank[voice_select_instance_id] - 1 <= 0) else if (voice_tmp < 0 && configuration.performance.bank[instance_id] - 1 <= 0)
{ {
voice_tmp = 0; voice_tmp = 0;
} }
if (voice_tmp < 0) if (voice_tmp < 0)
voice_tmp = MAX_VOICES + voice_tmp; voice_tmp = MAX_VOICES + voice_tmp;
configuration.performance.voice[voice_select_instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); configuration.performance.voice[instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(false); change_disp_sd(false);
#endif #endif
load_sd_voice(configuration.performance.bank[voice_select_instance_id], configuration.performance.voice[voice_select_instance_id], voice_select_instance_id); load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(true); change_disp_sd(true);
#endif #endif
@ -3419,36 +3432,36 @@ void UI_func_voice_select(uint8_t param)
switch (menu_voice_select) switch (menu_voice_select)
{ {
case MENU_VOICE_BANK: case MENU_VOICE_BANK:
memset(g_bank_name[voice_select_instance_id], 0, BANK_NAME_LEN); memset(g_bank_name[instance_id], 0, BANK_NAME_LEN);
bank_tmp = constrain(configuration.performance.bank[voice_select_instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); bank_tmp = constrain(configuration.performance.bank[instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1);
configuration.performance.bank[voice_select_instance_id] = bank_tmp; configuration.performance.bank[instance_id] = bank_tmp;
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(false); change_disp_sd(false);
#endif #endif
load_sd_voice(configuration.performance.bank[voice_select_instance_id], configuration.performance.voice[voice_select_instance_id], voice_select_instance_id); load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(true); change_disp_sd(true);
#endif #endif
break; break;
case MENU_VOICE_SOUND: case MENU_VOICE_SOUND:
memset(g_voice_name[voice_select_instance_id], 0, VOICE_NAME_LEN); memset(g_voice_name[instance_id], 0, VOICE_NAME_LEN);
voice_tmp = configuration.performance.voice[voice_select_instance_id] + ENCODER[ENC_R].speed(); voice_tmp = configuration.performance.voice[instance_id] + ENCODER[ENC_R].speed();
if (voice_tmp >= MAX_VOICES && configuration.performance.bank[voice_select_instance_id] + 1 < MAX_BANKS) if (voice_tmp >= MAX_VOICES && configuration.performance.bank[instance_id] + 1 < MAX_BANKS)
{ {
voice_tmp %= MAX_VOICES; voice_tmp %= MAX_VOICES;
configuration.performance.bank[voice_select_instance_id]++; configuration.performance.bank[instance_id]++;
configuration.performance.bank[voice_select_instance_id] = constrain(configuration.performance.bank[voice_select_instance_id], 0, MAX_BANKS - 1); configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1);
} }
else if (voice_tmp >= MAX_VOICES && configuration.performance.bank[voice_select_instance_id] + 1 >= MAX_BANKS) else if (voice_tmp >= MAX_VOICES && configuration.performance.bank[instance_id] + 1 >= MAX_BANKS)
{ {
voice_tmp = MAX_VOICES - 1; voice_tmp = MAX_VOICES - 1;
} }
configuration.performance.voice[voice_select_instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); configuration.performance.voice[instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(false); change_disp_sd(false);
#endif #endif
load_sd_voice(configuration.performance.bank[voice_select_instance_id], configuration.performance.voice[voice_select_instance_id], voice_select_instance_id); load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(true); change_disp_sd(true);
#endif #endif
@ -3469,31 +3482,27 @@ void UI_func_voice_select(uint8_t param)
if (menu_voice_select == MENU_VOICE_BANK) if (menu_voice_select == MENU_VOICE_BANK)
{ {
menu_voice_select = MENU_VOICE_SOUND; menu_voice_select = MENU_VOICE_SOUND;
voice_select_instance_id = !voice_select_instance_id; instance_id = !instance_id;
lcd_active_instance_number(instance_id);
char bank_name[BANK_NAME_LEN]; char bank_name[BANK_NAME_LEN];
char voice_name[VOICE_NAME_LEN]; char voice_name[VOICE_NAME_LEN];
if (!get_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, sizeof(bank_name))) if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name)))
strncpy(bank_name, "*ERROR*", sizeof(bank_name)); strncpy(bank_name, "*ERROR*", sizeof(bank_name));
if (!get_voice_by_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, configuration.performance.voice[voice_select_instance_id], voice_name, sizeof(voice_name))) if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name)))
strncpy(voice_name, "*ERROR*", sizeof(voice_name)); strncpy(voice_name, "*ERROR*", sizeof(voice_name));
lcd.show(0, 0, 2, configuration.performance.bank[voice_select_instance_id]); lcd.show(0, 0, 2, configuration.performance.bank[instance_id]);
lcd.show(1, 0, 2, configuration.performance.voice[voice_select_instance_id] + 1); lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1);
lcd.show(0, 4, 10, bank_name); lcd.show(0, 4, 10, bank_name);
lcd.show(1, 4, 10, voice_name); lcd.show(1, 4, 10, voice_name);
lcd.setCursor(15, 0); lcd.setCursor(15, 0);
if (voice_select_instance_id == 0) lcd.write(5);
lcd.write(voice_select_instance_id);
else
lcd.write(2);
lcd.setCursor(15, 1); lcd.setCursor(15, 1);
if (voice_select_instance_id == 1) lcd.write(6);
lcd.write(voice_select_instance_id);
else
lcd.write(3);
} }
else else
menu_voice_select = MENU_VOICE_BANK; menu_voice_select = MENU_VOICE_BANK;
@ -3501,28 +3510,28 @@ void UI_func_voice_select(uint8_t param)
#endif #endif
} }
if (strlen(g_bank_name[voice_select_instance_id]) > 0) if (strlen(g_bank_name[instance_id]) > 0)
{ {
strncpy(bank_name, g_bank_name[voice_select_instance_id], sizeof(bank_name)); strncpy(bank_name, g_bank_name[instance_id], sizeof(bank_name));
} }
else else
{ {
if (!get_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, sizeof(bank_name))) if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name)))
strncpy(bank_name, "*ERROR*", sizeof(bank_name)); strncpy(bank_name, "*ERROR*", sizeof(bank_name));
} }
if (strlen(g_voice_name[voice_select_instance_id]) > 0) if (strlen(g_voice_name[instance_id]) > 0)
{ {
strncpy(voice_name, g_voice_name[voice_select_instance_id], sizeof(voice_name)); strncpy(voice_name, g_voice_name[instance_id], sizeof(voice_name));
} }
else else
{ {
if (!get_voice_by_bank_name(configuration.performance.bank[voice_select_instance_id], bank_name, configuration.performance.voice[voice_select_instance_id], voice_name, sizeof(voice_name))) if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name)))
strncpy(voice_name, "*ERROR*", sizeof(voice_name)); strncpy(voice_name, "*ERROR*", sizeof(voice_name));
} }
lcd.show(0, 0, 2, configuration.performance.bank[voice_select_instance_id]); lcd.show(0, 0, 2, configuration.performance.bank[instance_id]);
lcd.show(1, 0, 2, configuration.performance.voice[voice_select_instance_id] + 1); lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1);
lcd.show(0, 4, 10, bank_name); lcd.show(0, 4, 10, bank_name);
lcd.show(1, 4, 10, voice_name); lcd.show(1, 4, 10, voice_name);
@ -3545,10 +3554,8 @@ void UI_func_voice_select(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_R].reset(); encoderDir[ENC_R].reset();
if (voice_select_instance_id == 0) if (instance_id == 0)
{ {
//eeprom_update_var(offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0], "configuration.performance.voice[0]"); //eeprom_update_var(offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0], "configuration.performance.voice[0]");
//eeprom_update_var(offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0], "configuration.performance.bank[0]"); //eeprom_update_var(offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0], "configuration.performance.bank[0]");
@ -4635,7 +4642,12 @@ 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) 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; uint8_t size = 0;
float v = float((value - min_value) * LCD_cols) / (max_value - min_value); #if NUM_DEXED == 1
uint8_t cols = LCD_cols;
#else
uint8_t cols = LCD_cols - 1;
#endif
float v = float((value - min_value) * cols) / (max_value - min_value);
float _vi = 0.0; float _vi = 0.0;
uint8_t vf = uint8_t(modff(v, &_vi) * 10.0 + 0.5); uint8_t vf = uint8_t(modff(v, &_vi) * 10.0 + 0.5);
uint8_t vi = uint8_t(_vi); uint8_t vi = uint8_t(_vi);
@ -4659,15 +4671,15 @@ void lcd_display_bar_float(const char* title, float value, float factor, int32_t
// Value-Brackets // Value-Brackets
if (brackets == true) if (brackets == true)
{ {
lcd.setCursor(LCD_cols - size, 0); lcd.setCursor(cols - size, 0);
lcd.print(F("[")); lcd.print(F("["));
lcd.setCursor(LCD_cols - 1, 0); lcd.setCursor(cols - 1, 0);
lcd.print(F("]")); lcd.print(F("]"));
} }
} }
// Value // Value
lcd.setCursor(LCD_cols - size, 0); lcd.setCursor(cols - size, 0);
lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign); lcd_display_float(value * factor, size_number, size_fraction, zeros, brackets, sign);
// Bar // Bar
@ -4676,16 +4688,16 @@ void lcd_display_bar_float(const char* title, float value, float factor, int32_t
if (vi == 0) if (vi == 0)
{ {
lcd.write((uint8_t)vf / 2.0 - 0.5); lcd.write((uint8_t)vf / 2.0 - 0.5);
for (uint8_t i = vi + 1; i < LCD_cols; i++) for (uint8_t i = vi + 1; i < cols; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
} }
else else
{ {
for (uint8_t i = 0; i < vi; i++) for (uint8_t i = 0; i < vi; i++)
lcd.write((uint8_t)4); // full block lcd.write((uint8_t)4); // full block
if (vi < LCD_cols) if (vi < cols)
lcd.write((uint8_t)vf / 2.0 - 0.5); lcd.write((uint8_t)vf / 2.0 - 0.5);
for (uint8_t i = vi + 1; i < LCD_cols; i++) for (uint8_t i = vi + 1; i < cols; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
} }
} }
@ -4698,7 +4710,12 @@ inline void lcd_display_meter_int(const char* title, uint32_t value, float facto
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_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; uint8_t size = 0;
float v = float((value - min_value) * LCD_cols) / (max_value - min_value); #if NUM_DEXED == 1
uint8_t cols = LCD_cols;
#else
uint8_t cols = LCD_cols - 1;
#endif
float v = float((value - min_value) * cols) / (max_value - min_value);
float _vi = 0.0; float _vi = 0.0;
uint8_t vf = uint8_t(modff(v, &_vi) * 10.0 + 0.5); uint8_t vf = uint8_t(modff(v, &_vi) * 10.0 + 0.5);
uint8_t vi = uint8_t(_vi); uint8_t vi = uint8_t(_vi);
@ -4722,15 +4739,15 @@ void lcd_display_meter_float(const char* title, float value, float factor, float
// Value-Brackets // Value-Brackets
if (brackets == true) if (brackets == true)
{ {
lcd.setCursor(LCD_cols - size, 0); lcd.setCursor(cols - size, 0);
lcd.print(F("[")); lcd.print(F("["));
lcd.setCursor(LCD_cols - 1, 0); lcd.setCursor(cols - 1, 0);
lcd.print(F("]")); lcd.print(F("]"));
} }
} }
// Value // Value
lcd.setCursor(LCD_cols - size, 0); lcd.setCursor(cols - size, 0);
lcd_display_float((value + offset) * factor, size_number, size_fraction, zeros, brackets, sign); lcd_display_float((value + offset) * factor, size_number, size_fraction, zeros, brackets, sign);
// Bar // Bar
@ -4739,26 +4756,46 @@ void lcd_display_meter_float(const char* title, float value, float factor, float
if (vi == 0) if (vi == 0)
{ {
lcd.write((uint8_t)(vf / 2.0 + 0.5)); lcd.write((uint8_t)(vf / 2.0 + 0.5));
for (uint8_t i = 1; i < LCD_cols; i++) for (uint8_t i = 1; i < cols; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
} }
else if (vi == LCD_cols) else if (vi == cols)
{ {
for (uint8_t i = 0; i < LCD_cols - 1; i++) for (uint8_t i = 0; i < cols - 1; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
lcd.write(4); lcd.write(4);
} }
else else
{ {
for (uint8_t i = 0; i < LCD_cols; i++) for (uint8_t i = 0; i < cols; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
lcd.setCursor(vi, 1); lcd.setCursor(vi, 1);
lcd.write((uint8_t)(vf / 2.0 + 0.5)); lcd.write((uint8_t)(vf / 2.0 + 0.5));
for (uint8_t i = vi + 1; i < LCD_cols; i++) for (uint8_t i = vi + 1; i < cols; i++)
lcd.print(F(" ")); // empty block lcd.print(F(" ")); // empty block
} }
} }
void lcd_active_instance_number(uint8_t instance_id)
{
for (uint8_t i = 0; i < 8; i++)
{
if (instance_id == 0)
{
instance_num[0][i] = inverse_num[0][i];
instance_num[1][i] = ~inverse_num[1][i];
}
else
{
instance_num[0][i] = ~inverse_num[0][i];
instance_num[1][i] = inverse_num[1][i];
}
}
lcd.createChar(5, (uint8_t*)instance_num[0]);
lcd.createChar(6, (uint8_t*)instance_num[1]);
}
void lcd_special_chars(uint8_t mode) void lcd_special_chars(uint8_t mode)
{ {
switch (mode) switch (mode)
@ -4775,8 +4812,8 @@ void lcd_special_chars(uint8_t mode)
} }
break; break;
case BLOCKBAR: case BLOCKBAR:
// set special chars for volumebar // set special chars for volume-bar
for (uint8_t i = 0; i < 5; i++) for (uint8_t i = 0; i < 7; i++)
{ {
#ifdef I2C_DISPLAY #ifdef I2C_DISPLAY
lcd.createChar(i, (uint8_t*)block_bar[i]); lcd.createChar(i, (uint8_t*)block_bar[i]);
@ -4786,24 +4823,13 @@ void lcd_special_chars(uint8_t mode)
} }
break; break;
case METERBAR: case METERBAR:
// set special chars for volumebar // set special chars for panorama-bar
for (uint8_t i = 0; i < 5; i++) for (uint8_t i = 0; i < 7; i++)
{ {
#ifdef I2C_DISPLAY #ifdef I2C_DISPLAY
lcd.createChar(i, (uint8_t*)meter_bar[i]); lcd.createChar(i, (uint8_t*)meter_bar[i]);
#else #else
flipped_meter_bar[i] = rotTile(meter_bar[i]); flipped_meter_bar[i] = rotTile(meter_bar[i]);
#endif
}
break;
case INVERSE_NUM:
// set special chars for volumebar
for (uint8_t i = 0; i < 4; i++)
{
#ifdef I2C_DISPLAY
lcd.createChar(i, (uint8_t*)inverse_num[i]);
#else
flipped_inverse_num[i] = rotTile(inverse_num[i]);
#endif #endif
} }
break; break;

@ -43,7 +43,7 @@
// Tools for testing MIDI: https://github.com/gbevin/SendMIDI // Tools for testing MIDI: https://github.com/gbevin/SendMIDI
// https://github.com/gbevin/ReceiveMIDI // https://github.com/gbevin/ReceiveMIDI
#define VERSION "0.9.9c" #define VERSION "0.9.9d"
//************************************************************************************************* //*************************************************************************************************
//* DEVICE SETTINGS //* DEVICE SETTINGS

Loading…
Cancel
Save