app.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <gui/gui.h>
  3. #include <gui/view_dispatcher.h>
  4. #include <gui/scene_manager.h>
  5. #include <gui/modules/submenu.h>
  6. #include <gui/modules/variable_item_list.h>
  7. #include <gui/modules/widget.h>
  8. #include <notification/notification_messages.h>
  9. #include <lib/subghz/subghz_setting.h>
  10. #include <lib/subghz/subghz_worker.h>
  11. #include <lib/subghz/receiver.h>
  12. #include <lib/subghz/transmitter.h>
  13. #include <lib/subghz/registry.h>
  14. #define TAG "ProtoView"
  15. typedef struct ProtoViewApp ProtoViewApp;
  16. /* Subghz system state */
  17. typedef enum {
  18. TxRxStateIDLE,
  19. TxRxStateRx,
  20. TxRxStateSleep,
  21. } TxRxState;
  22. /* This is the context of our subghz worker and associated thread.
  23. * It receives data and we get our protocol "feed" callback called
  24. * with the level (1 or 0) and duration. */
  25. struct ProtoViewTxRx {
  26. SubGhzWorker* worker;
  27. SubGhzEnvironment* environment;
  28. SubGhzReceiver* receiver;
  29. SubGhzRadioPreset* preset;
  30. TxRxState txrx_state; /* Receiving, idle or sleeping? */
  31. };
  32. typedef struct ProtoViewTxRx ProtoViewTxRx;
  33. struct ProtoViewApp {
  34. Gui *gui;
  35. ViewPort *view_port;
  36. FuriMessageQueue *event_queue;
  37. ProtoViewTxRx *txrx; /* Radio state. */
  38. SubGhzSetting *setting;
  39. int running; /* Once false exists the app. */
  40. uint32_t signal_bestlen; /* Longest coherent signal observed so far. */
  41. uint32_t us_scale; /* microseconds per pixel. */
  42. };
  43. void radio_begin(ProtoViewApp* app);
  44. uint32_t radio_rx(ProtoViewApp* app, uint32_t frequency);
  45. void radio_idle(ProtoViewApp* app);
  46. void radio_rx_end(ProtoViewApp* app);
  47. void radio_sleep(ProtoViewApp* app);