update LED driver

This commit is contained in:
2025-03-26 17:13:30 -05:00
parent 51001d6bc4
commit 7cdddb2c83
11 changed files with 153 additions and 107 deletions
+3 -10
View File
@@ -1,21 +1,14 @@
#ifndef ALL_H
#define ALL_H
// #include "driver/uart.h"
// #include "driver/i2c.h"
// #include "drivers/tft.h"
// #include "drivers/wires.h"
// #include "drivers/sd.h"
// #include "drivers/char_lcd.h"
// #include "drivers/leds.h"
// #include "drivers/power.h"
#include "char_lcd.h"
#include "bottom_half.h"
#include "sd.h"
#include "speaker.h"
#include "game_timer.h"
#include "drivers/tft.h"
#include "drivers/leds.h"
#include "drivers/power.h"
void init_drivers();
+8 -2
View File
@@ -1,4 +1,6 @@
#include "leds.h"
#include "led_strip.h"
#include <esp_log.h>
static const char* TAG = "leds";
@@ -25,8 +27,12 @@ void init_leds() {
ESP_LOGI(TAG, "LEDs initialized!");
}
void leds_set(IndicatorLED led, uint8_t r, uint8_t g, uint8_t b) {
led_strip_set_pixel(leds, i, i, LED_COUNT-i, 0)
void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) {
led_strip_set_pixel(leds, led, r, g, b);
}
void led_set(uint32_t led, uint32_t color) {
led_set(led, (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF);
}
void leds_flush() {
+49 -25
View File
@@ -1,36 +1,55 @@
#ifndef LEDS_H
#define LEDS_H
#include "led_strip.h"
#include <stdint.h>
#define LED_COUNT 21
#define NEOPIXEL_PIN GPIO_NUM_7
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
typedef enum {
led_shape1 = 0,
led_shape2 = 1,
led_shape3 = 2,
led_shape4 = 3,
led_module_sseg = 4,
led_game_sseg = 5,
led_tft = 6,
led_mic = 7,
led_ir_led = 8,
led_speaker = 9,
led_rfid = 10,
led_keypad = 11,
led_char_lcd = 12,
led_switch4 = 13,
led_switch3 = 14,
led_switch2 = 15,
led_switch1 = 16,
led_button4 = 17,
led_button3 = 18,
led_button2 = 19,
led_button1 = 20,
} IndicatorLED;
enum LEDColor: uint32_t {
LED_COLOR_OFF = 0x00'00'00,
LED_COLOR_RED = 0x17'00'00,
LED_COLOR_RED_STRONG = 0xFF'00'00,
LED_COLOR_ORANGE = 0x17'02'00,
LED_COLOR_ORANGE_STRONG = 0xFF'20'00,
LED_COLOR_YELLOW = 0x07'07'00,
LED_COLOR_YELLOW_STRONG = 0xFF'FF'00,
LED_COLOR_GREEN = 0x00'07'00,
LED_COLOR_GREEN_STRONG = 0x00'FF'00,
LED_COLOR_BLUE = 0x00'00'17,
LED_COLOR_BLUE_STRONG = 0x00'00'FF,
LED_COLOR_PINK = 0x10'00'04,
LED_COLOR_PINK_STRONG = 0xFF'00'80,
LED_COLOR_WHITE = 0x04'04'04,
LED_COLOR_WHITE_STRONG = 0xFF'FF'FF,
};
enum IndicatorLED {
LED_SHAPE1 = 0u,
LED_SHAPE2 = 1u,
LED_SHAPE3 = 2u,
LED_SHAPE4 = 3u,
LED_MODULE_SSEG = 4u,
LED_GAME_SSEG = 5u,
LED_TFT = 6u,
LED_MIC = 7u,
LED_IR_LED = 8u,
LED_SPEAKER = 9u,
LED_RFID = 10u,
LED_KEYPAD = 11u,
LED_LCD = 12u,
LED_S4 = 13u,
LED_S3 = 14u,
LED_S2 = 15u,
LED_S1 = 16u,
LED_B4 = 17u,
LED_B3 = 18u,
LED_B2 = 19u,
LED_B1 = 20u,
LED_MAX = 20u,
};
/// @brief Initializes the indicator LEDs
void init_leds();
@@ -38,7 +57,12 @@ void init_leds();
/// Sets the color of an LED.
///
/// Call `flush_leds()` to send the data to the LEDs.
void leds_set(IndicatorLED led, uint8_t r, uint8_t g, uint8_t b);
void led_set(uint32_t led, uint32_t color);
/// Sets the color of an LED with rgb.
///
/// Call `flush_leds()` to send the data to the LEDs.
void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b);
/// Outputs the data to the leds.
void leds_flush();
+1 -1
View File
@@ -37,7 +37,7 @@ void bat_monitor_task(void* arg) {
}
void init_power_board() {
ESP_LOGI(TAG, "Initializing power board...")
ESP_LOGI(TAG, "Initializing power board...");
if (!lipo.begin()) {
ESP_LOGE(TAG, "Failed to init communication with the battery gas guage");