Merge branch 'master' into feature/st7789_soft_reset

This commit is contained in:
Carlos Diaz 2021-02-13 18:50:51 -06:00 committed by GitHub
commit ee13a029c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 144 additions and 107 deletions

29
.editorconfig Normal file
View file

@ -0,0 +1,29 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{*.md,*.rst}]
trim_trailing_whitespace = false
[{Makefile,*.mk,*.bat}]
indent_style = tab
indent_size = 2
[{*.cmake,CMakeLists.txt}]
indent_style = space
indent_size = 4
max_line_length = 120
[{*.sh,*.yml}]
indent_style = space
indent_size = 2

View file

@ -61,7 +61,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#define TAG "FT81X" #define TAG_LOG "FT81X"
/* data structure for SPI reading that has (optional) space for inserted dummy byte */ /* data structure for SPI reading that has (optional) space for inserted dummy byte */
typedef struct _spi_read_data { typedef struct _spi_read_data {
@ -274,7 +274,7 @@ void EVE_memWrite_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len,
while(bytes_left > 0) while(bytes_left > 0)
{ {
uint32_t block_len = (bytes_left > SPI_TRANSER_SIZE ? SPI_TRANSER_SIZE : bytes_left); uint32_t block_len = (bytes_left > SPI_TRANSER_SIZE ? SPI_TRANSER_SIZE : bytes_left);
// only send flush on last chunk // only send flush on last chunk
disp_spi_send_flag_t flush_flag = 0; disp_spi_send_flag_t flush_flag = 0;
if(LvGL_Flush && bytes_left - block_len == 0) if(LvGL_Flush && bytes_left - block_len == 0)
@ -282,7 +282,7 @@ void EVE_memWrite_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len,
flush_flag = DISP_SPI_SIGNAL_FLUSH; flush_flag = DISP_SPI_SIGNAL_FLUSH;
} }
disp_spi_transaction(data, block_len, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags | flush_flag), NULL, (ftAddress | MEM_WRITE_24), 0); disp_spi_transaction(data, block_len, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags | flush_flag), NULL, (ftAddress | MEM_WRITE_24), 0);
data += block_len; data += block_len;
ftAddress += block_len; ftAddress += block_len;
bytes_left -= block_len; bytes_left -= block_len;
@ -409,7 +409,7 @@ void EVE_cmd_memzero(uint32_t ptr, uint32_t num)
EVE_begin_cmd(CMD_MEMZERO); EVE_begin_cmd(CMD_MEMZERO);
BUFFER_SPI_DWORD(ptr) BUFFER_SPI_DWORD(ptr)
BUFFER_SPI_DWORD(num) BUFFER_SPI_DWORD(num)
EVE_inc_cmdoffset(8); EVE_inc_cmdoffset(8);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -438,11 +438,11 @@ void EVE_cmd_memwrite(uint32_t dest, uint32_t num, const uint8_t *data)
EVE_begin_cmd(CMD_MEMWRITE); EVE_begin_cmd(CMD_MEMWRITE);
BUFFER_SPI_DWORD(dest) BUFFER_SPI_DWORD(dest)
BUFFER_SPI_DWORD(num) BUFFER_SPI_DWORD(num)
EVE_inc_cmdoffset(8); EVE_inc_cmdoffset(8);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
block_transfer(data, num); // block_transfer is immediate - make sure CMD buffer is prepared! block_transfer(data, num); // block_transfer is immediate - make sure CMD buffer is prepared!
} }
@ -468,7 +468,7 @@ void EVE_cmd_memcpy(uint32_t dest, uint32_t src, uint32_t num)
void eve_spi_CMD_write(uint64_t addr, const uint8_t *data, uint16_t len) void eve_spi_CMD_write(uint64_t addr, const uint8_t *data, uint16_t len)
{ {
// we can use a direct transaction because it is already chunked // we can use a direct transaction because it is already chunked
disp_spi_transaction(data, len, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags), NULL, (addr | MEM_WRITE_24), 0); disp_spi_transaction(data, len, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags), NULL, (addr | MEM_WRITE_24), 0);
uint8_t padding = len & 0x03; /* 0, 1, 2 or 3 */ uint8_t padding = len & 0x03; /* 0, 1, 2 or 3 */
padding = 4 - padding; /* 4, 3, 2 or 1 */ padding = 4 - padding; /* 4, 3, 2 or 1 */
@ -478,9 +478,9 @@ void eve_spi_CMD_write(uint64_t addr, const uint8_t *data, uint16_t len)
if(padding) if(padding)
{ {
addr += len; addr += len;
uint8_t padData[4] = {0}; uint8_t padData[4] = {0};
disp_spi_transaction(padData, padding, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags), NULL, (addr | MEM_WRITE_24), 0); disp_spi_transaction(padData, padding, (disp_spi_send_flag_t)(DISP_SPI_SEND_QUEUED | DISP_SPI_ADDRESS_24 | SPIInherentSendFlags), NULL, (addr | MEM_WRITE_24), 0);
len += padding; len += padding;
} }
@ -521,7 +521,7 @@ void EVE_cmd_inflate(uint32_t ptr, const uint8_t *data, uint16_t len)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
block_transfer(data, len); // block_transfer is immediate - make sure CMD buffer is prepared! block_transfer(data, len); // block_transfer is immediate - make sure CMD buffer is prepared!
} }
@ -707,7 +707,7 @@ uint32_t EVE_cmd_memcrc(uint32_t ptr, uint32_t num)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
return (EVE_memRead32(EVE_RAM_CMD + offset)); return (EVE_memRead32(EVE_RAM_CMD + offset));
@ -722,11 +722,11 @@ uint32_t EVE_cmd_getptr(void)
uint16_t offset = cmdOffset; uint16_t offset = cmdOffset;
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
return (EVE_memRead32(EVE_RAM_CMD + offset)); return (EVE_memRead32(EVE_RAM_CMD + offset));
} }
@ -743,7 +743,7 @@ uint32_t EVE_cmd_regread(uint32_t ptr)
BUFFER_SPI_DWORD(ptr) BUFFER_SPI_DWORD(ptr)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
offset = cmdOffset; offset = cmdOffset;
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
@ -873,16 +873,16 @@ uint8_t EVE_init(void)
/* The most reliable DIO/QIO switching point is after EVE start up but before reading the ChipID. */ /* The most reliable DIO/QIO switching point is after EVE start up but before reading the ChipID. */
#if defined(DISP_SPI_TRANS_MODE_DIO) #if defined(DISP_SPI_TRANS_MODE_DIO)
ESP_LOGI(TAG, "Switching to DIO mode"); ESP_LOGI(TAG_LOG, "Switching to DIO mode");
DELAY_MS(20); /* different boards may take a different delay but this generally seems to work */ DELAY_MS(20); /* different boards may take a different delay but this generally seems to work */
EVE_memWrite16(REG_SPI_WIDTH, SPI_WIDTH_DIO); EVE_memWrite16(REG_SPI_WIDTH, SPI_WIDTH_DIO);
SPIInherentSendFlags = DISP_SPI_MODE_DIO | DISP_SPI_MODE_DIOQIO_ADDR; SPIInherentSendFlags = DISP_SPI_MODE_DIO | DISP_SPI_MODE_DIOQIO_ADDR;
SPIDummyReadBits = 4; /* Esp32 DMA SPI transaction dummy_bits works more like clock cycles, so in DIO 4 dummy_bits == 8 total bits */ SPIDummyReadBits = 4; /* Esp32 DMA SPI transaction dummy_bits works more like clock cycles, so in DIO 4 dummy_bits == 8 total bits */
#elif defined(DISP_SPI_TRANS_MODE_QIO) #elif defined(DISP_SPI_TRANS_MODE_QIO)
ESP_LOGI(TAG, "Switching to QIO mode"); ESP_LOGI(TAG_LOG, "Switching to QIO mode");
DELAY_MS(20); /* different boards may take a different delay but this generally seems to work */ DELAY_MS(20); /* different boards may take a different delay but this generally seems to work */
EVE_memWrite16(REG_SPI_WIDTH, SPI_WIDTH_QIO); EVE_memWrite16(REG_SPI_WIDTH, SPI_WIDTH_QIO);
SPIInherentSendFlags = DISP_SPI_MODE_QIO | DISP_SPI_MODE_DIOQIO_ADDR; SPIInherentSendFlags = DISP_SPI_MODE_QIO | DISP_SPI_MODE_DIOQIO_ADDR;
SPIDummyReadBits = 2; /* Esp32 DMA SPI transaction dummy_bits works more like clock cycles, so in QIO 2 dummy_bits == 8 total bits */ SPIDummyReadBits = 2; /* Esp32 DMA SPI transaction dummy_bits works more like clock cycles, so in QIO 2 dummy_bits == 8 total bits */
#elif defined(DISP_SPI_HALF_DUPLEX) #elif defined(DISP_SPI_HALF_DUPLEX)
SPIDummyReadBits = 8; /* SIO half-duplex mode */ SPIDummyReadBits = 8; /* SIO half-duplex mode */
@ -895,7 +895,7 @@ uint8_t EVE_init(void)
timeout++; timeout++;
if(timeout > 400) if(timeout > 400)
{ {
ESP_LOGI(TAG, "Failed to read ChipID...aborting initialization."); ESP_LOGI(TAG_LOG, "Failed to read ChipID...aborting initialization.");
return 0; return 0;
} }
} }
@ -907,7 +907,7 @@ uint8_t EVE_init(void)
timeout++; timeout++;
if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */ if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */
{ {
ESP_LOGI(TAG, "Failed to read CPU status...aborting initialization."); ESP_LOGI(TAG_LOG, "Failed to read CPU status...aborting initialization.");
return 0; return 0;
} }
} }
@ -1068,7 +1068,7 @@ void EVE_cmd_dl(uint32_t command)
if(cmd_burst) if(cmd_burst)
{ {
BUFFER_SPI_DWORD(command) BUFFER_SPI_DWORD(command)
EVE_inc_cmdoffset(4); /* update the command-ram pointer */ EVE_inc_cmdoffset(4); /* update the command-ram pointer */
} }
else else
@ -1126,7 +1126,7 @@ void EVE_cmd_flashwrite(uint32_t ptr, uint32_t num, const uint8_t *data)
EVE_begin_cmd(CMD_FLASHWRITE); EVE_begin_cmd(CMD_FLASHWRITE);
BUFFER_SPI_DWORD(ptr) BUFFER_SPI_DWORD(ptr)
BUFFER_SPI_DWORD(num) BUFFER_SPI_DWORD(num)
EVE_inc_cmdoffset(8); EVE_inc_cmdoffset(8);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1147,11 +1147,11 @@ void EVE_cmd_flashread(uint32_t dest, uint32_t src, uint32_t num)
BUFFER_SPI_DWORD(dest) BUFFER_SPI_DWORD(dest)
BUFFER_SPI_DWORD(src) BUFFER_SPI_DWORD(src)
BUFFER_SPI_DWORD(num) BUFFER_SPI_DWORD(num)
EVE_inc_cmdoffset(12); EVE_inc_cmdoffset(12);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
} }
@ -1167,11 +1167,11 @@ void EVE_cmd_flashupdate(uint32_t dest, uint32_t src, uint32_t num)
BUFFER_SPI_DWORD(dest) BUFFER_SPI_DWORD(dest)
BUFFER_SPI_DWORD(src) BUFFER_SPI_DWORD(src)
BUFFER_SPI_DWORD(num) BUFFER_SPI_DWORD(num)
EVE_inc_cmdoffset(12); EVE_inc_cmdoffset(12);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
} }
@ -1181,7 +1181,7 @@ void EVE_cmd_flashupdate(uint32_t dest, uint32_t src, uint32_t num)
void EVE_cmd_flasherase(void) void EVE_cmd_flasherase(void)
{ {
EVE_begin_cmd(CMD_FLASHERASE); EVE_begin_cmd(CMD_FLASHERASE);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
@ -1193,7 +1193,7 @@ void EVE_cmd_flasherase(void)
void EVE_cmd_flashattach(void) void EVE_cmd_flashattach(void)
{ {
EVE_begin_cmd(CMD_FLASHATTACH); EVE_begin_cmd(CMD_FLASHATTACH);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
@ -1205,7 +1205,7 @@ void EVE_cmd_flashattach(void)
void EVE_cmd_flashdetach(void) void EVE_cmd_flashdetach(void)
{ {
EVE_begin_cmd(CMD_FLASHDETACH); EVE_begin_cmd(CMD_FLASHDETACH);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
@ -1217,7 +1217,7 @@ void EVE_cmd_flashdetach(void)
void EVE_cmd_flashspidesel(void) void EVE_cmd_flashspidesel(void)
{ {
EVE_begin_cmd(CMD_FLASHSPIDESEL); EVE_begin_cmd(CMD_FLASHSPIDESEL);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
@ -1238,7 +1238,7 @@ uint32_t EVE_cmd_flashfast(void)
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
EVE_cmd_execute(); EVE_cmd_execute();
return EVE_memRead32(EVE_RAM_CMD + offset); return EVE_memRead32(EVE_RAM_CMD + offset);
} }
@ -1254,7 +1254,7 @@ void EVE_cmd_flashspitx(uint32_t num, const uint8_t *data)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
WAIT_SPI() WAIT_SPI()
block_transfer(data, num); block_transfer(data, num);
} }
@ -1401,7 +1401,7 @@ void EVE_cmd_text(int16_t x0, int16_t y0, int16_t font, uint16_t options, const
EVE_inc_cmdoffset(8); EVE_inc_cmdoffset(8);
EVE_write_string(text); EVE_write_string(text);
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1440,7 +1440,7 @@ void EVE_cmd_button_var(int16_t x0, int16_t y0, int16_t w0, int16_t h0, int16_t
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
} }
} }
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1500,7 +1500,7 @@ void EVE_color_rgb(uint8_t red, uint8_t green, uint8_t blue)
BUFFER_SPI_BYTE(blue) BUFFER_SPI_BYTE(blue)
BUFFER_SPI_BYTE(red) BUFFER_SPI_BYTE(red)
BUFFER_SPI_BYTE(0x04) /* encoding for COLOR_RGB */ BUFFER_SPI_BYTE(0x04) /* encoding for COLOR_RGB */
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
if(!cmd_burst) if(!cmd_burst)
@ -1516,7 +1516,7 @@ void EVE_cmd_bgcolor(uint32_t color)
BUFFER_SPI_DWORD(color & 0x00ffffff) BUFFER_SPI_DWORD(color & 0x00ffffff)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1530,7 +1530,7 @@ void EVE_cmd_fgcolor(uint32_t color)
BUFFER_SPI_DWORD(color & 0x00ffffff) BUFFER_SPI_DWORD(color & 0x00ffffff)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1544,7 +1544,7 @@ void EVE_cmd_gradcolor(uint32_t color)
BUFFER_SPI_DWORD(color & 0x00ffffff) BUFFER_SPI_DWORD(color & 0x00ffffff)
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1624,7 +1624,7 @@ void EVE_cmd_progress(int16_t x0, int16_t y0, int16_t w0, int16_t h0, uint16_t o
BUFFER_SPI_WORD(val) BUFFER_SPI_WORD(val)
BUFFER_SPI_WORD(range) BUFFER_SPI_WORD(range)
BUFFER_SPI_WORD(0) /* dummy word for 4-byte alignment */ BUFFER_SPI_WORD(0) /* dummy word for 4-byte alignment */
EVE_inc_cmdoffset(16); EVE_inc_cmdoffset(16);
if(!cmd_burst) if(!cmd_burst)
@ -1726,7 +1726,7 @@ void EVE_cmd_toggle_var(int16_t x0, int16_t y0, int16_t w0, int16_t font, uint16
EVE_inc_cmdoffset(4); EVE_inc_cmdoffset(4);
} }
} }
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -1747,7 +1747,7 @@ void EVE_cmd_toggle(int16_t x0, int16_t y0, int16_t w0, int16_t font, uint16_t o
BUFFER_SPI_WORD(state) BUFFER_SPI_WORD(state)
EVE_inc_cmdoffset(12); EVE_inc_cmdoffset(12);
EVE_write_string(text); EVE_write_string(text);
if(!cmd_burst) if(!cmd_burst)
@ -1783,9 +1783,9 @@ void EVE_cmd_setbitmap(uint32_t addr, uint16_t fmt, uint16_t width, uint16_t hei
BUFFER_SPI_WORD(width) BUFFER_SPI_WORD(width)
BUFFER_SPI_WORD(height) BUFFER_SPI_WORD(height)
BUFFER_SPI_WORD(0) BUFFER_SPI_WORD(0)
EVE_inc_cmdoffset(12); EVE_inc_cmdoffset(12);
if(!cmd_burst) if(!cmd_burst)
{ {
SEND_SPI_BUFFER() SEND_SPI_BUFFER()
@ -2139,13 +2139,13 @@ void EVE_cmd_appendf(uint32_t ptr, uint32_t num)
void EVE_cmd_point(int16_t x0, int16_t y0, uint16_t size) void EVE_cmd_point(int16_t x0, int16_t y0, uint16_t size)
{ {
EVE_start_cmd((DL_BEGIN | EVE_POINTS)); EVE_start_cmd((DL_BEGIN | EVE_POINTS));
uint32_t calc = POINT_SIZE(size*16); uint32_t calc = POINT_SIZE(size*16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
calc = VERTEX2F(x0 * 16, y0 * 16); calc = VERTEX2F(x0 * 16, y0 * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
BUFFER_SPI_DWORD(DL_END) BUFFER_SPI_DWORD(DL_END)
EVE_inc_cmdoffset(12); EVE_inc_cmdoffset(12);
@ -2164,13 +2164,13 @@ void EVE_cmd_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t width
uint32_t calc = LINE_WIDTH(width * 16); uint32_t calc = LINE_WIDTH(width * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
calc = VERTEX2F(x0 * 16, y0 * 16); calc = VERTEX2F(x0 * 16, y0 * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
calc = VERTEX2F(x1 * 16, y1 * 16); calc = VERTEX2F(x1 * 16, y1 * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
BUFFER_SPI_DWORD(DL_END) BUFFER_SPI_DWORD(DL_END)
EVE_inc_cmdoffset(16); EVE_inc_cmdoffset(16);
@ -2189,13 +2189,13 @@ void EVE_cmd_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t corne
uint32_t calc = LINE_WIDTH(corner * 16); uint32_t calc = LINE_WIDTH(corner * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
calc = VERTEX2F(x0 * 16, y0 * 16); calc = VERTEX2F(x0 * 16, y0 * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
calc = VERTEX2F(x1 * 16, y1 * 16); calc = VERTEX2F(x1 * 16, y1 * 16);
BUFFER_SPI_DWORD(calc) BUFFER_SPI_DWORD(calc)
BUFFER_SPI_DWORD(DL_END) BUFFER_SPI_DWORD(DL_END)
EVE_inc_cmdoffset(16); EVE_inc_cmdoffset(16);

View file

@ -35,7 +35,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#ifndef EVE_CONFIG_H_ #ifndef EVE_CONFIG_H_
#define EVE_CONFIG_H_ #define EVE_CONFIG_H_
#ifdef LV_CONFIG_INCLUDE_SIMPLE #ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h" #include "lvgl.h"
#else #else
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"

View file

@ -109,7 +109,7 @@ menu "LVGL TFT Display controller"
bool bool
help help
ST7789 display controller. ST7789 display controller.
config LV_TFT_DISPLAY_CONTROLLER_GC9A01 config LV_TFT_DISPLAY_CONTROLLER_GC9A01
bool bool
help help
@ -211,14 +211,14 @@ menu "LVGL TFT Display controller"
config LV_TFT_DISPLAY_X_OFFSET config LV_TFT_DISPLAY_X_OFFSET
depends on LV_TFT_DISPLAY_OFFSETS depends on LV_TFT_DISPLAY_OFFSETS
int int
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED) default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED) default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
default 0 default 0
config LV_TFT_DISPLAY_Y_OFFSET config LV_TFT_DISPLAY_Y_OFFSET
depends on LV_TFT_DISPLAY_OFFSETS depends on LV_TFT_DISPLAY_OFFSETS
int int
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED) default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED) default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
default 0 default 0
@ -284,7 +284,7 @@ menu "LVGL TFT Display controller"
config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01 config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01
bool "GC9A01" bool "GC9A01"
select LV_TFT_DISPLAY_CONTROLLER_GC9A01 select LV_TFT_DISPLAY_CONTROLLER_GC9A01
select LV_TFT_DISPLAY_PROTOCOL_SPI select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_TFT_DISPLAY_USER_CONTROLLER_ST7735S config LV_TFT_DISPLAY_USER_CONTROLLER_ST7735S
bool "ST7735S" bool "ST7735S"
select LV_TFT_DISPLAY_CONTROLLER_ST7735S select LV_TFT_DISPLAY_CONTROLLER_ST7735S
@ -441,7 +441,7 @@ menu "LVGL TFT Display controller"
config LV_FT81X_CONFIG_EVE_SUNFLOWER config LV_FT81X_CONFIG_EVE_SUNFLOWER
bool "EVE_SUNFLOWER" bool "EVE_SUNFLOWER"
config LV_FT81X_CONFIG_EVE_CONNECTEVE config LV_FT81X_CONFIG_EVE_CONNECTEVE
bool "EVE_CONNECTEVE" bool "EVE_CONNECTEVE"
endchoice endchoice
choice choice
@ -579,16 +579,17 @@ menu "LVGL TFT Display controller"
default 2 default 2
config LV_INVERT_DISPLAY config LV_INVERT_DISPLAY
bool "IN DEPRECATION - Invert display." bool "IN DEPRECATION - Invert display." if LV_TFT_DISPLAY_CONTROLLER_RA8875
default y if LV_PREDEFINED_DISPLAY_M5STACK default n
help help
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 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.
If it didn't help try LVGL configuration -> Swap the 2 bytes of RGB565 color.
config LV_M5STICKC_HANDLE_AXP192 config LV_M5STICKC_HANDLE_AXP192
bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S
@ -782,7 +783,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_MISO depends on LV_DISPLAY_USE_SPI_MISO
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 19 if LV_PREDEFINED_PINS_TKOALA default 19 if LV_PREDEFINED_PINS_TKOALA
default 0 default 0
@ -803,7 +804,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32 range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2 range -1 43 if IDF_TARGET_ESP32S2
default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1 default -1
help help
@ -814,7 +815,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32 range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2 range -1 43 if IDF_TARGET_ESP32S2
default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1 default -1
help help
@ -824,7 +825,7 @@ menu "LVGL TFT Display controller"
int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 13 if LV_PREDEFINED_DISPLAY_M5STICKC default 13 if LV_PREDEFINED_DISPLAY_M5STICKC
default 18 if LV_PREDEFINED_DISPLAY_ATAG default 18 if LV_PREDEFINED_DISPLAY_ATAG
@ -851,7 +852,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_CS depends on LV_DISPLAY_USE_SPI_CS
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 5 if LV_PREDEFINED_PINS_38V1 default 5 if LV_PREDEFINED_PINS_38V1
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 5 if LV_PREDEFINED_DISPLAY_M5STICKC default 5 if LV_PREDEFINED_DISPLAY_M5STICKC
@ -878,7 +879,7 @@ menu "LVGL TFT Display controller"
int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
depends on LV_DISPLAY_USE_DC depends on LV_DISPLAY_USE_DC
default 19 if LV_PREDEFINED_PINS_38V1 default 19 if LV_PREDEFINED_PINS_38V1
default 17 if LV_PREDEFINED_PINS_38V4 default 17 if LV_PREDEFINED_PINS_38V4
@ -900,7 +901,7 @@ menu "LVGL TFT Display controller"
int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI && !LV_DISP_ST7789_SOFT_RESET int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI && !LV_DISP_ST7789_SOFT_RESET
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 18 if LV_PREDEFINED_PINS_38V1 default 18 if LV_PREDEFINED_PINS_38V1
default 25 if LV_PREDEFINED_PINS_38V4 default 25 if LV_PREDEFINED_PINS_38V4
default 33 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK default 33 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
@ -921,7 +922,7 @@ menu "LVGL TFT Display controller"
int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
default 35 default 35
@ -959,7 +960,7 @@ menu "LVGL TFT Display controller"
depends on LV_ENABLE_BACKLIGHT_CONTROL depends on LV_ENABLE_BACKLIGHT_CONTROL
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 23 if LV_PREDEFINED_PINS_38V1 default 23 if LV_PREDEFINED_PINS_38V1
default 26 if LV_PREDEFINED_PINS_38V4 default 26 if LV_PREDEFINED_PINS_38V4
default 32 if LV_PREDEFINED_DISPLAY_M5STACK default 32 if LV_PREDEFINED_DISPLAY_M5STACK
@ -979,7 +980,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 5 default 5
@ -990,7 +991,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32 range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2 range 0 43 if IDF_TARGET_ESP32S2
default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 4 default 4

View file

@ -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);
} }

View file

@ -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

View file

@ -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){

View file

@ -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);

View file

@ -65,7 +65,13 @@ void st7789_init(void)
{ST7789_CABCCTRL, {0xBE}, 1}, {ST7789_CABCCTRL, {0xBE}, 1},
{ST7789_MADCTL, {0x00}, 1}, // Set to 0x28 if your display is flipped {ST7789_MADCTL, {0x00}, 1}, // Set to 0x28 if your display is flipped
{ST7789_COLMOD, {0x55}, 1}, {ST7789_COLMOD, {0x55}, 1},
{ST7789_INVON, {0}, 0},
#if ST7789_INVERT_COLORS == 1
{ST7789_INVON, {0}, 0}, // set inverted mode
#else
{ST7789_INVOFF, {0}, 0}, // set non-inverted mode
#endif
{ST7789_RGBCTRL, {0x00, 0x1B}, 2}, {ST7789_RGBCTRL, {0x00, 0x1B}, 2},
{0xF2, {0x08}, 1}, {0xF2, {0x08}, 1},
{ST7789_GAMSET, {0x01}, 1}, {ST7789_GAMSET, {0x01}, 1},
@ -89,7 +95,7 @@ void st7789_init(void)
gpio_pad_select_gpio(ST7789_RST); gpio_pad_select_gpio(ST7789_RST);
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT); gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
#endif #endif
#if ST7789_ENABLE_BACKLIGHT_CONTROL #if ST7789_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ST7789_BCKL); gpio_pad_select_gpio(ST7789_BCKL);
gpio_set_direction(ST7789_BCKL, GPIO_MODE_OUTPUT); gpio_set_direction(ST7789_BCKL, GPIO_MODE_OUTPUT);
@ -226,7 +232,7 @@ static void st7789_set_orientation(uint8_t orientation)
ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]); ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
uint8_t data[] = uint8_t data[] =
{ {
#if CONFIG_LV_PREDEFINED_DISPLAY_TTGO #if CONFIG_LV_PREDEFINED_DISPLAY_TTGO
0x60, 0xA0, 0x00, 0xC0 0x60, 0xA0, 0x00, 0xC0
@ -234,7 +240,7 @@ static void st7789_set_orientation(uint8_t orientation)
0xC0, 0x00, 0x60, 0xA0 0xC0, 0x00, 0x60, 0xA0
#endif #endif
}; };
ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]); ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
st7789_send_cmd(ST7789_MADCTL); st7789_send_cmd(ST7789_MADCTL);

View file

@ -26,6 +26,7 @@ extern "C"
#define ST7789_BCKL CONFIG_LV_DISP_PIN_BCKL #define ST7789_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ST7789_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL #define ST7789_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL #if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ST7789_BCKL_ACTIVE_LVL 1 #define ST7789_BCKL_ACTIVE_LVL 1