starting with led configuration
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void init_led(void);
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void led_matrix_init(void *args);
|
||||||
|
@@ -1,15 +1,34 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "led_matrix.h"
|
#include "led_matrix.h"
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "led_strip.h"
|
#include "led_strip.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
|
typedef struct
|
||||||
|
|
||||||
led_strip_handle_t led_strip_init(uint8_t gpio_pin, uint32_t width, uint32_t height)
|
|
||||||
{
|
{
|
||||||
|
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 = {
|
led_strip_config_t strip_config = {
|
||||||
.strip_gpio_num = gpio_pin,
|
.strip_gpio_num = gpio_pin,
|
||||||
.max_leds = width * height,
|
.max_leds = size,
|
||||||
.led_model = LED_MODEL_WS2812,
|
.led_model = LED_MODEL_WS2812,
|
||||||
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_RGB,
|
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_RGB,
|
||||||
.flags = {
|
.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 = {
|
led_strip_rmt_config_t rmt_config = {
|
||||||
.clk_src = RMT_CLK_SRC_DEFAULT,
|
.clk_src = RMT_CLK_SRC_DEFAULT,
|
||||||
.resolution_hz = LED_STRIP_RMT_RES_HZ,
|
.resolution_hz = 0,
|
||||||
.mem_block_symbols = 64,
|
.mem_block_symbols = 0,
|
||||||
.flags = {
|
.flags = {
|
||||||
.with_dma = true,
|
.with_dma = true,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
led_strip_handle_t led_strip;
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_matrix.led_strip));
|
||||||
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
|
|
||||||
return led_strip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_led(void)
|
void led_matrix_init(void *args)
|
||||||
{
|
{
|
||||||
led_strip_handle_t led = led_strip_init(14, 8, 8);
|
ESP_LOGI(pcTaskGetName(NULL), "Calling led_matrix_init()");
|
||||||
// led_strip_set_pixel(led, 0, 255, 0, 0);
|
|
||||||
// led_strip_set_pixel(led, 1, 0, 255, 0);
|
led_strip_init(CONFIG_WLED_DIN_PIN, CONFIG_WLED_LED_COUNT);
|
||||||
// led_strip_set_pixel(led, 2, 0, 0, 255);
|
int value = 0;
|
||||||
led_strip_refresh(led);
|
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);
|
||||||
}
|
}
|
||||||
|
@@ -1 +1,3 @@
|
|||||||
void func(void);
|
#pragma once
|
||||||
|
|
||||||
|
void ble_init(void *args);
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "remote_control.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
13
main/Kconfig.projbuild
Normal 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
|
@@ -1,6 +1,11 @@
|
|||||||
#include "led_matrix.h"
|
#include "led_matrix.h"
|
||||||
|
#include "remote_control.h"
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
void app_main(void)
|
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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user