mirror of
https://gitlab.com/fabinfra/fabhardware/fablight.git
synced 2025-03-12 14:41:49 +01:00
Added: LED Timing Test
This commit is contained in:
parent
0353727c8d
commit
455a92ab4d
2
firmware/.vscode/c_cpp_properties.json
vendored
2
firmware/.vscode/c_cpp_properties.json
vendored
@ -2,7 +2,7 @@
|
||||
"configurations": [
|
||||
{
|
||||
"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": [
|
||||
"${config:idf.espIdfPath}/components/**",
|
||||
"${config:idf.espIdfPathWin}/components/**",
|
||||
|
8
firmware/.vscode/settings.json
vendored
8
firmware/.vscode/settings.json
vendored
@ -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"
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ dependencies:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 5.0.1
|
||||
version: 5.1.0
|
||||
manifest_hash: 866a017870fcec1240064adf450d5b56fe14dc761ed21f016308418230712755
|
||||
target: esp32
|
||||
target: esp32s2
|
||||
version: 1.0.0
|
||||
|
@ -104,7 +104,7 @@ menu "FabLight Configuration"
|
||||
|
||||
config LED_LIMIT
|
||||
int "Brightness limt"
|
||||
default 0xAA
|
||||
default 170 #0xAA
|
||||
help
|
||||
Brightness limit to prevent overheating of enclosure
|
||||
|
||||
|
@ -19,7 +19,7 @@ typedef struct LED_Segments
|
||||
uint8_t segment_id;
|
||||
uint8_t color;
|
||||
enum LED_Effect effect;
|
||||
} LED_Segment;
|
||||
} LED_Segments;
|
||||
|
||||
|
||||
#endif
|
@ -23,22 +23,90 @@ LED_Segments segments[CONFIG_LED_SEGMENT_COUNT];
|
||||
|
||||
esp_mqtt_client_handle_t mqtt_client;
|
||||
led_strip_handle_t led_internal;
|
||||
led_strip_handle_t led_segments;
|
||||
led_strip_handle_t led_segments[6];
|
||||
|
||||
// LED Task
|
||||
void vTaskLED( void * pvParameters )
|
||||
led_strip_config_t segments_led_configs[6];
|
||||
led_strip_rmt_config_t rmt_config;
|
||||
|
||||
void init_led_strip()
|
||||
{
|
||||
for( ;; )
|
||||
{
|
||||
// Task code goes here.
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
// LED Task
|
||||
void vTaskLEDUpdate( void * pvParameters )
|
||||
{
|
||||
TaskHandle_t xHandle_LED = NULL;
|
||||
xTaskCreate( vTaskLED, "LED", 200, NULL, tskIDLE_PRIORITY, &xHandle_LED );
|
||||
while(1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
init_led_strip();
|
||||
|
||||
TaskHandle_t xHandle_LEDUpdate = NULL;
|
||||
xTaskCreate( vTaskLEDUpdate, "LED", 200, NULL, tskIDLE_PRIORITY, &xHandle_LEDUpdate );
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user