From 9ec25ed0b4cf840a42dc8eb0af5f8191350282e2 Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Sat, 16 Dec 2023 08:47:55 -0800 Subject: [PATCH 1/3] Reduce to 512 LEDS (out of mem) on some FW. --- gpio/ws2812b_tester/app.c | 7 +++---- gpio/ws2812b_tester/led_driver.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gpio/ws2812b_tester/app.c b/gpio/ws2812b_tester/app.c index 2aa8cc5..53f5fda 100644 --- a/gpio/ws2812b_tester/app.c +++ b/gpio/ws2812b_tester/app.c @@ -168,10 +168,9 @@ static void led_tester_setting_led_pin_change(VariableItem* item) { // Settings for configuring how many LEDs to enable. static const char* setting_led_count_config_label = "LED Count"; -static uint16_t setting_led_count_values[] = - {1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 64, 128, 256, 512, 1024}; +static uint16_t setting_led_count_values[] = {1, 2, 3, 4, 5, 6, 7, 8, 16, 32, 64, 128, 256, 512}; static char* setting_led_count_names[] = - {"1", "2", "3", "4", "5", "6", "7", "8", "16", "32", "64", "128", "256", "512", "1024"}; + {"1", "2", "3", "4", "5", "6", "7", "8", "16", "32", "64", "128", "256", "512"}; static uint8_t setting_led_count_default_index = 3; // 4 LEDs static void led_tester_setting_led_count_change(VariableItem* item) { LedTesterApp* app = variable_item_get_context(item); @@ -347,7 +346,7 @@ static bool led_tester_custom_event_callback(void* context, uint32_t event) { led_driver_set_led(app->led_driver, i, 0); } - led_driver_transmit(app->led_driver, false); + led_driver_transmit(app->led_driver, true); if(event == LedTesterEventDeinit) { led_driver_free(app->led_driver); diff --git a/gpio/ws2812b_tester/led_driver.h b/gpio/ws2812b_tester/led_driver.h index ed03d61..9dfba6a 100644 --- a/gpio/ws2812b_tester/led_driver.h +++ b/gpio/ws2812b_tester/led_driver.h @@ -1,7 +1,7 @@ #include #include -#define MAX_LED_COUNT 1024 +#define MAX_LED_COUNT 512 typedef struct LedDriver LedDriver; From fe3bb3b3544cfd46a6ccfecb0b57b651513a69c5 Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Wed, 17 Jan 2024 10:24:28 -0600 Subject: [PATCH 2/3] Use logic LOW when not sending data. --- gpio/ws2812b_tester/led_driver.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gpio/ws2812b_tester/led_driver.c b/gpio/ws2812b_tester/led_driver.c index 08523d1..abedeab 100644 --- a/gpio/ws2812b_tester/led_driver.c +++ b/gpio/ws2812b_tester/led_driver.c @@ -23,6 +23,7 @@ #define LED_DRIVER_T0L 850U #define LED_DRIVER_T1L 450U #define LED_DRIVER_TRESETL 55 * 1000U +#define LED_DRIVER_TDONE 2000U // Wait for 35ms for the DMA to complete. NOTE: 1000 leds*(850ns+450ns)*24 = 32ms #define LED_DRIVER_SETINEL_WAIT_MS 35 @@ -250,18 +251,18 @@ void led_driver_transmit(LedDriver* led_driver, bool transmit_if_clean) { const uint32_t bit_set = led_driver->gpio->pin << GPIO_BSRR_BS0_Pos; const uint32_t bit_reset = led_driver->gpio->pin << GPIO_BSRR_BR0_Pos; - // Always start with LOW (reset) - led_driver->gpio_buf[0] = bit_reset; - led_driver->gpio_buf[1] = bit_set; + // Our initial state is LOW, so first pulse is HIGH (set) + led_driver->gpio_buf[0] = bit_set; + led_driver->gpio_buf[1] = bit_reset; for(size_t i = 0; i < LED_DRIVER_BUFFER_SIZE; i++) { led_driver->timer_buffer[i] = LED_DRIVER_TIMER_SETINEL; } - led_driver_add_period(led_driver, LED_DRIVER_TRESETL); for(size_t i = 0; i < led_driver->count_leds; i++) { led_driver_add_color(led_driver, led_driver->led_data[i]); } + led_driver_add_period(led_driver, LED_DRIVER_TDONE); led_driver->dma_led_transition_timer.NbData = led_driver->write_pos + 1; FURI_CRITICAL_ENTER(); From a012ec78e0f2f51fb130192427596b001c82b139 Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Wed, 17 Jan 2024 10:26:35 -0600 Subject: [PATCH 3/3] Version 1.9 - fix first LED "laggy" issue (reported by Z3BRO). --- gpio/ws2812b_tester/README.md | 2 ++ gpio/ws2812b_tester/application.fam | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gpio/ws2812b_tester/README.md b/gpio/ws2812b_tester/README.md index 128c3cb..33d9506 100644 --- a/gpio/ws2812b_tester/README.md +++ b/gpio/ws2812b_tester/README.md @@ -23,6 +23,8 @@ This application has three submenu items: The "About" menu item contains information about the application. # Updates +- Version 1.9 + - Use logic LOW instead of HIGH as resting state. Fixes first LED was "laggy" issue. - Version 1.8 - Renamed app to fit on Flipper Zero main menu screen - Improved initialization to only happen when configuring the LEDs diff --git a/gpio/ws2812b_tester/application.fam b/gpio/ws2812b_tester/application.fam index a1eaba9..a213daa 100644 --- a/gpio/ws2812b_tester/application.fam +++ b/gpio/ws2812b_tester/application.fam @@ -3,7 +3,7 @@ App( name="WS2812B LED Tester", apptype=FlipperAppType.EXTERNAL, entry_point="ws2812b_led_tester_app", - fap_version=(1, 8), + fap_version=(1, 9), stack_size=4 * 1024, requires=[ "gui",