Add backlight into state, macro functionality

Now the current backlight level is part of the radio state, and the
first few macros have been implemented although the rate limiting of
presses has still to be fixed.
replace/e0b7f8dd29a13974fff09b340173d8e4257d5b61
Niccolò Izzo 2021-01-03 22:53:07 +01:00
rodzic 09c94a943a
commit 2dcefb7c0e
3 zmienionych plików z 37 dodań i 2 usunięć

Wyświetl plik

@ -38,6 +38,7 @@ typedef struct
float v_bat;
uint8_t ui_screen;
uint8_t backlight_level;
uint8_t tuner_mode;
//time_t rx_status_tv;

Wyświetl plik

@ -36,6 +36,7 @@ void state_init()
#endif
state.v_bat = platform_getVbat();
state.backlight_level = 255;
state.channelInfoUpdated = true;
state.channel.mode = FM;
state.channel.bandwidth = BW_25;

Wyświetl plik

@ -162,6 +162,7 @@ freq_t new_tx_frequency;
char new_rx_freq_buf[14] = "";
char new_tx_freq_buf[14] = "";
#ifdef HAS_RTC
curTime_t new_timedate = {0};
char new_date_buf[9] = "";
@ -733,7 +734,8 @@ bool _ui_drawMenuMacro(state_t* last_state) {
gfx_print(layout.line2_left, "4", layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413);
char bw_str[7] = { 0 };
switch (last_state->channel.bandwidth) {
switch (last_state->channel.bandwidth)
{
case BW_12_5:
snprintf(bw_str, 7, " 12.5");
break;
@ -1015,12 +1017,43 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
else if(msg.keys & KEY_MONI)
{
// Open Macro Menu
_ui_drawDarkOverlay();
state.ui_screen = MENU_MACRO;
}
break;
// Macro menu
case MENU_MACRO:
_ui_drawDarkOverlay();
// If a number is pressed perform the corresponding macro
if(!msg.long_press && input_isNumberPressed(msg))
{
input_number = input_getPressedNumber(msg);
int32_t new_blight = state.backlight_level;
switch(input_number)
{
case 3:
if (state.channel.power == 1.0f)
state.channel.power = 5.0f;
else
state.channel.power = 1.0f;
break;
case 4:
state.channel.bandwidth++;
state.channel.bandwidth %= 3;
break;
case 7:
new_blight += 10;
new_blight = (new_blight > 255) ? 255 : new_blight;
state.backlight_level = new_blight;
platform_setBacklightLevel(state.backlight_level);
break;
case 8:
new_blight -= 10;
new_blight = (new_blight < 0) ? 0 : new_blight;
state.backlight_level = new_blight;
platform_setBacklightLevel(state.backlight_level);
break;
}
}
// Exit from this menu when monitor key is released
if(!(msg.keys & KEY_MONI))
state.ui_screen = VFO_MAIN;