virtual_portal.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <furi_hal_light.h>
  3. #include <notification/notification_messages.h>
  4. #include "pof_token.h"
  5. #define POF_TOKEN_LIMIT 16
  6. typedef enum {
  7. PoFHid,
  8. PoFXbox360
  9. } PoFType;
  10. typedef enum {
  11. EventExit = (1 << 0),
  12. EventReset = (1 << 1),
  13. EventRx = (1 << 2),
  14. EventTx = (1 << 3),
  15. EventTxComplete = (1 << 4),
  16. EventResetSio = (1 << 5),
  17. EventTxImmediate = (1 << 6),
  18. EventAll = EventExit | EventReset | EventRx | EventTx | EventTxComplete | EventResetSio |
  19. EventTxImmediate,
  20. } PoFEvent;
  21. typedef struct {
  22. uint8_t r;
  23. uint8_t g;
  24. uint8_t b;
  25. uint8_t target_r;
  26. uint8_t target_g;
  27. uint8_t target_b;
  28. uint8_t last_r;
  29. uint8_t last_g;
  30. uint8_t last_b;
  31. uint16_t delay;
  32. uint32_t start_time;
  33. bool two_phase;
  34. bool running;
  35. int current_phase;
  36. } VirtualPortalLed;
  37. typedef struct {
  38. PoFToken* tokens[POF_TOKEN_LIMIT];
  39. uint8_t sequence_number;
  40. bool active;
  41. bool speaker;
  42. NotificationApp* notifications;
  43. PoFType type;
  44. VirtualPortalLed left;
  45. VirtualPortalLed right;
  46. VirtualPortalLed trap;
  47. FuriTimer* led_timer;
  48. } VirtualPortal;
  49. VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);
  50. void virtual_portal_free(VirtualPortal* virtual_portal);
  51. void virtual_portal_cleanup(VirtualPortal* virtual_portal);
  52. void virtual_portal_load_token(VirtualPortal* virtual_portal, PoFToken* pof_token);
  53. void virtual_portal_tick();
  54. int virtual_portal_process_message(
  55. VirtualPortal* virtual_portal,
  56. uint8_t* message,
  57. uint8_t* response);
  58. int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response);