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

@@ -1,6 +1,7 @@
#include "dolphin_i.h"
#include <furi_hal.h>
#include <storage/storage.h>
#include <momentum/momentum.h>
#define TAG "Dolphin"
@@ -226,6 +227,10 @@ static bool dolphin_process_event(FuriMessageQueue* queue, void* context) {
dolphin_state_increase_level(dolphin->state);
furi_event_loop_timer_start(dolphin->flush_timer, FLUSH_TIMEOUT_TICKS);
} else if(event.type == DolphinEventTypeReloadState) {
dolphin_state_load(dolphin->state);
furi_event_loop_timer_start(dolphin->butthurt_timer, BUTTHURT_INCREASE_PERIOD_TICKS);
} else {
furi_crash();
}
@@ -235,6 +240,32 @@ static bool dolphin_process_event(FuriMessageQueue* queue, void* context) {
return true;
}
static void dolphin_storage_callback(const void* message, void* context) {
furi_assert(context);
Dolphin* dolphin = context;
const StorageEvent* event = message;
if(event->type == StorageEventTypeCardMount) {
DolphinEvent event = {
.type = DolphinEventTypeReloadState,
};
dolphin_event_send_async(dolphin, &event);
}
}
static void dolphin_init_state(Dolphin* dolphin) {
Storage* storage = furi_record_open(RECORD_STORAGE);
furi_pubsub_subscribe(storage_get_pubsub(storage), dolphin_storage_callback, dolphin);
if(storage_sd_status(storage) != FSE_OK) {
FURI_LOG_D(TAG, "SD Card not ready, skipping state");
return;
}
dolphin_state_load(dolphin->state);
}
// Application thread
int32_t dolphin_srv(void* p) {
@@ -250,7 +281,7 @@ int32_t dolphin_srv(void* p) {
Dolphin* dolphin = dolphin_alloc();
furi_record_create(RECORD_DOLPHIN, dolphin);
dolphin_state_load(dolphin->state);
dolphin_init_state(dolphin);
furi_event_loop_message_queue_subscribe(
dolphin->event_loop,