Add XTREME_SETTINGS_WAIT() for race conditions

This commit is contained in:
Willy-JL
2023-05-02 22:54:32 +01:00
parent 5d62ce919b
commit 331f26547b
3 changed files with 17 additions and 2 deletions
+13 -1
View File
@@ -6,6 +6,7 @@
#define TAG "XtremeSettings"
XtremeSettings xtreme_settings = {
.loaded = false,
.asset_pack = "",
.anim_speed = 100, // 100%
.cycle_anims = 0, // Meta.txt
@@ -27,7 +28,7 @@ XtremeSettings xtreme_settings = {
.favorite_timeout = 0, // OFF
.bad_bt = false, // USB
.bad_bt_remember = false, // OFF
.butthurt_timer = 43200, // 12 H
.butthurt_timer = 21600, // 6 H
.rgb_backlight = false, // OFF
};
@@ -88,6 +89,8 @@ void XTREME_SETTINGS_LOAD() {
}
flipper_format_free(file);
furi_record_close(RECORD_STORAGE);
xtreme_settings.loaded = true;
}
void XTREME_SETTINGS_SAVE() {
@@ -128,3 +131,12 @@ void XTREME_SETTINGS_SAVE() {
XtremeSettings* XTREME_SETTINGS() {
return &xtreme_settings;
}
XtremeSettings* XTREME_SETTINGS_WAIT() {
if(furi_hal_is_normal_boot()) {
while(!xtreme_settings.loaded) {
furi_delay_ms(50);
}
}
return &xtreme_settings;
}
+3 -1
View File
@@ -13,6 +13,7 @@ extern "C" {
#define XTREME_ASSETS_PACK_NAME_LEN 32
typedef struct {
bool loaded;
char asset_pack[XTREME_ASSETS_PACK_NAME_LEN];
uint32_t anim_speed;
int32_t cycle_anims;
@@ -38,8 +39,9 @@ typedef struct {
bool rgb_backlight;
} XtremeSettings;
XtremeSettings* XTREME_SETTINGS();
void XTREME_SETTINGS_SAVE();
XtremeSettings* XTREME_SETTINGS();
XtremeSettings* XTREME_SETTINGS_WAIT();
typedef struct {
bool is_nsfw;