Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug that shows 'Text' for all labels because no default language is set on boot #34

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Firmware/Grbl_Esp32/src/Grbl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -123,8 +124,10 @@ 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);
}

static void reset_variables() {
// Reset system variables.
Expand Down
36 changes: 18 additions & 18 deletions Firmware/Grbl_Esp32/src/mks/MKS_FREERTOS_TASK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -214,19 +214,19 @@ 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) {

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
}
}
}
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Firmware/Grbl_Esp32/src/mks/MKS_LVGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions Firmware/Grbl_Esp32/src/mks/MKS_draw_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down
26 changes: 14 additions & 12 deletions Firmware/Grbl_Esp32/src/mks/MKS_draw_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
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;


typedef struct {

/* 公共 */
/* 公共 public */
const char *back;
const char *yes;
const char *no;

/* 主页 */
/* 主页 Home page */
const char *control;
const char *sculpture;
const char *tool;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -69,7 +69,7 @@ typedef struct {



/* 提示语 */
/* 提示语 hint */
const char *dis_stop_print;
const char *dis_homing;
const char *dis_no_hard_homing;
Expand All @@ -85,4 +85,6 @@ extern mc_lg_muilt_t mc_language;
void draw_language(void);
void mks_clear_language(void);

void set_language(uint8_t language);

#endif
7 changes: 4 additions & 3 deletions Firmware/Grbl_Esp32/src/mks/MKS_draw_lvgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Grbl_Esp32/src/mks/MKS_draw_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);;
Expand All @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions Firmware/Grbl_Esp32/src/mks/MKS_draw_ready.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -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]);

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

}


Expand Down
12 changes: 6 additions & 6 deletions Firmware/Grbl_Esp32/src/mks/language_en.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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..."
Expand Down