2021-06-02 15:16:05 +00:00
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include <irda.h>
|
|
|
|
#include <furi.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include "scene/irda_app_scene.h"
|
|
|
|
#include "scene/irda_app_scene.h"
|
|
|
|
#include "irda_app_view_manager.h"
|
|
|
|
#include "irda_app_remote_manager.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
#include <forward_list>
|
|
|
|
#include <stdint.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <notification/notification_messages.h>
|
2021-07-16 16:43:54 +00:00
|
|
|
#include <irda_worker.h>
|
2022-02-24 11:59:36 +00:00
|
|
|
#include "irda_app_view_manager.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
class IrdaApp {
|
|
|
|
public:
|
|
|
|
enum class EditElement : uint8_t {
|
|
|
|
Button,
|
|
|
|
Remote,
|
|
|
|
};
|
|
|
|
enum class EditAction : uint8_t {
|
|
|
|
Rename,
|
|
|
|
Delete,
|
|
|
|
};
|
|
|
|
enum class Scene : uint8_t {
|
|
|
|
Exit,
|
|
|
|
Start,
|
|
|
|
Universal,
|
|
|
|
UniversalTV,
|
|
|
|
UniversalAudio,
|
|
|
|
UniversalAirConditioner,
|
|
|
|
Learn,
|
|
|
|
LearnSuccess,
|
|
|
|
LearnEnterName,
|
|
|
|
LearnDone,
|
2022-02-16 11:09:47 +00:00
|
|
|
AskBack,
|
2021-06-02 15:16:05 +00:00
|
|
|
Remote,
|
|
|
|
RemoteList,
|
|
|
|
Edit,
|
|
|
|
EditKeySelect,
|
|
|
|
EditRename,
|
|
|
|
EditDelete,
|
|
|
|
EditRenameDone,
|
|
|
|
EditDeleteDone,
|
|
|
|
};
|
|
|
|
|
2021-07-16 16:50:18 +00:00
|
|
|
int32_t run(void* args);
|
2021-06-02 15:16:05 +00:00
|
|
|
void switch_to_next_scene(Scene index);
|
|
|
|
void switch_to_next_scene_without_saving(Scene index);
|
|
|
|
bool switch_to_previous_scene(uint8_t count = 1);
|
|
|
|
Scene get_previous_scene();
|
|
|
|
IrdaAppViewManager* get_view_manager();
|
|
|
|
void set_text_store(uint8_t index, const char* text...);
|
|
|
|
char* get_text_store(uint8_t index);
|
|
|
|
uint8_t get_text_store_size();
|
|
|
|
IrdaAppRemoteManager* get_remote_manager();
|
2021-07-16 16:43:54 +00:00
|
|
|
|
|
|
|
IrdaWorker* get_irda_worker();
|
|
|
|
const IrdaAppSignal& get_received_signal() const;
|
|
|
|
void set_received_signal(const IrdaAppSignal& signal);
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
void search_and_switch_to_previous_scene(const std::initializer_list<Scene>& scenes_list);
|
|
|
|
|
|
|
|
void set_edit_element(EditElement value);
|
|
|
|
EditElement get_edit_element(void);
|
|
|
|
|
|
|
|
void set_edit_action(EditAction value);
|
|
|
|
EditAction get_edit_action(void);
|
|
|
|
|
|
|
|
bool get_learn_new_remote();
|
|
|
|
void set_learn_new_remote(bool value);
|
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
enum : int {
|
2021-08-11 17:51:06 +00:00
|
|
|
ButtonNA = -1,
|
2021-06-09 13:04:49 +00:00
|
|
|
};
|
|
|
|
int get_current_button();
|
|
|
|
void set_current_button(int value);
|
|
|
|
|
|
|
|
void notify_success();
|
|
|
|
void notify_red_blink();
|
2021-11-01 16:34:50 +00:00
|
|
|
void notify_sent_just_learnt();
|
2021-06-09 13:04:49 +00:00
|
|
|
void notify_green_on();
|
|
|
|
void notify_green_off();
|
|
|
|
void notify_click();
|
2021-08-11 17:51:06 +00:00
|
|
|
void notify_click_and_green_blink();
|
|
|
|
void notify_blink_green();
|
2021-06-09 13:04:49 +00:00
|
|
|
|
2021-06-23 21:46:52 +00:00
|
|
|
static void text_input_callback(void* context);
|
2021-06-02 15:16:05 +00:00
|
|
|
static void popup_callback(void* context);
|
2022-02-18 20:16:22 +00:00
|
|
|
static void signal_sent_callback(void* context);
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2021-08-19 00:18:42 +00:00
|
|
|
IrdaApp();
|
|
|
|
~IrdaApp();
|
2021-08-11 17:51:06 +00:00
|
|
|
|
2022-01-10 17:13:41 +00:00
|
|
|
static constexpr const char* irda_directory = "/any/irda";
|
|
|
|
static constexpr const char* irda_extension = ".ir";
|
|
|
|
static constexpr const uint32_t max_raw_timings_in_signal = 512;
|
|
|
|
static constexpr const uint32_t max_line_length =
|
|
|
|
(9 + 1) * IrdaApp::max_raw_timings_in_signal + 100;
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
private:
|
2022-01-10 17:13:41 +00:00
|
|
|
static constexpr const uint8_t text_store_size = 128;
|
|
|
|
static constexpr const uint8_t text_store_max = 2;
|
2021-06-02 15:16:05 +00:00
|
|
|
char text_store[text_store_max][text_store_size + 1];
|
|
|
|
bool learn_new_remote;
|
|
|
|
EditElement element;
|
|
|
|
EditAction action;
|
2021-06-09 13:04:49 +00:00
|
|
|
uint32_t current_button;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
NotificationApp* notification;
|
2021-06-02 15:16:05 +00:00
|
|
|
IrdaAppViewManager view_manager;
|
|
|
|
IrdaAppRemoteManager remote_manager;
|
2021-07-16 16:43:54 +00:00
|
|
|
IrdaWorker* irda_worker;
|
|
|
|
IrdaAppSignal received_signal;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
std::forward_list<Scene> previous_scenes_list;
|
|
|
|
Scene current_scene = Scene::Start;
|
|
|
|
|
|
|
|
std::map<Scene, IrdaAppScene*> scenes = {
|
|
|
|
{Scene::Start, new IrdaAppSceneStart()},
|
|
|
|
{Scene::Universal, new IrdaAppSceneUniversal()},
|
2021-06-25 13:52:27 +00:00
|
|
|
{Scene::UniversalTV, new IrdaAppSceneUniversalTV()},
|
2021-08-11 17:51:06 +00:00
|
|
|
// {Scene::UniversalAudio, new IrdaAppSceneUniversalAudio()},
|
2021-06-02 15:16:05 +00:00
|
|
|
{Scene::Learn, new IrdaAppSceneLearn()},
|
|
|
|
{Scene::LearnSuccess, new IrdaAppSceneLearnSuccess()},
|
|
|
|
{Scene::LearnEnterName, new IrdaAppSceneLearnEnterName()},
|
|
|
|
{Scene::LearnDone, new IrdaAppSceneLearnDone()},
|
2022-02-16 11:09:47 +00:00
|
|
|
{Scene::AskBack, new IrdaAppSceneAskBack()},
|
2021-06-02 15:16:05 +00:00
|
|
|
{Scene::Remote, new IrdaAppSceneRemote()},
|
|
|
|
{Scene::RemoteList, new IrdaAppSceneRemoteList()},
|
|
|
|
{Scene::Edit, new IrdaAppSceneEdit()},
|
|
|
|
{Scene::EditKeySelect, new IrdaAppSceneEditKeySelect()},
|
|
|
|
{Scene::EditRename, new IrdaAppSceneEditRename()},
|
|
|
|
{Scene::EditDelete, new IrdaAppSceneEditDelete()},
|
|
|
|
{Scene::EditRenameDone, new IrdaAppSceneEditRenameDone()},
|
|
|
|
{Scene::EditDeleteDone, new IrdaAppSceneEditDeleteDone()},
|
|
|
|
};
|
|
|
|
};
|