Merge remote-tracking branch 'ofw/dev' into mntm-dev

This commit is contained in:
Willy-JL
2024-08-05 01:50:20 +02:00
109 changed files with 1115 additions and 1860 deletions

View File

@@ -423,8 +423,8 @@ static void
}
}
static bool notification_save_settings(NotificationApp* app) {
return saved_struct_save(
static bool notification_load_settings(NotificationApp* app) {
return saved_struct_load(
NOTIFICATION_SETTINGS_PATH,
&app->settings,
sizeof(NotificationSettings),
@@ -432,8 +432,8 @@ static bool notification_save_settings(NotificationApp* app) {
NOTIFICATION_SETTINGS_VERSION);
}
static bool notification_load_settings(NotificationApp* app) {
return saved_struct_load(
static bool notification_save_settings(NotificationApp* app) {
return saved_struct_save(
NOTIFICATION_SETTINGS_PATH,
&app->settings,
sizeof(NotificationSettings),
@@ -505,12 +505,46 @@ static NotificationApp* notification_app_alloc(void) {
return app;
}
static void notification_storage_callback(const void* message, void* context) {
furi_assert(context);
NotificationApp* app = context;
const StorageEvent* event = message;
if(event->type == StorageEventTypeCardMount) {
NotificationAppMessage m = {
.type = LoadSettingsMessage,
};
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
}
}
static void notification_apply_settings(NotificationApp* app) {
if(!notification_load_settings(app)) {
notification_save_settings(app);
}
notification_apply_lcd_contrast(app);
}
static void notification_init_settings(NotificationApp* app) {
Storage* storage = furi_record_open(RECORD_STORAGE);
furi_pubsub_subscribe(storage_get_pubsub(storage), notification_storage_callback, app);
if(storage_sd_status(storage) != FSE_OK) {
FURI_LOG_D(TAG, "SD Card not ready, skipping settings");
return;
}
notification_apply_settings(app);
}
// App
int32_t notification_srv(void* p) {
UNUSED(p);
NotificationApp* app = notification_app_alloc();
notification_load_settings(app);
notification_init_settings(app);
notification_vibro_off();
notification_sound_off();
@@ -518,7 +552,6 @@ int32_t notification_srv(void* p) {
notification_apply_internal_led_layer(&app->led[0], 0x00);
notification_apply_internal_led_layer(&app->led[1], 0x00);
notification_apply_internal_led_layer(&app->led[2], 0x00);
notification_apply_lcd_contrast(app);
furi_record_create(RECORD_NOTIFICATION, app);
@@ -536,6 +569,9 @@ int32_t notification_srv(void* p) {
case SaveSettingsMessage:
notification_save_settings(app);
break;
case LoadSettingsMessage:
notification_load_settings(app);
break;
}
if(message.back_event != NULL) {