mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-22 10:43:11 +00:00
ad421a81bc
* FS-Api: removed datetime manipulation functions and most of the file flags * Filesystem: common proxy api * Filesystem: renamed to Storage. Work has begun on a glue layer. Added functions for reentrance. * Storage: sd mount and sd file open * Storage: sd file close * Storage: temporary test app * Storage: free filedata on close * Storage: sd file read and write * Storage: added internal storage (LittleFS) * Storage: renamed internal commands * Storage: seek, tell, truncate, size, sync, eof * Storage: error descriptions * Storage: directory management api (open, close, read, rewind) * Storage: common management api (stat, fs_stat, remove, rename, mkdir) * Dolphin app and Notifications app now use raw storage. * Storage: storage statuses renamed. Implemented sd card icon. * Storage: added raw sd-card api. * Storage settings: work started * Assets: use new icons approach * Storage settings: working storage settings * Storage: completely redesigned api, no longer sticking out FS_Api * Storage: more simplified api, getting error_id from file is hidden from user, pointer to api is hidden inside file * Storage: cli info and format commands * Storage-cli: file list * Storage: a simpler and more reliable api * FatFS: slightly lighter and faster config. Also disabled reentrancy and file locking functions. They moved to a storage service. * Storage-cli: accommodate to the new cli api. * Storage: filesystem api is separated into internal and common api. * Cli: added the ability to print the list of free heap blocks * Storage: uses a list instead of an array to store the StorageFile. Rewrote api calls to use semaphores instead of thread flags. * Storage settings: added the ability to benchmark the SD card. * Gui module file select: uses new storage api * Apps: removed deprecated sd_card_test application * Args lib: support for enquoted arguments * Dialogs: a new gui app for simple non-asynchronous apps * Dialogs: view holder for easy single view work * File worker: use new storage api * IButton and lfrrfid apps: save keys to any storage * Apps: fix ibutton and lfrfid stack, remove sd_card_test. * SD filesystem: app removed * File worker: fixed api pointer type * Subghz: loading assets using the new storage api * NFC: use the new storage api * Dialogs: the better api for the message element * Archive: use new storage api * Irda: changed assest path, changed app path * FileWorker: removed unused file_buf_cnt * Storage: copying and renaming files now works between storages * Storage cli: read, copy, remove, rename commands * Archive: removed commented code * Storage cli: write command * Applications: add SRV_STORAGE and SRV_DIALOGS * Internal-storage: removed * Storage: improved api * Storage app: changed api pointer from StorageApp to Storage * Storage: better file_id handling * Storage: more consistent errors * Loader: support for NULL icons * Storage: do nothing with the lfs file or directory if it is not open * Storage: fix typo * Storage: minor float usage cleanup, rename some symbols. * Storage: compact doxygen comments. Co-authored-by: あく <alleteam@gmail.com>
143 lines
No EOL
4.3 KiB
C++
143 lines
No EOL
4.3 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-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-select-key.h"
|
|
#include "scene/ibutton-scene-add-type.h"
|
|
#include "scene/ibutton-scene-add-value.h"
|
|
|
|
#include "helpers/key-worker.h"
|
|
|
|
#include "one_wire_master.h"
|
|
#include "maxim_crc.h"
|
|
#include "ibutton-key.h"
|
|
|
|
#include <notification/notification-messages.h>
|
|
|
|
#include <record-controller.hpp>
|
|
|
|
class iButtonApp {
|
|
public:
|
|
void run(void* args);
|
|
|
|
iButtonApp();
|
|
~iButtonApp();
|
|
|
|
enum class Scene : uint8_t {
|
|
SceneExit,
|
|
SceneStart,
|
|
SceneRead,
|
|
SceneReadNotKeyError,
|
|
SceneReadCRCError,
|
|
SceneReadSuccess,
|
|
SceneReadedKeyMenu,
|
|
SceneWrite,
|
|
SceneWriteSuccess,
|
|
SceneEmulate,
|
|
SceneSavedKeyMenu,
|
|
SceneDeleteConfirm,
|
|
SceneDeleteSuccess,
|
|
SceneSaveName,
|
|
SceneSaveSuccess,
|
|
SceneInfo,
|
|
SceneSelectKey,
|
|
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_error();
|
|
void notify_success();
|
|
void notify_green_on();
|
|
void notify_green_off();
|
|
void notify_red_on();
|
|
void notify_red_off();
|
|
|
|
void set_text_store(const char* text...);
|
|
char* get_text_store();
|
|
uint8_t get_text_store_size();
|
|
|
|
char* get_file_name();
|
|
uint8_t get_file_name_size();
|
|
|
|
void generate_random_name(char* name, uint8_t max_name_size);
|
|
|
|
bool save_key(const char* key_name);
|
|
bool load_key();
|
|
bool load_key(const char* key_name);
|
|
bool delete_key();
|
|
|
|
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::SceneSavedKeyMenu, new iButtonSceneSavedKeyMenu()},
|
|
{Scene::SceneDeleteConfirm, new iButtonSceneDeleteConfirm()},
|
|
{Scene::SceneDeleteSuccess, new iButtonSceneDeleteSuccess()},
|
|
{Scene::SceneSaveName, new iButtonSceneSaveName()},
|
|
{Scene::SceneSaveSuccess, new iButtonSceneSaveSuccess()},
|
|
{Scene::SceneInfo, new iButtonSceneInfo()},
|
|
{Scene::SceneSelectKey, new iButtonSceneSelectKey()},
|
|
{Scene::SceneAddType, new iButtonSceneAddType()},
|
|
{Scene::SceneAddValue, new iButtonSceneAddValue()},
|
|
};
|
|
|
|
KeyWorker* key_worker;
|
|
|
|
iButtonKey key;
|
|
|
|
RecordController<NotificationApp> notification;
|
|
|
|
static const uint8_t file_name_size = 100;
|
|
char file_name[file_name_size];
|
|
|
|
static const uint8_t text_store_size = 128;
|
|
char text_store[text_store_size + 1];
|
|
|
|
static const char* app_folder;
|
|
static const char* app_extension;
|
|
|
|
bool load_key_data(string_t key_path);
|
|
void make_app_folder();
|
|
}; |