infrared_i.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #pragma once
  2. #include <gui/gui.h>
  3. #include <gui/view.h>
  4. #include <gui/view_stack.h>
  5. #include <gui/view_dispatcher.h>
  6. #include <gui/scene_manager.h>
  7. #include <gui/modules/popup.h>
  8. #include <gui/modules/loading.h>
  9. #include <gui/modules/submenu.h>
  10. #include <gui/modules/dialog_ex.h>
  11. #include <gui/modules/text_input.h>
  12. #include <gui/modules/button_menu.h>
  13. #include <gui/modules/button_panel.h>
  14. #include <storage/storage.h>
  15. #include <dialogs/dialogs.h>
  16. #include <notification/notification_messages.h>
  17. #include <infrared_worker.h>
  18. #include "infrared.h"
  19. #include "infrared_remote.h"
  20. #include "infrared_brute_force.h"
  21. #include "infrared_custom_event.h"
  22. #include "scenes/infrared_scene.h"
  23. #include "views/infrared_progress_view.h"
  24. #include "views/infrared_debug_view.h"
  25. #define INFRARED_FILE_NAME_SIZE 100
  26. #define INFRARED_TEXT_STORE_NUM 2
  27. #define INFRARED_TEXT_STORE_SIZE 128
  28. #define INFRARED_MAX_BUTTON_NAME_LENGTH 22
  29. #define INFRARED_MAX_REMOTE_NAME_LENGTH 22
  30. #define INFRARED_APP_FOLDER "/any/infrared"
  31. #define INFRARED_APP_EXTENSION ".ir"
  32. #define INFRARED_DEFAULT_REMOTE_NAME "Remote"
  33. typedef enum {
  34. InfraredButtonIndexNone = -1,
  35. } InfraredButtonIndex;
  36. typedef enum {
  37. InfraredEditTargetNone,
  38. InfraredEditTargetRemote,
  39. InfraredEditTargetButton,
  40. } InfraredEditTarget;
  41. typedef enum {
  42. InfraredEditModeNone,
  43. InfraredEditModeRename,
  44. InfraredEditModeDelete,
  45. } InfraredEditMode;
  46. typedef struct {
  47. bool is_learning_new_remote;
  48. bool is_debug_enabled;
  49. InfraredEditTarget edit_target : 8;
  50. InfraredEditMode edit_mode : 8;
  51. int32_t current_button_index;
  52. } InfraredAppState;
  53. struct Infrared {
  54. SceneManager* scene_manager;
  55. ViewDispatcher* view_dispatcher;
  56. Gui* gui;
  57. Storage* storage;
  58. DialogsApp* dialogs;
  59. NotificationApp* notifications;
  60. InfraredWorker* worker;
  61. InfraredRemote* remote;
  62. InfraredSignal* received_signal;
  63. InfraredBruteForce* brute_force;
  64. Submenu* submenu;
  65. TextInput* text_input;
  66. DialogEx* dialog_ex;
  67. ButtonMenu* button_menu;
  68. Popup* popup;
  69. ViewStack* view_stack;
  70. InfraredDebugView* debug_view;
  71. ButtonPanel* button_panel;
  72. Loading* loading;
  73. InfraredProgressView* progress;
  74. string_t file_path;
  75. char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1];
  76. InfraredAppState app_state;
  77. };
  78. typedef enum {
  79. InfraredViewSubmenu,
  80. InfraredViewTextInput,
  81. InfraredViewDialogEx,
  82. InfraredViewButtonMenu,
  83. InfraredViewPopup,
  84. InfraredViewStack,
  85. InfraredViewDebugView,
  86. } InfraredView;
  87. typedef enum {
  88. InfraredNotificationMessageSuccess,
  89. InfraredNotificationMessageGreenOn,
  90. InfraredNotificationMessageGreenOff,
  91. InfraredNotificationMessageBlinkRead,
  92. InfraredNotificationMessageBlinkSend,
  93. InfraredNotificationMessageYellowOn,
  94. InfraredNotificationMessageYellowOff,
  95. } InfraredNotificationMessage;
  96. bool infrared_add_remote_with_button(Infrared* infrared, const char* name, InfraredSignal* signal);
  97. bool infrared_rename_current_remote(Infrared* infrared, const char* name);
  98. void infrared_tx_start_signal(Infrared* infrared, InfraredSignal* signal);
  99. void infrared_tx_start_button_index(Infrared* infrared, size_t button_index);
  100. void infrared_tx_start_received(Infrared* infrared);
  101. void infrared_tx_stop(Infrared* infrared);
  102. void infrared_text_store_set(Infrared* infrared, uint32_t bank, const char* text, ...);
  103. void infrared_text_store_clear(Infrared* infrared, uint32_t bank);
  104. void infrared_play_notification_message(Infrared* infrared, uint32_t message);
  105. void infrared_show_loading_popup(Infrared* infrared, bool show);
  106. void infrared_signal_sent_callback(void* context);
  107. void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal);
  108. void infrared_text_input_callback(void* context);
  109. void infrared_popup_closed_callback(void* context);