Driver breakdown improvements

This commit is contained in:
Ken Van Hoeylandt 2026-07-16 20:14:10 +02:00
parent 822a7a2fd4
commit 6986cbd1c5
11 changed files with 151 additions and 89 deletions

View File

@ -105,22 +105,27 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Cst816sInternal*>(device_get_driver_data(device));
bool ok = true;
// esp_lcd_touch_del() only releases the touch-side resources; the panel IO handle is owned
// separately and needs its own deletion.
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
ok = false;
if (internal->touch_handle != nullptr) {
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
return ERROR_RESOURCE;
}
internal->touch_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
ok = false;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
free(internal);
return ok ? ERROR_NONE : ERROR_RESOURCE;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -105,22 +105,27 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Ft5x06Internal*>(device_get_driver_data(device));
bool ok = true;
// esp_lcd_touch_del() only releases the touch-side resources; the panel IO handle is owned
// separately and needs its own deletion.
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
ok = false;
if (internal->touch_handle != nullptr) {
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
return ERROR_RESOURCE;
}
internal->touch_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
ok = false;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
free(internal);
return ok ? ERROR_NONE : ERROR_RESOURCE;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -105,22 +105,27 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Ft6x36Internal*>(device_get_driver_data(device));
bool ok = true;
// esp_lcd_touch_del() only releases the touch-side resources; the panel IO handle is owned
// separately and needs its own deletion.
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
ok = false;
if (internal->touch_handle != nullptr) {
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
return ERROR_RESOURCE;
}
internal->touch_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
ok = false;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
free(internal);
return ok ? ERROR_NONE : ERROR_RESOURCE;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -114,22 +114,27 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Gt911Internal*>(device_get_driver_data(device));
bool ok = true;
// esp_lcd_touch_del() only releases the touch-side resources; the panel IO handle is owned
// separately and needs its own deletion.
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
ok = false;
if (internal->touch_handle != nullptr) {
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
return ERROR_RESOURCE;
}
internal->touch_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
ok = false;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
free(internal);
return ok ? ERROR_NONE : ERROR_RESOURCE;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -165,20 +165,26 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Ili9341Internal*>(device_get_driver_data(device));
error_t result = ERROR_NONE;
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
result = ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
result = ERROR_RESOURCE;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
vSemaphoreDelete(internal->draw_done_semaphore);
free(internal);
return result;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -161,17 +161,25 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<Ili9488Internal*>(device_get_driver_data(device));
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
vSemaphoreDelete(internal->draw_done_semaphore);
free(internal);
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}

View File

@ -256,15 +256,17 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<RgbDisplayInternal*>(device_get_driver_data(device));
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
vSemaphoreDelete(internal->frame_complete_semaphore);
free(internal);
return ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
vSemaphoreDelete(internal->frame_complete_semaphore);
free(internal);
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}

View File

@ -204,20 +204,26 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<St7789I8080Internal*>(device_get_driver_data(device));
error_t result = ERROR_NONE;
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
result = ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
result = ERROR_RESOURCE;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
vSemaphoreDelete(internal->draw_done_semaphore);
free(internal);
return result;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -165,17 +165,25 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<St7789Internal*>(device_get_driver_data(device));
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
vSemaphoreDelete(internal->draw_done_semaphore);
free(internal);
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}

View File

@ -165,20 +165,26 @@ static error_t start(Device* device) {
static error_t stop(Device* device) {
auto* internal = static_cast<St7796Internal*>(device_get_driver_data(device));
error_t result = ERROR_NONE;
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
result = ERROR_RESOURCE;
if (internal->panel_handle != nullptr) {
if (esp_lcd_panel_del(internal->panel_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel");
return ERROR_RESOURCE;
}
internal->panel_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
result = ERROR_RESOURCE;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
vSemaphoreDelete(internal->draw_done_semaphore);
free(internal);
return result;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion

View File

@ -239,24 +239,30 @@ static error_t stop(Device* device) {
if (internal->power_supply_device != nullptr) {
destroy_power_supply_child(internal->power_supply_device);
internal->power_supply_device = nullptr;
}
bool ok = true;
// esp_lcd_touch_del() only releases the touch-side resources; the panel IO handle is owned
// separately and needs its own deletion.
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
ok = false;
if (internal->touch_handle != nullptr) {
if (esp_lcd_touch_del(internal->touch_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete touch handle");
return ERROR_RESOURCE;
}
internal->touch_handle = nullptr;
}
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
ok = false;
if (internal->io_handle != nullptr) {
if (esp_lcd_panel_io_del(internal->io_handle) != ESP_OK) {
LOG_E(TAG, "Failed to delete panel IO handle");
return ERROR_RESOURCE;
}
internal->io_handle = nullptr;
}
free(internal);
return ok ? ERROR_NONE : ERROR_RESOURCE;
device_set_driver_data(device, nullptr);
return ERROR_NONE;
}
// endregion