dolphin.h 1.3 KB

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