dolphin_i.h 994 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "furi/pubsub.h"
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include "dolphin.h"
  6. #include "helpers/dolphin_state.h"
  7. typedef enum {
  8. DolphinEventTypeDeed,
  9. DolphinEventTypeStats,
  10. DolphinEventTypeFlush,
  11. DolphinEventTypeIncreaseButthurt,
  12. DolphinEventTypeClearLimits,
  13. } DolphinEventType;
  14. typedef struct {
  15. DolphinEventType type;
  16. osEventFlagsId_t flag;
  17. union {
  18. DolphinDeed deed;
  19. DolphinStats* stats;
  20. };
  21. } DolphinEvent;
  22. struct Dolphin {
  23. // State
  24. DolphinState* state;
  25. // Queue
  26. osMessageQueueId_t event_queue;
  27. FuriPubSub* pubsub;
  28. TimerHandle_t butthurt_timer;
  29. TimerHandle_t flush_timer;
  30. TimerHandle_t clear_limits_timer;
  31. };
  32. Dolphin* dolphin_alloc();
  33. void dolphin_free(Dolphin* dolphin);
  34. void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event);
  35. void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event);
  36. void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event);