2022-06-21 12:45:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gui/gui.h>
|
|
|
|
#include <gui/view.h>
|
2022-10-28 14:08:50 +00:00
|
|
|
#include <assets_icons.h>
|
2022-06-21 12:45:50 +00:00
|
|
|
#include <gui/view_stack.h>
|
|
|
|
#include <gui/view_dispatcher.h>
|
|
|
|
#include <gui/scene_manager.h>
|
|
|
|
|
|
|
|
#include <gui/modules/popup.h>
|
|
|
|
#include <gui/modules/loading.h>
|
|
|
|
#include <gui/modules/submenu.h>
|
2023-02-26 02:23:26 +00:00
|
|
|
#include <gui/modules/variable_item_list.h>
|
2022-06-21 12:45:50 +00:00
|
|
|
#include <gui/modules/dialog_ex.h>
|
|
|
|
#include <gui/modules/text_input.h>
|
|
|
|
#include <gui/modules/button_menu.h>
|
|
|
|
#include <gui/modules/button_panel.h>
|
|
|
|
|
|
|
|
#include <storage/storage.h>
|
|
|
|
#include <dialogs/dialogs.h>
|
|
|
|
|
|
|
|
#include <notification/notification_messages.h>
|
|
|
|
|
|
|
|
#include <infrared_worker.h>
|
|
|
|
|
|
|
|
#include "infrared.h"
|
|
|
|
#include "infrared_remote.h"
|
|
|
|
#include "infrared_brute_force.h"
|
|
|
|
#include "infrared_custom_event.h"
|
|
|
|
|
|
|
|
#include "scenes/infrared_scene.h"
|
|
|
|
#include "views/infrared_progress_view.h"
|
|
|
|
#include "views/infrared_debug_view.h"
|
2023-08-04 15:52:03 +00:00
|
|
|
#include "views/infrared_move_view.h"
|
2022-06-21 12:45:50 +00:00
|
|
|
|
2022-07-04 13:09:46 +00:00
|
|
|
#include "rpc/rpc_app.h"
|
|
|
|
|
2022-06-21 12:45:50 +00:00
|
|
|
#define INFRARED_FILE_NAME_SIZE 100
|
|
|
|
#define INFRARED_TEXT_STORE_NUM 2
|
|
|
|
#define INFRARED_TEXT_STORE_SIZE 128
|
|
|
|
|
|
|
|
#define INFRARED_MAX_BUTTON_NAME_LENGTH 22
|
|
|
|
#define INFRARED_MAX_REMOTE_NAME_LENGTH 22
|
|
|
|
|
2022-07-26 12:21:51 +00:00
|
|
|
#define INFRARED_APP_FOLDER ANY_PATH("infrared")
|
2022-06-21 12:45:50 +00:00
|
|
|
#define INFRARED_APP_EXTENSION ".ir"
|
|
|
|
|
|
|
|
#define INFRARED_DEFAULT_REMOTE_NAME "Remote"
|
2022-08-12 13:50:04 +00:00
|
|
|
#define INFRARED_LOG_TAG "InfraredApp"
|
2022-06-21 12:45:50 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
InfraredButtonIndexNone = -1,
|
|
|
|
} InfraredButtonIndex;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
InfraredEditTargetNone,
|
|
|
|
InfraredEditTargetRemote,
|
|
|
|
InfraredEditTargetButton,
|
|
|
|
} InfraredEditTarget;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
InfraredEditModeNone,
|
|
|
|
InfraredEditModeRename,
|
|
|
|
InfraredEditModeDelete,
|
|
|
|
} InfraredEditMode;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool is_learning_new_remote;
|
|
|
|
bool is_debug_enabled;
|
2022-08-12 13:50:04 +00:00
|
|
|
bool is_transmitting;
|
2022-06-21 12:45:50 +00:00
|
|
|
InfraredEditTarget edit_target : 8;
|
|
|
|
InfraredEditMode edit_mode : 8;
|
|
|
|
int32_t current_button_index;
|
2023-08-02 03:43:36 +00:00
|
|
|
int32_t current_button_index_move_orig;
|
2023-02-27 17:30:11 +00:00
|
|
|
uint32_t last_transmit_time;
|
2022-06-21 12:45:50 +00:00
|
|
|
} InfraredAppState;
|
|
|
|
|
|
|
|
struct Infrared {
|
|
|
|
SceneManager* scene_manager;
|
|
|
|
ViewDispatcher* view_dispatcher;
|
|
|
|
|
|
|
|
Gui* gui;
|
|
|
|
Storage* storage;
|
|
|
|
DialogsApp* dialogs;
|
|
|
|
NotificationApp* notifications;
|
|
|
|
InfraredWorker* worker;
|
|
|
|
InfraredRemote* remote;
|
|
|
|
InfraredSignal* received_signal;
|
|
|
|
InfraredBruteForce* brute_force;
|
|
|
|
|
|
|
|
Submenu* submenu;
|
|
|
|
TextInput* text_input;
|
2023-02-26 02:23:26 +00:00
|
|
|
VariableItemList* variable_item_list;
|
2022-06-21 12:45:50 +00:00
|
|
|
DialogEx* dialog_ex;
|
|
|
|
ButtonMenu* button_menu;
|
|
|
|
Popup* popup;
|
|
|
|
|
|
|
|
ViewStack* view_stack;
|
|
|
|
InfraredDebugView* debug_view;
|
2023-08-04 15:52:03 +00:00
|
|
|
InfraredMoveView* move_view;
|
2022-06-21 12:45:50 +00:00
|
|
|
|
|
|
|
ButtonPanel* button_panel;
|
|
|
|
Loading* loading;
|
|
|
|
InfraredProgressView* progress;
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* file_path;
|
2022-06-21 12:45:50 +00:00
|
|
|
char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1];
|
|
|
|
InfraredAppState app_state;
|
2022-07-04 13:09:46 +00:00
|
|
|
|
|
|
|
void* rpc_ctx;
|
2022-06-21 12:45:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
InfraredViewSubmenu,
|
|
|
|
InfraredViewTextInput,
|
2023-02-26 02:23:26 +00:00
|
|
|
InfraredViewVariableItemList,
|
2022-06-21 12:45:50 +00:00
|
|
|
InfraredViewDialogEx,
|
|
|
|
InfraredViewButtonMenu,
|
|
|
|
InfraredViewPopup,
|
|
|
|
InfraredViewStack,
|
|
|
|
InfraredViewDebugView,
|
2023-08-04 15:52:03 +00:00
|
|
|
InfraredViewMove,
|
2022-06-21 12:45:50 +00:00
|
|
|
} InfraredView;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
InfraredNotificationMessageSuccess,
|
|
|
|
InfraredNotificationMessageGreenOn,
|
|
|
|
InfraredNotificationMessageGreenOff,
|
2022-06-21 14:45:55 +00:00
|
|
|
InfraredNotificationMessageYellowOn,
|
|
|
|
InfraredNotificationMessageYellowOff,
|
2022-08-04 12:11:01 +00:00
|
|
|
InfraredNotificationMessageBlinkStartRead,
|
|
|
|
InfraredNotificationMessageBlinkStartSend,
|
|
|
|
InfraredNotificationMessageBlinkStop,
|
2022-06-21 12:45:50 +00:00
|
|
|
} InfraredNotificationMessage;
|
|
|
|
|
|
|
|
bool infrared_add_remote_with_button(Infrared* infrared, const char* name, InfraredSignal* signal);
|
|
|
|
bool infrared_rename_current_remote(Infrared* infrared, const char* name);
|
|
|
|
void infrared_tx_start_signal(Infrared* infrared, InfraredSignal* signal);
|
|
|
|
void infrared_tx_start_button_index(Infrared* infrared, size_t button_index);
|
|
|
|
void infrared_tx_start_received(Infrared* infrared);
|
|
|
|
void infrared_tx_stop(Infrared* infrared);
|
|
|
|
void infrared_text_store_set(Infrared* infrared, uint32_t bank, const char* text, ...);
|
|
|
|
void infrared_text_store_clear(Infrared* infrared, uint32_t bank);
|
|
|
|
void infrared_play_notification_message(Infrared* infrared, uint32_t message);
|
|
|
|
void infrared_show_loading_popup(Infrared* infrared, bool show);
|
|
|
|
|
|
|
|
void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal);
|
|
|
|
void infrared_text_input_callback(void* context);
|
2022-06-21 14:45:55 +00:00
|
|
|
void infrared_popup_closed_callback(void* context);
|