|
|
@@ -7,11 +7,13 @@
|
|
|
#include <stdlib.h>
|
|
|
#include <sys/cdefs.h>
|
|
|
#include "sdkconfig.h"
|
|
|
+
|
|
|
#if CONFIG_LCD_ENABLE_DEBUG_LOG
|
|
|
// The local log level must be defined before including esp_log.h
|
|
|
// Set the maximum log level for this source file
|
|
|
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
|
|
#endif
|
|
|
+
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
#include "freertos/task.h"
|
|
|
#include "esp_lcd_panel_interface.h"
|
|
|
@@ -28,7 +30,8 @@ static const char *TAG = "lcd_panel.nt35510";
|
|
|
static esp_err_t panel_nt35510_del(esp_lcd_panel_t *panel);
|
|
|
static esp_err_t panel_nt35510_reset(esp_lcd_panel_t *panel);
|
|
|
static esp_err_t panel_nt35510_init(esp_lcd_panel_t *panel);
|
|
|
-static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
|
|
+static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end,
|
|
|
+ const void *color_data);
|
|
|
static esp_err_t panel_nt35510_invert_color(esp_lcd_panel_t *panel, bool invert_color_data);
|
|
|
static esp_err_t panel_nt35510_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool mirror_y);
|
|
|
static esp_err_t panel_nt35510_swap_xy(esp_lcd_panel_t *panel, bool swap_axes);
|
|
|
@@ -47,7 +50,9 @@ typedef struct {
|
|
|
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
|
|
|
} nt35510_panel_t;
|
|
|
|
|
|
-esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel)
|
|
|
+esp_err_t
|
|
|
+esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
|
|
+ esp_lcd_panel_handle_t *ret_panel)
|
|
|
{
|
|
|
#if CONFIG_LCD_ENABLE_DEBUG_LOG
|
|
|
esp_log_level_set(TAG, ESP_LOG_DEBUG);
|
|
|
@@ -151,7 +156,8 @@ static esp_err_t panel_nt35510_reset(esp_lcd_panel_t *panel)
|
|
|
vTaskDelay(pdMS_TO_TICKS(10));
|
|
|
} else {
|
|
|
// perform software reset
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET << 8, NULL, 0);
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET << 8, NULL, 0), TAG,
|
|
|
+ "io tx param LCD_CMD_SWRESET failed");
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); // spec, wait at least 5m before sending new command
|
|
|
}
|
|
|
|
|
|
@@ -163,19 +169,21 @@ static esp_err_t panel_nt35510_init(esp_lcd_panel_t *panel)
|
|
|
nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base);
|
|
|
esp_lcd_panel_io_handle_t io = nt35510->io;
|
|
|
// LCD goes into sleep mode and display will be turned off after power on reset, exit sleep mode first
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT << 8, NULL, 0);
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT << 8, NULL, 0), TAG,
|
|
|
+ "io tx param LCD_CMD_SLPOUT failed");;
|
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
nt35510->madctl_val,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD << 8, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_MADCTL failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_COLMOD << 8, (uint16_t[]) {
|
|
|
nt35510->colmod_cal,
|
|
|
- }, 2);
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_COLMOD failed");
|
|
|
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
-static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
|
|
|
+static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end,
|
|
|
+ const void *color_data)
|
|
|
{
|
|
|
nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base);
|
|
|
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
|
|
|
@@ -187,33 +195,33 @@ static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start,
|
|
|
y_end += nt35510->y_gap;
|
|
|
|
|
|
// define an area of frame memory where MCU can access
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 0, (uint16_t[]) {
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 0, (uint16_t[]) {
|
|
|
(x_start >> 8) & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 1, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_CASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 1, (uint16_t[]) {
|
|
|
x_start & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 2, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_CASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 2, (uint16_t[]) {
|
|
|
((x_end - 1) >> 8) & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 3, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_CASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_CASET << 8) + 3, (uint16_t[]) {
|
|
|
(x_end - 1) & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 0, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_CASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 0, (uint16_t[]) {
|
|
|
(y_start >> 8) & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 1, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_RASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 1, (uint16_t[]) {
|
|
|
y_start & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 2, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_RASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 2, (uint16_t[]) {
|
|
|
((y_end - 1) >> 8) & 0xFF,
|
|
|
- }, 2);
|
|
|
- esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 3, (uint16_t[]) {
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_RASET failed");
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, (LCD_CMD_RASET << 8) + 3, (uint16_t[]) {
|
|
|
(y_end - 1) & 0xFF,
|
|
|
- }, 2);
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_RASET failed");
|
|
|
// transfer frame buffer
|
|
|
size_t len = (x_end - x_start) * (y_end - y_start) * nt35510->fb_bits_per_pixel / 8;
|
|
|
- esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len);
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len), TAG, "io tx color failed");
|
|
|
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
@@ -228,7 +236,8 @@ static esp_err_t panel_nt35510_invert_color(esp_lcd_panel_t *panel, bool invert_
|
|
|
} else {
|
|
|
command = LCD_CMD_INVOFF;
|
|
|
}
|
|
|
- esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0);
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0), TAG,
|
|
|
+ "io tx param LCD_CMD_INVON/LCD_CMD_INVOFF failed");
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
@@ -246,9 +255,9 @@ static esp_err_t panel_nt35510_mirror(esp_lcd_panel_t *panel, bool mirror_x, boo
|
|
|
} else {
|
|
|
nt35510->madctl_val &= ~LCD_CMD_MY_BIT;
|
|
|
}
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
nt35510->madctl_val
|
|
|
- }, 2);
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_MADCTL failed");
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
@@ -261,9 +270,9 @@ static esp_err_t panel_nt35510_swap_xy(esp_lcd_panel_t *panel, bool swap_axes)
|
|
|
} else {
|
|
|
nt35510->madctl_val &= ~LCD_CMD_MV_BIT;
|
|
|
}
|
|
|
- esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL << 8, (uint16_t[]) {
|
|
|
nt35510->madctl_val
|
|
|
- }, 2);
|
|
|
+ }, 2), TAG, "io tx param LCD_CMD_MADCTL failed");
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
@@ -285,6 +294,7 @@ static esp_err_t panel_nt35510_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
|
|
|
} else {
|
|
|
command = LCD_CMD_DISPOFF;
|
|
|
}
|
|
|
- esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0);
|
|
|
+ ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command << 8, NULL, 0), TAG,
|
|
|
+ "io tx param LCD_CMD_DISPON/LCD_CMD_DISPOFF failed");
|
|
|
return ESP_OK;
|
|
|
}
|