starting with led configuration
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#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 "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);
|
||||
}
|
||||
|
@@ -1 +1,3 @@
|
||||
void func(void);
|
||||
#pragma once
|
||||
|
||||
void ble_init(void *args);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user