From 8fcc27af0e76b2385e7e5a8c13df1782cf2a77d2 Mon Sep 17 00:00:00 2001 From: FReenen Date: Thu, 11 Jul 2024 18:23:45 +0200 Subject: [PATCH] inital setup for led controll --- rx_esp32/CMakeLists.txt | 1 + rx_esp32/src/led.c | 33 +++++++++++++++++++++++++++++++++ rx_esp32/src/led.h | 10 ++++++++++ 3 files changed, 44 insertions(+) create mode 100644 rx_esp32/src/led.c create mode 100644 rx_esp32/src/led.h diff --git a/rx_esp32/CMakeLists.txt b/rx_esp32/CMakeLists.txt index 15c4ae3..bc6030d 100644 --- a/rx_esp32/CMakeLists.txt +++ b/rx_esp32/CMakeLists.txt @@ -1,3 +1,4 @@ cmake_minimum_required(VERSION 3.16.0) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +list(APPEND EXTRA_COMPONENT_DIRS led_strip) project(rx_esp32) diff --git a/rx_esp32/src/led.c b/rx_esp32/src/led.c new file mode 100644 index 0000000..7525eec --- /dev/null +++ b/rx_esp32/src/led.c @@ -0,0 +1,33 @@ +#include "led.h" + +#include "driver/gpio.h" +#include "led_strip.h" + +static led_strip_handle_t led_strip; + +void led_init(void) +{ + /* LED strip initialization with the GPIO and pixels number*/ + led_strip_config_t strip_config = { + .strip_gpio_num = 8, + .max_leds = 1, + }; + led_strip_rmt_config_t rmt_config = { + .resolution_hz = 10 * 1000 * 1000, // 10MHz + .flags.with_dma = false, + }; + led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip); + /* Set all LED off to clear all pixels */ + led_strip_clear(led_strip); +} + +void led_deinit(void) +{ + //TODO +} + +void led_setColor(uint8_t r, uint8_t g, uint8_t b) +{ + led_strip_set_pixel(led_strip, 0, 16, 16, 16); + led_strip_refresh(led_strip); +} diff --git a/rx_esp32/src/led.h b/rx_esp32/src/led.h new file mode 100644 index 0000000..d840649 --- /dev/null +++ b/rx_esp32/src/led.h @@ -0,0 +1,10 @@ +#ifndef LED_H +#define LED_H + +#include + +void led_init(void); +void led_deinit(void); +void led_setColor(uint8_t r, uint8_t g, uint8_t b); + +#endif \ No newline at end of file