فهرست منبع

add:gtfont绘制函数添加颜色参数,同lcd的绘制参数

Dozingfiretruck 2 سال پیش
والد
کامیت
81279b5734
2فایلهای تغییر یافته به همراه17 افزوده شده و 4 حذف شده
  1. 8 3
      components/gtfont/luat_lib_gtfont.c
  2. 9 1
      components/lcd/luat_lib_lcd.c

+ 8 - 3
components/gtfont/luat_lib_gtfont.c

@@ -17,7 +17,12 @@
 #define LUAT_LOG_TAG "gt"
 #include "luat_log.h"
 
-extern luat_color_t BACK_COLOR , FORE_COLOR;
+#ifdef LUAT_USE_LCD
+extern luat_color_t lcd_str_fg_color,lcd_str_bg_color;
+#else
+luat_color_t lcd_str_fg_color  = WHITE ,lcd_str_bg_color  = BLACK ;
+#endif
+
 extern luat_spi_device_t* gt_spi_dev;
 
 //横置横排显示
@@ -32,11 +37,11 @@ void gtfont_draw_w(unsigned char *pBits,unsigned int x,unsigned int y,unsigned i
 			for(k = 0;k < 8;k++){
 				if(((temp << k)& 0x80) == 0 ){
 					/* 显示一个像素点 */
-					if (mode == 0)point((luat_lcd_conf_t *)userdata, x+k+(j*8), y+i, BACK_COLOR);
+					if (mode == 0)point((luat_lcd_conf_t *)userdata, x+k+(j*8), y+i, lcd_str_bg_color);
 					else if (mode == 1)point((Paint *)userdata, x+k+(j*8), y+i, 0xFFFF);
 				}else{
 					/* 显示一个像素点 */
-					if (mode == 0)point((luat_lcd_conf_t *)userdata, x+k+(j*8), y+i, FORE_COLOR);
+					if (mode == 0)point((luat_lcd_conf_t *)userdata, x+k+(j*8), y+i, lcd_str_fg_color);
 					else if (mode == 1)point((Paint *)userdata, x+k+(j*8), y+i, 0x0000);
 					else if (mode == 2)point((u8g2_t *)userdata, x+k+(j*8), y+i, 0x0000);
 				}

+ 9 - 1
components/lcd/luat_lib_lcd.c

@@ -72,7 +72,7 @@ static void lcd_auto_flush(luat_lcd_conf_t *conf) {
   luat_lcd_flush(conf);
 }
 
-static luat_color_t lcd_str_fg_color,lcd_str_bg_color;
+luat_color_t lcd_str_fg_color,lcd_str_bg_color;
 /*
 lcd显示屏初始化
 @api lcd.init(tp, args)
@@ -960,6 +960,8 @@ static int l_lcd_draw_gtfont_gb2312(lua_State *L) {
   unsigned char size = luaL_checkinteger(L, 2);
 	int x = luaL_checkinteger(L, 3);
 	int y = luaL_checkinteger(L, 4);
+  lcd_str_fg_color = (luat_color_t)luaL_optinteger(L, 5,FORE_COLOR);
+  lcd_str_bg_color = (luat_color_t)luaL_optinteger(L, 6,BACK_COLOR);
 	while ( i < len){
 		strhigh = *fontCode;
 		fontCode++;
@@ -1002,6 +1004,8 @@ static int l_lcd_draw_gtfont_gb2312_gray(lua_State* L) {
 	unsigned char font_g = luaL_checkinteger(L, 3);
 	int x = luaL_checkinteger(L, 4);
 	int y = luaL_checkinteger(L, 5);
+  lcd_str_fg_color = (luat_color_t)luaL_optinteger(L, 6,FORE_COLOR);
+  lcd_str_bg_color = (luat_color_t)luaL_optinteger(L, 7,BACK_COLOR);
 	while ( i < len){
 		strhigh = *fontCode;
 		fontCode++;
@@ -1045,6 +1049,8 @@ static int l_lcd_draw_gtfont_utf8(lua_State *L) {
     unsigned char size = luaL_checkinteger(L, 2);
     int x = luaL_checkinteger(L, 3);
     int y = luaL_checkinteger(L, 4);
+    lcd_str_fg_color = (luat_color_t)luaL_optinteger(L, 5,FORE_COLOR);
+    lcd_str_bg_color = (luat_color_t)luaL_optinteger(L, 6,BACK_COLOR);
     for(;;){
       e = utf8_next((uint8_t)*fontCode);
       if ( e == 0x0ffff )
@@ -1087,6 +1093,8 @@ static int l_lcd_draw_gtfont_utf8_gray(lua_State* L) {
 	unsigned char font_g = luaL_checkinteger(L, 3);
 	int x = luaL_checkinteger(L, 4);
 	int y = luaL_checkinteger(L, 5);
+  lcd_str_fg_color = (luat_color_t)luaL_optinteger(L, 6,FORE_COLOR);
+  lcd_str_bg_color = (luat_color_t)luaL_optinteger(L, 7,BACK_COLOR);
 	for(;;){
         e = utf8_next((uint8_t)*fontCode);
         if ( e == 0x0ffff )