Dolphin_srv timestamp and butthurt; Desktop_srv refactoring (#750)

* dolphin_srv: save timestamp on deed; desktop_srv minor refactoring
* dolphin_srv timegated butthurt increse, desktop refactoring
* desktop app: update debug screen
* remove debug logging
* increasing icounter affects butthurt value
* Dolphin: correct error message on DolphinStore load

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
its your bedtime
2021-10-07 16:32:37 +03:00
committed by GitHub
parent 1dd96419ab
commit 5dbfe3d90a
15 changed files with 152 additions and 61 deletions

View File

@@ -1,6 +1,6 @@
#include "dolphin_i.h"
#include <furi.h>
#define DOLPHIN_TIMEGATE 86400 // one day
#define DOLPHIN_LOCK_EVENT_FLAG (0x1)
void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) {
@@ -77,6 +77,21 @@ void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
}
}
static void dolphin_check_butthurt(DolphinState* state) {
furi_assert(state);
float diff_time = difftime(dolphin_state_get_timestamp(state), dolphin_state_timestamp());
#if 0
FURI_LOG_I("dolphin-state", "Butthurt check, time since deed %.0f", fabs(diff_time));
#endif
if((fabs(diff_time)) > DOLPHIN_TIMEGATE) {
// increase butthurt
FURI_LOG_I("dolphin-state", "Increasing butthurt");
dolphin_state_butthurted(state);
}
}
int32_t dolphin_srv(void* p) {
Dolphin* dolphin = dolphin_alloc();
furi_record_create("dolphin", dolphin);
@@ -91,11 +106,13 @@ int32_t dolphin_srv(void* p) {
} else if(event.type == DolphinEventTypeStats) {
event.stats->icounter = dolphin_state_get_icounter(dolphin->state);
event.stats->butthurt = dolphin_state_get_butthurt(dolphin->state);
event.stats->timestamp = dolphin_state_get_timestamp(dolphin->state);
} else if(event.type == DolphinEventTypeFlush) {
dolphin_state_save(dolphin->state);
}
dolphin_event_release(dolphin, &event);
} else {
dolphin_check_butthurt(dolphin->state);
dolphin_state_save(dolphin->state);
}
}