Implemented softpot settings UI for Module 17

pull/139/head
Mathis Schmieder 2022-10-30 16:17:57 +01:00 zatwierdzone przez Silvano Seva
rodzic 2b7fc6e150
commit f32255c258
3 zmienionych plików z 159 dodań i 0 usunięć

Wyświetl plik

@ -24,6 +24,7 @@
#include <state.h>
#include <graphics.h>
#include <interfaces/keyboard.h>
#include <calibInfo_Mod17.h>
#include <stdint.h>
#include <event.h>
#include <hwconfig.h>
@ -61,6 +62,7 @@ enum uiScreen
SETTINGS_DISPLAY,
SETTINGS_GPS,
SETTINGS_M17,
SETTINGS_MODULE17,
SETTINGS_RESET2DEFAULTS,
LOW_BAT
};
@ -93,6 +95,7 @@ enum settingsItems
,S_GPS
#endif
,S_M17
,S_MOD17
,S_RESET2DEFAULTS
};
@ -120,6 +123,15 @@ enum settingsGPSItems
};
#endif
enum module17Items
{
D_TXWIPER,
D_RXWIPER,
D_TXINVERT,
D_RXINVERT,
D_SAVE
};
/**
* Struct containing a set of positions and sizes that get
* calculated for the selected display size.
@ -200,6 +212,7 @@ extern const char *menu_items[];
extern const char *settings_items[];
extern const char *display_items[];
extern const char *settings_gps_items[];
extern const char *module17_items[];
extern const char *backup_restore_items[];
extern const char *info_items[];
extern const char *authors[];
@ -208,6 +221,7 @@ extern const uint8_t settings_num;
extern const uint8_t display_num;
extern const uint8_t settings_gps_num;
extern const uint8_t backup_restore_num;
extern const uint8_t module17_num;
extern const uint8_t info_num;
extern const uint8_t author_num;
extern const color_t color_black;
@ -215,4 +229,7 @@ extern const color_t color_grey;
extern const color_t color_white;
extern const color_t yellow_fab413;
// Calibration data, for digital pot and phase inversion
extern mod17Calib_t mod17CalData;
#endif /* UI_MOD17_H */

Wyświetl plik

@ -60,6 +60,7 @@ extern void _ui_drawSettingsTimeDateSet(ui_state_t* ui_state);
#endif
extern void _ui_drawSettingsDisplay(ui_state_t* ui_state);
extern void _ui_drawSettingsM17(ui_state_t* ui_state);
extern void _ui_drawSettingsModule17(ui_state_t* ui_state);
extern void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state);
extern bool _ui_drawMacroMenu();
@ -83,6 +84,7 @@ const char *settings_items[] =
"GPS",
#endif
"M17",
"Module 17",
"Default Settings"
};
@ -94,6 +96,14 @@ const char *display_items[] =
"Timer"
};
const char *module17_items[] =
{
"TX Wiper",
"RX Wiper",
"TX Phase Inversion",
"RX Phase Inversion"
};
#ifdef GPS_PRESENT
const char *settings_gps_items[] =
{
@ -163,6 +173,7 @@ const uint8_t display_num = sizeof(display_items)/sizeof(display_items[0]);
#ifdef GPS_PRESENT
const uint8_t settings_gps_num = sizeof(settings_gps_items)/sizeof(settings_gps_items[0]);
#endif
const uint8_t module17_num = sizeof(module17_items)/sizeof(module17_items[0]);
const uint8_t info_num = sizeof(info_items)/sizeof(info_items[0]);
const uint8_t author_num = sizeof(authors)/sizeof(authors[0]);
@ -564,6 +575,36 @@ bool _ui_exitStandby(long long now)
return true;
}
void _ui_changeTxWiper(int variation)
{
mod17CalData.tx_wiper += variation;
// Max value for softpot is 0x100, min value is set to 0x001
if(mod17CalData.tx_wiper > 0x100) mod17CalData.tx_wiper = 0x100;
if(mod17CalData.tx_wiper < 0x001) mod17CalData.tx_wiper = 0x001;
}
void _ui_changeRxWiper(int variation)
{
mod17CalData.rx_wiper += variation;
// Max value for softpot is 0x100, min value is set to 0x001
if(mod17CalData.rx_wiper > 0x100) mod17CalData.rx_wiper = 0x100;
if(mod17CalData.rx_wiper < 0x001) mod17CalData.rx_wiper = 0x001;
}
void _ui_changeTxInvert(int variation)
{
// Inversion can be 1 or 0, bit field value ensures no overflow
mod17CalData.tx_invert += variation;
}
void _ui_changeRxInvert(int variation)
{
// Inversion can be 1 or 0, bit field value ensures no overflow
mod17CalData.rx_invert += variation;
}
void _ui_menuUp(uint8_t menu_entries)
{
if(ui_state.menu_selected > 0)
@ -960,6 +1001,9 @@ void ui_updateFSM(bool *sync_rtx)
case S_M17:
state.ui_screen = SETTINGS_M17;
break;
case S_MOD17:
state.ui_screen = SETTINGS_MODULE17;
break;
case S_RESET2DEFAULTS:
state.ui_screen = SETTINGS_RESET2DEFAULTS;
break;
@ -1173,6 +1217,59 @@ void ui_updateFSM(bool *sync_rtx)
}
}
break;
// Module17 Settings
case SETTINGS_MODULE17:
if(msg.keys & KEY_LEFT || (ui_state.edit_mode &&
(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)))
{
switch(ui_state.menu_selected)
{
case D_TXWIPER:
_ui_changeTxWiper(-1);
break;
case D_RXWIPER:
_ui_changeRxWiper(-1);
break;
case D_TXINVERT:
_ui_changeTxInvert(-1);
break;
case D_RXINVERT:
_ui_changeRxInvert(-1);
break;
default:
state.ui_screen = SETTINGS_MODULE17;
}
}
else if(msg.keys & KEY_RIGHT || (ui_state.edit_mode &&
(msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)))
{
switch(ui_state.menu_selected)
{
case D_TXWIPER:
_ui_changeTxWiper(+1);
break;
case D_RXWIPER:
_ui_changeRxWiper(+1);
break;
case D_TXINVERT:
_ui_changeTxInvert(+1);
break;
case D_RXINVERT:
_ui_changeRxInvert(+1);
break;
default:
state.ui_screen = SETTINGS_MODULE17;
}
}
else if(msg.keys & KEY_UP || msg.keys & KNOB_LEFT)
_ui_menuUp(module17_num);
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
_ui_menuDown(module17_num);
else if(msg.keys & KEY_ENTER)
ui_state.edit_mode = !ui_state.edit_mode;
else if(msg.keys & KEY_ESC)
_ui_menuBack(MENU_SETTINGS);
break;
}
}
else if(event.type == EVENT_STATUS)
@ -1261,6 +1358,10 @@ bool ui_updateGUI()
case SETTINGS_M17:
_ui_drawSettingsM17(&ui_state);
break;
// Module 17 settings screen
case SETTINGS_MODULE17:
_ui_drawSettingsModule17(&ui_state);
break;
// Screen to support resetting Settings and VFO to defaults
case SETTINGS_RESET2DEFAULTS:
_ui_drawSettingsReset2Defaults(&ui_state);

Wyświetl plik

@ -168,6 +168,36 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
return 0;
}
int _ui_getModule17EntryName(char *buf, uint8_t max_len, uint8_t index)
{
if(index >= module17_num) return -1;
snprintf(buf, max_len, "%s", module17_items[index]);
return 0;
}
int _ui_getModule17ValueName(char *buf, uint8_t max_len, uint8_t index)
{
if(index >= module17_num) return -1;
uint16_t value = 0;
switch(index)
{
case D_TXWIPER:
value = mod17CalData.tx_wiper;
break;
case D_RXWIPER:
value = mod17CalData.rx_wiper;
break;
case D_TXINVERT:
value = mod17CalData.tx_invert;
break;
case D_RXINVERT:
value = mod17CalData.rx_invert;
break;
}
snprintf(buf, max_len, "%d", value);
return 0;
}
#ifdef GPS_PRESENT
int _ui_getSettingsGPSEntryName(char *buf, uint8_t max_len, uint8_t index)
{
@ -499,6 +529,17 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
}
}
void _ui_drawSettingsModule17(ui_state_t* ui_state)
{
gfx_clearScreen();
// Print "Module17 Settings" on top bar
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, "Module17 Settings");
// Print Module17 settings entries
_ui_drawMenuListValue(ui_state, ui_state->menu_selected, _ui_getModule17EntryName,
_ui_getModule17ValueName);
}
void _ui_drawSettingsReset2Defaults(ui_state_t* ui_state)
{
(void) ui_state;