From b7e1b51c7358f8a4738666a263a14a1cd3088131 Mon Sep 17 00:00:00 2001 From: Carlos Diaz Date: Sat, 16 Jan 2021 20:37:55 -0600 Subject: [PATCH] SSD1306: Add portrait inverted support By @VedantParanjape --- lvgl_tft/ssd1306.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lvgl_tft/ssd1306.c b/lvgl_tft/ssd1306.c index e2be65e..a1801fa 100644 --- a/lvgl_tft/ssd1306.c +++ b/lvgl_tft/ssd1306.c @@ -105,8 +105,17 @@ void ssd1306_init() i2c_master_write_byte(cmd, OLED_CMD_SET_CHARGE_PUMP, true); i2c_master_write_byte(cmd, 0x14, true); - i2c_master_write_byte(cmd, OLED_CMD_SET_SEGMENT_REMAP, true); + +#if defined (CONFIG_DISPLAY_ORIENTATION_PORTRAIT) + i2c_master_write_byte(cmd, OLED_CMD_SET_SEGMENT_REMAP, true); i2c_master_write_byte(cmd, OLED_CMD_SET_COM_SCAN_MODE_REMAP, true); +#elif defined (CONFIG_DISPLAY_ORIENTATION_PORTRAIT_INVERTED) + i2c_master_write_byte(cmd, 0xA0, true); + i2c_master_write_byte(cmd, OLED_CMD_SET_COM_SCAN_MODE_NORMAL, true); +#else + #error "Unsopported orientation" +#endif + i2c_master_write_byte(cmd, OLED_CMD_SET_CONTRAST, true); #if defined CONFIG_LV_INVERT_DISPLAY