kopia lustrzana https://github.com/OpenRTX/OpenRTX
Added 'packed' attribute to settings data structure. Some refactoring of settings and state code.
rodzic
35bde9bccb
commit
d0e8d15389
|
@ -30,8 +30,17 @@ typedef struct
|
|||
bool gps_enabled;
|
||||
bool gps_set_time;
|
||||
}
|
||||
settings_t;
|
||||
__attribute__((packed)) settings_t;
|
||||
|
||||
extern const settings_t default_settings;
|
||||
|
||||
static const settings_t default_settings =
|
||||
{
|
||||
"OPNRTX", // Settings valid string
|
||||
255, // Brightness
|
||||
60, // Contrast
|
||||
0, // UTC Timezone
|
||||
false, // GPS enabled
|
||||
true // GPS set time
|
||||
};
|
||||
|
||||
#endif /* SETTINGS_H */
|
||||
|
|
|
@ -75,10 +75,10 @@ typedef struct
|
|||
|
||||
uint8_t ui_screen;
|
||||
uint8_t tuner_mode;
|
||||
|
||||
|
||||
//time_t rx_status_tv;
|
||||
//bool rx_status;
|
||||
|
||||
|
||||
//time_t tx_status_tv;
|
||||
//bool tx_status;
|
||||
|
||||
|
@ -113,7 +113,7 @@ enum RtxStatus
|
|||
RTX_TX
|
||||
};
|
||||
|
||||
extern state_t state;
|
||||
state_t state;
|
||||
|
||||
/**
|
||||
* This function initializes the Radio state, acquiring the information
|
||||
|
|
|
@ -26,22 +26,10 @@
|
|||
#include <interfaces/platform.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
|
||||
state_t state;
|
||||
|
||||
const settings_t default_settings =
|
||||
{
|
||||
"OPNRTX", // Settings valid string
|
||||
255, // Brightness
|
||||
60, // Contrast
|
||||
0, // UTC Timezone
|
||||
false, // GPS enabled
|
||||
true // GPS set time
|
||||
};
|
||||
|
||||
void state_init()
|
||||
{
|
||||
/*
|
||||
* TODO: Read current state parameters from hardware,
|
||||
* TODO: Read current state parameters from hardware,
|
||||
* or initialize them to sane defaults
|
||||
*/
|
||||
state.radioStateUpdated = true;
|
||||
|
@ -52,7 +40,7 @@ void state_init()
|
|||
state.v_bat = platform_getVbat();
|
||||
state.charge = battery_getCharge(state.v_bat);
|
||||
state.rssi = rtx_getRssi();
|
||||
|
||||
|
||||
// Set default channel index (it is 1-based)
|
||||
state.channel_index = 1;
|
||||
// Read VFO channel from Flash storage
|
||||
|
@ -79,7 +67,7 @@ void state_init()
|
|||
state.voxLevel = 0;
|
||||
|
||||
state.emergency = false;
|
||||
|
||||
|
||||
// Read settings from flash memory
|
||||
int valid = nvm_readSettings(&state.settings);
|
||||
// Settings in flash memory were not valid, restoring default settings
|
||||
|
@ -98,10 +86,16 @@ void state_terminate()
|
|||
|
||||
void state_applyTimezone()
|
||||
{
|
||||
if(state.time.hour + state.settings.utc_timezone >= 24)
|
||||
if(state.time.hour + state.settings.utc_timezone >= 24)
|
||||
{
|
||||
state.time.hour = state.time.hour - 24 + state.settings.utc_timezone;
|
||||
else if(state.time.hour + state.settings.utc_timezone < 0)
|
||||
}
|
||||
else if(state.time.hour + state.settings.utc_timezone < 0)
|
||||
{
|
||||
state.time.hour = state.time.hour + 24 + state.settings.utc_timezone;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.time.hour += state.settings.utc_timezone;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue