Added 'packed' attribute to settings data structure. Some refactoring of settings and state code.

replace/1ccc5b19fe76c12ee179fc4b5afb698e5a5c0fdd
Silvano Seva 2021-02-21 19:25:09 +01:00
rodzic 35bde9bccb
commit d0e8d15389
3 zmienionych plików z 25 dodań i 22 usunięć

Wyświetl plik

@ -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 */

Wyświetl plik

@ -113,7 +113,7 @@ enum RtxStatus
RTX_TX
};
extern state_t state;
state_t state;
/**
* This function initializes the Radio state, acquiring the information

Wyświetl plik

@ -26,18 +26,6 @@
#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()
{
/*
@ -99,9 +87,15 @@ void state_terminate()
void state_applyTimezone()
{
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)
{
state.time.hour = state.time.hour + 24 + state.settings.utc_timezone;
}
else
{
state.time.hour += state.settings.utc_timezone;
}
}