inital setup for led controll

This commit is contained in:
Laila van Reenen 2024-07-11 18:23:45 +02:00
parent f17bf03eaf
commit 8fcc27af0e
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769
3 changed files with 44 additions and 0 deletions

View File

@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.16.0) cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
list(APPEND EXTRA_COMPONENT_DIRS led_strip)
project(rx_esp32) project(rx_esp32)

33
rx_esp32/src/led.c Normal file
View File

@ -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);
}

10
rx_esp32/src/led.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef LED_H
#define LED_H
#include <stdint.h>
void led_init(void);
void led_deinit(void);
void led_setColor(uint8_t r, uint8_t g, uint8_t b);
#endif