# HG changeset patch # User Ethan Zonca # Date 2024-08-12 21:59:33 # Node ID 8645339bec1e0c406801244217982e5d3426d471 # Parent 33512a8a338c5ac3c64724fc9ff16f7bc63b840d Add addressable LED control diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,2 +1,2 @@ -idf_component_register(SRCS "main.c" "wifi.c" "usb_cdc.c" "can.c" "display.c" "display_gui.c" "osc_control.c" +idf_component_register(SRCS "main.c" "wifi.c" "usb_cdc.c" "can.c" "display.c" "display_gui.c" "osc_control.c" "ledstrip.c" INCLUDE_DIRS .) diff --git a/main/idf_component.yml b/main/idf_component.yml --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,5 +1,6 @@ ## IDF Component Manager Manifest File dependencies: + espressif/led_strip: "^2.5.4" espressif/esp_lcd_touch_tt21100: "*" espressif/esp_lvgl_port: "*" espressif/esp_tinyusb: "^1" diff --git a/main/ledstrip.c b/main/ledstrip.c new file mode 100644 --- /dev/null +++ b/main/ledstrip.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +#include "ledstrip.h" + + +#define BLINK_GPIO 0 + +led_strip_handle_t led_strip; + +/* LED strip initialization with the GPIO and pixels number*/ +led_strip_config_t strip_config = { + .strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line + .max_leds = 1, // The number of LEDs in the strip, + .led_pixel_format = LED_PIXEL_FORMAT_GRB, // Pixel format of your LED strip + .led_model = LED_MODEL_WS2812, // LED strip model + .flags.invert_out = false, // whether to invert the output signal (useful when your hardware has a level inverter) +}; + +led_strip_rmt_config_t rmt_config = { + .clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption + .resolution_hz = 10 * 1000 * 1000, // 10MHz + .flags.with_dma = false, // whether to enable the DMA feature +}; + +void ledstrip_init(void) +{ + ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip)); +} \ No newline at end of file diff --git a/main/ledstrip.h b/main/ledstrip.h new file mode 100644 --- /dev/null +++ b/main/ledstrip.h @@ -0,0 +1,7 @@ +#ifndef _LED_STRIPPER_H +#define _LED_STRIPPER_H + + +void ledstrip_init(void); + +#endif \ No newline at end of file diff --git a/main/main.c b/main/main.c --- a/main/main.c +++ b/main/main.c @@ -16,6 +16,7 @@ // #include "usb_cdc.h" #include "can.h" #include "display.h" +#include "ledstrip.h" #include "display_gui.h" @@ -37,9 +38,6 @@ void app_main(void) } ESP_ERROR_CHECK(ret); - //vTaskDelay(pdTICKS_TO_MS(3000)); - - // Initialize display display_init(); display_gui_homescreen(); @@ -50,6 +48,8 @@ void app_main(void) // Initialize OSC osc_init(); + ledstrip_init(); + // Initialize canbus //can_init();