Improved LED Ring

This commit is contained in:
2026-04-26 11:43:59 +02:00
parent 479162e47b
commit 2845c33955
3 changed files with 35 additions and 37 deletions
+22 -10
View File
@@ -1,3 +1,4 @@
#include "bosch456.h"
#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/i2c_types.h"
@@ -8,7 +9,7 @@
#include "led_strip.h"
#include "uart.h"
#include <stdint.h>
#include "bosch456.h"
#include <sys/types.h>
#define LED_GPIO 21
#define TASTER_GPIO 12
@@ -19,6 +20,8 @@
#define I2C_SDA 6
#define LED_RING 7
#define RING_LEDS 95
#define I2C_PORT 0
#define IO_EXPANDER_ADDRESS 0x20
@@ -80,23 +83,32 @@ void vTaskInput(void *pvParameters) {
void vTaskRingBlink(void *pvParameters) {
ESP_LOGI("GPIO_TASK", "GPIO ring blink task started");
static bool state;
uint8_t c1 = 255, c2 = 255, c3 = 255;
while (1) {
if (state) {
// GREEN
led_strip_set_pixel(led_ring, 0, 25, 0, 0);
led_strip_set_pixel(led_ring, 10, 25, 0, 0);
for (int i = 0; i < RING_LEDS; i++) {
led_strip_set_pixel(led_ring, i, c1, c2, c3);
led_strip_refresh(led_ring);
vTaskDelay(pdMS_TO_TICKS(10));
}
} else {
led_strip_set_pixel(led_ring, 0, 0, 0, 0);
led_strip_set_pixel(led_ring, 10, 0, 0, 0);
for (int i = 0; i < RING_LEDS; i++) {
led_strip_set_pixel(led_ring, i, 0, 0, 0);
led_strip_refresh(led_ring);
vTaskDelay(pdMS_TO_TICKS(10));
}
}
led_strip_refresh(led_ring);
state = !state;
vTaskDelay(pdMS_TO_TICKS(1000));
uint8_t temp = c1;
c1 = c3;
c3 = c2;
c2 = temp;
vTaskDelay(pdMS_TO_TICKS(100));
}
}
@@ -121,7 +133,7 @@ void app_main(void) {
/* LED Ring config */
led_strip_config_t ring_config = {
.strip_gpio_num = LED_RING,
.max_leds = 94,
.max_leds = RING_LEDS,
};
led_strip_rmt_config_t rmt_ring_config = {
.resolution_hz = 10 * 1000 * 1000, // 10 MHz