Module17: hide menu entries for soft potentiometers if hardware does not have them

This commit is contained in:
Silvano Seva 2024-06-21 18:38:00 +02:00
parent e50b8ce80c
commit 84d9803f57
3 changed files with 36 additions and 26 deletions

View File

@ -129,13 +129,13 @@ enum m17Items
enum module17Items enum module17Items
{ {
D_TXWIPER = 0, D_MICGAIN = 0,
D_RXWIPER, D_PTTINLEVEL,
D_PTTOUTLEVEL,
D_TXINVERT, D_TXINVERT,
D_RXINVERT, D_RXINVERT,
D_MICGAIN, D_TXWIPER,
D_PTTINLEVEL, D_RXWIPER
D_PTTOUTLEVEL
}; };
/** /**

View File

@ -100,13 +100,13 @@ const char *m17_items[] =
const char *module17_items[] = const char *module17_items[] =
{ {
"TX Softpot",
"RX Softpot",
"TX Phase",
"RX Phase",
"Mic Gain", "Mic Gain",
"PTT In", "PTT In",
"PTT Out" "PTT Out",
"TX Phase",
"RX Phase",
"TX Softpot",
"RX Softpot"
}; };
#ifdef CONFIG_GPS #ifdef CONFIG_GPS
@ -388,12 +388,17 @@ static void _ui_changeMicGain(int variation)
static void _ui_menuUp(uint8_t menu_entries) static void _ui_menuUp(uint8_t menu_entries)
{ {
uint8_t maxEntries = menu_entries - 1; uint8_t maxEntries = menu_entries - 1;
uint8_t ver = platform_getHwInfo()->hw_version; const hwInfo_t* hwinfo = platform_getHwInfo();
// Hide the "shutdown" main menu entry for versions lower than 0.1e // Hide the "shutdown" main menu entry for versions lower than 0.1e
if((ver < 1) && (state.ui_screen == MENU_TOP)) if((hwinfo->hw_version < 1) && (state.ui_screen == MENU_TOP))
maxEntries -= 1; maxEntries -= 1;
// Hide the softpot menu entries if hardware does not have them
uint8_t softpot = hwinfo->flags & MOD17_FLAGS_SOFTPOT;
if((softpot == 0) && (state.ui_screen == SETTINGS_MODULE17))
maxEntries -= 2;
if(ui_state.menu_selected > 0) if(ui_state.menu_selected > 0)
ui_state.menu_selected -= 1; ui_state.menu_selected -= 1;
else else
@ -403,12 +408,17 @@ static void _ui_menuUp(uint8_t menu_entries)
static void _ui_menuDown(uint8_t menu_entries) static void _ui_menuDown(uint8_t menu_entries)
{ {
uint8_t maxEntries = menu_entries - 1; uint8_t maxEntries = menu_entries - 1;
uint8_t ver = platform_getHwInfo()->hw_version; const hwInfo_t* hwinfo = platform_getHwInfo();
// Hide the "shutdown" main menu entry for versions lower than 0.1e // Hide the "shutdown" main menu entry for versions lower than 0.1e
if((ver < 1) && (state.ui_screen == MENU_TOP)) if((hwinfo->hw_version < 1) && (state.ui_screen == MENU_TOP))
maxEntries -= 1; maxEntries -= 1;
// Hide the softpot menu entries if hardware does not have them
uint8_t softpot = hwinfo->flags & MOD17_FLAGS_SOFTPOT;
if((softpot == 0) && (state.ui_screen == SETTINGS_MODULE17))
maxEntries -= 2;
if(ui_state.menu_selected < maxEntries) if(ui_state.menu_selected < maxEntries)
ui_state.menu_selected += 1; ui_state.menu_selected += 1;
else else

View File

@ -220,18 +220,6 @@ int _ui_getModule17ValueName(char *buf, uint8_t max_len, uint8_t index)
switch(index) switch(index)
{ {
case D_TXWIPER:
snprintf(buf, max_len, "%d", mod17CalData.tx_wiper);
break;
case D_RXWIPER:
snprintf(buf, max_len, "%d", mod17CalData.rx_wiper);
break;
case D_TXINVERT:
snprintf(buf, max_len, "%s", phase_values[mod17CalData.bb_tx_invert]);
break;
case D_RXINVERT:
snprintf(buf, max_len, "%s", phase_values[mod17CalData.bb_rx_invert]);
break;
case D_MICGAIN: case D_MICGAIN:
snprintf(buf, max_len, "%s", mic_gain_values[mod17CalData.mic_gain]); snprintf(buf, max_len, "%s", mic_gain_values[mod17CalData.mic_gain]);
break; break;
@ -241,6 +229,18 @@ int _ui_getModule17ValueName(char *buf, uint8_t max_len, uint8_t index)
case D_PTTOUTLEVEL: case D_PTTOUTLEVEL:
snprintf(buf, max_len, "%s", mod17CalData.ptt_out_level ? "Act high" : "Act low"); snprintf(buf, max_len, "%s", mod17CalData.ptt_out_level ? "Act high" : "Act low");
break; break;
case D_TXINVERT:
snprintf(buf, max_len, "%s", phase_values[mod17CalData.bb_tx_invert]);
break;
case D_RXINVERT:
snprintf(buf, max_len, "%s", phase_values[mod17CalData.bb_rx_invert]);
break;
case D_TXWIPER:
snprintf(buf, max_len, "%d", mod17CalData.tx_wiper);
break;
case D_RXWIPER:
snprintf(buf, max_len, "%d", mod17CalData.rx_wiper);
break;
} }
return 0; return 0;