Added: LED Timing Test

This commit is contained in:
TheJoKlLa 2023-07-17 01:05:41 +02:00
parent 0353727c8d
commit 455a92ab4d
6 changed files with 91 additions and 17 deletions

View File

@ -2,7 +2,7 @@
"configurations": [ "configurations": [
{ {
"name": "ESP-IDF", "name": "ESP-IDF",
"compilerPath": "", "compilerPath": "c:\\Users\\thejo\\Espressif\\tools\\tools\\xtensa-esp32s2-elf\\esp-12.2.0_20230208\\xtensa-esp32s2-elf\\bin\\xtensa-esp32s2-elf-gcc.exe",
"includePath": [ "includePath": [
"${config:idf.espIdfPath}/components/**", "${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**", "${config:idf.espIdfPathWin}/components/**",

View File

@ -1,3 +1,9 @@
{ {
"C_Cpp.intelliSenseEngine": "default" "C_Cpp.intelliSenseEngine": "default",
"idf.adapterTargetName": "esp32s2",
"idf.openOcdConfigs": [
"board/esp32s2-bridge.cfg"
],
"idf.portWin": "COM1",
"idf.flashType": "DFU"
} }

View File

@ -9,7 +9,7 @@ dependencies:
component_hash: null component_hash: null
source: source:
type: idf type: idf
version: 5.0.1 version: 5.1.0
manifest_hash: 866a017870fcec1240064adf450d5b56fe14dc761ed21f016308418230712755 manifest_hash: 866a017870fcec1240064adf450d5b56fe14dc761ed21f016308418230712755
target: esp32 target: esp32s2
version: 1.0.0 version: 1.0.0

View File

@ -104,7 +104,7 @@ menu "FabLight Configuration"
config LED_LIMIT config LED_LIMIT
int "Brightness limt" int "Brightness limt"
default 0xAA default 170 #0xAA
help help
Brightness limit to prevent overheating of enclosure Brightness limit to prevent overheating of enclosure

View File

@ -19,7 +19,7 @@ typedef struct LED_Segments
uint8_t segment_id; uint8_t segment_id;
uint8_t color; uint8_t color;
enum LED_Effect effect; enum LED_Effect effect;
} LED_Segment; } LED_Segments;
#endif #endif

View File

@ -23,22 +23,90 @@ LED_Segments segments[CONFIG_LED_SEGMENT_COUNT];
esp_mqtt_client_handle_t mqtt_client; esp_mqtt_client_handle_t mqtt_client;
led_strip_handle_t led_internal; led_strip_handle_t led_internal;
led_strip_handle_t led_segments; led_strip_handle_t led_segments[6];
led_strip_config_t segments_led_configs[6];
led_strip_rmt_config_t rmt_config;
void init_led_strip()
{
led_strip_config_t strip_config =
{
.strip_gpio_num = 0,
.max_leds = CONFIG_LED_SEGMENT_COUNT * CONFIG_LED_SEGMENT_SIZE,
.led_pixel_format = LED_PIXEL_FORMAT_GRB,
.led_model = LED_MODEL_WS2812,
.flags.invert_out = false,
};
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_0;
segments_led_configs[0] = strip_config;
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_1;
segments_led_configs[1] = strip_config;
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_2;
segments_led_configs[2] = strip_config;
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_3;
segments_led_configs[3] = strip_config;
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_4;
segments_led_configs[4] = strip_config;
strip_config.strip_gpio_num = CONFIG_PIN_SEGMENT_DATA_5;
segments_led_configs[5] = strip_config;
led_strip_rmt_config_t rmt =
{
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = LED_STRIP_RMT_RES_HZ,
.flags.with_dma = true,
};
rmt_config = rmt;
strip_config.strip_gpio_num = CONFIG_PIN_INTERNAL_LED;
led_strip_new_rmt_device(&strip_config, &rmt_config, &led_internal);
}
// LED Task // LED Task
void vTaskLED( void * pvParameters ) void vTaskLEDUpdate( void * pvParameters )
{ {
for( ;; ) while(1)
{ {
// Task code goes here. ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[0], &rmt_config, &led_segments[0]));
} ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[1], &rmt_config, &led_segments[1]));
ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[2], &rmt_config, &led_segments[2]));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[0], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[1], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[2], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_del(led_segments[0]));
ESP_ERROR_CHECK(led_strip_del(led_segments[1]));
ESP_ERROR_CHECK(led_strip_del(led_segments[2]));
ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[3], &rmt_config, &led_segments[3]));
ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[4], &rmt_config, &led_segments[4]));
ESP_ERROR_CHECK(led_strip_new_rmt_device(&segments_led_configs[5], &rmt_config, &led_segments[5]));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[3], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[4], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_set_pixel(led_segments[5], 0 , 0xFF, 0xFF, 0xFF));
ESP_ERROR_CHECK(led_strip_del(led_segments[3]));
ESP_ERROR_CHECK(led_strip_del(led_segments[4]));
ESP_ERROR_CHECK(led_strip_del(led_segments[5]));
vTaskDelay(pdMS_TO_TICKS(100));
}
} }
void app_main(void) void app_main(void)
{ {
TaskHandle_t xHandle_LED = NULL; init_led_strip();
xTaskCreate( vTaskLED, "LED", 200, NULL, tskIDLE_PRIORITY, &xHandle_LED );
TaskHandle_t xHandle_LEDUpdate = NULL;
xTaskCreate( vTaskLEDUpdate, "LED", 200, NULL, tskIDLE_PRIORITY, &xHandle_LEDUpdate );
} }