Use correct option for color inversion
This commit is contained in:
parent
4e0667a065
commit
849afed80d
|
@ -585,7 +585,7 @@ menu "LVGL TFT Display controller"
|
||||||
If text is backwards on your display, try enabling this.
|
If text is backwards on your display, try enabling this.
|
||||||
|
|
||||||
config LV_INVERT_COLORS
|
config LV_INVERT_COLORS
|
||||||
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481 || LV_TFT_DISPLAY_CONTROLLER_ST7789
|
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481 || LV_TFT_DISPLAY_CONTROLLER_ST7789 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 || LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_HX8357
|
||||||
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
|
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
|
||||||
help
|
help
|
||||||
If the colors look inverted on your display, try enabling this.
|
If the colors look inverted on your display, try enabling this.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
|
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
|
||||||
* http://www.adafruit.com/products/2050
|
* http://www.adafruit.com/products/2050
|
||||||
*
|
*
|
||||||
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
|
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
|
||||||
* https://www.adafruit.com/product/3651
|
* https://www.adafruit.com/product/3651
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -177,7 +177,7 @@ void hx8357_init(void)
|
||||||
vTaskDelay(120 / portTICK_RATE_MS);
|
vTaskDelay(120 / portTICK_RATE_MS);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Initialization.");
|
ESP_LOGI(TAG, "Initialization.");
|
||||||
|
|
||||||
//Send all the commands
|
//Send all the commands
|
||||||
const uint8_t *addr = (displayType == HX8357B) ? initb : initd;
|
const uint8_t *addr = (displayType == HX8357B) ? initb : initd;
|
||||||
uint8_t cmd, x, numArgs;
|
uint8_t cmd, x, numArgs;
|
||||||
|
@ -199,9 +199,11 @@ void hx8357_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
hx8357_set_rotation(1);
|
hx8357_set_rotation(1);
|
||||||
|
|
||||||
#if HX8357_INVERT_DISPLAY
|
#if HX8357_INVERT_COLORS
|
||||||
hx8357_send_cmd(HX8357_INVON);;
|
hx8357_send_cmd(HX8357_INVON);
|
||||||
|
#else
|
||||||
|
hx8357_send_cmd(HX8357_INVOFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hx8357_enable_backlight(true);
|
hx8357_enable_backlight(true);
|
||||||
|
@ -211,7 +213,7 @@ void hx8357_init(void)
|
||||||
void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||||
{
|
{
|
||||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||||
|
|
||||||
/* Column addresses */
|
/* Column addresses */
|
||||||
uint8_t xb[] = {
|
uint8_t xb[] = {
|
||||||
(uint8_t) (area->x1 >> 8) & 0xFF,
|
(uint8_t) (area->x1 >> 8) & 0xFF,
|
||||||
|
@ -219,7 +221,7 @@ void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
||||||
(uint8_t) (area->x2 >> 8) & 0xFF,
|
(uint8_t) (area->x2 >> 8) & 0xFF,
|
||||||
(uint8_t) (area->x2) & 0xFF,
|
(uint8_t) (area->x2) & 0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Page addresses */
|
/* Page addresses */
|
||||||
uint8_t yb[] = {
|
uint8_t yb[] = {
|
||||||
(uint8_t) (area->y1 >> 8) & 0xFF,
|
(uint8_t) (area->y1 >> 8) & 0xFF,
|
||||||
|
@ -261,7 +263,7 @@ void hx8357_enable_backlight(bool backlight)
|
||||||
void hx8357_set_rotation(uint8_t r)
|
void hx8357_set_rotation(uint8_t r)
|
||||||
{
|
{
|
||||||
r = r & 3; // can't be higher than 3
|
r = r & 3; // can't be higher than 3
|
||||||
|
|
||||||
switch(r) {
|
switch(r) {
|
||||||
case 0:
|
case 0:
|
||||||
r = MADCTL_MX | MADCTL_MY | MADCTL_RGB;
|
r = MADCTL_MX | MADCTL_MY | MADCTL_RGB;
|
||||||
|
@ -276,7 +278,7 @@ void hx8357_set_rotation(uint8_t r)
|
||||||
r = MADCTL_MX | MADCTL_MV | MADCTL_RGB;
|
r = MADCTL_MX | MADCTL_MV | MADCTL_RGB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hx8357_send_cmd(HX8357_MADCTL);
|
hx8357_send_cmd(HX8357_MADCTL);
|
||||||
hx8357_send_data(&r, 1);
|
hx8357_send_data(&r, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
|
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
|
||||||
* http://www.adafruit.com/products/2050
|
* http://www.adafruit.com/products/2050
|
||||||
*
|
*
|
||||||
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
|
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
|
||||||
* https://www.adafruit.com/product/3651
|
* https://www.adafruit.com/product/3651
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +40,7 @@ extern "C" {
|
||||||
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
|
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
|
||||||
|
|
||||||
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
|
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
|
||||||
|
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
|
||||||
|
|
||||||
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
|
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
|
||||||
#define HX8357_BCKL_ACTIVE_LVL 1
|
#define HX8357_BCKL_ACTIVE_LVL 1
|
||||||
|
@ -47,9 +48,6 @@ extern "C" {
|
||||||
#define HX8357_BCKL_ACTIVE_LVL 0
|
#define HX8357_BCKL_ACTIVE_LVL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if text/images are backwards, try setting this to 1
|
|
||||||
#define HX8357_INVERT_DISPLAY CONFIG_LV_INVERT_DISPLAY
|
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* HX8357B/D REGS
|
* HX8357B/D REGS
|
||||||
|
|
|
@ -62,8 +62,8 @@ void sh1107_init(void)
|
||||||
{0x81, {0}, 0}, // Set display contrast
|
{0x81, {0}, 0}, // Set display contrast
|
||||||
{0x2F, {0}, 0}, // ...value
|
{0x2F, {0}, 0}, // ...value
|
||||||
{0x20, {0}, 0}, // Set memory mode
|
{0x20, {0}, 0}, // Set memory mode
|
||||||
{0xA0, {0}, 0}, // Non-rotated display
|
{0xA0, {0}, 0}, // Non-rotated display
|
||||||
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||||
{0xC8, {0}, 0}, // flipped vertical
|
{0xC8, {0}, 0}, // flipped vertical
|
||||||
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
|
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
|
||||||
{0xC7, {0}, 0}, // flipped vertical
|
{0xC7, {0}, 0}, // flipped vertical
|
||||||
|
@ -82,11 +82,11 @@ void sh1107_init(void)
|
||||||
{0xDA, {0}, 0}, // Set com pins
|
{0xDA, {0}, 0}, // Set com pins
|
||||||
{0x12, {0}, 0}, // ...value
|
{0x12, {0}, 0}, // ...value
|
||||||
{0xA4, {0}, 0}, // output ram to display
|
{0xA4, {0}, 0}, // output ram to display
|
||||||
#if defined CONFIG_LV_INVERT_DISPLAY
|
#if defined CONFIG_LV_INVERT_COLORS
|
||||||
{0xA7, {0}, 0}, // inverted display
|
{0xA7, {0}, 0}, // inverted display
|
||||||
#else
|
#else
|
||||||
{0xA6, {0}, 0}, // Non-inverted display
|
{0xA6, {0}, 0}, // Non-inverted display
|
||||||
#endif
|
#endif
|
||||||
{0xAF, {0}, 0}, // Turn display on
|
{0xAF, {0}, 0}, // Turn display on
|
||||||
{0, {0}, 0xff},
|
{0, {0}, 0xff},
|
||||||
};
|
};
|
||||||
|
@ -116,14 +116,14 @@ void sh1107_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void sh1107_set_px_cb(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
void sh1107_set_px_cb(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||||
lv_color_t color, lv_opa_t opa)
|
lv_color_t color, lv_opa_t opa)
|
||||||
{
|
{
|
||||||
/* buf_w will be ignored, the configured CONFIG_LV_DISPLAY_HEIGHT and _WIDTH,
|
/* buf_w will be ignored, the configured CONFIG_LV_DISPLAY_HEIGHT and _WIDTH,
|
||||||
and CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE and _PORTRAIT will be used. */
|
and CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE and _PORTRAIT will be used. */
|
||||||
uint16_t byte_index = 0;
|
uint16_t byte_index = 0;
|
||||||
uint8_t bit_index = 0;
|
uint8_t bit_index = 0;
|
||||||
|
|
||||||
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||||
byte_index = y + (( x>>3 ) * LV_VER_RES_MAX);
|
byte_index = y + (( x>>3 ) * LV_VER_RES_MAX);
|
||||||
bit_index = x & 0x7;
|
bit_index = x & 0x7;
|
||||||
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
|
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
|
||||||
|
@ -146,10 +146,10 @@ void sh1107_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||||
row1 = area->x1>>3;
|
row1 = area->x1>>3;
|
||||||
row2 = area->x2>>3;
|
row2 = area->x2>>3;
|
||||||
#else
|
#else
|
||||||
row1 = area->y1>>3;
|
row1 = area->y1>>3;
|
||||||
row2 = area->y2>>3;
|
row2 = area->y2>>3;
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,9 +158,9 @@ void sh1107_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
|
||||||
sh1107_send_cmd(0x00 | columnLow); // Set Lower Column Start Address for Page Addressing Mode
|
sh1107_send_cmd(0x00 | columnLow); // Set Lower Column Start Address for Page Addressing Mode
|
||||||
sh1107_send_cmd(0xB0 | i); // Set Page Start Address for Page Addressing Mode
|
sh1107_send_cmd(0xB0 | i); // Set Page Start Address for Page Addressing Mode
|
||||||
size = area->y2 - area->y1 + 1;
|
size = area->y2 - area->y1 + 1;
|
||||||
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
|
||||||
ptr = color_map + i * LV_VER_RES_MAX;
|
ptr = color_map + i * LV_VER_RES_MAX;
|
||||||
#else
|
#else
|
||||||
ptr = color_map + i * LV_HOR_RES_MAX;
|
ptr = color_map + i * LV_HOR_RES_MAX;
|
||||||
#endif
|
#endif
|
||||||
if(i != row2){
|
if(i != row2){
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* Code from https://github.com/yanbe/ssd1306-esp-idf-i2c.git is used as a starting point,
|
* Code from https://github.com/yanbe/ssd1306-esp-idf-i2c.git is used as a starting point,
|
||||||
* in addition to code from https://github.com/espressif/esp-iot-solution.
|
* in addition to code from https://github.com/espressif/esp-iot-solution.
|
||||||
*
|
*
|
||||||
* Definitions are borrowed from:
|
* Definitions are borrowed from:
|
||||||
* http://robotcantalk.blogspot.com/2015/03/interfacing-arduino-with-ssd1306-driven.html
|
* http://robotcantalk.blogspot.com/2015/03/interfacing-arduino-with-ssd1306-driven.html
|
||||||
*
|
*
|
||||||
* For LVGL the forum has been used, in particular: https://blog.littlevgl.com/2019-05-06/oled
|
* For LVGL the forum has been used, in particular: https://blog.littlevgl.com/2019-05-06/oled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ void ssd1306_init(void)
|
||||||
|
|
||||||
uint8_t display_mode = 0;
|
uint8_t display_mode = 0;
|
||||||
|
|
||||||
#if defined CONFIG_LV_INVERT_DISPLAY
|
#if defined CONFIG_LV_INVERT_COLORS
|
||||||
display_mode = OLED_CMD_DISPLAY_INVERTED;
|
display_mode = OLED_CMD_DISPLAY_INVERTED;
|
||||||
#else
|
#else
|
||||||
display_mode = OLED_CMD_DISPLAY_NORMAL;
|
display_mode = OLED_CMD_DISPLAY_NORMAL;
|
||||||
|
@ -130,7 +130,7 @@ void ssd1306_init(void)
|
||||||
0xFF,
|
0xFF,
|
||||||
OLED_CMD_DISPLAY_ON
|
OLED_CMD_DISPLAY_ON
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t err = send_data(NULL, conf, sizeof(conf));
|
uint8_t err = send_data(NULL, conf, sizeof(conf));
|
||||||
assert(0 == err);
|
assert(0 == err);
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ static uint8_t send_data(lv_disp_drv_t *disp_drv, void *bytes, size_t bytes_len)
|
||||||
uint8_t *data = (uint8_t *) bytes;
|
uint8_t *data = (uint8_t *) bytes;
|
||||||
|
|
||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
|
|
||||||
i2c_master_start(cmd);
|
i2c_master_start(cmd);
|
||||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ static uint8_t send_data(lv_disp_drv_t *disp_drv, void *bytes, size_t bytes_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_master_stop(cmd);
|
i2c_master_stop(cmd);
|
||||||
|
|
||||||
/* Send queued commands */
|
/* Send queued commands */
|
||||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||||
i2c_cmd_link_delete(cmd);
|
i2c_cmd_link_delete(cmd);
|
||||||
|
@ -234,7 +234,7 @@ static uint8_t send_pixels(lv_disp_drv_t *disp_drv, void *color_buffer, size_t b
|
||||||
{
|
{
|
||||||
(void) disp_drv;
|
(void) disp_drv;
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
|
|
||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
i2c_master_start(cmd);
|
i2c_master_start(cmd);
|
||||||
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
i2c_master_write_byte(cmd, (OLED_I2C_ADDRESS << 1) | I2C_MASTER_WRITE, true);
|
||||||
|
@ -242,7 +242,7 @@ static uint8_t send_pixels(lv_disp_drv_t *disp_drv, void *color_buffer, size_t b
|
||||||
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_DATA_STREAM, true);
|
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_DATA_STREAM, true);
|
||||||
i2c_master_write(cmd, (uint8_t *) color_buffer, buffer_len, true);
|
i2c_master_write(cmd, (uint8_t *) color_buffer, buffer_len, true);
|
||||||
i2c_master_stop(cmd);
|
i2c_master_stop(cmd);
|
||||||
|
|
||||||
/* Send queued commands */
|
/* Send queued commands */
|
||||||
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
err = i2c_master_cmd_begin(DISP_I2C_PORT, cmd, 10 / portTICK_PERIOD_MS);
|
||||||
i2c_cmd_link_delete(cmd);
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
Loading…
Reference in a new issue