kopia lustrzana https://github.com/OpenRTX/OpenRTX
Added CAN setting
rodzic
e93666a515
commit
adc916dbca
|
@ -125,9 +125,15 @@ enum settingsGPSItems
|
|||
};
|
||||
#endif
|
||||
|
||||
enum m17Items
|
||||
{
|
||||
M_CALLSIGN = 0
|
||||
,M_CAN
|
||||
};
|
||||
|
||||
enum module17Items
|
||||
{
|
||||
D_TXWIPER,
|
||||
D_TXWIPER = 0,
|
||||
D_RXWIPER,
|
||||
D_TXINVERT,
|
||||
D_RXINVERT,
|
||||
|
@ -214,6 +220,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 *m17_items[];
|
||||
extern const char *module17_items[];
|
||||
extern const char *backup_restore_items[];
|
||||
extern const char *info_items[];
|
||||
|
@ -223,6 +230,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 m17_num;
|
||||
extern const uint8_t module17_num;
|
||||
extern const uint8_t info_num;
|
||||
extern const uint8_t author_num;
|
||||
|
|
|
@ -96,6 +96,12 @@ const char *display_items[] =
|
|||
"Timer"
|
||||
};
|
||||
|
||||
const char *m17_items[] =
|
||||
{
|
||||
"Callsign",
|
||||
"CAN"
|
||||
};
|
||||
|
||||
const char *module17_items[] =
|
||||
{
|
||||
"TX Softpot",
|
||||
|
@ -176,6 +182,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 m17_num = sizeof(m17_items)/sizeof(m17_items[0]);
|
||||
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]);
|
||||
|
@ -578,6 +585,15 @@ bool _ui_exitStandby(long long now)
|
|||
return true;
|
||||
}
|
||||
|
||||
void _ui_changeCAN(int variation)
|
||||
{
|
||||
state.m17_data.can += variation;
|
||||
|
||||
// Inversion can be 1 or 0
|
||||
if(state.m17_data.can > 15) state.m17_data.can = 15;
|
||||
if(state.m17_data.can < 0) state.m17_data.can = 0;
|
||||
}
|
||||
|
||||
void _ui_changeTxWiper(int variation)
|
||||
{
|
||||
mod17CalData.tx_wiper += variation;
|
||||
|
@ -1197,6 +1213,7 @@ void ui_updateFSM(bool *sync_rtx)
|
|||
#endif
|
||||
// M17 Settings
|
||||
case SETTINGS_M17:
|
||||
|
||||
if(ui_state.edit_mode)
|
||||
{
|
||||
if(msg.keys & KEY_ENTER)
|
||||
|
@ -1205,7 +1222,6 @@ void ui_updateFSM(bool *sync_rtx)
|
|||
// Save selected callsign and disable input mode
|
||||
strncpy(state.settings.callsign, ui_state.new_callsign, 10);
|
||||
ui_state.edit_mode = false;
|
||||
*sync_rtx = true;
|
||||
}
|
||||
else if(msg.keys & KEY_ESC)
|
||||
// Discard selected callsign and disable input mode
|
||||
|
@ -1216,15 +1232,49 @@ void ui_updateFSM(bool *sync_rtx)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(msg.keys & KEY_ENTER)
|
||||
if(msg.keys & KEY_LEFT)
|
||||
{
|
||||
// Enable callsign input
|
||||
ui_state.edit_mode = true;
|
||||
// Reset text input variables
|
||||
_ui_textInputReset(ui_state.new_callsign);
|
||||
switch(ui_state.menu_selected)
|
||||
{
|
||||
case M_CAN:
|
||||
_ui_changeCAN(-1);
|
||||
break;
|
||||
default:
|
||||
state.ui_screen = SETTINGS_M17;
|
||||
}
|
||||
}
|
||||
else if(msg.keys & KEY_RIGHT)
|
||||
{
|
||||
switch(ui_state.menu_selected)
|
||||
{
|
||||
case M_CAN:
|
||||
_ui_changeCAN(+1);
|
||||
break;
|
||||
default:
|
||||
state.ui_screen = SETTINGS_M17;
|
||||
}
|
||||
}
|
||||
else if(msg.keys & KEY_ENTER)
|
||||
{
|
||||
switch(ui_state.menu_selected)
|
||||
{
|
||||
case M_CALLSIGN:
|
||||
// Enable callsign input
|
||||
ui_state.edit_mode = true;
|
||||
// Reset text input variables
|
||||
_ui_textInputReset(ui_state.new_callsign);
|
||||
break;
|
||||
default:
|
||||
state.ui_screen = SETTINGS_M17;
|
||||
}
|
||||
}
|
||||
else if(msg.keys & KEY_UP || msg.keys & KNOB_LEFT)
|
||||
_ui_menuUp(m17_num);
|
||||
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_RIGHT)
|
||||
_ui_menuDown(m17_num);
|
||||
else if(msg.keys & KEY_ESC)
|
||||
{
|
||||
*sync_rtx = true;
|
||||
nvm_writeSettings(&state.settings);
|
||||
_ui_menuBack(MENU_SETTINGS);
|
||||
}
|
||||
|
|
|
@ -181,6 +181,30 @@ int _ui_getDisplayValueName(char *buf, uint8_t max_len, uint8_t index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getM17EntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= m17_num) return -1;
|
||||
snprintf(buf, max_len, "%s", m17_items[index]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getM17ValueName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= m17_num) return -1;
|
||||
uint16_t value = 0;
|
||||
switch(index)
|
||||
{
|
||||
case M_CALLSIGN:
|
||||
snprintf(buf, max_len, "%s", last_state.settings.callsign);
|
||||
return 0;
|
||||
case M_CAN:
|
||||
value = last_state.m17_data.can;
|
||||
break;
|
||||
}
|
||||
snprintf(buf, max_len, "%d", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _ui_getModule17EntryName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
if(index >= module17_num) return -1;
|
||||
|
@ -521,9 +545,11 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
// Print "M17 Settings" on top bar
|
||||
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "M17 Settings");
|
||||
gfx_printLine(1, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
/* gfx_printLine(1, 4, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
layout.horizontal_pad, layout.menu_font,
|
||||
TEXT_ALIGN_LEFT, color_white, "Callsign:");
|
||||
TEXT_ALIGN_LEFT, color_white, "Callsign:"); */
|
||||
_ui_drawMenuListValue(ui_state, ui_state->menu_selected, _ui_getM17EntryName,
|
||||
_ui_getM17ValueName);
|
||||
if(ui_state->edit_mode)
|
||||
{
|
||||
uint16_t rect_width = SCREEN_WIDTH - (layout.horizontal_pad * 2);
|
||||
|
@ -536,13 +562,13 @@ void _ui_drawSettingsM17(ui_state_t* ui_state)
|
|||
layout.horizontal_pad, layout.input_font,
|
||||
TEXT_ALIGN_CENTER, color_white, ui_state->new_callsign);
|
||||
}
|
||||
else
|
||||
/*else
|
||||
{
|
||||
// Print M17 current callsign
|
||||
gfx_printLine(1, 1, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
|
||||
layout.horizontal_pad, layout.input_font,
|
||||
TEXT_ALIGN_CENTER, color_white, last_state.settings.callsign);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void _ui_drawSettingsModule17(ui_state_t* ui_state)
|
||||
|
|
Ładowanie…
Reference in New Issue