[FL-2393][FL-2381] iButton, OneWire: move to plain C (#1068)
* iButton: getting started on the worker concept * Hal delay: added global instructions_per_us variable * iButton: one wire slave * iButton: ibutton key setter * iButton: one wire host, use ibutton_hal * iButton\RFID: common pulse decoder concept * iButton: cyfral decoder * iButton: worker thread concept * iButton: metakom decoder * iButton: write key through worker * iButton: worker mode holder * iButton: worker improvements * iButton: Cyfral encoder * iButton: Metakom encoder * lib: pulse protocol helpers * iButton: Metakom decoder * iButton: Cyfral decoder * iButton worker: separate modes * iButton: libs documentation * HAL: iButton gpio modes * iButton worker: rename modes file * iButton worker, hal: move to LL * iButton CLI: worker for reading and emulation commands * iButton HAL: correct init and emulation sequence * iButton cli: moved to plain C * iButton: move to worker, small step to plain C * Libs, one wire: move to plain C * Libs: added forgotten files to compilation * iButton writer: get rid of manual disable/enable irq
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
#include "ibutton_scene_add_value.h"
|
||||
#include "../ibutton_app.h"
|
||||
#include "../ibutton_view_manager.h"
|
||||
#include "../ibutton_event.h"
|
||||
#include <callback-connector.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
static void byte_input_callback(void* 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();
|
||||
auto callback = cbc::obtain_connector(this, &iButtonSceneAddValue::byte_input_callback);
|
||||
memcpy(this->new_key_data, app->get_key()->get_data(), app->get_key()->get_type_data_size());
|
||||
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, callback, NULL, app, this->new_key_data, app->get_key()->get_type_data_size());
|
||||
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);
|
||||
@@ -21,6 +34,7 @@ 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;
|
||||
@@ -35,13 +49,4 @@ void iButtonSceneAddValue::on_exit(iButtonApp* app) {
|
||||
|
||||
byte_input_set_result_callback(byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(byte_input, {0});
|
||||
}
|
||||
|
||||
void iButtonSceneAddValue::byte_input_callback(void* context) {
|
||||
iButtonApp* app = static_cast<iButtonApp*>(context);
|
||||
iButtonEvent event;
|
||||
|
||||
event.type = iButtonEvent::Type::EventTypeByteEditResult;
|
||||
memcpy(app->get_key()->get_data(), this->new_key_data, app->get_key()->get_type_data_size());
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user