weather_station_history.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include <math.h>
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <lib/flipper_format/flipper_format.h>
  6. #include <lib/subghz/types.h>
  7. typedef struct WSHistory WSHistory;
  8. /** History state add key */
  9. typedef enum {
  10. WSHistoryStateAddKeyUnknown,
  11. WSHistoryStateAddKeyTimeOut,
  12. WSHistoryStateAddKeyNewDada,
  13. WSHistoryStateAddKeyUpdateData,
  14. WSHistoryStateAddKeyOverflow,
  15. } WSHistoryStateAddKey;
  16. /** Allocate WSHistory
  17. *
  18. * @return WSHistory*
  19. */
  20. WSHistory* ws_history_alloc(void);
  21. /** Free WSHistory
  22. *
  23. * @param instance - WSHistory instance
  24. */
  25. void ws_history_free(WSHistory* instance);
  26. /** Clear history
  27. *
  28. * @param instance - WSHistory instance
  29. */
  30. void ws_history_reset(WSHistory* instance);
  31. /** Get frequency to history[idx]
  32. *
  33. * @param instance - WSHistory instance
  34. * @param idx - record index
  35. * @return frequency - frequency Hz
  36. */
  37. uint32_t ws_history_get_frequency(WSHistory* instance, uint16_t idx);
  38. SubGhzRadioPreset* ws_history_get_radio_preset(WSHistory* instance, uint16_t idx);
  39. /** Get preset to history[idx]
  40. *
  41. * @param instance - WSHistory instance
  42. * @param idx - record index
  43. * @return preset - preset name
  44. */
  45. const char* ws_history_get_preset(WSHistory* instance, uint16_t idx);
  46. /** Get history index write
  47. *
  48. * @param instance - WSHistory instance
  49. * @return idx - current record index
  50. */
  51. uint16_t ws_history_get_item(WSHistory* instance);
  52. /** Get type protocol to history[idx]
  53. *
  54. * @param instance - WSHistory instance
  55. * @param idx - record index
  56. * @return type - type protocol
  57. */
  58. uint8_t ws_history_get_type_protocol(WSHistory* instance, uint16_t idx);
  59. /** Get name protocol to history[idx]
  60. *
  61. * @param instance - WSHistory instance
  62. * @param idx - record index
  63. * @return name - const char* name protocol
  64. */
  65. const char* ws_history_get_protocol_name(WSHistory* instance, uint16_t idx);
  66. /** Get string item menu to history[idx]
  67. *
  68. * @param instance - WSHistory instance
  69. * @param output - FuriString* output
  70. * @param idx - record index
  71. */
  72. void ws_history_get_text_item_menu(WSHistory* instance, FuriString* output, uint16_t idx);
  73. /** Get string the remaining number of records to history
  74. *
  75. * @param instance - WSHistory instance
  76. * @param output - FuriString* output
  77. * @return bool - is FUUL
  78. */
  79. bool ws_history_get_text_space_left(WSHistory* instance, FuriString* output);
  80. /** Add protocol to history
  81. *
  82. * @param instance - WSHistory instance
  83. * @param context - SubGhzProtocolCommon context
  84. * @param preset - SubGhzRadioPreset preset
  85. * @return WSHistoryStateAddKey;
  86. */
  87. WSHistoryStateAddKey
  88. ws_history_add_to_history(WSHistory* instance, void* context, SubGhzRadioPreset* preset);
  89. /** Get SubGhzProtocolCommonLoad to load into the protocol decoder bin data
  90. *
  91. * @param instance - WSHistory instance
  92. * @param idx - record index
  93. * @return SubGhzProtocolCommonLoad*
  94. */
  95. FlipperFormat* ws_history_get_raw_data(WSHistory* instance, uint16_t idx);