virtual_portal.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 last_r;
  26. uint8_t last_g;
  27. uint8_t last_b;
  28. uint16_t delay;
  29. uint32_t start_time;
  30. bool two_phase;
  31. bool running;
  32. int current_phase;
  33. } VirtualPortalLed;
  34. typedef struct {
  35. PoFToken* tokens[POF_TOKEN_LIMIT];
  36. uint8_t sequence_number;
  37. bool active;
  38. bool speaker;
  39. NotificationApp* notifications;
  40. PoFType type;
  41. VirtualPortalLed left;
  42. VirtualPortalLed right;
  43. VirtualPortalLed trap;
  44. FuriTimer* led_timer;
  45. } VirtualPortal;
  46. VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);
  47. void virtual_portal_free(VirtualPortal* virtual_portal);
  48. void virtual_portal_cleanup(VirtualPortal* virtual_portal);
  49. void virtual_portal_load_token(VirtualPortal* virtual_portal, PoFToken* pof_token);
  50. void virtual_portal_tick();
  51. int virtual_portal_process_message(
  52. VirtualPortal* virtual_portal,
  53. uint8_t* message,
  54. uint8_t* response);
  55. int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response);