From cafdbcc0016bfbb24b1e63854027ae47b91379cd Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Wed, 6 Dec 2023 18:30:15 -0600 Subject: [PATCH] Improvements for ws2812b_tester app --- gpio/ws2812b_tester/README.md | 3 +++ gpio/ws2812b_tester/app.c | 15 ++++++++++++--- gpio/ws2812b_tester/application.fam | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gpio/ws2812b_tester/README.md b/gpio/ws2812b_tester/README.md index 1d9d2df..128c3cb 100644 --- a/gpio/ws2812b_tester/README.md +++ b/gpio/ws2812b_tester/README.md @@ -23,6 +23,9 @@ This application has three submenu items: The "About" menu item contains information about the application. # Updates +- Version 1.8 + - Renamed app to fit on Flipper Zero main menu screen + - Improved initialization to only happen when configuring the LEDs - Version 1.7 - Added blanking TRESET (LOW) signal before sending data to LEDs. - Increased timer_buffer to uint16 to support blanking signal duration. Maybe there is a better way to do the initial low & save memory? diff --git a/gpio/ws2812b_tester/app.c b/gpio/ws2812b_tester/app.c index 0abecdb..2aa8cc5 100644 --- a/gpio/ws2812b_tester/app.c +++ b/gpio/ws2812b_tester/app.c @@ -249,6 +249,11 @@ static bool led_tester_custom_event_callback(void* context, uint32_t event) { LedTesterApp* app = (LedTesterApp*)context; const GpioPin* pin = setting_led_pin_values[app->model->led_pin_index]; + if(!app->led_driver) { + FURI_LOG_E(TAG, "led_driver is NULL. Custom event %lu ignored.", event); + return false; + } + if(event == LedTesterEventTimer) { app->model->timer_counter++; } @@ -344,6 +349,11 @@ static bool led_tester_custom_event_callback(void* context, uint32_t event) { led_driver_transmit(app->led_driver, false); + if(event == LedTesterEventDeinit) { + led_driver_free(app->led_driver); + app->led_driver = NULL; + } + return true; } @@ -362,6 +372,8 @@ void led_tester_enter_leds_callback(void* _context) { app->timer = furi_timer_alloc(led_tester_timer_callback, FuriTimerTypePeriodic, app); furi_timer_start(app->timer, 250); view_dispatcher_send_custom_event(app->view_dispatcher, LedTesterEventInitialized); + app->led_driver = + led_driver_alloc(MAX_LED_COUNT, setting_led_pin_values[app->model->led_pin_index]); } /** @@ -432,8 +444,6 @@ static LedTesterApp* led_tester_app_alloc() { variable_item_set_current_value_index(item, setting_led_pin_index); variable_item_set_current_value_text(item, setting_led_pin_names[setting_led_pin_index]); app->model->led_pin_index = setting_led_pin_index; - app->led_driver = - led_driver_alloc(MAX_LED_COUNT, setting_led_pin_values[setting_led_pin_index]); // Count item = variable_item_list_add( @@ -530,7 +540,6 @@ static LedTesterApp* led_tester_app_alloc() { * @param app The led tester application object. */ static void led_tester_app_free(LedTesterApp* app) { - led_driver_free(app->led_driver); view_dispatcher_remove_view(app->view_dispatcher, LedTesterViewAbout); widget_free(app->widget_about); view_dispatcher_remove_view(app->view_dispatcher, LedTesterViewLeds); diff --git a/gpio/ws2812b_tester/application.fam b/gpio/ws2812b_tester/application.fam index 7b68058..a1eaba9 100644 --- a/gpio/ws2812b_tester/application.fam +++ b/gpio/ws2812b_tester/application.fam @@ -1,9 +1,9 @@ App( appid="ws2812b_tester_app", - name="WS2812B LED Tester App", + name="WS2812B LED Tester", apptype=FlipperAppType.EXTERNAL, entry_point="ws2812b_led_tester_app", - fap_version=(1, 7), + fap_version=(1, 8), stack_size=4 * 1024, requires=[ "gui",