mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-08 05:39:09 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -48,6 +48,26 @@ void dolphin_deed(DolphinDeed deed) {
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
}
|
||||
|
||||
void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings) {
|
||||
furi_check(dolphin);
|
||||
furi_check(settings);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeSettingsGet;
|
||||
event.settings = settings;
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings) {
|
||||
furi_check(dolphin);
|
||||
furi_check(settings);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeSettingsSet;
|
||||
event.settings = settings;
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
DolphinStats dolphin_stats(Dolphin* dolphin) {
|
||||
furi_check(dolphin);
|
||||
|
||||
@@ -230,7 +250,9 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
|
||||
|
||||
} else if(event.type == DolphinEventTypeStats) {
|
||||
event.stats->icounter = dolphin->state->data.icounter;
|
||||
event.stats->butthurt = dolphin->state->data.butthurt;
|
||||
event.stats->butthurt = (dolphin->state->data.flags & DolphinFlagHappyMode) ?
|
||||
0 :
|
||||
dolphin->state->data.butthurt;
|
||||
event.stats->timestamp = dolphin->state->data.timestamp;
|
||||
event.stats->level = dolphin_get_level(dolphin->state->data.icounter);
|
||||
event.stats->level_up_is_pending =
|
||||
@@ -248,6 +270,15 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
|
||||
dolphin_state_load(dolphin->state);
|
||||
dolphin_reset_butthurt_timer(dolphin);
|
||||
|
||||
} else if(event.type == DolphinEventTypeSettingsGet) {
|
||||
event.settings->happy_mode = dolphin->state->data.flags & DolphinFlagHappyMode;
|
||||
|
||||
} else if(event.type == DolphinEventTypeSettingsSet) {
|
||||
dolphin->state->data.flags &= ~DolphinFlagHappyMode;
|
||||
if(event.settings->happy_mode) dolphin->state->data.flags |= DolphinFlagHappyMode;
|
||||
dolphin->state->dirty = true;
|
||||
dolphin_state_save(dolphin->state);
|
||||
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ typedef struct {
|
||||
bool level_up_is_pending;
|
||||
} DolphinStats;
|
||||
|
||||
typedef struct {
|
||||
bool happy_mode;
|
||||
} DolphinSettings;
|
||||
|
||||
typedef enum {
|
||||
DolphinPubsubEventUpdate,
|
||||
} DolphinPubsubEvent;
|
||||
@@ -31,6 +35,10 @@ typedef enum {
|
||||
*/
|
||||
void dolphin_deed(DolphinDeed deed);
|
||||
|
||||
void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings);
|
||||
|
||||
void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings);
|
||||
|
||||
/** Retrieve dolphin stats
|
||||
* Thread safe, blocking
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,8 @@ typedef enum {
|
||||
DolphinEventTypeFlush,
|
||||
DolphinEventTypeLevel,
|
||||
DolphinEventTypeReloadState,
|
||||
DolphinEventTypeSettingsGet,
|
||||
DolphinEventTypeSettingsSet,
|
||||
} DolphinEventType;
|
||||
|
||||
typedef struct {
|
||||
@@ -21,6 +23,7 @@ typedef struct {
|
||||
union {
|
||||
DolphinDeed deed;
|
||||
DolphinStats* stats;
|
||||
DolphinSettings* settings;
|
||||
};
|
||||
} DolphinEvent;
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
#include "dolphin_deed.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const uint32_t DOLPHIN_LEVELS[];
|
||||
extern const size_t DOLPHIN_LEVEL_COUNT;
|
||||
|
||||
#define BUTTHURT_MAX 14
|
||||
#define BUTTHURT_MIN 0
|
||||
|
||||
typedef enum {
|
||||
DolphinFlagHappyMode = 1,
|
||||
} DolphinFlags;
|
||||
|
||||
typedef struct DolphinState DolphinState;
|
||||
typedef struct {
|
||||
uint8_t icounter_daily_limit[DolphinAppMAX];
|
||||
@@ -57,7 +57,3 @@ bool dolphin_state_is_levelup(uint32_t icounter);
|
||||
void dolphin_state_increase_level(DolphinState* dolphin_state);
|
||||
|
||||
uint8_t dolphin_get_level(uint32_t icounter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user