Reorganised settings data structure

pull/53/head
Silvano Seva 2021-11-08 21:44:33 +01:00
rodzic bbf77c4ab0
commit c91e306026
8 zmienionych plików z 33 dodań i 27 usunięć

Wyświetl plik

@ -25,29 +25,29 @@
typedef struct
{
uint8_t valid[7]; // Should contain "OPNRTX" in a valid settings_t
uint8_t brightness;
uint8_t contrast;
int8_t utc_timezone;
bool gps_enabled;
bool gps_set_time;
char callsign[10]; // Plaintext callsign, for future use
uint8_t brightness; // Display brightness
uint8_t contrast; // Display contrast
uint8_t sqlLevel; // Squelch level
uint8_t voxLevel; // Vox level
int8_t utc_timezone; // Timezone
bool gps_enabled; // GPS active
char callsign[10]; // Plaintext callsign, for future use
}
__attribute__((packed)) settings_t;
static const settings_t default_settings =
{
"OPNRTX", // Settings valid string
255, // Brightness
#ifdef SCREEN_CONTRAST
DEFAULT_CONTRAST, // Contrast
#else
255, // Contrast
#endif
4, // Squelch level, 4 = S3
0, // Vox level
0, // UTC Timezone
false, // GPS enabled
true, // GPS set time
"" // Empty callsign
};

Wyświetl plik

@ -98,13 +98,11 @@ typedef struct
bool zone_enabled;
zone_t zone;
uint8_t rtxStatus;
// Squelch steps from 0 to 15
uint8_t sqlLevel;
uint8_t voxLevel;
bool emergency;
settings_t settings;
gps_t gps_data;
bool gps_set_time;
m17_t m17_data;
}
state_t;

Wyświetl plik

@ -36,7 +36,7 @@ void gps_taskFunc(char *line, __attribute__((unused)) int len, state_t *state)
// Little mechanism to ensure that RTC is synced with GPS time only once.
static bool isRtcSyncronised = false;
if(!state->settings.gps_set_time)
if(!state->gps_set_time)
{
isRtcSyncronised = false;
}
@ -67,7 +67,7 @@ void gps_taskFunc(char *line, __attribute__((unused)) int len, state_t *state)
}
// Synchronize RTC with GPS UTC clock, only when fix is done
if((state->settings.gps_set_time) &&
if((state->gps_set_time) &&
(state->gps_data.fix_quality > 0) && (!isRtcSyncronised))
{
rtc_setTime(state->gps_data.timestamp);

Wyświetl plik

@ -72,8 +72,8 @@ void state_init()
}
state.zone_enabled = false;
state.rtxStatus = RTX_OFF;
state.sqlLevel = 4; // Default Squelch: S3 = 4
state.voxLevel = 0;
state.settings.sqlLevel = 4; // Default Squelch: S3 = 4
state.settings.voxLevel = 0;
state.emergency = false;

Wyświetl plik

@ -97,7 +97,7 @@ void *ui_task(void *arg)
rtx_cfg.rxFrequency = state.channel.rx_frequency;
rtx_cfg.txFrequency = state.channel.tx_frequency;
rtx_cfg.txPower = state.channel.power;
rtx_cfg.sqlLevel = state.sqlLevel;
rtx_cfg.sqlLevel = state.settings.sqlLevel;
rtx_cfg.rxToneEn = state.channel.fm.rxToneEn;
rtx_cfg.rxTone = ctcss_tone[state.channel.fm.rxTone];
rtx_cfg.txToneEn = state.channel.fm.txToneEn;

Wyświetl plik

@ -704,18 +704,26 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
#ifdef HAS_ABSOLUTE_KNOB // If the radio has an absolute position knob
if(msg.keys & KNOB_LEFT || msg.keys & KNOB_RIGHT) {
state.sqlLevel = platform_getChSelector() - 1;
state.settings.sqlLevel = platform_getChSelector() - 1;
*sync_rtx = true;
}
#else // Use left and right buttons or relative position knob
// NOTE: Use up and down for UV380 which has not yet a functional knob
if(msg.keys & KEY_LEFT || msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT) {
state.sqlLevel = (state.sqlLevel == 0) ? 0 : state.sqlLevel - 1;
*sync_rtx = true;
if(msg.keys & KEY_LEFT || msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
{
if(state.settings.sqlLevel > 0)
{
state.settings.sqlLevel -= 1;
*sync_rtx = true;
}
}
else if(msg.keys & KEY_RIGHT || msg.keys & KEY_UP || msg.keys & KNOB_RIGHT) {
state.sqlLevel = (state.sqlLevel == 15) ? 15 : state.sqlLevel + 1;
*sync_rtx = true;
else if(msg.keys & KEY_RIGHT || msg.keys & KEY_UP || msg.keys & KNOB_RIGHT)
{
if(state.settings.sqlLevel < 15)
{
state.settings.sqlLevel += 1;
*sync_rtx = true;
}
}
#endif
}
@ -1416,7 +1424,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
}
break;
case G_SET_TIME:
state.settings.gps_set_time = !state.settings.gps_set_time;
state.gps_set_time = !state.gps_set_time;
break;
case G_TIMEZONE:
if(msg.keys & KEY_LEFT || msg.keys & KEY_UP ||

Wyświetl plik

@ -154,7 +154,7 @@ void _ui_drawMainBottom()
{
// Squelch bar
float rssi = last_state.rssi;
float squelch = last_state.sqlLevel / 16.0f;
float squelch = last_state.settings.sqlLevel / 16.0f;
uint16_t meter_width = SCREEN_WIDTH - 2 * layout.horizontal_pad;
uint16_t meter_height = layout.bottom_h;
point_t meter_pos = { layout.horizontal_pad,

Wyświetl plik

@ -160,7 +160,7 @@ int _ui_getSettingsGPSValueName(char *buf, uint8_t max_len, uint8_t index)
snprintf(buf, max_len, "%s", (last_state.settings.gps_enabled) ? "ON" : "OFF");
break;
case G_SET_TIME:
snprintf(buf, max_len, "%s", (last_state.settings.gps_set_time) ? "ON" : "OFF");
snprintf(buf, max_len, "%s", (last_state.gps_set_time) ? "ON" : "OFF");
break;
case G_TIMEZONE:
// Add + prefix to positive numbers