Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "my_include.h"
#endif

#define LV_USE_CUSTOM_MIPI 0

/*====================
COLOR SETTINGS
*====================*/
Expand Down Expand Up @@ -900,6 +902,14 @@
#define LV_FS_ARDUINO_ESP_LITTLEFS_PATH "" /**< Set the working directory. File/directory paths will be appended to it. */
#endif

/** API for Arduino FFat. */
#define LV_USE_FS_ARDUINO_ESP_FFAT 0
#if LV_USE_FS_ARDUINO_ESP_FFAT
#define LV_FS_ARDUINO_ESP_FFAT_LETTER '\0' /**< Set an upper-case driver-identifier letter for this driver (e.g. 'A'). */
#define LV_FS_ARDUINO_ESP_FFAT_PATH "" /**< Set the working directory. File/directory paths will be appended to it. */
#endif


/** API for Arduino Sd. */
#define LV_USE_FS_ARDUINO_SD 0
#if LV_USE_FS_ARDUINO_SD
Expand Down
8 changes: 6 additions & 2 deletions src/core/lv_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,15 @@ typedef struct _lv_global_t {
#endif

#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
lv_fs_drv_t arduino_esp_littlefs_fs_drv;
lv_fs_drv_t arduino_esp_littlefs_drv;
#endif

#if LV_USE_FS_ARDUINO_ESP_FFAT
lv_fs_drv_t arduino_esp_ffat_drv;
#endif

#if LV_USE_FS_ARDUINO_SD
lv_fs_drv_t arduino_sd_fs_drv;
lv_fs_drv_t arduino_esp_sd_drv;
#endif

#if LV_USE_FREETYPE
Expand Down
22 changes: 20 additions & 2 deletions src/drivers/display/lcd/lv_lcd_generic_mipi.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ static void flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_m
* GLOBAL FUNCTIONS
**********************/

lv_display_t * lv_lcd_generic_mipi_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb, lv_lcd_send_color_cb_t send_color_cb)
lv_display_t * lv_lcd_generic_mipi_create_ex(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb,
lv_lcd_send_color_cb_t send_color_cb,
void * user_data)
{
lv_display_t * disp = lv_display_create(hor_res, ver_res);
if(disp == NULL) {
Expand All @@ -59,6 +64,9 @@ lv_display_t * lv_lcd_generic_mipi_create(uint32_t hor_res, uint32_t ver_res, lv
return NULL;
}

/* Assigning user data. This will allow you to do something during initialization. Unnecessary global variables can be avoided. */
lv_display_set_user_data(disp, user_data);

/* init driver struct */
drv->disp = disp;
drv->send_cmd = send_cmd_cb;
Expand All @@ -77,6 +85,16 @@ lv_display_t * lv_lcd_generic_mipi_create(uint32_t hor_res, uint32_t ver_res, lv
return disp;
}

lv_display_t * lv_lcd_generic_mipi_create(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb,
lv_lcd_send_color_cb_t send_color_cb)
{
return lv_lcd_generic_mipi_create_ex(hor_res, ver_res, flags, send_cmd_cb, send_color_cb, NULL);
}

void lv_lcd_generic_mipi_set_gap(lv_display_t * disp, uint16_t x, uint16_t y)
{
lv_lcd_generic_mipi_driver_t * drv = get_driver(disp);
Expand Down
27 changes: 25 additions & 2 deletions src/drivers/display/lcd/lv_lcd_generic_mipi.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,33 @@ typedef struct {
* @param send_cmd platform-dependent function to send a command to the LCD controller (usually uses polling transfer)
* @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer).
* `lv_display_flush_ready` must be called after the transfer has finished.
* @param user_data User data. This will allow you to do something during initialization. Unnecessary global variables can be avoided.
* @return pointer to the created display
*/
lv_display_t * lv_lcd_generic_mipi_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb, lv_lcd_send_color_cb_t send_color_cb);
lv_display_t * lv_lcd_generic_mipi_create_ex(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb,
lv_lcd_send_color_cb_t send_color_cb,
void * user_data);

/**
* Create a MIPI DCS compatible LCD display
* @param hor_res horizontal resolution
* @param ver_res vertical resolution
* @param flags default configuration settings (mirror, RGB ordering, etc.)
* @param send_cmd platform-dependent function to send a command to the LCD controller (usually uses polling transfer)
* @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer).
* `lv_display_flush_ready` must be called after the transfer has finished.
* @return pointer to the created display
*/
lv_display_t * lv_lcd_generic_mipi_create(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_lcd_send_cmd_cb_t send_cmd_cb,
lv_lcd_send_color_cb_t send_color_cb);

/**
* Set gap, i.e., the offset of the (0,0) pixel in the VRAM
Expand Down
111 changes: 85 additions & 26 deletions src/drivers/display/st7789/lv_st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
* DEFINES
*********************/

#define CMD_FRMCTR1 0xB1
#define CMD_FRMCTR2 0xB2
#define CMD_FRMCTR3 0xB3
#define CMD_INVCTR 0xB4
#define CMD_DFUNCTR 0xB6
#define CMD_ETMOD 0xB7
#define CMD_PWCTR1 0xC0
#define CMD_PWCTR2 0xC1
#define CMD_PWCTR3 0xC2
#define CMD_PWCTR4 0xC3
#define CMD_PWCTR5 0xC4
#define CMD_VMCTR 0xC5
#define CMD_GMCTRP1 0xE0
#define CMD_GMCTRN1 0xE1
#define CMD_DOCA 0xE8
#define CMD_CSCON 0xF0

#define CMD_RAMCTRL 0xB0
#define CMD_PORCTRL 0xB2 /* Porch control */
#define CMD_GCTRL 0xB7 /* Gate control */
Expand All @@ -43,6 +26,67 @@
#define CMD_PWCTRL1 0xD0 /* Power control 1 */
#define CMD_PVGAMCTRL 0xE0 /* Positive Gamma Correction */
#define CMD_NVGAMCTRL 0xE1 /* Negative Gamma Correction */
#define CMD_GATESEL 0xD6 /* Gate Output Selection in Sleep In Mode */

#ifndef LV_ST_7789_GAMCTRL
#define LV_ST_7789_GAMCTRL -1
#endif

#define MAKE_GAMMA( \
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, \
n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14 \
) \
CMD_PVGAMCTRL, 14, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, \
CMD_NVGAMCTRL, 14, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14


#if LV_ST_7789_GAMCTRL == 0 // Default from this library
#define GAMMA MAKE_GAMMA( \
0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17, \
0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E)
#elif LV_ST_7789_GAMCTRL == 1 // Waveshare 1.54" (IPS)
#define GAMMA MAKE_GAMMA( \
0xF0, 0x09, 0x13, 0x12, 0x0B, 0x11, 0x07, 0x31, 0x33, 0x42, 0x05, 0x0C, 0x0A, 0x28, \
0xF0, 0x09, 0x13, 0x0C, 0x0D, 0x27, 0x3F, 0x42, 0x39, 0x12, 0x0E, 0x14, 0x31, 0x30)
#elif LV_ST_7789_GAMCTRL == 2 // Waveshare ESP32-S3-Touch-LCD-2.8
#define GAMMA MAKE_GAMMA( \
0xD0, 0x0D, 0x14, 0x0D, 0x0D, 0x09, 0x38, 0x44, 0x4E, 0x3A, 0x17, 0x18, 0x2F, 0x30, \
0xD0, 0x09, 0x0F, 0x08, 0x07, 0x14, 0x37, 0x44, 0x4D, 0x38, 0x15, 0x16, 0x2C, 0x2E)
#elif LV_ST_7789_GAMCTRL == 3 // JD-T9350 (IPS)
#define GAMMA MAKE_GAMMA( \
0xD0, 0x08, 0x11, 0x0B, 0x0A, 0x1F, 0x43, 0x53, 0x53, 0x31, 0x13, 0x07, 0x11, 0x10, \
0xD0, 0x08, 0x10, 0x0B, 0x0A, 0x06, 0x3B, 0x44, 0x44, 0x1F, 0x15, 0x0F, 0x31, 0x35)
#elif LV_ST_7789_GAMCTRL == 4 // Nintendo Switch Lite (IPS)
#define GAMMA MAKE_GAMMA( \
0xE0, 0x1F, 0x29, 0x26, 0x0C, 0x0E, 0x09, 0x4B, 0xCD, 0x3C, 0x09, 0x13, 0x05, 0x22, \
0xE1, 0x20, 0x2A, 0x27, 0x0D, 0x0F, 0x0A, 0x4C, 0xCE, 0x3D, 0x0A, 0x14, 0x06, 0x23)
#elif LV_ST_7789_GAMCTRL == 5 // Acuamarine
#define GAMMA MAKE_GAMMA( \
0xE0, 0xD0, 0x05, 0x0E, 0x15, 0x0D, 0x37, 0x54, 0x46, 0x18, 0x12, 0x0A, 0x17, 0x1D, \
0xE1, 0xD0, 0x06, 0x0D, 0x14, 0x0C, 0x35, 0x53, 0x45, 0x17, 0x13, 0x0B, 0x18, 0x1E)
#elif LV_ST_7789_GAMCTRL == 6 // High contrast
#define GAMMA MAKE_GAMMA( \
0xE0, 0xF0, 0x09, 0x13, 0x12, 0x18, 0x2F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x2F, 0xFF, \
0xE1, 0xF0, 0x09, 0x00, 0x00, 0x18, 0x2F, 0x3F, 0x3F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F)
#elif LV_ST_7789_GAMCTRL == 7 // Cinema mode, DCI-P3 color space
#define GAMMA MAKE_GAMMA( \
0xE0, 0x70, 0x11, 0x1A, 0x0D, 0x1B, 0x06, 0x4C, 0x97, 0x39, 0x0A, 0x13, 0x03, 0x43, \
0xE1, 0x70, 0x10, 0x19, 0x0C, 0x1C, 0x06, 0x4D, 0x97, 0x39, 0x0A, 0x13, 0x05, 0x44)
#elif LV_ST_7789_GAMCTRL == 8 // HDR
#define GAMMA MAKE_GAMMA( \
0xE0, 0xFF, 0x1A, 0x00, 0x0A, 0x02, 0x3C, 0xBB, 0x36, 0x0A, 0x0F, 0x01, 0x35, 0x33, \
0xE1, 0xFF, 0x21, 0x00, 0x0B, 0x02, 0x3A, 0x54, 0x4C, 0x18, 0x0D, 0x0B, 0x20, 0x24)
#elif LV_ST_7789_GAMCTRL == 9 // Anbernic RG353V
#define GAMMA MAKE_GAMMA( \
0xE0, 0xF0, 0x09, 0x0B, 0x06, 0x04, 0x15, 0x2F, 0x54, 0x44, 0x3C, 0x17, 0x14, 0x18, \
0xE1, 0xF0, 0x09, 0x0B, 0x06, 0x06, 0x01, 0x2F, 0x54, 0x43, 0x3C, 0x17, 0x14, 0x18)
#elif LV_ST_7789_GAMCTRL == 10 // Miyoo Mini+
#define GAMMA MAKE_GAMMA( \
0xE0, 0x20, 0x1A, 0x0A, 0x0B, 0x06, 0x4A, 0xB8, 0x37, 0x0A, 0x0F, 0x06, 0x32, 0x33, \
0xE1, 0x20, 0x1C, 0x09, 0x0B, 0x2B, 0x3B, 0x55, 0x4D, 0x0F, 0x0E, 0x12, 0x16, 0x1D)
#else
#define GAMMA 0x00, 0
#endif

/**********************
* TYPEDEFS
Expand All @@ -58,13 +102,13 @@

/* init commands based on LovyanGFX ST7789 driver */
static const uint8_t init_cmd_list[] = {
CMD_GCTRL, 1, 0x44, /* GCTRL -- panel dependent */
CMD_VCOMS, 1, 0x24, /* VCOMS -- panel dependent */
CMD_GCTRL, 1, 0x53, /* GCTRL -- panel dependent */
CMD_VCOMS, 1, 0x1A, /* VCOMS -- panel dependent */
CMD_VRHS, 1, 0x13, /* VRHS - panel dependent */
CMD_PWCTRL1, 2, 0xa4, 0xa1,
CMD_RAMCTRL, 2, 0x00, 0xC0, /* controls mapping of RGB565 to RGB666 */
CMD_PVGAMCTRL, 14, 0xd0, 0x00, 0x02, 0x07, 0x0a, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0e, 0x12, 0x14, 0x17,
CMD_NVGAMCTRL, 14, 0xd0, 0x00, 0x02, 0x07, 0x0a, 0x28, 0x31, 0x54, 0x47, 0x0e, 0x1c, 0x17, 0x1b, 0x1e,
CMD_PWCTRL1, 2, 0xA4, 0xA1,
CMD_RAMCTRL, 2, 0x00, 0xEC, /* controls mapping of RGB565 to RGB666 */
CMD_GATESEL, 1, 0xA1, /* D4 -> “0”: Gate output is GND in sleep in mode */
GAMMA,
LV_LCD_CMD_SET_GAMMA_CURVE, 1, 0x01,
LV_LCD_CMD_DELAY_MS, LV_LCD_CMD_EOF
};
Expand All @@ -81,14 +125,29 @@ static const uint8_t init_cmd_list[] = {
* GLOBAL FUNCTIONS
**********************/

lv_display_t * lv_st7789_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb, lv_st7789_send_color_cb_t send_color_cb)
lv_display_t * lv_st7789_create_ex(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb,
lv_st7789_send_color_cb_t send_color_cb,
void * user_data)
{
lv_display_t * disp = lv_lcd_generic_mipi_create(hor_res, ver_res, flags, send_cmd_cb, send_color_cb);
lv_display_t * disp = lv_lcd_generic_mipi_create_ex(hor_res, ver_res, flags, send_cmd_cb, send_color_cb, user_data);
lv_lcd_generic_mipi_send_cmd_list(disp, init_cmd_list);
return disp;
}

lv_display_t * lv_st7789_create(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb,
lv_st7789_send_color_cb_t send_color_cb)
{
return lv_st7789_create_ex(hor_res, ver_res, flags, send_cmd_cb, send_color_cb, NULL);
}

void lv_st7789_set_gap(lv_display_t * disp, uint16_t x, uint16_t y)
{
lv_lcd_generic_mipi_set_gap(disp, x, y);
Expand Down
26 changes: 24 additions & 2 deletions src/drivers/display/st7789/lv_st7789.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,30 @@ typedef lv_lcd_send_color_cb_t lv_st7789_send_color_cb_t;
* @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer: must implement a 'ready' callback)
* @return pointer to the created display
*/
lv_display_t * lv_st7789_create(uint32_t hor_res, uint32_t ver_res, lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb, lv_st7789_send_color_cb_t send_color_cb);
lv_display_t * lv_st7789_create(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb,
lv_st7789_send_color_cb_t send_color_cb);

/**
* Create an LCD display with ST7789 driver
* @param hor_res horizontal resolution
* @param ver_res vertical resolution
* @param flags default configuration settings (mirror, RGB ordering, etc.)
* @param send_cmd platform-dependent function to send a command to the LCD controller (usually uses polling transfer)
* @param send_color platform-dependent function to send pixel data to the LCD controller (usually uses DMA transfer: must implement a 'ready' callback)
* @param user_data user data...
* @return pointer to the created display
*/
lv_display_t * lv_st7789_create_ex(
uint32_t hor_res,
uint32_t ver_res,
lv_lcd_flag_t flags,
lv_st7789_send_cmd_cb_t send_cmd_cb,
lv_st7789_send_color_cb_t send_color_cb,
void * user_data);

/**
* Set gap, i.e., the offset of the (0,0) pixel in the VRAM
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/wayland/lv_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ static uint32_t tick_get_cb(void);
**********************/

static bool is_wayland_initialized = false;
static const struct wl_registry_listener registry_listener = {.global = handle_global,
.global_remove = handle_global_remove
static const struct wl_registry_listener registry_listener = {
.global = handle_global,
.global_remove = handle_global_remove
};

/**********************
Expand Down
15 changes: 10 additions & 5 deletions src/drivers/wayland/lv_wl_dmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ static void buffer_free(struct buffer * buf);
* STATIC VARIABLES
**********************/

static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener_v3 = {.format = dmabuf_format,
.modifier = dmabuf_modifiers
static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener_v3 = {
.format = dmabuf_format,
.modifier = dmabuf_modifiers
};

static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {
.format = dmabuf_format
};
static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = {.format = dmabuf_format};

/**********************
* MACROS
Expand Down Expand Up @@ -209,8 +213,9 @@ static void create_failed(void * data, struct zwp_linux_buffer_params_v1 * param
LV_LOG_ERROR("Failed to create dmabuf buffer\n");
}

static const struct zwp_linux_buffer_params_v1_listener params_listener = {.created = create_succeeded,
.failed = create_failed
static const struct zwp_linux_buffer_params_v1_listener params_listener = {
.created = create_succeeded,
.failed = create_failed
};

lv_result_t lv_wayland_dmabuf_resize_window(dmabuf_ctx_t * context, struct window * window)
Expand Down
37 changes: 37 additions & 0 deletions src/libs/fsdrv/lv_fs_arduino_esp_ffat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../../../lvgl.h"
#include "lv_fs_arduino_esp_fs.h"

#if LV_USE_FS_ARDUINO_ESP_FFAT

#include "FFat.h"

#if !LV_FS_IS_VALID_LETTER(LV_FS_ARDUINO_ESP_FFAT_LETTER)
#error "Invalid drive letter"
#endif

// &(LV_GLOBAL_DEFAULT()->arduino_esp_fs_drv

/**
* Register a driver for the LittleFS File System interface
*/
extern "C" void lv_fs_arduino_esp_ffat_init(void)
{
lv_fs_arduino_esp_fs_init((esp_fs_init_t[]) {
{
.letter = LV_FS_ARDUINO_ESP_FFAT_LETTER,
.drv = &(LV_GLOBAL_DEFAULT()->arduino_esp_ffat_drv),
.init = []() -> FS* {
FFat.begin();
return &FFat;
}
}
});
}

#else /*LV_USE_FS_ARDUINO_ESP_FFAT == 0*/

#if defined(LV_FS_ARDUINO_ESP_FFAT_LETTER) && LV_FS_ARDUINO_ESP_FFAT_LETTER != '\0'
#warning "LV_USE_FS_ARDUINO_ESP_FFAT is not enabled but LV_FS_ARDUINO_ESP_FFAT_LETTER is set"
#endif

#endif /*LV_USE_FS_ARDUINO_ESP_FFAT*/
Loading
Loading