example: update led strip example with new rmt driver

This commit is contained in:
morris
2022-04-07 13:12:16 +08:00
parent 977a2830dd
commit d537da5bfb
25 changed files with 803 additions and 532 deletions
@@ -39,17 +39,20 @@
#include "led_strip.h"
#include "light_driver.h"
static led_strip_t *led_strip;
static led_strip_handle_t s_led_strip;
void light_driver_set_power(bool power)
{
ESP_ERROR_CHECK(led_strip->set_pixel(led_strip, 0, 255 * power, 255 * power, 255 * power));
ESP_ERROR_CHECK(led_strip->refresh(led_strip, 100));
ESP_ERROR_CHECK(led_strip_set_pixel(s_led_strip, 0, 255 * power, 255 * power, 255 * power));
ESP_ERROR_CHECK(led_strip_refresh(s_led_strip));
}
int light_driver_init(bool power)
void light_driver_init(bool power)
{
led_strip = led_strip_init(RMT_TX_CHANNEL, CONFIG_EXAMPLE_RMT_TX_GPIO, CONFIG_EXAMPLE_STRIP_LED_NUMBER);
led_strip_config_t led_strip_conf = {
.max_leds = CONFIG_EXAMPLE_STRIP_LED_NUMBER,
.strip_gpio_num = CONFIG_EXAMPLE_STRIP_LED_GPIO,
};
ESP_ERROR_CHECK(led_strip_new_rmt_device(&led_strip_conf, &s_led_strip));
light_driver_set_power(power);
return ESP_OK;
}
@@ -37,8 +37,7 @@
#pragma once
#include "driver/rmt.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -49,8 +48,7 @@ extern "C" {
#define LIGHT_DEFAULT_OFF 0
/* LED strip configuration */
#define RMT_TX_CHANNEL RMT_CHANNEL_0
#define CONFIG_EXAMPLE_RMT_TX_GPIO 8
#define CONFIG_EXAMPLE_STRIP_LED_GPIO 8
#define CONFIG_EXAMPLE_STRIP_LED_NUMBER 1
/**
@@ -65,7 +63,7 @@ void light_driver_set_power(bool power);
*
* @param power power on/off
*/
int light_driver_init(bool power);
void light_driver_init(bool power);
#ifdef __cplusplus
} // extern "C"