From 0b094070fe09e58c402b582f38b94153be6cd972 Mon Sep 17 00:00:00 2001 From: suku Date: Thu, 30 Jan 2025 17:35:18 +0100 Subject: [PATCH 1/7] SUKU self:draw_pixel implemented --- grid_common/grid_protocol.h | 5 +++ grid_common/grid_ui_lcd.c | 3 ++ grid_common/grid_ui_lcd.h | 32 +++++++++++++++++++ .../grid_esp32_lcd/grid_lua_api_gui.c | 31 ++++++++++++++++++ .../grid_esp32_lcd/grid_lua_api_gui.h | 1 + 5 files changed, 72 insertions(+) diff --git a/grid_common/grid_protocol.h b/grid_common/grid_protocol.h index a66b79f8..f48f8cf9 100644 --- a/grid_common/grid_protocol.h +++ b/grid_common/grid_protocol.h @@ -408,6 +408,11 @@ #define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_fnptr l_grid_gui_draw_pixel #define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_usage "grid_gui_draw_pixel(x, y, {r, g, b}) Draws a pixel at (x, y) with the specified 8-bit color channels." +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_short "ggdp2" +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_human "gui_draw_pixel2" +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_fnptr l_grid_gui_draw_pixel2 +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_usage "grid_gui_draw_pixel(screen_index, x, y, {r, g, b}) Draws a pixel at (x, y) with the specified 8-bit color channels." + #define GRID_LUA_FNC_G_GUI_DRAW_LINE_short "ggdl" #define GRID_LUA_FNC_G_GUI_DRAW_LINE_human "gui_draw_line" #define GRID_LUA_FNC_G_GUI_DRAW_LINE_fnptr l_grid_gui_draw_line diff --git a/grid_common/grid_ui_lcd.c b/grid_common/grid_ui_lcd.c index 439f6b44..48e54bb8 100644 --- a/grid_common/grid_ui_lcd.c +++ b/grid_common/grid_ui_lcd.c @@ -38,4 +38,7 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* int32_t* template_parameter_list = buf->template_parameter_list; template_parameter_list[GRID_LUA_FNC_L_ELEMENT_INDEX_index] = element_index; + template_parameter_list[GRID_LUA_FNC_L_SCREEN_INDEX_index] = element_index % 2; // TODO:implement proper logic here + template_parameter_list[GRID_LUA_FNC_L_SCREEN_WIDTH_index] = 320; + template_parameter_list[GRID_LUA_FNC_L_SCREEN_HEIGHT_index] = 240; } diff --git a/grid_common/grid_ui_lcd.h b/grid_common/grid_ui_lcd.h index e1bb4d90..4bc8247d 100644 --- a/grid_common/grid_ui_lcd.h +++ b/grid_common/grid_ui_lcd.h @@ -15,6 +15,24 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* #define GRID_LUA_FNC_L_ELEMENT_INDEX_short "ind" #define GRID_LUA_FNC_L_ELEMENT_INDEX_human "element_index" +#define GRID_LUA_FNC_L_SCREEN_INDEX_index 1 +#define GRID_LUA_FNC_L_SCREEN_INDEX_helper "1" +#define GRID_LUA_FNC_L_SCREEN_INDEX_short "lin" +#define GRID_LUA_FNC_L_SCREEN_INDEX_human "screen_index" + +#define GRID_LUA_FNC_L_SCREEN_WIDTH_index 2 +#define GRID_LUA_FNC_L_SCREEN_WIDTH_helper "2" +#define GRID_LUA_FNC_L_SCREEN_WIDTH_short "lsw" +#define GRID_LUA_FNC_L_SCREEN_WIDTH_human "screen_width" + +#define GRID_LUA_FNC_L_SCREEN_HEIGHT_index 3 +#define GRID_LUA_FNC_L_SCREEN_HEIGHT_helper "3" +#define GRID_LUA_FNC_L_SCREEN_HEIGHT_short "lsh" +#define GRID_LUA_FNC_L_SCREEN_HEIGHT_human "screen_height" + +#define GRID_LUA_FNC_L_DRAW_PIXEL_short "ldp" +#define GRID_LUA_FNC_L_DRAW_PIXEL_human "draw_pixel" + #define GRID_LUA_FNC_L_LIST_length 1 // LCD init function @@ -23,9 +41,23 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* \ " GRID_LUA_FNC_L_ELEMENT_INDEX_short "=function (self,a) return " \ "gtv(self.index, " GRID_LUA_FNC_L_ELEMENT_INDEX_helper ", a) end, \ + " GRID_LUA_FNC_L_SCREEN_INDEX_short "=function (self,a) return " \ + "gtv(self.index, " GRID_LUA_FNC_L_SCREEN_INDEX_helper ", a) end, \ + " GRID_LUA_FNC_L_SCREEN_WIDTH_short "=function (self,a) return " \ + "gtv(self.index, " GRID_LUA_FNC_L_SCREEN_WIDTH_helper ", a) end, \ + " GRID_LUA_FNC_L_SCREEN_HEIGHT_short "=function (self,a) return " \ + "gtv(self.index, " GRID_LUA_FNC_L_SCREEN_HEIGHT_helper ", a) end, \ \ " GRID_LUA_FNC_A_INIT_short " = function (self) print('undefined action') end, \ \ + \ + " GRID_LUA_FNC_L_DRAW_PIXEL_short " =function (self, ...) " \ + "local screen_index = " \ + "self" \ + ":" GRID_LUA_FNC_L_SCREEN_INDEX_short "() " \ + "print('screen_index: ', screen_index) " GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_short "(screen_indexm ...)" \ + "end, \ + \ gtt = function (self,a) " GRID_LUA_FNC_G_TIMER_START_short "(self.index,a) end,\ gtp = function (self) " GRID_LUA_FNC_G_TIMER_STOP_short "(self.index) end,\ get = function (self,a) " GRID_LUA_FNC_G_EVENT_TRIGGER_short "(self.index,a) end\ diff --git a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c index d866be9e..ff03acaa 100644 --- a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c +++ b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c @@ -47,6 +47,37 @@ void grid_gui_lua_draw_demo(lua_State* L, uint8_t loopcounter) { // grid_gui_draw_polygon_filled(gui, x_points, y_points, num_points, color); } +int l_grid_gui_draw_pixel2(lua_State* L) { + + // grid_platform_printf("TEST GUI: l_grid_gui_draw_pixel\r\n"); + + int screen_index = luaL_checknumber(L, 1); + + int x = luaL_checknumber(L, 2); + int y = luaL_checknumber(L, 3); + // Optional color parameter + if (lua_gettop(L) >= 4) { + luaL_checktype(L, 4, LUA_TTABLE); + lua_rawgeti(L, 4, 1); + int r = luaL_checknumber(L, -1); + lua_rawgeti(L, 4, 2); + int g = luaL_checknumber(L, -1); + lua_rawgeti(L, 4, 3); + int b = luaL_checknumber(L, -1); + // Use r, g, b values to set color + // grid_platform_printf("Received color: R=%d, G=%d, B=%d\n", r, g, b); + + // use select the screen using the proper grid_gui_state + if (screen_index == 0) { + grid_gui_draw_pixel(&grid_gui_state, x, y, grid_gui_color_from_rgb(r, g, b)); + + } else { + grid_gui_draw_pixel(&grid_gui_state, x, y, grid_gui_color_from_rgb(r, g, b)); + } + } + return 0; +} + int l_grid_gui_draw_pixel(lua_State* L) { // grid_platform_printf("TEST GUI: l_grid_gui_draw_pixel\r\n"); diff --git a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.h b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.h index 15aff3b5..12ebcedb 100644 --- a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.h +++ b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.h @@ -6,6 +6,7 @@ void grid_gui_lua_draw_demo(lua_State* L, uint8_t loopcounter); +int l_grid_gui_draw_pixel2(lua_State* L); int l_grid_gui_draw_pixel(lua_State* L); int l_grid_gui_draw_line(lua_State* L); int l_grid_gui_draw_rectangle(lua_State* L); From 2aabead01c884f339aad3df14620529c0bab9cbf Mon Sep 17 00:00:00 2001 From: suku Date: Thu, 30 Jan 2025 17:39:04 +0100 Subject: [PATCH 2/7] SUKU list lenght fixed --- grid_common/grid_ui_lcd.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grid_common/grid_ui_lcd.h b/grid_common/grid_ui_lcd.h index 4bc8247d..0e4a4a3c 100644 --- a/grid_common/grid_ui_lcd.h +++ b/grid_common/grid_ui_lcd.h @@ -30,10 +30,11 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* #define GRID_LUA_FNC_L_SCREEN_HEIGHT_short "lsh" #define GRID_LUA_FNC_L_SCREEN_HEIGHT_human "screen_height" +#define GRID_LUA_FNC_L_LIST_length 4 + #define GRID_LUA_FNC_L_DRAW_PIXEL_short "ldp" #define GRID_LUA_FNC_L_DRAW_PIXEL_human "draw_pixel" -#define GRID_LUA_FNC_L_LIST_length 1 // LCD init function #define GRID_LUA_L_META_init \ From 744ce96bf1a802802b20e87fd685d7bcba309d2f Mon Sep 17 00:00:00 2001 From: suku Date: Thu, 30 Jan 2025 17:58:49 +0100 Subject: [PATCH 3/7] SUKU problem --- grid_esp/main/grid_fw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grid_esp/main/grid_fw.c b/grid_esp/main/grid_fw.c index 941964aa..ff5c4cd8 100644 --- a/grid_esp/main/grid_fw.c +++ b/grid_esp/main/grid_fw.c @@ -142,6 +142,7 @@ char grid_doublebuffer_rx_memory_array[2][GRID_DOUBLE_BUFFER_RX_SIZE] = {0}; #include "grid_lua_api_gui.h" #include "grid_ui_lcd.h" +// TODO: LCD META IS NEVER USED void grid_lua_ui_init_tek1(struct grid_lua_model* lua) { // define encoder_init_function From 814e5c035a701fee0572ffa08fc65eac0872ff02 Mon Sep 17 00:00:00 2001 From: suku Date: Thu, 30 Jan 2025 21:23:40 +0100 Subject: [PATCH 4/7] SUKU tek1 lcd meta initialization fixed --- grid_common/grid_ui_lcd.h | 1 - grid_esp/main/grid_fw.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/grid_common/grid_ui_lcd.h b/grid_common/grid_ui_lcd.h index 0e4a4a3c..78554869 100644 --- a/grid_common/grid_ui_lcd.h +++ b/grid_common/grid_ui_lcd.h @@ -35,7 +35,6 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* #define GRID_LUA_FNC_L_DRAW_PIXEL_short "ldp" #define GRID_LUA_FNC_L_DRAW_PIXEL_human "draw_pixel" - // LCD init function #define GRID_LUA_L_META_init \ "lcd_meta = { __index = { \ diff --git a/grid_esp/main/grid_fw.c b/grid_esp/main/grid_fw.c index ff5c4cd8..c20ab072 100644 --- a/grid_esp/main/grid_fw.c +++ b/grid_esp/main/grid_fw.c @@ -142,7 +142,6 @@ char grid_doublebuffer_rx_memory_array[2][GRID_DOUBLE_BUFFER_RX_SIZE] = {0}; #include "grid_lua_api_gui.h" #include "grid_ui_lcd.h" -// TODO: LCD META IS NEVER USED void grid_lua_ui_init_tek1(struct grid_lua_model* lua) { // define encoder_init_function @@ -168,7 +167,7 @@ void grid_lua_ui_init_tek1(struct grid_lua_model* lua) { grid_lua_dostring(lua, "for i=9, 12 do setmetatable(" GRID_LUA_KW_ELEMENT_short "[i], button_meta) end"); grid_lua_dostring(lua, "for i=13, 13 do " GRID_LUA_KW_ELEMENT_short "[i] = {index = i} end"); - grid_lua_dostring(lua, "for i=13, 13 do setmetatable(" GRID_LUA_KW_ELEMENT_short "[i], endless_meta) end"); + grid_lua_dostring(lua, "for i=13, 13 do setmetatable(" GRID_LUA_KW_ELEMENT_short "[i], lcd_meta) end"); grid_lua_gc_try_collect(lua); From a8340abf5f9dd40ea6fba2f6b5bef046ab0bef23 Mon Sep 17 00:00:00 2001 From: suku Date: Fri, 31 Jan 2025 11:37:23 +0100 Subject: [PATCH 5/7] SUKU draw pixel short code fixed --- grid_common/grid_protocol.h | 9 ++---- grid_common/grid_ui_lcd.h | 2 +- .../grid_esp32_lcd/grid_lua_api_gui.c | 30 ++----------------- 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/grid_common/grid_protocol.h b/grid_common/grid_protocol.h index f48f8cf9..a4ae749f 100644 --- a/grid_common/grid_protocol.h +++ b/grid_common/grid_protocol.h @@ -403,15 +403,10 @@ #define GRID_LUA_FNC_G_POTMETER_CALIBRATION_SET_fnptr l_grid_potmeter_calibration_set #define GRID_LUA_FNC_G_POTMETER_CALIBRATION_SET_usage "potmeter_calibration_set({ int c1, ... }) Sets potentiometer calibration centers from an array of integers." -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_short "ggdp" +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_short "ggdpx" #define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_human "gui_draw_pixel" #define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_fnptr l_grid_gui_draw_pixel -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_usage "grid_gui_draw_pixel(x, y, {r, g, b}) Draws a pixel at (x, y) with the specified 8-bit color channels." - -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_short "ggdp2" -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_human "gui_draw_pixel2" -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_fnptr l_grid_gui_draw_pixel2 -#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_usage "grid_gui_draw_pixel(screen_index, x, y, {r, g, b}) Draws a pixel at (x, y) with the specified 8-bit color channels." +#define GRID_LUA_FNC_G_GUI_DRAW_PIXEL_usage "grid_gui_draw_pixel(screen_index, x, y, {r, g, b}) Draws a pixel at (x, y) with the specified 8-bit color channels." #define GRID_LUA_FNC_G_GUI_DRAW_LINE_short "ggdl" #define GRID_LUA_FNC_G_GUI_DRAW_LINE_human "gui_draw_line" diff --git a/grid_common/grid_ui_lcd.h b/grid_common/grid_ui_lcd.h index 78554869..c9cf53a4 100644 --- a/grid_common/grid_ui_lcd.h +++ b/grid_common/grid_ui_lcd.h @@ -55,7 +55,7 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* "local screen_index = " \ "self" \ ":" GRID_LUA_FNC_L_SCREEN_INDEX_short "() " \ - "print('screen_index: ', screen_index) " GRID_LUA_FNC_G_GUI_DRAW_PIXEL2_short "(screen_indexm ...)" \ + "print('screen_index: ', screen_index) " GRID_LUA_FNC_G_GUI_DRAW_PIXEL_short "(screen_index, ...)" \ "end, \ \ gtt = function (self,a) " GRID_LUA_FNC_G_TIMER_START_short "(self.index,a) end,\ diff --git a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c index ff03acaa..55e5a0c4 100644 --- a/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c +++ b/grid_esp/components/grid_esp32_lcd/grid_lua_api_gui.c @@ -47,7 +47,7 @@ void grid_gui_lua_draw_demo(lua_State* L, uint8_t loopcounter) { // grid_gui_draw_polygon_filled(gui, x_points, y_points, num_points, color); } -int l_grid_gui_draw_pixel2(lua_State* L) { +int l_grid_gui_draw_pixel(lua_State* L) { // grid_platform_printf("TEST GUI: l_grid_gui_draw_pixel\r\n"); @@ -67,7 +67,7 @@ int l_grid_gui_draw_pixel2(lua_State* L) { // Use r, g, b values to set color // grid_platform_printf("Received color: R=%d, G=%d, B=%d\n", r, g, b); - // use select the screen using the proper grid_gui_state + // TODO: select the screen using the proper grid_gui_state if (screen_index == 0) { grid_gui_draw_pixel(&grid_gui_state, x, y, grid_gui_color_from_rgb(r, g, b)); @@ -78,32 +78,6 @@ int l_grid_gui_draw_pixel2(lua_State* L) { return 0; } -int l_grid_gui_draw_pixel(lua_State* L) { - - // grid_platform_printf("TEST GUI: l_grid_gui_draw_pixel\r\n"); - - int x = luaL_checknumber(L, 1); - int y = luaL_checknumber(L, 2); - // Optional color parameter - if (lua_gettop(L) >= 3) { - luaL_checktype(L, 3, LUA_TTABLE); - lua_rawgeti(L, 3, 1); - int r = luaL_checknumber(L, -1); - lua_rawgeti(L, 3, 2); - int g = luaL_checknumber(L, -1); - lua_rawgeti(L, 3, 3); - int b = luaL_checknumber(L, -1); - // Use r, g, b values to set color - // grid_platform_printf("Received color: R=%d, G=%d, B=%d\n", r, g, b); - - grid_gui_draw_pixel(&grid_gui_state, x, y, grid_gui_color_from_rgb(r, g, b)); - } - // Draw the pixel at (x, y) - - // Draw the line from (x1, y1) to (x2, y2) with optional color - return 0; -} - int l_grid_gui_draw_line(lua_State* L) { // grid_platform_printf("TEST GUI: l_grid_gui_draw_pixel\r\n"); From b0936679d6ad75aa7bfb3af2bf5f6ef7511b8c18 Mon Sep 17 00:00:00 2001 From: suku Date: Fri, 31 Jan 2025 11:53:35 +0100 Subject: [PATCH 6/7] SUKU encoder led member function added --- grid_common/grid_ui_encoder.h | 7 +++++++ grid_common/grid_ui_lcd.h | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/grid_common/grid_ui_encoder.h b/grid_common/grid_ui_encoder.h index 684c0b8b..cb7f900d 100644 --- a/grid_common/grid_ui_encoder.h +++ b/grid_common/grid_ui_encoder.h @@ -120,6 +120,9 @@ void grid_ui_encoder_store_input(struct grid_ui_encoder_state* state, uint8_t in #define GRID_LUA_FNC_E_BUTTON_STEP_short "bstp" #define GRID_LUA_FNC_E_BUTTON_STEP_human "button_step" +#define GRID_LUA_FNC_E_LED_COLOR_short "elc" +#define GRID_LUA_FNC_E_LED_COLOR_human "led_color" + // Encoder parameters #define GRID_LUA_FNC_E_LIST_length 17 @@ -171,6 +174,10 @@ void grid_ui_encoder_store_input(struct grid_ui_encoder_state* state, uint8_t in "return value // ((max - min) // steps) " \ "end, \ \ + " GRID_LUA_FNC_E_LED_COLOR_short " =function (self, ...) " \ + "" GRID_LUA_FNC_G_LED_COLOR_short "(self:" GRID_LUA_FNC_E_ELEMENT_INDEX_short "(), ...) " \ + "end, \ + \ " GRID_LUA_FNC_A_INIT_short " = function (self) print('undefined action') end,\ " GRID_LUA_FNC_A_ENCODER_short " = function (self) print('undefined action') end,\ " GRID_LUA_FNC_A_BUTTON_short " = function (self) print('undefined action') end,\ diff --git a/grid_common/grid_ui_lcd.h b/grid_common/grid_ui_lcd.h index c9cf53a4..51842666 100644 --- a/grid_common/grid_ui_lcd.h +++ b/grid_common/grid_ui_lcd.h @@ -52,9 +52,7 @@ void grid_ui_element_lcd_template_parameter_init(struct grid_ui_template_buffer* \ \ " GRID_LUA_FNC_L_DRAW_PIXEL_short " =function (self, ...) " \ - "local screen_index = " \ - "self" \ - ":" GRID_LUA_FNC_L_SCREEN_INDEX_short "() " \ + "local screen_index = self:" GRID_LUA_FNC_L_SCREEN_INDEX_short "() " \ "print('screen_index: ', screen_index) " GRID_LUA_FNC_G_GUI_DRAW_PIXEL_short "(screen_index, ...)" \ "end, \ \ From 25447efd410f03879fb7384bc3286be68c6f4c7e Mon Sep 17 00:00:00 2001 From: suku Date: Fri, 31 Jan 2025 12:36:00 +0100 Subject: [PATCH 7/7] SUKU double upload fixed --- .github/workflows/codeql_intech.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/codeql_intech.yml b/.github/workflows/codeql_intech.yml index 5fa8a61b..4b1997fe 100644 --- a/.github/workflows/codeql_intech.yml +++ b/.github/workflows/codeql_intech.yml @@ -108,13 +108,6 @@ jobs: cp codeql-db/codeql-sarif codeql-sarif cat codeql-sarif - # Upload CodeQL results as an artifact - - name: Upload CodeQL results - uses: actions/upload-artifact@v4 - with: - name: codeql-results - path: codeql-sarif - - name: Upload CodeQL results to code scanning uses: github/codeql-action/upload-sarif@v2 with: