Skip to content

Commit c4cd524

Browse files
arktrinC47D
authored andcommitted
add offset for 240x135 displays based on ST7789
1 parent 8d1fbcf commit c4cd524

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

lvgl_tft/st7789.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ void st7789_init(void)
120120
st7789_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
121121
}
122122

123-
/* The ST7789 display controller can drive 320*240 displays, when using a 240*240
124-
* display there's a gap of 80px, we need to edit the coordinates to take into
125-
* account that gap, this is not necessary in all orientations. */
123+
/* The ST7789 display controller can drive up to 320*240 displays, when using a 240*240
124+
* or 240*135 displays there's a gap of 80px or 40/52/53px respectivly, we need to edit
125+
* the coordinates to take into account those gaps, this is not necessary in all orientations. */
126126
void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
127127
{
128128
uint8_t data[4] = {0};
@@ -139,13 +139,29 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
139139
offsety2 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET;
140140

141141
#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 240)
142-
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
143-
offsetx1 += 80;
144-
offsetx2 += 80;
145-
#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
146-
offsety1 += 80;
147-
offsety2 += 80;
148-
#endif
142+
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
143+
offsetx1 += 80;
144+
offsetx2 += 80;
145+
#elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
146+
offsety1 += 80;
147+
offsety2 += 80;
148+
#endif
149+
#elif (LV_HOR_RES_MAX == 240) && (LV_VER_RES_MAX == 135)
150+
#if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT) || \
151+
(CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
152+
offsetx1 += 40;
153+
offsetx2 += 40;
154+
offsety1 += 53;
155+
offsety2 += 53;
156+
#endif
157+
#elif (LV_HOR_RES_MAX == 135) && (LV_VER_RES_MAX == 240)
158+
#if (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE) || \
159+
(CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
160+
offsetx1 += 52;
161+
offsetx2 += 52;
162+
offsety1 += 40;
163+
offsety2 += 40;
164+
#endif
149165
#endif
150166

151167
/*Column addresses*/

0 commit comments

Comments
 (0)