|
|
@ -29,12 +29,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef I2C_DISPLAY // selecting sounds by encoder, button and display
|
|
|
|
#ifdef I2C_DISPLAY // selecting sounds by encoder, button and display
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elapsedMillis ui_back_to_main; |
|
|
|
enum ui_state {UI_MAIN}; |
|
|
|
|
|
|
|
uint8_t ui_state = UI_MAIN; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handle_ui(void) |
|
|
|
void handle_ui(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (ui_back_to_main >= UI_AUTO_BACK_MS && ui_state != UI_MAIN) |
|
|
|
|
|
|
|
ui_show_main(); |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_ENCODER; i++) |
|
|
|
for (uint8_t i = 0; i < NUM_ENCODER; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
but[i].update(); |
|
|
|
but[i].update(); |
|
|
@ -57,11 +58,13 @@ void handle_ui(void) |
|
|
|
case 0: // left encoder moved
|
|
|
|
case 0: // left encoder moved
|
|
|
|
if (enc[i].read() <= 0) |
|
|
|
if (enc[i].read() <= 0) |
|
|
|
enc[i].write(0); |
|
|
|
enc[i].write(0); |
|
|
|
else if (enc[i].read() >= 20) |
|
|
|
else if (enc[i].read() >= ENC_VOL_STEPS) |
|
|
|
enc[i].write(20); |
|
|
|
enc[i].write(ENC_VOL_STEPS); |
|
|
|
set_volume(float(map(enc[i].read(), 0, 20, 0, 100))/100, vol_left, vol_right); |
|
|
|
set_volume(float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100, vol_left, vol_right); |
|
|
|
|
|
|
|
ui_show_volume(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1: // right encoder moved
|
|
|
|
case 1: // right encoder moved
|
|
|
|
|
|
|
|
ui_show_main(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -75,15 +78,33 @@ void handle_ui(void) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*int32_t getEncPosition(uint8_t encoder_number)
|
|
|
|
void ui_show_main(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return enc[encoder_number].read() / 4; |
|
|
|
ui_state = UI_MAIN; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
lcd.clear(); |
|
|
|
|
|
|
|
lcd.show(0, 0, 2, bank + 1); |
|
|
|
|
|
|
|
lcd.show(0, 2, 1, " "); |
|
|
|
|
|
|
|
lcd.show(0, 3, 10, bank_name); |
|
|
|
|
|
|
|
lcd.show(1, 0, 2, voice + 1); |
|
|
|
|
|
|
|
lcd.show(1, 2, 1, " "); |
|
|
|
|
|
|
|
lcd.show(1, 3, 10, voice_name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setEncPosition(uint8_t encoder_number, int32_t value) |
|
|
|
void ui_show_volume(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
enc[encoder_number].write(value * 4); |
|
|
|
ui_back_to_main = 0; |
|
|
|
enc_val[encoder_number] = value * 4; |
|
|
|
|
|
|
|
}*/ |
|
|
|
if (ui_state != UI_VOLUME) |
|
|
|
|
|
|
|
lcd.show(0, 0, LCD_CHARS, "Volume"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lcd.show(0, LCD_CHARS - 3, 3, vol * 100); |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < map(vol * 100, 0, 100, 0, LCD_CHARS); i++) |
|
|
|
|
|
|
|
lcd.show(1, i, 1, "*"); |
|
|
|
|
|
|
|
for (uint8_t i = map(vol * 100, 0, 100, 0, LCD_CHARS); i < LCD_CHARS; i++) |
|
|
|
|
|
|
|
lcd.show(1, i, 1, " "); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui_state = UI_VOLUME; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|