138
138
#define ST7789_HOR_RES MYNEWT_VAL(LVGL_DISPLAY_HORIZONTAL_RESOLUTION)
139
139
#define ST7789_VER_RES MYNEWT_VAL(LVGL_DISPLAY_VERTICAL_RESOLUTION)
140
140
141
+ #ifdef MYNEWT_VAL_ST7789_HORIZONTAL_OFFSET
142
+ #define HOR_OFF MYNEWT_VAL_ST7789_HORIZONTAL_OFFSET
143
+ #else
144
+ #define HOR_OFF ((240 - ST7789_HOR_RES) / 2)
145
+ #endif
146
+ #ifdef MYNEWT_VAL_ST7789_VERTICAL_OFFSET
147
+ #define VER_OFF MYNEWT_VAL_ST7789_VERTICAL_OFFSET
148
+ #else
149
+ #define VER_OFF ((320 - ST7789_VER_RES) / 2)
150
+ #endif
151
+
152
+ static const uint16_t x_off [4 ] = { HOR_OFF , 320 - ST7789_VER_RES - VER_OFF ,
153
+ 240 - ST7789_HOR_RES - HOR_OFF , VER_OFF };
154
+ static const uint16_t y_off [4 ] = { VER_OFF , 240 - ST7789_HOR_RES - HOR_OFF ,
155
+ 320 - ST7789_VER_RES - VER_OFF , HOR_OFF };
156
+
141
157
void
142
158
st7789_rotate (lv_disp_rot_t rotation )
143
159
{
@@ -212,6 +228,7 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
212
228
lv_disp_t * disp = lv_disp_get_default ();
213
229
lv_coord_t hor_res = lv_disp_get_hor_res (disp );
214
230
lv_coord_t ver_res = lv_disp_get_ver_res (disp );
231
+ int rot = drv -> rotated ;
215
232
216
233
if (area -> x2 < 0 || area -> y2 < 0 || area -> x1 >= hor_res || area -> y1 >= ver_res ) {
217
234
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)
224
241
int32_t offsetx2 = area -> x2 >= hor_res ? hor_res - 1 : area -> x2 ;
225
242
int32_t offsety2 = area -> y2 >= ver_res ? ver_res - 1 : area -> y2 ;
226
243
227
- #if (CONFIG_LV_TFT_DISPLAY_OFFSETS )
228
- offsetx1 += CONFIG_LV_TFT_DISPLAY_X_OFFSET ;
229
- offsetx2 += CONFIG_LV_TFT_DISPLAY_X_OFFSET ;
230
- offsety1 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET ;
231
- offsety2 += CONFIG_LV_TFT_DISPLAY_Y_OFFSET ;
232
-
233
- #elif (ST7789_HOR_RES == 240 ) && (ST7789_VER_RES == 240 )
234
- #if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT )
235
- offsetx1 += 80 ;
236
- offsetx2 += 80 ;
237
- #elif (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED )
238
- offsety1 += 80 ;
239
- offsety2 += 80 ;
240
- #endif
241
- #elif (LV_HOR_RES_MAX == 240 ) && (LV_VER_RES_MAX == 135 )
242
- #if (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT ) || \
243
- (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED )
244
- offsetx1 += 40 ;
245
- offsetx2 += 40 ;
246
- offsety1 += 53 ;
247
- offsety2 += 53 ;
248
- #endif
249
- #elif (LV_HOR_RES_MAX == 135 ) && (LV_VER_RES_MAX == 240 )
250
- #if (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE ) || \
251
- (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED )
252
- offsetx1 += 52 ;
253
- offsetx2 += 52 ;
254
- offsety1 += 40 ;
255
- offsety2 += 40 ;
256
- #endif
257
- #endif
244
+ offsetx1 += x_off [rot ];
245
+ offsetx2 += x_off [rot ];
246
+ offsety1 += y_off [rot ];
247
+ offsety2 += y_off [rot ];
258
248
259
249
/* Column addresses */
260
250
cmd [0 ] = ST7789_CASET ;
0 commit comments