dolphin.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <core/pubsub.h>
  3. #include "gui/view.h"
  4. #include "helpers/dolphin_deed.h"
  5. #include <stdbool.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define RECORD_DOLPHIN "dolphin"
  10. typedef struct Dolphin Dolphin;
  11. typedef struct {
  12. uint32_t icounter;
  13. uint32_t butthurt;
  14. uint64_t timestamp;
  15. uint8_t level;
  16. bool level_up_is_pending;
  17. } DolphinStats;
  18. typedef enum {
  19. DolphinPubsubEventUpdate,
  20. } DolphinPubsubEvent;
  21. #define DOLPHIN_DEED(deed) \
  22. do { \
  23. Dolphin* dolphin = (Dolphin*)furi_record_open("dolphin"); \
  24. dolphin_deed(dolphin, deed); \
  25. furi_record_close("dolphin"); \
  26. } while(0)
  27. /** Deed complete notification. Call it on deed completion.
  28. * See dolphin_deed.h for available deeds. In futures it will become part of assets.
  29. * Thread safe, async
  30. */
  31. void dolphin_deed(Dolphin* dolphin, DolphinDeed deed);
  32. /** Retrieve dolphin stats
  33. * Thread safe, blocking
  34. */
  35. DolphinStats dolphin_stats(Dolphin* dolphin);
  36. /** Flush dolphin queue and save state
  37. * Thread safe, blocking
  38. */
  39. void dolphin_flush(Dolphin* dolphin);
  40. void dolphin_upgrade_level(Dolphin* dolphin);
  41. FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin);
  42. #ifdef __cplusplus
  43. }
  44. #endif