From 355e245fd47f6f71554702bd121926ef1053a4f5 Mon Sep 17 00:00:00 2001 From: KP <42572567+kpatel122@users.noreply.github.com> Date: Sun, 17 Sep 2023 14:12:03 +0100 Subject: [PATCH 1/3] Fixed language bug that shows 'Text' for all labels. Added English comments -Fixed Language bug that would show 'Text' for all labels. Default language is set to English -Added English translated comments next to Chinese --- Firmware/Grbl_Esp32/src/Grbl.cpp | 6 +++- .../Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp | 36 +++++++++---------- Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp | 6 ++-- .../Grbl_Esp32/src/mks/MKS_draw_language.cpp | 7 ++-- .../Grbl_Esp32/src/mks/MKS_draw_language.h | 27 +++++++------- Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp | 7 ++-- .../Grbl_Esp32/src/mks/MKS_draw_print.cpp | 4 +-- .../Grbl_Esp32/src/mks/MKS_draw_ready.cpp | 7 ++-- Firmware/Grbl_Esp32/src/mks/language_en.h | 12 +++---- 9 files changed, 61 insertions(+), 51 deletions(-) diff --git a/Firmware/Grbl_Esp32/src/Grbl.cpp b/Firmware/Grbl_Esp32/src/Grbl.cpp index 85b2e1c..5939d43 100644 --- a/Firmware/Grbl_Esp32/src/Grbl.cpp +++ b/Firmware/Grbl_Esp32/src/Grbl.cpp @@ -26,6 +26,7 @@ #include "mks/MKS_draw_ready.h" #include "mks/MKS_ctrl.h" #include "mks/MKS_SDCard.h" +#include "mks/MKS_draw_language.h" void grbl_init() { @@ -123,8 +124,11 @@ void _mc_task_init(void) { tft_TS35_init(); test_cfg_find_init(); disp_task_init(); -} + //set default language to english (0:Simple Chinese, 1:English 2:Deutsch ) + set_language(1); + set_language_btn_style(1); +} static void reset_variables() { // Reset system variables. diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp index a6dac87..d93d996 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp @@ -5,7 +5,7 @@ #define DISP_TASK_CORE 1 #define FRAME_TASK_STACK 4096*2 -#define FRAME_TASK_PRO 3 // 尝试巡边的线程与lvgl线程同优先级 +#define FRAME_TASK_PRO 3 // 尝试巡边的线程与lvgl线程同优先级 The thread trying to patrol the edge has the same priority as the lvgl thread #define FRAME_TASK_CORE 1 TaskHandle_t lv_disp_tcb = NULL; @@ -31,7 +31,7 @@ IRAM_ATTR void lvgl_disp_task(void *parg) { mks_draw_logo(); - // 创建二值量 + // 创建二值量 Create a binary quantity is_fram_need = xSemaphoreCreateBinary(); frame_task_init(); mks_grbl.wifi_connect_enable = true; @@ -66,7 +66,7 @@ IRAM_ATTR void lvgl_disp_task(void *parg) { } #if defined(USE_DelayUntil) - vTaskDelayUntil(&xLastWakeTime, xDisplayFrequency); //使用相对延时,保证时间精准 + vTaskDelayUntil(&xLastWakeTime, xDisplayFrequency); //使用相对延时,保证时间精准 Use relative delay to ensure accurate time #else vTaskDelay(5); // 5ms 绝对延时 #endif @@ -86,14 +86,14 @@ static void mks_page_data_updata(void) { draw_testing(); } } - else if (mks_ui_page.mks_ui_page == MKS_UI_Ready) { //只有在当前页面才更新数据 + else if (mks_ui_page.mks_ui_page == MKS_UI_Ready) { //只有在当前页面才更新数据 Only update data on the current page if((count_updata == 20) || (count_updata > 20) ) { // 20*5=100ms if(SD_ready_next == false) ready_data_updata(); count_updata = 0; } } - else if(mks_ui_page.mks_ui_page == MKS_UI_Pring) { // 雕刻界面更新数据 + else if(mks_ui_page.mks_ui_page == MKS_UI_Pring) { // 雕刻界面更新数据 Engraving interface update data if((count_updata == 200) || (count_updata > 200) ) { // 200*5=1000ms = 1s @@ -103,14 +103,14 @@ static void mks_page_data_updata(void) { count_updata = 0; } } - else if(mks_ui_page.mks_ui_page == MKS_UI_inFile) { // 雕刻界面更新数据 + else if(mks_ui_page.mks_ui_page == MKS_UI_inFile) { // 雕刻界面更新数据 Engraving interface update data if((count_updata == 200) || (count_updata > 200) ) { // 200*5=1000ms = 1s move_pos_update(); probe_check(); } } - else if(mks_ui_page.mks_ui_page == MKS_UI_Control) { //控制界面 + else if(mks_ui_page.mks_ui_page == MKS_UI_Control) { //控制界面 control interface if((count_updata == 20) || (count_updata > 20) ) { // 20*5=100ms = 1s hard_home_check(); @@ -151,8 +151,8 @@ static void mks_page_data_updata(void) { mks_draw_wifi_show(); mks_wifi.wifi_scanf_status = wifi_none; }else if(mks_wifi.wifi_scanf_status == wifi_connecting) { - if(mks_grbl.wifi_connect_status == true) { // 正在连接状态 - if(mks_get_wifi_status() == true) { // 确认连接上 + if(mks_grbl.wifi_connect_status == true) { // 正在连接状态 Connecting status + if(mks_get_wifi_status() == true) { // 确认连接上 Confirm connection mks_lv_clean_ui(); mks_draw_wifi(); mks_wifi.wifi_scanf_status = wifi_none; @@ -166,8 +166,8 @@ static void mks_page_data_updata(void) { } else if(mks_wifi.wifi_scanf_status == wifi_disconnecting) { - if(mks_get_wifi_status() == false) { // 确认断开 - mks_wifi.wifi_scanf_status = wifi_scanf_begin; // 重新扫描 + if(mks_get_wifi_status() == false) { // 确认断开 Confirm disconnection + mks_wifi.wifi_scanf_status = wifi_scanf_begin; // 重新扫描 Rescan mks_lv_clean_ui(); mks_draw_wifi(); } @@ -180,13 +180,13 @@ static void mks_page_data_updata(void) { mks_cfg_find(); } else if(mks_updata.updata_flag == UD_UPDATA_FINSH) { - // 更新完成弹窗 + // 更新完成弹窗 Update completed pop-up window mks_draw_common_pupup_info("Info", "Update succeed", "Please restart!"); mks_cfg_rename(CFG_FILE_PATG2); mks_updata.updata_flag = UD_NONE; } else if(mks_updata.updata_flag == UD_UPDATA_FAIL) { - // 更新失败弹窗 + // 更新失败弹窗 Update failed pop-up window mks_draw_common_pupup_info("Error", "Update Fail", "Please Check mkscfg.txt or sdcard"); mks_updata.updata_flag = UD_NONE; } @@ -214,7 +214,7 @@ IRAM_ATTR void disp_task_init(void) { IRAM_ATTR void frame_task(void *parg) { grbl_send(CLIENT_SERIAL,"Creat frame task succeed\n"); - // 定义一个信号量返回值 + // 定义一个信号量返回值 Define a semaphore return value BaseType_t sem_receive = pdPASS; while(1) { @@ -222,11 +222,11 @@ IRAM_ATTR void frame_task(void *parg) { sem_receive = xSemaphoreTake(is_fram_need, portMAX_DELAY); if(sem_receive == pdTRUE) { - // 触发信号量 + // 触发信号量 trigger semaphore grbl_send(CLIENT_SERIAL,"receive sem succeed\n"); - vTaskSuspend(lv_disp_tcb); // 挂起任务da + vTaskSuspend(lv_disp_tcb); // 挂起任务da pending tasks mks_run_frame(frame_ctrl.file_name); - vTaskResume(lv_disp_tcb); // 恢复任务 + vTaskResume(lv_disp_tcb); // 恢复任务 recovery task } } } @@ -245,7 +245,7 @@ IRAM_ATTR void frame_task_init(void ) { ); } -/*-------------------------------------------测试模式----------------------------------------------*/ +/*-------------------------------------------测试模式 test mode ----------------------------------------------*/ #define TEST_CODE_TASK_STACK 4096 #define TEST_CODE_TASK_PRO 3 diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp index bab393c..28254b0 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp @@ -119,9 +119,9 @@ void mks_grbl_parg_init(void) { mks_grbl.mks_sd_status = 0; mks_grbl.wifi_back_from = 0; mks_grbl.is_need_ref_sd_file = true; - mks_ui_page.mks_ui_page = MKS_UI_Ready; // 开机进入主页的标记 - mks_ui_page.wait_count = DEFAULT_UI_COUNT; // 允许10个周期的等待lvgl数据缓冲 - mks_grbl.carve_times = 0; // 雕刻次数 + mks_ui_page.mks_ui_page = MKS_UI_Ready; // 开机进入主页的标记 Mark to enter the home page after booting + mks_ui_page.wait_count = DEFAULT_UI_COUNT; // 允许10个周期的等待lvgl数据缓冲 Allow 10 cycles to wait for lvgl data buffer + mks_grbl.carve_times = 0; // 雕刻次数 Number of engravings #if defined(ENABLE_WIFI) mks_wifi.wifi_show_page = 1; mks_wifi.wifi_scanf_status = wifi_none; diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.cpp index 2a6bd2e..926f5b7 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.cpp @@ -5,11 +5,11 @@ LANGUAGE_PAGE_T language_page; void mc_language_init(void) { - if(mks_grbl.language = SimpleChinese) { + if(mks_grbl.language == SimpleChinese) { } - else if(mks_grbl.language = English) { + else if(mks_grbl.language == English) { mc_language.back = BACK_EN; mc_language.yes = YES_EN; mc_language.no = NO_EN; @@ -76,7 +76,8 @@ static uint8_t get_event(lv_obj_t* obj) { * 2------de * 3... */ -static void set_language(uint8_t language) { +//static void set_language(uint8_t language) { +void set_language(uint8_t language) { switch(language) { diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h index 4076ae5..ad30b3d 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h @@ -8,14 +8,14 @@ typedef struct { lv_obj_t *imgbtn_back; - lv_obj_t *imgbtn_simple_cn; // 简体中文 - lv_obj_t *imgbtn_en; // 英语 - lv_obj_t *imgbtn_de; // 德语 + lv_obj_t *imgbtn_simple_cn; // 简体中文 Simplified Chinese + lv_obj_t *imgbtn_en; // 英语 English + lv_obj_t *imgbtn_de; // 德语 German lv_obj_t *label_back; - lv_obj_t *label_simple_cn; // 简体中文 - lv_obj_t *label_en; // 英语 - lv_obj_t *label_de; // 德语 + lv_obj_t *label_simple_cn; // 简体中文 Simplified Chinese + lv_obj_t *label_en; // 英语 English + lv_obj_t *label_de; // 德语 German }LANGUAGE_PAGE_T; @@ -23,12 +23,12 @@ typedef struct { typedef struct { - /* 公共 */ + /* 公共 public */ const char *back; const char *yes; const char *no; - /* 主页 */ + /* 主页 Home page */ const char *control; const char *sculpture; const char *tool; @@ -38,7 +38,7 @@ typedef struct { const char *wifi_connect; const char *wifi_disconnect; - /* 控制界面 */ + /* 控制界面 control interface*/ const char *xy_clear; const char *z_clear; const char *knife; @@ -52,10 +52,10 @@ typedef struct { const char *spindle; const char *carve; - /* 文件界面 */ + /* 文件界面 File interface */ const char *dis_no_sd_card; - /* 雕刻界面 */ + /* 雕刻界面 Engraving interface */ const char *hold; const char *cycle; const char *stop; @@ -69,7 +69,7 @@ typedef struct { - /* 提示语 */ + /* 提示语 hint */ const char *dis_stop_print; const char *dis_homing; const char *dis_no_hard_homing; @@ -85,4 +85,7 @@ extern mc_lg_muilt_t mc_language; void draw_language(void); void mks_clear_language(void); +void set_language(uint8_t language); +void set_language_btn_style(uint8_t language); + #endif diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp index 761fdf4..dd62992 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp @@ -91,7 +91,7 @@ lv_obj_t* mks_lvgl_long_sroll_label_with_wight_set_center(lv_obj_t* scr, lv_obj_ } /* - * 用于显示文件名 + * 用于显示文件名 Used to display file names */ lv_obj_t* label_for_file(lv_obj_t* scr, lv_obj_t* lab, lv_coord_t x, lv_coord_t y, const char* text, lv_coord_t w) { @@ -106,7 +106,7 @@ lv_obj_t* label_for_file(lv_obj_t* scr, lv_obj_t* lab, lv_coord_t x, lv_coord_t } /* - * 用于按键里面的文本 + * 用于按键里面的文本 Used for text inside buttons */ lv_obj_t* label_for_btn_name(lv_obj_t* scr, lv_obj_t* lab,lv_coord_t x, lv_coord_t y, const char* text) { lab = lv_label_create(scr, NULL); @@ -119,13 +119,14 @@ lv_obj_t* label_for_btn_name(lv_obj_t* scr, lv_obj_t* lab,lv_coord_t x, lv_coord } /* - * 用于图片按键的文本 + * 用于图片按键的文本 Text to use for image buttons */ lv_obj_t* label_for_imgbtn_name(lv_obj_t* scr, lv_obj_t* lab, lv_obj_t* base, lv_coord_t x, lv_coord_t y, const char* text) { lab = lv_label_create(scr, NULL); lv_label_set_long_mode(lab, LV_LABEL_LONG_EXPAND); lv_label_set_recolor(lab, true); lv_label_set_text(lab, text); + // lv_label_set_align(lab ,LV_LABEL_ALIGN_CENTER); lv_obj_align(lab, base, LV_ALIGN_OUT_BOTTOM_MID, x, y); return lab; diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_print.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_draw_print.cpp index a54cd17..29395e1 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_print.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_print.cpp @@ -945,7 +945,7 @@ void draw_adj_popup(void) { lv_style_copy(&print_src.print_mm_btn1_style, &lv_style_scr); print_src.print_mm_btn1_style.body.main_color = LV_COLOR_MAKE(0xCE, 0xD6, 0xE5); print_src.print_mm_btn1_style.body.grad_color = LV_COLOR_MAKE(0xCE, 0xD6, 0xE5); - print_src.print_mm_btn1_style.body.opa = LV_OPA_COVER;//设置背景色完全不透明 + print_src.print_mm_btn1_style.body.opa = LV_OPA_COVER;//设置背景色完全不透明 Set the background color to be completely opaque print_src.print_mm_btn1_style.body.border.width = 1; print_src.print_mm_btn1_style.body.border.color = LV_COLOR_MAKE(0x3F, 0x46, 0x66); print_src.print_mm_btn1_style.text.color = LV_COLOR_MAKE(0x3F, 0x46, 0x66);; @@ -954,7 +954,7 @@ void draw_adj_popup(void) { lv_style_copy(&print_src.print_mm_btn2_style, &lv_style_scr); print_src.print_mm_btn2_style.body.main_color = LV_COLOR_MAKE(0x3F, 0x46, 0x66); print_src.print_mm_btn2_style.body.grad_color = LV_COLOR_MAKE(0x3F, 0x46, 0x66); - print_src.print_mm_btn2_style.body.opa = LV_OPA_COVER;//设置背景色完全不透明 + print_src.print_mm_btn2_style.body.opa = LV_OPA_COVER;//设置背景色完全不透明 Set the background color to be completely opaque print_src.print_mm_btn2_style.text.color = LV_COLOR_WHITE; print_src.print_mm_btn2_style.body.radius = 10; diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_ready.cpp b/Firmware/Grbl_Esp32/src/mks/MKS_draw_ready.cpp index 092084f..1854e14 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_ready.cpp +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_ready.cpp @@ -161,12 +161,12 @@ void mks_widi_show_ip(IPAddress ip, uint8_t p) { void ready_data_updata(void) { - + static uint8_t wifi_ref_count = 0; static float mks_print_position[MAX_N_AXIS]; float* print_position = system_get_mpos(); - sprintf(xpos_str, "X:%.1f", print_position[0]); + sprintf(xpos_str, "X:%.1f", print_position[0]); //machine position sprintf(ypos_str, "Y:%.1f", print_position[1]); sprintf(zpos_str, "Z:%.1f", print_position[2]); @@ -175,7 +175,7 @@ void ready_data_updata(void) { lv_label_set_static_text(ready_src.ready_label_m_zpos, zpos_str); mpos_to_wpos(print_position); - sprintf(m_xpos_str, "X:%.1f", print_position[0]); + sprintf(m_xpos_str, "X:%.1f", print_position[0]); //work position sprintf(m_ypos_str, "Y:%.1f", print_position[1]); sprintf(m_zpos_str, "Z:%.1f", print_position[2]); @@ -191,6 +191,7 @@ void ready_data_updata(void) { ready_src.ready_label_wifi_status = mks_lv_label_updata(ready_src.ready_label_wifi_status, "WIFI:Connect"); } #endif + } diff --git a/Firmware/Grbl_Esp32/src/mks/language_en.h b/Firmware/Grbl_Esp32/src/mks/language_en.h index 1978dac..52e00b8 100644 --- a/Firmware/Grbl_Esp32/src/mks/language_en.h +++ b/Firmware/Grbl_Esp32/src/mks/language_en.h @@ -1,12 +1,12 @@ #ifndef __language_ch_h #define __language_ch_h -/* 公共 */ +/* 公共 public */ #define BACK_EN "Back" #define YES_EN "Yes" #define NO_EN "No" -/* 主页 */ +/* 主页 Home page */ #define CONTROL_EN "Control" #define SCULPTURE_EN "Sculpture" #define TOOL_EN "Tool" @@ -15,7 +15,7 @@ #define WIFI_CONNECT_EN "Connect" #define WIFI_DISCONNECT_EN "Disconnect" -/* 控制界面 */ +/* 控制界面 control interface */ #define XY_CLEAR_EN "XY_Clear" #define Z_CLEAR_EN "Z_Clear" #define KNIFE_EN "Knife" @@ -29,10 +29,10 @@ #define SPINDLE_EN "Spindle" #define CARVE_EN "Carve" -/* 文件界面 */ +/* 文件界面 File interface */ #define DIS_NO_SDCARD_EN "No SD Card" -/* 雕刻界面 */ +/* 雕刻界面 Engraving interface */ #define HOLD_EN "Hold" #define CYCLE_EN "Cycle" #define STOP_EN "Stop" @@ -42,7 +42,7 @@ #define RAPID_SPEED_EN "Rapid speed" #define CARVE_TIMES_EN "time:" -/* 提示 */ +/* 提示 hint */ #define DIS_STOP_CARVE_EN "Do you want to stop carve?" #define DIS_HOMEING_EN "Homing..." #define DIS_NO_HARD_HOME_EN "No Enable Hard Homing..." From 9d173cad0d57da7f47271af22510988a08bf5656 Mon Sep 17 00:00:00 2001 From: KP <42572567+kpatel122@users.noreply.github.com> Date: Sun, 17 Sep 2023 16:39:14 +0100 Subject: [PATCH 2/3] removed set_language_btn_style which was causing issues --- Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h index ad30b3d..9a36a35 100644 --- a/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h +++ b/Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h @@ -86,6 +86,5 @@ void draw_language(void); void mks_clear_language(void); void set_language(uint8_t language); -void set_language_btn_style(uint8_t language); #endif From 48a55c67346b72975c86857d8a5eddd7001383ef Mon Sep 17 00:00:00 2001 From: KP <42572567+kpatel122@users.noreply.github.com> Date: Sun, 17 Sep 2023 16:39:26 +0100 Subject: [PATCH 3/3] Update Grbl.cpp --- Firmware/Grbl_Esp32/src/Grbl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/Grbl_Esp32/src/Grbl.cpp b/Firmware/Grbl_Esp32/src/Grbl.cpp index 5939d43..0d72633 100644 --- a/Firmware/Grbl_Esp32/src/Grbl.cpp +++ b/Firmware/Grbl_Esp32/src/Grbl.cpp @@ -127,7 +127,6 @@ void _mc_task_init(void) { //set default language to english (0:Simple Chinese, 1:English 2:Deutsch ) set_language(1); - set_language_btn_style(1); } static void reset_variables() {