@@ -450,7 +450,7 @@ LUAT_WEAK int luat_lcd_draw(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16
int luat_lcd_draw_point(luat_lcd_conf_t* conf, int16_t x, int16_t y, luat_color_t color) {
luat_color_t tmp = color;
- if (conf->lcd_rgb_swap)
+ if (conf->endianness_swap)
tmp = color_swap(color);// 注意, 这里需要把颜色swap了
return luat_lcd_draw(conf, x, y, x, y, &tmp);
}
@@ -489,7 +489,7 @@ int luat_lcd_draw_line(luat_lcd_conf_t* conf,int16_t x1, int16_t y1, int16_t x2,
{
size_t dots = (x2 - x1 + 1) * (y2 - y1 + 1);//点数量
luat_color_t* line_buf = (luat_color_t*) luat_heap_malloc(dots * sizeof(luat_color_t));
tmp = color_swap(color);// 颜色swap
if (line_buf) {
for (i = 0; i < dots; i++)
@@ -107,7 +107,7 @@ typedef struct luat_lcd_conf {
luat_spi_device_t* lcd_spi_device;
int lcd_spi_ref;
int lcd_use_lvgl;
- int lcd_rgb_swap;
+ int endianness_swap;
void* userdata;
u8g2_t luat_lcd_u8g2 ;
} luat_lcd_conf_t;
@@ -10,6 +10,7 @@ static const uint16_t gc9106l_init_cmds[] = {
0x02EF,
0x02B3,0x0303,
0x0221,
+ // 0x0236,0x03C0,
0x023A,0x0305,
0x02B4,0x0321,
0x02F0,0x032D,0x0354,0x0324,0x0361,0x03AB,0x032E,0x032F,0x0300,0x0320,0x0310,0x0310,0x0317,0x0313,0x030F,
@@ -26,5 +27,5 @@ luat_lcd_opts_t lcd_opts_gc9106l = {
.direction0 = 0xC8,
.direction90 = 0x08,
.direction180 = 0x68,
- .direction270 = 0xA8
+ .direction270 = 0xA8,
};
@@ -51,7 +51,6 @@ luat_lcd_opts_t lcd_opts_jd9261t_inited = {
.direction90 = 0x00,
.direction180 = 0x03,
.direction270 = 0x03,
- .rb_swap = 1,
.no_ram_mode = 1,
.user_ctrl_init = jd9261t_inited_init,
@@ -29,6 +29,5 @@ luat_lcd_opts_t lcd_opts_nv3037 = {
.direction90 = 0xC0,
.direction180 = 0x70,
.direction270 = 0xA0,
@@ -33,6 +33,5 @@ luat_lcd_opts_t lcd_opts_st7735 = {
.direction90 = 0x70,
.direction180 = 0x00,
@@ -41,5 +41,4 @@ luat_lcd_opts_t lcd_opts_st7789 = {
@@ -170,6 +170,7 @@ static int l_lcd_init(lua_State* L) {
LLOGD("ic support: %s",tp);
if (lua_gettop(L) > 1) {
conf->opts = (struct luat_lcd_opts *)lcd_regs[s_index].lcd_opts;
+ conf->opts->rb_swap = 1;
lua_settop(L, 2); // 丢弃多余的参数
lua_pushstring(L, "port");
@@ -196,13 +197,19 @@ static int l_lcd_init(lua_State* L) {
goto end;
if (conf->port < LUAT_LCD_HW_ID_0 || conf->port == LUAT_LCD_SPI_DEVICE){
- conf->lcd_rgb_swap = 1;
+ conf->endianness_swap = 1;
lua_pop(L, 1);
- lua_pushstring(L, "swap");
+ lua_pushstring(L, "endianness_swap");
if (LUA_TBOOLEAN == lua_gettable(L, 2)) {
- conf->lcd_rgb_swap = lua_toboolean(L, -1);
+ conf->endianness_swap = lua_toboolean(L, -1);
+ }
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "rb_swap");
+ if (LUA_TBOOLEAN == lua_gettable(L, 2)) {
+ conf->opts->rb_swap = lua_toboolean(L, -1);
@@ -66,7 +66,7 @@ static int lcd_out_func (JDEC* jd, void* bitmap, JRECT* rect){
// rgb高低位swap
uint16_t count = (rect->right - rect->left + 1) * (rect->bottom - rect->top + 1);
for (size_t i = 0; i < count; i++){
- if (lcd_dft_conf->lcd_rgb_swap)
+ if (lcd_dft_conf->endianness_swap)
dev->buff[i] = ((tmp[i] >> 8) & 0xFF)+ ((tmp[i] << 8) & 0xFF00);
else
dev->buff[i] = tmp[i];