forked from xiaozhi/xiaozhi-esp32
Fixed the issue where voice wake-up causes panic when DEBUG is enabled. (#1606)
This commit is contained in:
@@ -82,6 +82,9 @@ GpioLed::GpioLed(gpio_num_t gpio, int output_invert, ledc_timer_t timer_num, led
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_timer_create(&blink_timer_args, &blink_timer_));
|
||||
|
||||
xTaskCreate(EventTask, "LedEvent", 2048, this,
|
||||
tskIDLE_PRIORITY + 2, &event_task_handle_);
|
||||
|
||||
ledc_initialized_ = true;
|
||||
}
|
||||
|
||||
@@ -194,7 +197,9 @@ void GpioLed::OnFadeEnd() {
|
||||
bool IRAM_ATTR GpioLed::FadeCallback(const ledc_cb_param_t *param, void *user_arg) {
|
||||
if (param->event == LEDC_FADE_END_EVT) {
|
||||
auto led = static_cast<GpioLed*>(user_arg);
|
||||
led->OnFadeEnd();
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
xTaskNotifyFromISR(led->event_task_handle_, 0x01, eSetValueWithOverwrite,
|
||||
&xHigherPriorityTaskWoken);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -247,3 +252,12 @@ void GpioLed::OnStateChanged() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void GpioLed::EventTask(void* arg) {
|
||||
GpioLed* led = static_cast<GpioLed*>(arg);
|
||||
|
||||
while (1) {
|
||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||
led->OnFadeEnd();
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,9 @@ class GpioLed : public Led {
|
||||
int blink_interval_ms_ = 0;
|
||||
esp_timer_handle_t blink_timer_ = nullptr;
|
||||
bool fade_up_ = true;
|
||||
TaskHandle_t event_task_handle_;
|
||||
|
||||
static void EventTask(void* arg);
|
||||
void StartBlinkTask(int times, int interval_ms);
|
||||
void OnBlinkTimer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user