@@ -200,15 +200,15 @@ bool Axs15231bDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp
200200
201201 if (configuration->tePin > 0 )
202202 {
203- tear_ctx = malloc (sizeof (lcd_tear_t ));
204- // ESP_GOTO_ON_FALSE(tear_ctx != NULL , ESP_ERR_NO_MEM, err, TAG, "Not enough memory for tear_ctx allocation!");
203+ tear_ctx = ( lcd_tear_t *) malloc (sizeof (lcd_tear_t ));
204+ ESP_GOTO_ON_FALSE (tear_ctx != nullptr , ESP_ERR_NO_MEM, err, TAG, " Not enough memory for tear_ctx allocation!" );
205205
206206 te_v_sync_sem = xSemaphoreCreateCounting (1 , 0 );
207- // ESP_GOTO_ON_FALSE(te_v_sync_sem, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for te_v_sync_sem Semaphore.");
207+ ESP_GOTO_ON_FALSE (te_v_sync_sem, ESP_ERR_NO_MEM, err, TAG, " Not enough memory for te_v_sync_sem Semaphore." );
208208 tear_ctx->te_v_sync_sem = te_v_sync_sem;
209209
210210 te_catch_sem = xSemaphoreCreateCounting (1 , 0 );
211- // ESP_GOTO_ON_FALSE(te_catch_sem, ESP_ERR_NO_MEM, err, TAG, "Not enough memory for te_catch_sem Semaphore.");
211+ ESP_GOTO_ON_FALSE (te_catch_sem, ESP_ERR_NO_MEM, err, TAG, " Not enough memory for te_catch_sem Semaphore." );
212212 tear_ctx->te_catch_sem = te_catch_sem;
213213
214214 tear_ctx->time_Tvdl = time_Tvdl;
@@ -217,23 +217,48 @@ bool Axs15231bDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp
217217 tear_ctx->lock .count = 0 ;
218218
219219 const gpio_config_t te_detect_cfg = {
220- .intr_type = GPIO_INTR_NEGEDGE,
221- .mode = GPIO_MODE_INPUT,
222220 .pin_bit_mask = BIT64 (configuration->tePin ),
221+ .mode = GPIO_MODE_INPUT,
222+ .pull_up_en = GPIO_PULLUP_ENABLE,
223223 .pull_down_en = GPIO_PULLDOWN_DISABLE,
224- .pull_up_en = GPIO_PULLUP_ENABLE};
224+ .intr_type = tear_intr_type
225+ };
225226
226227 ESP_ERROR_CHECK (gpio_config (&te_detect_cfg));
227228 gpio_install_isr_service (0 );
228229 ESP_ERROR_CHECK (gpio_isr_handler_add (configuration->tePin , display_tear_interrupt, tear_ctx));
229230
230- BaseType_t res = xTaskCreate (display_sync_task, " Tear Task" , 2048 , tear_ctx, 4 , NULL );
231- // ESP_GOTO_ON_FALSE(res == pdPASS, ESP_FAIL, err, TAG, "Create Sync Task Fail!");
231+ BaseType_t res = xTaskCreate (display_sync_task, " Tear Task" , 2048 , tear_ctx, 4 , nullptr );
232+ ESP_GOTO_ON_FALSE (res == pdPASS, ESP_FAIL, err, TAG, " Create Sync Task Fail!" );
232233 }
233234
234- lv_display_add_event_cb (display , display_sync_cb, LV_EVENT_FLUSH_START, tear_ctx);
235+ lv_display_add_event_cb (lvglDisplay , display_sync_cb, LV_EVENT_FLUSH_START, tear_ctx);
235236
236237 return true ;
238+
239+ err:
240+ if (te_v_sync_sem)
241+ {
242+ vSemaphoreDelete (te_v_sync_sem);
243+ }
244+ if (te_catch_sem)
245+ {
246+ vSemaphoreDelete (te_catch_sem);
247+ }
248+ if (tear_ctx)
249+ {
250+ free (tear_ctx);
251+ }
252+ if (panelHandle)
253+ {
254+ esp_lcd_panel_del (panelHandle);
255+ }
256+ if (ioHandle)
257+ {
258+ esp_lcd_panel_io_del (ioHandle);
259+ }
260+ spi_bus_free (SPI2_HOST);
261+ return false ;
237262}
238263
239264lvgl_port_display_cfg_t Axs15231bDisplay::getLvglPortDisplayConfig (esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
0 commit comments