mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 21:13:16 +00:00
134 lines
4.1 KiB
C
134 lines
4.1 KiB
C
|
#pragma once
|
||
|
#include <map>
|
||
|
#include <list>
|
||
|
|
||
|
#include "ibutton-view-manager.h"
|
||
|
#include "scene/ibutton-scene-generic.h"
|
||
|
#include "scene/ibutton-scene-start.h"
|
||
|
#include "scene/ibutton-scene-read.h"
|
||
|
#include "scene/ibutton-scene-read-crc-error.h"
|
||
|
#include "scene/ibutton-scene-read-not-key-error.h"
|
||
|
#include "scene/ibutton-scene-read-success.h"
|
||
|
#include "scene/ibutton-scene-readed-key-menu.h"
|
||
|
#include "scene/ibutton-scene-write.h"
|
||
|
#include "scene/ibutton-scene-write-success.h"
|
||
|
#include "scene/ibutton-scene-saved.h"
|
||
|
#include "scene/ibutton-scene-saved-key-menu.h"
|
||
|
#include "scene/ibutton-scene-delete-confirm.h"
|
||
|
#include "scene/ibutton-scene-delete-success.h"
|
||
|
#include "scene/ibutton-scene-emulate.h"
|
||
|
#include "scene/ibutton-scene-save-name.h"
|
||
|
#include "scene/ibutton-scene-save-success.h"
|
||
|
#include "scene/ibutton-scene-info.h"
|
||
|
#include "scene/ibutton-scene-add-type.h"
|
||
|
#include "scene/ibutton-scene-add-value.h"
|
||
|
|
||
|
#include "helpers/key-store.h"
|
||
|
#include "helpers/key-worker.h"
|
||
|
|
||
|
#include "one_wire_master.h"
|
||
|
#include "maxim_crc.h"
|
||
|
#include "ibutton-key.h"
|
||
|
|
||
|
class iButtonApp {
|
||
|
public:
|
||
|
void run(void);
|
||
|
|
||
|
iButtonApp();
|
||
|
~iButtonApp();
|
||
|
|
||
|
enum class Scene : uint8_t {
|
||
|
SceneExit,
|
||
|
SceneStart,
|
||
|
SceneRead,
|
||
|
SceneReadNotKeyError,
|
||
|
SceneReadCRCError,
|
||
|
SceneReadSuccess,
|
||
|
SceneReadedKeyMenu,
|
||
|
SceneWrite,
|
||
|
SceneWriteSuccess,
|
||
|
SceneEmulate,
|
||
|
SceneSavedList,
|
||
|
SceneSavedKeyMenu,
|
||
|
SceneDeleteConfirm,
|
||
|
SceneDeleteSuccess,
|
||
|
SceneSaveName,
|
||
|
SceneSaveSuccess,
|
||
|
SceneInfo,
|
||
|
SceneAddType,
|
||
|
SceneAddValue,
|
||
|
};
|
||
|
|
||
|
iButtonAppViewManager* get_view_manager();
|
||
|
void switch_to_next_scene(Scene index);
|
||
|
void search_and_switch_to_previous_scene(std::initializer_list<Scene> scenes_list);
|
||
|
bool switch_to_previous_scene(uint8_t count = 1);
|
||
|
Scene get_previous_scene();
|
||
|
|
||
|
const GpioPin* get_ibutton_pin();
|
||
|
KeyWorker* get_key_worker();
|
||
|
iButtonKey* get_key();
|
||
|
|
||
|
void notify_green_blink();
|
||
|
void notify_yellow_blink();
|
||
|
void notify_red_blink();
|
||
|
|
||
|
void notify_green_on();
|
||
|
void notify_green_off();
|
||
|
void notify_red_on();
|
||
|
void notify_red_off();
|
||
|
|
||
|
void notify_error();
|
||
|
void notify_success();
|
||
|
|
||
|
void notify_vibro_on();
|
||
|
void notify_vibro_off();
|
||
|
|
||
|
void set_text_store(const char* text...);
|
||
|
char* get_text_store();
|
||
|
uint8_t get_text_store_size();
|
||
|
|
||
|
KeyStore* get_key_store();
|
||
|
uint8_t get_stored_key_index();
|
||
|
void set_stored_key_index(uint8_t index);
|
||
|
|
||
|
void generate_random_name(char* name, uint8_t max_name_size);
|
||
|
|
||
|
private:
|
||
|
std::list<Scene> previous_scenes_list = {Scene::SceneExit};
|
||
|
Scene current_scene = Scene::SceneStart;
|
||
|
iButtonAppViewManager view;
|
||
|
|
||
|
std::map<Scene, iButtonScene*> scenes = {
|
||
|
{Scene::SceneStart, new iButtonSceneStart()},
|
||
|
{Scene::SceneRead, new iButtonSceneRead()},
|
||
|
{Scene::SceneReadCRCError, new iButtonSceneReadCRCError()},
|
||
|
{Scene::SceneReadNotKeyError, new iButtonSceneReadNotKeyError()},
|
||
|
{Scene::SceneReadSuccess, new iButtonSceneReadSuccess()},
|
||
|
{Scene::SceneReadedKeyMenu, new iButtonSceneReadedKeyMenu()},
|
||
|
{Scene::SceneWrite, new iButtonSceneWrite()},
|
||
|
{Scene::SceneWriteSuccess, new iButtonSceneWriteSuccess()},
|
||
|
{Scene::SceneEmulate, new iButtonSceneEmulate()},
|
||
|
{Scene::SceneSavedList, new iButtonSceneSavedList()},
|
||
|
{Scene::SceneSavedKeyMenu, new iButtonSceneSavedKeyMenu()},
|
||
|
{Scene::SceneDeleteConfirm, new iButtonSceneDeleteConfirm()},
|
||
|
{Scene::SceneDeleteSuccess, new iButtonSceneDeleteSuccess()},
|
||
|
{Scene::SceneSaveName, new iButtonSceneSaveName()},
|
||
|
{Scene::SceneSaveSuccess, new iButtonSceneSaveSuccess()},
|
||
|
{Scene::SceneInfo, new iButtonSceneInfo()},
|
||
|
{Scene::SceneAddType, new iButtonSceneAddType()},
|
||
|
{Scene::SceneAddValue, new iButtonSceneAddValue()},
|
||
|
};
|
||
|
|
||
|
KeyWorker* key_worker;
|
||
|
|
||
|
iButtonKey key;
|
||
|
uint8_t key_index = 0;
|
||
|
|
||
|
static const uint8_t text_store_size = 128;
|
||
|
char text_store[text_store_size + 1];
|
||
|
|
||
|
KeyStore store;
|
||
|
|
||
|
void notify_init();
|
||
|
};
|