Changeset - 8645339bec1e
[Not reviewed]
default
0 3 2
Ethan Zonca - 11 months ago 2024-08-12 21:59:33
ez@ethanzonca.com
Add addressable LED control
5 files changed with 43 insertions and 4 deletions:
0 comments (0 inline, 0 general)
main/CMakeLists.txt
Show inline comments
 
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 .)
main/idf_component.yml
Show inline comments
 
## 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"
main/ledstrip.c
Show inline comments
 
new file 100644
 
#include <esp_event.h>
 
#include <esp_log.h>
 
#include <esp_wifi.h>
 
#include <led_strip.h>
 

	
 
#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
main/ledstrip.h
Show inline comments
 
new file 100644
 
#ifndef _LED_STRIPPER_H
 
#define _LED_STRIPPER_H
 

	
 

	
 
void ledstrip_init(void);
 

	
 
#endif
 
\ No newline at end of file
main/main.c
Show inline comments
 
@@ -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();
 

	
0 comments (0 inline, 0 general)