starting with led configuration

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-05-17 22:05:39 +02:00
parent ed7a23256c
commit 82f0b3f02b
6 changed files with 86 additions and 22 deletions

View File

@@ -1,3 +1,5 @@
#pragma once
void init_led(void);
#include <stdint.h>
void led_matrix_init(void *args);

View File

@@ -1,15 +1,34 @@
#include <stdio.h>
#include "led_matrix.h"
#include "freertos/FreeRTOS.h"
#include "led_strip.h"
#include "esp_log.h"
#include "sdkconfig.h"
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
led_strip_handle_t led_strip_init(uint8_t gpio_pin, uint32_t width, uint32_t height)
typedef struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
} led_data_t;
typedef struct
{
led_strip_handle_t led_strip;
led_data_t *data;
uint32_t size;
} led_matrix_t;
led_matrix_t led_matrix;
static void led_strip_init(uint8_t gpio_pin, uint32_t size)
{
led_matrix.size = size;
led_matrix.data = (led_data_t *)malloc(sizeof(led_data_t) * size);
led_strip_config_t strip_config = {
.strip_gpio_num = gpio_pin,
.max_leds = width * height,
.max_leds = size,
.led_model = LED_MODEL_WS2812,
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_RGB,
.flags = {
@@ -18,22 +37,34 @@ led_strip_handle_t led_strip_init(uint8_t gpio_pin, uint32_t width, uint32_t hei
led_strip_rmt_config_t rmt_config = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = LED_STRIP_RMT_RES_HZ,
.mem_block_symbols = 64,
.resolution_hz = 0,
.mem_block_symbols = 0,
.flags = {
.with_dma = true,
}};
led_strip_handle_t led_strip;
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
return led_strip;
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_matrix.led_strip));
}
void init_led(void)
void led_matrix_init(void *args)
{
led_strip_handle_t led = led_strip_init(14, 8, 8);
// led_strip_set_pixel(led, 0, 255, 0, 0);
// led_strip_set_pixel(led, 1, 0, 255, 0);
// led_strip_set_pixel(led, 2, 0, 0, 255);
led_strip_refresh(led);
ESP_LOGI(pcTaskGetName(NULL), "Calling led_matrix_init()");
led_strip_init(CONFIG_WLED_DIN_PIN, CONFIG_WLED_LED_COUNT);
int value = 0;
for (int i = 0; i < led_matrix.size; i++)
{
led_strip_set_pixel(led_matrix.led_strip, i, value, 0, 0);
}
led_strip_refresh(led_matrix.led_strip);
while (true)
{
vTaskDelay(pdMS_TO_TICKS(100));
}
free(led_matrix.data);
ESP_LOGI(pcTaskGetName(NULL), "Exiting led_matrix_init()");
vTaskDelete(NULL);
}

View File

@@ -1 +1,3 @@
void func(void);
#pragma once
void ble_init(void *args);

View File

@@ -1,7 +1,18 @@
#include <stdio.h>
#include "remote_control.h"
void func(void)
{
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void ble_init(void *args)
{
ESP_LOGI(pcTaskGetName(NULL), "Calling ble_init()");
while (1)
{
vTaskDelay(pdMS_TO_TICKS(100));
}
ESP_LOGI(pcTaskGetName(NULL), "Exiting ble_init()");
vTaskDelete(NULL);
}

13
main/Kconfig.projbuild Normal file
View File

@@ -0,0 +1,13 @@
menu "Miniatur Town"
config WLED_DIN_PIN
int "WLED Data In Pin"
default 14
help
The number of the WLED data in pin.
config WLED_LED_COUNT
int "WLED LED counter"
default 64
help
The number of the WLED LEDs.
endmenu

View File

@@ -1,6 +1,11 @@
#include "led_matrix.h"
#include "remote_control.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void app_main(void)
{
init_led();
xTaskCreatePinnedToCore(led_matrix_init, "led_matrix", configMINIMAL_STACK_SIZE * 2, NULL, 5, NULL, 1);
xTaskCreatePinnedToCore(ble_init, "remote_control", configMINIMAL_STACK_SIZE * 2, NULL, 5, NULL, 1);
}