virtual_portal.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include <notification/notification_messages.h>
  3. #include <furi_hal_light.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. uint16_t delay;
  26. } VirtualPortalLed;
  27. typedef struct {
  28. PoFToken* tokens[POF_TOKEN_LIMIT];
  29. uint8_t sequence_number;
  30. bool active;
  31. bool speaker;
  32. NotificationApp* notifications;
  33. PoFType type;
  34. VirtualPortalLed left;
  35. VirtualPortalLed right;
  36. VirtualPortalLed trap;
  37. } VirtualPortal;
  38. VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);
  39. void virtual_portal_free(VirtualPortal* virtual_portal);
  40. void virtual_portal_cleanup(VirtualPortal* virtual_portal);
  41. void virtual_portal_load_token(VirtualPortal* virtual_portal, PoFToken* pof_token);
  42. void virtual_portal_tick();
  43. int virtual_portal_process_message(
  44. VirtualPortal* virtual_portal,
  45. uint8_t* message,
  46. uint8_t* response);
  47. int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response);