add BLE bonding
Some checks failed
ESP-IDF Build / build (esp32, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32h2, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.5) (push) Failing after 52s
ESP-IDF Build / build (esp32s3, latest) (push) Failing after 56s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 45s
Some checks failed
ESP-IDF Build / build (esp32, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32h2, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.5) (push) Failing after 52s
ESP-IDF Build / build (esp32s3, latest) (push) Failing after 56s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 45s
Signed-off-by: Peter Siegmund <mars3142@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,11 @@ esp_err_t wled_init(void)
|
||||
led_strip_config_t strip_config = {.strip_gpio_num = CONFIG_WLED_DIN_PIN,
|
||||
.max_leds = led_matrix.size,
|
||||
.led_model = LED_MODEL_WS2812,
|
||||
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRB,
|
||||
#if CONFIG_WLED_WITH_WHITE
|
||||
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRBW,
|
||||
#else
|
||||
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_RGB,
|
||||
#endif
|
||||
.flags = {
|
||||
.invert_out = false,
|
||||
}};
|
||||
|
@@ -7,26 +7,21 @@
|
||||
|
||||
static const char *TAG = "outdoor";
|
||||
|
||||
// Timer resolution (10 bit = 1024 steps)
|
||||
#define LEDC_RESOLUTION LEDC_TIMER_10_BIT
|
||||
#define LEDC_RESOLUTION LEDC_TIMER_10_BIT // Timer resolution (10 bit = 1024 steps)
|
||||
#define MAX_DUTY 1023
|
||||
|
||||
// Constant brightness for the "normal state" (approx. 90%)
|
||||
#define NORMAL_DUTY (MAX_DUTY * 0.9)
|
||||
#define NORMAL_DUTY (MAX_DUTY * 0.9) // 90% brightness
|
||||
|
||||
// Parameters for flickering
|
||||
#define FLICKER_CHANCE 5 // 5% chance of flickering per cycle
|
||||
#define FLICKER_CHANCE 2 // 2% chance of flickering per cycle
|
||||
#define FLICKER_COUNT 8 // Number of brightness changes during a flicker
|
||||
|
||||
TaskHandle_t outdoor_task_handle = NULL;
|
||||
|
||||
void outdoor_task(void *pvParameters)
|
||||
{
|
||||
ESP_LOGI(TAG, "Simulation of a defective light bulb started.");
|
||||
|
||||
int led_pin = *(int *)pvParameters;
|
||||
|
||||
// 1. LEDC timer configuration
|
||||
ledc_timer_config_t ledc_timer = {.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.timer_num = LEDC_TIMER_0,
|
||||
.duty_resolution = LEDC_RESOLUTION,
|
||||
@@ -34,7 +29,6 @@ void outdoor_task(void *pvParameters)
|
||||
.clk_cfg = LEDC_AUTO_CLK};
|
||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));
|
||||
|
||||
// 2. LEDC channel configuration
|
||||
ledc_channel_config_t ledc_channel = {.speed_mode = LEDC_LOW_SPEED_MODE,
|
||||
.channel = LEDC_CHANNEL_0,
|
||||
.timer_sel = LEDC_TIMER_0,
|
||||
@@ -44,40 +38,38 @@ void outdoor_task(void *pvParameters)
|
||||
.hpoint = 0};
|
||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
|
||||
|
||||
// 3. Main loop with flicker logic
|
||||
while (1)
|
||||
{
|
||||
// First, set the LED to its normal brightness
|
||||
ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, NORMAL_DUTY);
|
||||
ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
|
||||
|
||||
// Random trigger for flickering
|
||||
uint32_t random_val = esp_random() % 100; // Random number between 0 and 99
|
||||
uint32_t random_val = esp_random() % 100;
|
||||
|
||||
if (random_val < FLICKER_CHANCE)
|
||||
{
|
||||
// Start flicker sequence
|
||||
for (int i = 0; i < FLICKER_COUNT; i++)
|
||||
{
|
||||
// Set a random, lower brightness (e.g., 30-70% of normal brightness)
|
||||
uint32_t flicker_duty = (NORMAL_DUTY * 0.3) + (esp_random() % (uint32_t)(NORMAL_DUTY * 0.4));
|
||||
ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, flicker_duty);
|
||||
ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
|
||||
|
||||
// Short, random delay for irregular flickering
|
||||
vTaskDelay(pdMS_TO_TICKS(20 + (esp_random() % 50)));
|
||||
}
|
||||
}
|
||||
|
||||
// A fixed delay in normal operation
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t outdoor_start(void)
|
||||
{
|
||||
static const int led_pin = 13;
|
||||
xTaskCreate(outdoor_task, "outdoor_task", 2048, (void *)&led_pin, 5, &outdoor_task_handle);
|
||||
ESP_LOGI(TAG, "Simulation of a defective light bulb started.");
|
||||
|
||||
static const int led_left_pin = CONFIG_LED_PIN_LEFT;
|
||||
xTaskCreate(outdoor_task, "outdoor_task_left", 2048, (void *)&led_left_pin, 5, &outdoor_task_handle);
|
||||
|
||||
static const int led_right_pin = CONFIG_LED_PIN_RIGHT;
|
||||
xTaskCreate(outdoor_task, "outdoor_task_right", 2048, (void *)&led_right_pin, 5, &outdoor_task_handle);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -93,4 +85,4 @@ esp_err_t outdoor_stop(void)
|
||||
outdoor_task_handle = NULL;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user