Merge pull request #26 from lvgl/fix/ssd1306_orientation

Fix/ssd1306 orientation
This commit is contained in:
Carlos Diaz 2021-02-15 22:25:43 -06:00 committed by GitHub
commit 347aaa68d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View file

@ -55,7 +55,11 @@ extern "C" {
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SSD1306
#if defined (CONFIG_LV_THEME_MONO)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8)) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * (LV_VER_RES_MAX / 8))
#else
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * LV_VER_RES_MAX)
#endif
#elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X) #elif defined (CONFIG_LV_TFT_DISPLAY_CONTROLLER_FT81X)
#define DISP_BUF_LINES 40 #define DISP_BUF_LINES 40
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * DISP_BUF_LINES) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * DISP_BUF_LINES)

View file

@ -186,11 +186,12 @@ menu "LVGL TFT Display controller"
# Used in display init function to send display orientation commands # Used in display init function to send display orientation commands
choice DISPLAY_ORIENTATION choice DISPLAY_ORIENTATION
prompt "Display orientation" prompt "Display orientation"
default DISPLAY_ORIENTATION_PORTRAIT default DISPLAY_ORIENTATION_PORTRAIT if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
default DISPLAY_ORIENTATION_LANDSCAPE if LV_TFT_DISPLAY_CONTROLLER_SSD1306
config DISPLAY_ORIENTATION_PORTRAIT config DISPLAY_ORIENTATION_PORTRAIT
bool "Portrait" bool "Portrait" if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
config DISPLAY_ORIENTATION_PORTRAIT_INVERTED config DISPLAY_ORIENTATION_PORTRAIT_INVERTED
bool "Portrait inverted" bool "Portrait inverted" if !LV_TFT_DISPLAY_CONTROLLER_SSD1306
config DISPLAY_ORIENTATION_LANDSCAPE config DISPLAY_ORIENTATION_LANDSCAPE
bool "Landscape" bool "Landscape"
config DISPLAY_ORIENTATION_LANDSCAPE_INVERTED config DISPLAY_ORIENTATION_LANDSCAPE_INVERTED

View file

@ -101,10 +101,10 @@ void ssd1306_init(void)
uint8_t orientation_1 = 0; uint8_t orientation_1 = 0;
uint8_t orientation_2 = 0; uint8_t orientation_2 = 0;
#if defined (CONFIG_DISPLAY_ORIENTATION_PORTRAIT) #if defined (CONFIG_DISPLAY_ORIENTATION_LANDSCAPE)
orientation_1 = OLED_CMD_SET_SEGMENT_REMAP; orientation_1 = OLED_CMD_SET_SEGMENT_REMAP;
orientation_2 = OLED_CMD_SET_COM_SCAN_MODE_REMAP; orientation_2 = OLED_CMD_SET_COM_SCAN_MODE_REMAP;
#elif defined (CONFIG_DISPLAY_ORIENTATION_PORTRAIT_INVERTED) #elif defined (CONFIG_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
orientation_1 = 0xA0; orientation_1 = 0xA0;
orientation_2 = OLED_CMD_SET_COM_SCAN_MODE_NORMAL; orientation_2 = OLED_CMD_SET_COM_SCAN_MODE_NORMAL;
#else #else
@ -176,8 +176,13 @@ void ssd1306_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t
void ssd1306_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area) void ssd1306_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area)
{ {
area->x1 = area->x1 & ~(0x07); uint8_t hor_max = disp_drv->hor_res;
area->x2 = area->x2 | 0x07; uint8_t ver_max = disp_drv->ver_res;
area->x1 = 0;
area->y1 = 0;
area->x2 = hor_max - 1;
area->y2 = ver_max - 1;
} }
void ssd1306_sleep_in(void) void ssd1306_sleep_in(void)