vibe code the initial impl
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
#include "esp_log.h"
|
||||
#include "led.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BUZZ_RGB_LED_ENABLE
|
||||
#include "driver/rmt_types.h"
|
||||
#include "led_strip.h"
|
||||
#include "board_config.h"
|
||||
|
||||
static led_strip_handle_t s_strip;
|
||||
|
||||
esp_err_t led_init(void)
|
||||
{
|
||||
led_strip_config_t strip_cfg = {
|
||||
.strip_gpio_num = RGB_LED_GPIO,
|
||||
.max_leds = 1,
|
||||
};
|
||||
led_strip_rmt_config_t rmt_cfg = {
|
||||
.clk_src = RMT_CLK_SRC_DEFAULT,
|
||||
.resolution_hz = 10 * 1000 * 1000,
|
||||
};
|
||||
esp_err_t err = led_strip_new_rmt_device(&strip_cfg, &rmt_cfg, &s_strip);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW("led", "led_strip init failed: %s (LED disabled)", esp_err_to_name(err));
|
||||
s_strip = NULL;
|
||||
return err;
|
||||
}
|
||||
led_strip_clear(s_strip);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void led_set(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
if (!s_strip) return;
|
||||
led_strip_set_pixel(s_strip, 0, r, g, b);
|
||||
led_strip_refresh(s_strip);
|
||||
}
|
||||
#else
|
||||
esp_err_t led_init(void) { return ESP_OK; }
|
||||
void led_set(uint8_t r, uint8_t g, uint8_t b) { (void)r; (void)g; (void)b; }
|
||||
#endif
|
||||
Reference in New Issue
Block a user