mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-21 04:11:48 +03:00
855f2584ab
* Storage: correct replacement for "/any" path in path holder * Unit tests: storage, blocking file open test * File stream: error getter * Storage: common copy and common remove now executes in external thread * Filesystems: got rid of unused functions * Storage: untangle dependencies, ram-frendly filesystem api * iButton: context assertions * Storage: pubsub messages * Storage: wait for the file to close if it was open * Storage: fix folder copying * Storage: unit test * Storage: pubsub documentation * Fix merge error * Fix memleak in storage test * Storage: remove unused define Co-authored-by: あく <alleteam@gmail.com>
53 lines
1.7 KiB
C++
Executable File
53 lines
1.7 KiB
C++
Executable File
#include "ibutton_scene_add_value.h"
|
|
#include "../ibutton_app.h"
|
|
#include <dolphin/dolphin.h>
|
|
|
|
static void byte_input_callback(void* context) {
|
|
furi_assert(context);
|
|
iButtonApp* app = static_cast<iButtonApp*>(context);
|
|
iButtonEvent event;
|
|
|
|
event.type = iButtonEvent::Type::EventTypeByteEditResult;
|
|
app->get_view_manager()->send_event(&event);
|
|
}
|
|
|
|
void iButtonSceneAddValue::on_enter(iButtonApp* app) {
|
|
iButtonAppViewManager* view_manager = app->get_view_manager();
|
|
ByteInput* byte_input = view_manager->get_byte_input();
|
|
iButtonKey* key = app->get_key();
|
|
|
|
memcpy(this->new_key_data, ibutton_key_get_data_p(key), ibutton_key_get_data_size(key));
|
|
|
|
byte_input_set_result_callback(
|
|
byte_input,
|
|
byte_input_callback,
|
|
NULL,
|
|
app,
|
|
this->new_key_data,
|
|
ibutton_key_get_data_size(key));
|
|
|
|
byte_input_set_header_text(byte_input, "Enter the key");
|
|
|
|
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewByteInput);
|
|
}
|
|
|
|
bool iButtonSceneAddValue::on_event(iButtonApp* app, iButtonEvent* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == iButtonEvent::Type::EventTypeByteEditResult) {
|
|
ibutton_key_set_data(app->get_key(), this->new_key_data, IBUTTON_KEY_DATA_SIZE);
|
|
DOLPHIN_DEED(DolphinDeedIbuttonAdd);
|
|
app->switch_to_next_scene(iButtonApp::Scene::SceneSaveName);
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void iButtonSceneAddValue::on_exit(iButtonApp* app) {
|
|
iButtonAppViewManager* view_manager = app->get_view_manager();
|
|
ByteInput* byte_input = view_manager->get_byte_input();
|
|
|
|
byte_input_set_result_callback(byte_input, NULL, NULL, NULL, NULL, 0);
|
|
byte_input_set_header_text(byte_input, {0});
|
|
} |