LF-RFID debug: make it work (#2793)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Sergey Gavrilov 2023-06-28 10:30:59 +03:00 committed by GitHub
parent e680cf59b6
commit 92c1bb83bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 13 deletions

View file

@ -6,6 +6,11 @@ static void comparator_trigger_callback(bool level, void* comp_ctx) {
furi_hal_gpio_write(&gpio_ext_pa7, !level);
}
void lfrfid_debug_view_tune_callback(void* context) {
LfRfidDebug* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, 0xBA);
}
void lfrfid_debug_scene_tune_on_enter(void* context) {
LfRfidDebug* app = context;
@ -16,6 +21,8 @@ void lfrfid_debug_scene_tune_on_enter(void* context) {
furi_hal_rfid_tim_read_start(125000, 0.5);
lfrfid_debug_view_tune_set_callback(app->tune_view, lfrfid_debug_view_tune_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidDebugViewTune);
}

View file

@ -13,6 +13,8 @@ typedef struct {
uint32_t ARR;
uint32_t CCR;
int pos;
void (*update_callback)(void* context);
void* update_context;
} LfRfidTuneViewModel;
static void lfrfid_debug_view_tune_draw_callback(Canvas* canvas, void* _model) {
@ -151,6 +153,18 @@ static bool lfrfid_debug_view_tune_input_callback(InputEvent* event, void* conte
consumed = false;
break;
}
if(event->key == InputKeyLeft || event->key == InputKeyRight) {
with_view_model(
tune_view->view,
LfRfidTuneViewModel * model,
{
if(model->update_callback) {
model->update_callback(model->update_context);
}
},
false);
}
}
return consumed;
@ -161,19 +175,7 @@ LfRfidTuneView* lfrfid_debug_view_tune_alloc() {
tune_view->view = view_alloc();
view_set_context(tune_view->view, tune_view);
view_allocate_model(tune_view->view, ViewModelTypeLocking, sizeof(LfRfidTuneViewModel));
with_view_model(
tune_view->view,
LfRfidTuneViewModel * model,
{
model->dirty = true;
model->fine = false;
model->ARR = 511;
model->CCR = 255;
model->pos = 0;
},
true);
lfrfid_debug_view_tune_clean(tune_view);
view_set_draw_callback(tune_view->view, lfrfid_debug_view_tune_draw_callback);
view_set_input_callback(tune_view->view, lfrfid_debug_view_tune_input_callback);
@ -199,6 +201,8 @@ void lfrfid_debug_view_tune_clean(LfRfidTuneView* tune_view) {
model->ARR = 511;
model->CCR = 255;
model->pos = 0;
model->update_callback = NULL;
model->update_context = NULL;
},
true);
}
@ -232,3 +236,17 @@ uint32_t lfrfid_debug_view_tune_get_ccr(LfRfidTuneView* tune_view) {
return result;
}
void lfrfid_debug_view_tune_set_callback(
LfRfidTuneView* tune_view,
void (*callback)(void* context),
void* context) {
with_view_model(
tune_view->view,
LfRfidTuneViewModel * model,
{
model->update_callback = callback;
model->update_context = context;
},
false);
}

View file

@ -16,3 +16,8 @@ bool lfrfid_debug_view_tune_is_dirty(LfRfidTuneView* tune_view);
uint32_t lfrfid_debug_view_tune_get_arr(LfRfidTuneView* tune_view);
uint32_t lfrfid_debug_view_tune_get_ccr(LfRfidTuneView* tune_view);
void lfrfid_debug_view_tune_set_callback(
LfRfidTuneView* tune_view,
void (*callback)(void* context),
void* context);