From 2d1d1515667951f076ef088d5acbcd0d1ff02351 Mon Sep 17 00:00:00 2001 From: Samuel H Date: Sun, 19 Mar 2023 20:12:20 -0500 Subject: [PATCH] Updated to use the newer Furi mutex api. --- i2ctools.c | 16 +++++++--------- i2ctools_i.h | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/i2ctools.c b/i2ctools.c index 9d73a73b8f9..4f1c8e62b49 100644 --- a/i2ctools.c +++ b/i2ctools.c @@ -1,7 +1,10 @@ #include "i2ctools_i.h" void i2ctools_draw_callback(Canvas* canvas, void* ctx) { - i2cTools* i2ctools = acquire_mutex((ValueMutex*)ctx, 25); + i2cTools* i2ctools = ctx; + if(furi_mutex_acquire(i2ctools->mutex, 200) != FuriStatusOk) { + return; + } switch(i2ctools->main_view->current_view) { case MAIN_VIEW: @@ -23,7 +26,7 @@ void i2ctools_draw_callback(Canvas* canvas, void* ctx) { default: break; } - release_mutex((ValueMutex*)ctx, i2ctools); + furi_mutex_release(i2ctools->mutex); } void i2ctools_input_callback(InputEvent* input_event, void* ctx) { @@ -38,16 +41,11 @@ int32_t i2ctools_app(void* p) { // Alloc i2ctools i2cTools* i2ctools = malloc(sizeof(i2cTools)); - ValueMutex i2ctools_mutex; - if(!init_mutex(&i2ctools_mutex, i2ctools, sizeof(i2cTools))) { - FURI_LOG_E(APP_NAME, "cannot create mutex\r\n"); - free(i2ctools); - return -1; - } + i2ctools->mutex = furi_mutex_alloc(FuriMutexTypeNormal); // Alloc viewport i2ctools->view_port = view_port_alloc(); - view_port_draw_callback_set(i2ctools->view_port, i2ctools_draw_callback, &i2ctools_mutex); + view_port_draw_callback_set(i2ctools->view_port, i2ctools_draw_callback, i2ctools); view_port_input_callback_set(i2ctools->view_port, i2ctools_input_callback, event_queue); // Register view port in GUI diff --git a/i2ctools_i.h b/i2ctools_i.h index 33917dc34d2..f31e4247859 100644 --- a/i2ctools_i.h +++ b/i2ctools_i.h @@ -13,6 +13,7 @@ // App datas typedef struct { + FuriMutex* mutex; ViewPort* view_port; i2cMainView* main_view;