You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2025/08/28 14:49:59 UTC
(mynewt-core) branch master updated (ca6ba0ebb -> 355127fa7)
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
from ca6ba0ebb hw/mcu: Improve watchdog handling on LPC55xx
new d4e17e8ae lvgl/drivers: change rotation
new d9dc15831 lvgl/indev: Fix touch during rotation
new 355127fa7 lvgl/st7789: Screen resolution update
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../display/lvgl/indev/adc_touch/src/adc_touch.c | 6 ++-
.../display/lvgl/indev/stmpe610/src/stmpe610.c | 12 ++---
.../display/lvgl/indev/xpt2046/src/xpt2046.c | 12 ++---
hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c | 4 +-
hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c | 4 +-
hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c | 4 +-
hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c | 5 +-
hw/drivers/display/lvgl/tft/st7789/src/st7789.c | 56 +++++++++-------------
hw/drivers/display/lvgl/tft/st7789/syscfg.yml | 11 ++++-
hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c | 4 +-
10 files changed, 59 insertions(+), 59 deletions(-)
(mynewt-core) 03/03: lvgl/st7789: Screen resolution update
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 355127fa788f3ad29b36c9e0bf3ece79a75e29ce
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Aug 21 00:08:12 2025 +0200
lvgl/st7789: Screen resolution update
ST7789 had hardcoded configurations for few
resolutions (240x320, 240x240, 240x135)
There are other configurations available.
Now offsets are computed in runtime.
This also fixes rotation to be aligned
with other drivers.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/drivers/display/lvgl/tft/st7789/src/st7789.c | 52 ++++++++++---------------
hw/drivers/display/lvgl/tft/st7789/syscfg.yml | 11 +++++-
2 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
index 633f1c98c..c8d0677ae 100644
--- a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
+++ b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
@@ -138,6 +138,22 @@
#define ST7789_HOR_RES MYNEWT_VAL(LVGL_DISPLAY_HORIZONTAL_RESOLUTION)
#define ST7789_VER_RES MYNEWT_VAL(LVGL_DISPLAY_VERTICAL_RESOLUTION)
+#ifdef MYNEWT_VAL_ST7789_HORIZONTAL_OFFSET
+#define HOR_OFF MYNEWT_VAL_ST7789_HORIZONTAL_OFFSET
+#else
+#define HOR_OFF ((240 - ST7789_HOR_RES) / 2)
+#endif
+#ifdef MYNEWT_VAL_ST7789_VERTICAL_OFFSET
+#define VER_OFF MYNEWT_VAL_ST7789_VERTICAL_OFFSET
+#else
+#define VER_OFF ((320 - ST7789_VER_RES) / 2)
+#endif
+
+static const uint16_t x_off[4] = { HOR_OFF, 320 - ST7789_VER_RES - VER_OFF,
+ 240 - ST7789_HOR_RES - HOR_OFF, VER_OFF };
+static const uint16_t y_off[4] = { VER_OFF, 240 - ST7789_HOR_RES - HOR_OFF,
+ 320 - ST7789_VER_RES - VER_OFF, HOR_OFF };
+
void
st7789_rotate(lv_disp_rot_t rotation)
{
@@ -212,6 +228,7 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
lv_disp_t *disp = lv_disp_get_default();
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
lv_coord_t ver_res = lv_disp_get_ver_res(disp);
+ int rot = drv->rotated;
if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) {
lv_disp_flush_ready(drv);
@@ -224,37 +241,10 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
int32_t offsetx2 = area->x2 >= hor_res ? hor_res - 1 : area->x2;
int32_t offsety2 = area->y2 >= ver_res ? ver_res - 1 : area->y2;
-#if (CONFIG_LV_TFT_DISPLAY_OFFSETS)
- offsetx1 += CONFIG_LV_TFT_DISPLAY_X_OFFSET;
- offsetx2 += CONFIG_LV_TFT_DISPLAY_X_OFFSET;
- offsety1 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET;
- offsety2 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET;
-
-#elif (ST7789_HOR_RES == 240) && (ST7789_VER_RES == 240)
-#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
- offsetx1 += 80;
- offsetx2 += 80;
-#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
- offsety1 += 80;
- offsety2 += 80;
-#endif
-#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 135)
-#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT) || \
- (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
- offsetx1 += 40;
- offsetx2 += 40;
- offsety1 += 53;
- offsety2 += 53;
-#endif
-#elif (LV_HOR_RES_MAX == 135) && (LV_VER_RES_MAX == 240)
-#if (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE) || \
- (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
- offsetx1 += 52;
- offsetx2 += 52;
- offsety1 += 40;
- offsety2 += 40;
-#endif
-#endif
+ offsetx1 += x_off[rot];
+ offsetx2 += x_off[rot];
+ offsety1 += y_off[rot];
+ offsety2 += y_off[rot];
/* Column addresses */
cmd[0] = ST7789_CASET;
diff --git a/hw/drivers/display/lvgl/tft/st7789/syscfg.yml b/hw/drivers/display/lvgl/tft/st7789/syscfg.yml
index d37a5b817..2e44a93fd 100644
--- a/hw/drivers/display/lvgl/tft/st7789/syscfg.yml
+++ b/hw/drivers/display/lvgl/tft/st7789/syscfg.yml
@@ -20,7 +20,16 @@ syscfg.defs:
ST7789_INVERSION_ON:
description: ST7789 enable display inversion.
value: 1
-
+ ST7789_HORIZONTAL_OFFSET:
+ description: >
+ Value added to x coordinates.
+ This can be set if display is not aligned correctly.
+ value:
+ ST7789_VERTICAL_OFFSET:
+ description: >
+ Value added to y coordinates.
+ This can be set if display is not aligned correctly.
+ value:
syscfg.vals:
LVGL_DISPLAY_HORIZONTAL_RESOLUTION: 240
LVGL_DISPLAY_VERTICAL_RESOLUTION: 320
(mynewt-core) 02/03: lvgl/indev: Fix touch during rotation
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit d9dc15831efeb2deab54187bd68933c5ca172782
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Aug 20 21:17:28 2025 +0200
lvgl/indev: Fix touch during rotation
Driver converts values reported by xpt2046 (adc values)
and stmpe610 to screen coordinates.
It was using screen resolution reported by LV_HOR_RES
and LV_VER_RES but those values were already subject
to rotation conversion.
Input device is expected report values without rotation
conversion.
Now coordinates conversion is changed so touch screen
works in all 4 rotations.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c | 6 ++++--
hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c | 12 ++++++------
hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c | 12 ++++++------
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c b/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c
index 453591b45..a8323f8aa 100644
--- a/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c
+++ b/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c
@@ -67,6 +67,8 @@ struct touch_screen_data {
#define INVERTED_X (MYNEWT_VAL(ADC_TOUCH_ADC_LEFT) > MYNEWT_VAL(ADC_TOUCH_ADC_RIGHT))
#define INVERTED_Y (MYNEWT_VAL(ADC_TOUCH_ADC_TOP) > MYNEWT_VAL(ADC_TOUCH_ADC_BOTTOM))
+#define HOR_RES MYNEWT_VAL_LVGL_DISPLAY_HORIZONTAL_RESOLUTION
+#define VER_RES MYNEWT_VAL_LVGL_DISPLAY_VERTICAL_RESOLUTION
static struct touch_screen_data touch_screen_data = {
.adc_left = MYNEWT_VAL(ADC_TOUCH_ADC_LEFT),
@@ -184,9 +186,9 @@ adc_touch_handler(void)
}
/* Convert to display coordinates */
- touch_screen_data.x = (x - touch_screen_data.adc_left) * LV_HOR_RES /
+ touch_screen_data.x = (x - touch_screen_data.adc_left) * HOR_RES /
(touch_screen_data.adc_right - touch_screen_data.adc_left);
- touch_screen_data.y = (y - touch_screen_data.adc_top) * LV_VER_RES /
+ touch_screen_data.y = (y - touch_screen_data.adc_top) * VER_RES /
(touch_screen_data.adc_bottom - touch_screen_data.adc_top);
}
done:
diff --git a/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c b/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c
index dd17f603e..f6b008114 100644
--- a/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c
+++ b/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c
@@ -34,8 +34,8 @@
#define STMPE610_MAX_Y MYNEWT_VAL(STMPE610_MAX_Y)
#define STMPE610_X_RANGE ((STMPE610_MAX_X) - (STMPE610_MIN_X))
#define STMPE610_Y_RANGE ((STMPE610_MAX_Y) - (STMPE610_MIN_Y))
-#define STMPE610_HOR_RES MYNEWT_VAL(STMPE610_HOR_RES)
-#define STMPE610_VER_RES MYNEWT_VAL(STMPE610_VER_RES)
+#define STMPE610_HOR_RES MYNEWT_VAL_LVGL_DISPLAY_HORIZONTAL_RESOLUTION
+#define STMPE610_VER_RES MYNEWT_VAL_LVGL_DISPLAY_VERTICAL_RESOLUTION
struct bus_spi_node touch;
struct bus_spi_node_cfg touch_spi_cfg = {
@@ -202,15 +202,15 @@ xpt2046_corr(int16_t *xp, int16_t *yp)
y = MYNEWT_VAL(STMPE610_MIN_Y);
}
- x = (x - STMPE610_MIN_X) * LV_HOR_RES / STMPE610_X_RANGE;
- y = (y - STMPE610_MIN_Y) * LV_VER_RES / STMPE610_Y_RANGE;
+ x = (x - STMPE610_MIN_X) * STMPE610_HOR_RES / STMPE610_X_RANGE;
+ y = (y - STMPE610_MIN_Y) * STMPE610_VER_RES / STMPE610_Y_RANGE;
#if STMPE610_X_INV
- x = LV_HOR_RES - x;
+ x = STMPE610_HOR_RES - x;
#endif
#if STMPE610_Y_INV
- y = LV_VER_RES - y;
+ y = STMPE610_VER_RES - y;
#endif
*xp = x;
*yp = y;
diff --git a/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c b/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c
index 9ec052066..b9b582b29 100644
--- a/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c
+++ b/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c
@@ -39,8 +39,8 @@
#define XPT2046_MAX_Y MYNEWT_VAL(XPT2046_MAX_Y)
#define XPT2046_X_RANGE ((XPT2046_MAX_X) - (XPT2046_MIN_X))
#define XPT2046_Y_RANGE ((XPT2046_MAX_Y) - (XPT2046_MIN_Y))
-#define XPT2046_HOR_RES MYNEWT_VAL(XPT2046_HOR_RES)
-#define XPT2046_VER_RES MYNEWT_VAL(XPT2046_VER_RES)
+#define XPT2046_HOR_RES MYNEWT_VAL_LVGL_DISPLAY_HORIZONTAL_RESOLUTION
+#define XPT2046_VER_RES MYNEWT_VAL_LVGL_DISPLAY_VERTICAL_RESOLUTION
struct bus_spi_node touch;
struct bus_spi_node_cfg touch_spi_cfg = {
@@ -99,15 +99,15 @@ xpt2046_corr(int16_t *xp, int16_t *yp)
y = MYNEWT_VAL(XPT2046_MIN_Y);
}
- x = (x - XPT2046_MIN_X) * LV_HOR_RES / XPT2046_X_RANGE;
- y = (y - XPT2046_MIN_Y) * LV_VER_RES / XPT2046_Y_RANGE;
+ x = (x - XPT2046_MIN_X) * XPT2046_HOR_RES / XPT2046_X_RANGE;
+ y = (y - XPT2046_MIN_Y) * XPT2046_VER_RES / XPT2046_Y_RANGE;
#if XPT2046_X_INV
- x = LV_HOR_RES - x;
+ x = XPT2046_HOR_RES - x;
#endif
#if XPT2046_Y_INV
- y = LV_VER_RES - y;
+ y = XPT2046_VER_RES - y;
#endif
*xp = x;
*yp = y;
(mynewt-core) 01/03: lvgl/drivers: change rotation
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit d4e17e8aedec079272149183e8f146381d848556
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Aug 6 22:47:20 2025 +0200
lvgl/drivers: change rotation
Driver is able to rotate screen by changing
how addresses are change when data is
transmitted.
For 90 and 270 degree rotation screen appeared
to rotate clock wise. Problem pops up when
touch screen is present and in those rotations
touch screen orientation which does not changed
did not correspond to display orientation.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c | 4 ++--
hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c | 4 ++--
hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c | 4 ++--
hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c | 5 ++---
hw/drivers/display/lvgl/tft/st7789/src/st7789.c | 4 ++--
hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c | 4 ++--
6 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
index 56a21c36b..8edfc3c92 100644
--- a/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
+++ b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
@@ -106,9 +106,9 @@
static const uint8_t madctl[] = {
GC9A01_MADCTL_MX,
- GC9A01_MADCTL_MV | GC9A01_MADCTL_MY | GC9A01_MADCTL_ML,
- GC9A01_MADCTL_MY,
GC9A01_MADCTL_MX | GC9A01_MADCTL_MV,
+ GC9A01_MADCTL_MY,
+ GC9A01_MADCTL_MV | GC9A01_MADCTL_MY | GC9A01_MADCTL_ML,
};
void
diff --git a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
index daf353583..280941800 100644
--- a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
+++ b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
@@ -132,9 +132,9 @@
static const uint8_t madctl[] = {
MADCTL_MX,
- MADCTL_MV,
- MADCTL_MY,
MADCTL_MX | MADCTL_MY | MADCTL_MV,
+ MADCTL_MY,
+ MADCTL_MV,
};
void
diff --git a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
index 59826baf3..c888c170f 100644
--- a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
+++ b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
@@ -123,9 +123,9 @@
static const uint8_t madctl[] = {
0,
- MADCTL_MX | MADCTL_MV,
- MADCTL_MX | MADCTL_MY,
MADCTL_MV | MADCTL_MY | MADCTL_ML,
+ MADCTL_MX | MADCTL_MY,
+ MADCTL_MX | MADCTL_MV,
};
void
diff --git a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
index 7e980771f..3ddaf101e 100644
--- a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
+++ b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
@@ -107,13 +107,13 @@ st7735s_rotate(lv_disp_rot_t rotation)
switch (rotation) {
case LV_DISP_ROT_270:
- madctl[1] |= ST7735S_MADCTL_MV | ST7735S_MADCTL_MY | ST7735S_MADCTL_ML;
+ madctl[1] |= ST7735S_MADCTL_MX | ST7735S_MADCTL_MV;
break;
case LV_DISP_ROT_180:
madctl[1] |= ST7735S_MADCTL_MX | ST7735S_MADCTL_MY;
break;
case LV_DISP_ROT_90:
- madctl[1] |= ST7735S_MADCTL_MX | ST7735S_MADCTL_MV;
+ madctl[1] |= ST7735S_MADCTL_MV | ST7735S_MADCTL_MY | ST7735S_MADCTL_ML;
break;
case LV_DISP_ROT_NONE:
break;
@@ -139,7 +139,6 @@ LCD_SEQUENCE(init_cmds)
LCD_SEQUENCE_DELAY(5),
4, ST7735S_FRMCTR1, 0x01, 0x2C, 0x2D,
4, ST7735S_FRMCTR2, 0x01, 0x2C, 0x2D,
- 7, ST7735S_FRMCTR2, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D,
2, ST7735S_INVCTR, 0x07,
4, ST7735S_PWCTR1, 0xA2, 0x02, 0x84,
2, ST7735S_PWCTR2, 0xC5,
diff --git a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
index 44c24780e..633f1c98c 100644
--- a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
+++ b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
@@ -145,13 +145,13 @@ st7789_rotate(lv_disp_rot_t rotation)
switch (rotation) {
case LV_DISP_ROT_270:
- madcmd[1] |= ST7789_MADCTL_MV | ST7789_MADCTL_MY | ST7789_MADCTL_ML;
+ madcmd[1] |= ST7789_MADCTL_MX | ST7789_MADCTL_MV;
break;
case LV_DISP_ROT_180:
madcmd[1] |= ST7789_MADCTL_MX | ST7789_MADCTL_MY;
break;
case LV_DISP_ROT_90:
- madcmd[1] |= ST7789_MADCTL_MX | ST7789_MADCTL_MV;
+ madcmd[1] |= ST7789_MADCTL_MV | ST7789_MADCTL_MY | ST7789_MADCTL_ML;
break;
case LV_DISP_ROT_NONE:
break;
diff --git a/hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c b/hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c
index 4a498deeb..8fa11cef7 100644
--- a/hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c
+++ b/hw/drivers/display/lvgl/tft/st7796S/src/st7796s.c
@@ -126,9 +126,9 @@
#define ST7796S_MADCTL_RGB 0x00
#define ST7796S_MADCTL_BGR 0x08
#define ST7796S_MADCTL_0 ST7796S_MADCTL_MX
-#define ST7796S_MADCTL_90 (ST7796S_MADCTL_MV)
+#define ST7796S_MADCTL_90 (ST7796S_MADCTL_MY | ST7796S_MADCTL_ML | ST7796S_MADCTL_MV | ST7796S_MADCTL_MX)
#define ST7796S_MADCTL_180 (ST7796S_MADCTL_MY | ST7796S_MADCTL_ML)
-#define ST7796S_MADCTL_270 (ST7796S_MADCTL_MY | ST7796S_MADCTL_ML | ST7796S_MADCTL_MV | ST7796S_MADCTL_MX)
+#define ST7796S_MADCTL_270 (ST7796S_MADCTL_MV)
#define ST7796S_HOR_RES MYNEWT_VAL(LVGL_DISPLAY_HORIZONTAL_RESOLUTION)
#define ST7796S_VER_RES MYNEWT_VAL(LVGL_DISPLAY_VERTICAL_RESOLUTION)