V4.4.19 update

This commit is contained in:
CChen616
2024-05-03 09:57:27 +08:00
parent d1d606ada4
commit 0ce78cc607
9 changed files with 173 additions and 22 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -255,4 +255,8 @@ void refresh_page_auto_unload();
int get_mks_ethernet();
void set_mks_ethernet(int target);
std::string hex_to_utf8(const std::string& hex);
void check_print_interrupted();
#endif

View File

@@ -420,6 +420,15 @@
#define TJC_PAGE_INSTALLING 90
#define TJC_PAGE_AUTO_WARNING 91
#define TJC_PAGE_AUTO_WARNING_YES 0x00
#define TJC_PAGE_CALIBRATE_WARNING 92
#define TJC_PAGE_CALIBRATE_WARNING_NEXT 0x00
#define TJC_PAGE_CALIBRATE_WARNING_BACK 0x01
#define TJC_PAGE_RE_PRINTING 93
void parse_cmd_msg_from_tjc_screen(char *cmd);
void page_to(int page_id);
void tjc_event_clicked_handler(int page_id, int widget_id, int type_id);

View File

@@ -240,7 +240,7 @@ int main(int argc, char** argv) {
mks_get_version();
sleep(3);
send_cmd_val(tty_fd, "logo.version", "18"); // CLL 检测UI与SOC版本是否匹配4.4.18版本输出标记数字为18
send_cmd_val(tty_fd, "logo.version", "19"); // CLL 检测UI与SOC版本是否匹配4.4.19版本输出标记数字为19
if (find_screen_tft_file == false) {
previous_page_id = TJC_PAGE_LOGO;
if (get_mks_oobe_enabled() == true) {

View File

@@ -364,6 +364,8 @@ extern std::string thumbnail_path;
extern bool cache_clicked;
int unhomed_move_mode = 0; // CLL 用于保存上次按下的移动按钮,当触发需先归位操作时进行移动, 1(x up),2(x down),3(y up),4(y down),5(z up),6(z down)
// CLL 以下变量用于修复gcode响应函数和refresh函数之间的冲突(gcode响应函数需设置变量在refresh_page_show中统一改变页面否则会产生冲突)
bool jump_to_move_pop_1 = false;
bool jump_to_move_pop_2 = false;
@@ -404,6 +406,42 @@ void refresh_page_show() {
page_to(TJC_PAGE_MOVE_POP_1);
}
if (jump_to_move_pop_2 == true) {
switch (unhomed_move_mode)
{
case 1: // X_UP
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 X10 F3000\nG90\nM84\n"));
break;
case 2: // X_DOWN
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 X-10 F3000\nG90\nM84\n"));
break;
case 3: // Y_UP
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 Y10 F3000\nG90\nM84\n"));
break;
case 4: // Y_DOWN
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 Y-10 F3000\nG90\nM84\n"));
break;
case 5: // Z_UP
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 Z-10 F600\nG90\nM84\n"));
break;
case 6: // Z_DOWN
ep->Send(json_run_a_gcode("SET_KINEMATIC_POSITION Z=150\nSET_KINEMATIC_POSITION X=150\nSET_KINEMATIC_POSITION Y=150\n"));
ep->Send(json_run_a_gcode("G91\nG1 Z10 F600\nG90\nM84\n"));
break;
default:
break;
}
unhomed_move_mode = 0;
jump_to_move_pop_2 = false;
page_to(TJC_PAGE_MOVE_POP_2);
}
@@ -855,6 +893,7 @@ void refresh_page_auto_finish() {
}
void refresh_page_auto_moving() {
send_cmd_txt(tty_fd, "t5", "(" + std::to_string(printer_heater_bed_temperature) + "/" + std::to_string(printer_heater_bed_target) + ")");
if (step_1 == true) {
send_cmd_picc(tty_fd, "q0", "109");
send_cmd_pco(tty_fd, "t1", "65535");
@@ -1491,7 +1530,7 @@ void refresh_page_main() {
// CLL 每次开机发送断电续打
if (open_reprint_asked == false) {
ep->Send(json_run_a_gcode("KINEMATIC_POSITION\n"));
check_print_interrupted();
open_reprint_asked = true;
}
}
@@ -1696,26 +1735,32 @@ void move_home() {
void move_x_decrease() {
ep->Send(move(AXIS_X, "-" + std::to_string(printer_move_dist), 130));
unhomed_move_mode = 2;
}
void move_x_increase() {
ep->Send(move(AXIS_X, "+" + std::to_string(printer_move_dist), 130));
unhomed_move_mode = 1;
}
void move_y_decrease() {
ep->Send(move(AXIS_Y, "-" + std::to_string(printer_move_dist), 130));
unhomed_move_mode = 4;
}
void move_y_increase() {
ep->Send(move(AXIS_Y, "+" + std::to_string(printer_move_dist), 130));
unhomed_move_mode = 3;
}
void move_z_decrease() {
ep->Send(move(AXIS_Z, "-" + std::to_string(printer_move_dist), 10));
unhomed_move_mode = 5;
}
void move_z_increase() {
ep->Send(move(AXIS_Z, "+" + std::to_string(printer_move_dist), 10));
unhomed_move_mode = 6;
}
bool get_filament_detected() {
@@ -2115,7 +2160,7 @@ void go_to_network() {
scan_ssid_and_show();
get_wlan0_status();
if (strcmp(status_result.wpa_state, "COMPLETED") == 0) {
current_connected_ssid_name = status_result.ssid; // 如果已经连接wifi获取wifi的名字
current_connected_ssid_name = hex_to_utf8(status_result.ssid); // 如果已经连接wifi获取wifi的名字
} else if (strcmp(status_result.wpa_state, "INACTIVE")) {
current_connected_ssid_name.clear(); // 如果没连接wifi清除掉当前已连接wifi的名字
}
@@ -2143,7 +2188,7 @@ void refresh_page_wifi_list() {
if (0 == page_wifi_current_pages) {
if (0 == i) {
if (strcmp(status_result.wpa_state, "COMPLETED") == 0) {
send_cmd_txt(tty_fd, "t" + std::to_string(i+1), status_result.ssid);
send_cmd_txt(tty_fd, "t" + std::to_string(i+1), hex_to_utf8(status_result.ssid));
} else {
send_cmd_txt(tty_fd, "t" + std::to_string(i+1), page_wifi_ssid_list[i]);
}
@@ -2496,7 +2541,10 @@ void level_mode_printing_print_file() {
}
void update_finished_tips() {
page_to(TJC_PAGE_UPDATE_FINISH);
// page_to(TJC_PAGE_UPDATE_FINISH);
sleep(5);
system("sync");
system("systemctl restart makerbase-client.service");
}
bool get_mks_oobe_enabled() {
@@ -2885,6 +2933,7 @@ void bed_calibrate() {
if (manual_count == 4) {
bed_offset = 0;
printer_idle_timeout_state = "Printing";
ep->Send(json_run_a_gcode("ABORT\n"));
ep->Send(json_run_a_gcode("M4030"));
page_to(TJC_PAGE_BED_MOVING);
}else if (manual_count == 3) {
@@ -3055,7 +3104,7 @@ void print_log() {
system("bash -c 'cp /home/mks/klipper_logs/auto_update.log* /home/mks/gcode_files/sda1/QD_Log/'");
system("bash -c 'cp /root/frp/frpc.log* /home/mks/gcode_files/sda1/QD_Log/'");
system("bash -c 'cp /root/frp/frpc.*.log /home/mks/gcode_files/sda1/QD_Log/'");
system("cp /root/frp/frpc.toml /home/mks/gcode_files/sda1/QD_Log/frpc.toml");
system("cp /root/frp/frpc.toml /home/mks/gcode_files/sda1/QD_Log/server.cfg");
page_to(TJC_PAGE_PRINT_LOG_S);
}
}
@@ -3228,16 +3277,15 @@ void go_to_showqr() {
page_to(TJC_PAGE_SHOW_QR);
if (strcmp(status_result.wpa_state, "COMPLETED") == 0 || mks_ethernet) {
if (qr_refreshed == false) {
send_cmd_cp_close(tty_fd, "cp0");
if (open_qr_refreshed == true || access("/home/mks/qrcode/qrcode.jpg", F_OK) == -1)
qrmessage = run_python_code("python3 /home/mks/qrcode/qrcode_QD.py 176\n");
std::cout << "qrmessage:" << qrmessage << std::endl;
if (qrmessage.find("Missing or invalid") != -1) {
send_cmd_txt(tty_fd, "t4", qrmessage);
send_cmd_vis(tty_fd, "t4", "1");
send_cmd_cp_close(tty_fd, "cp0");
} else if (qrmessage.find("No") != -1) {
send_cmd_vis(tty_fd, "t4", "1");
send_cmd_cp_close(tty_fd, "cp0");
} else {
open_qr_refreshed = true;
refresh_files_list_picture("/home/mks/qrcode/qrcode.jpg", 176, 0);
@@ -3295,7 +3343,12 @@ void update_server(int choice)
{
// CLL 连接服务器获取json文件
if (choice == 0) {
system("curl -s -S -L -o /root/frp/server_list.json http://www.aws.qidi3dprinter.com:5050/downloads/server_list.json");
// system("curl -s -S -L -o /root/frp/server_list.json http://www.aws.qidi3dprinter.com:5050/downloads/server_list.json");
get_mks_selected_server();
std::string server_for_command = selected_server.empty() ? "aws" : selected_server;
std::string command = "curl -s -S -L -o /root/frp/server_list.json http://www." + server_for_command + ".qidi3dprinter.com:5050/downloads/server_list.json";
std::cout << "Executing command: " << command << std::endl;
system(command.c_str());
} else {
qr_refreshed = false; // CLL 当choice不为0时该函数用于切换服务器需要重新刷新二维码
}
@@ -3468,7 +3521,7 @@ void check_online_version() {
page_to(TJC_PAGE_SEARCH_SERVER);
if (connection_method == 0)
return;
target_soc_version = run_python_code("python3 /root/auto_update/version_check_Q1.py");
target_soc_version = run_python_code("python3 /root/auto_update/version_check.py");
std::cout << "服务器版本:" << target_soc_version << std::endl;
if (target_soc_version.find("0") == 0) {
page_to(TJC_PAGE_UPDATE_MODE);
@@ -3520,7 +3573,7 @@ void online_update() {
pthread_t recevice_progress_pthread;
pthread_create(&recevice_progress_pthread, NULL, recevice_progress_handle, NULL);
system("rm /home/mks/gcode_files/.cache/*\n");
system("python3 /root/auto_update/download_update_Q1.py\n");
system("python3 /root/auto_update/download_update.py\n");
// page_to(TJC_PAGE_UPDATE_FINISH);
system("sync\n");
system("systemctl restart makerbase-client\n");
@@ -3582,4 +3635,38 @@ void set_mks_ethernet(int target) {
mksini_save();
mksini_free();
mks_ethernet = target;
}
std::string hex_to_utf8(const std::string& hex) {
std::ostringstream utf8;
size_t i = 0;
while (i < hex.size()) {
if (i + 3 < hex.size() && hex[i] == '\\' && hex[i + 1] == 'x') {
std::string hex_byte = hex.substr(i + 2, 2);
int value;
std::istringstream(hex_byte) >> std::hex >> value;
utf8 << static_cast<char>(value);
i += 4;
} else {
utf8 << hex[i++];
}
}
return utf8.str();
}
void check_print_interrupted() {
std::ifstream infile("/home/mks/klipper_config/saved_variables.cfg");
if (!infile) {
std::cerr << "无法打开文件 " << "/home/mks/klipper_config/saved_variables.cfg" << std::endl;
return;
}
std::stringstream buffer;
buffer << infile.rdbuf();
std::string printer_variables = buffer.str();
infile.close();
std::string print_interrupted_status = printer_variables.substr(printer_variables.find("was_interrupted =") + 18, 5);
if (print_interrupted_status != "False") {
ep->Send(json_run_a_gcode("DETECT_INTERRUPTION\n"));
jump_to_resume_print = true;
}
}

View File

@@ -234,7 +234,7 @@ void parse_gcode_response(nlohmann::json params) {
step_2 = true;
}
} else if (params0.find("echo: Detected unexpected interruption during the last print.") != -1 || params0.find("echo: Yes: RESUME_INTERRUPTED") != -1 || params0.find("echo: No: CLEAR_LAST_FILE") != -1) {
jump_to_resume_print = true;
// jump_to_resume_print = true;
}
}
}

View File

@@ -416,6 +416,8 @@ void start_update()
system("systemctl stop moonraker.service\n");
system("find /home/mks/gcode_files -maxdepth 1 -type d ! -name sd* -a ! -name '.*' | grep gcode_files/ | xargs rm -rf");
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_gcode/*.gcode /home/mks/gcode_files; chmod 777 /home/mks/gcode_files/*.gcode; sync");
sleep(3);
system("systemctl restart moonraker.service\n");
}
// 检测到UI文件
@@ -435,8 +437,7 @@ void start_update()
if (!factory_mode) {
command += "mv " + filePath + " " + filePath + ".bak; ";
}
}
command += "sync";
system(command.c_str());
break; // 每次更新只处理一个UI文件
@@ -460,7 +461,7 @@ void start_update()
{
std::string filename = entry->d_name;
if (filename.rfind(".bak") != std::string::npos) continue;
if (filename.find("QD_Q1_PATCH") == 0 || filename.find("QD_Q1_SOC") == 0 || filename.find("QD_Mate3_SOC") == 0)
if (filename.find("QD_Q1_PATCH") == 0 || filename.find("QD_Q1_SOC") == 0 || filename.find("QD_Mates3_SOC") == 0)
{
std::string file_path = base_path + filename;
std::string command = "mv " + file_path + " " + base_path + "mks.deb; dpkg -i --force-overwrite " + base_path + "mks.deb;";
@@ -472,7 +473,6 @@ void start_update()
{
new_file_name += ".bak";
}
command = "mv " + base_path + "mks.deb " + new_file_name + "; sync";
system(command.c_str());
}

View File

@@ -104,6 +104,8 @@ extern bool mks_file_parse_finished;
extern int printer_extruder_temperature;
extern int printer_extruder_target;
extern int printer_heater_bed_target;
extern std::string printer_webhooks_state;
extern bool printer_ready;
@@ -642,18 +644,30 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
switch (widget_id)
{
case TJC_PAGE_ALL_TO_MAIN:
page_to(TJC_PAGE_MAIN);
if (printer_print_stats_state == "printing" || printer_print_stats_state == "paused") {
page_to(TJC_PAGE_PRINTING);
jump_to_print = false;
} else
page_to(TJC_PAGE_MAIN);
break;
case TJC_PAGE_ALL_TO_FILE_LIST:
break;
case TJC_PAGE_ALL_TO_ADJUST:
go_to_adjust();
if (printer_print_stats_state == "printing" || printer_print_stats_state == "paused") {
page_to(TJC_PAGE_PRINTING);
jump_to_print = false;
} else
go_to_adjust();
break;
case TJC_PAGE_ALL_TO_SETTING:
go_to_setting();
if (printer_print_stats_state == "printing" || printer_print_stats_state == "paused") {
page_to(TJC_PAGE_PRINTING);
jump_to_print = false;
} else
go_to_setting();
break;
case TJC_PAGE_PREVIEW_BACK:
@@ -699,6 +713,11 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
break;
case TJC_PAGE_PREVIEW_BED_LEVELING:
if (printer_print_stats_state == "printing" || printer_print_stats_state == "paused") {
page_to(TJC_PAGE_PRINTING);
jump_to_print = false;
break;
}
if (printer_bed_leveling == true) {
printer_bed_leveling = false;
}else {
@@ -1369,8 +1388,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
break;
case TJC_PAGE_LEVEL_MODE_BED_CALIBRATION:
manual_count = 4;
bed_calibrate();
page_to(TJC_PAGE_CALIBRATE_WARNING);
break;
case TJC_PAGE_LEVEL_MODE_TO_COMMON_SETTING:
@@ -1419,6 +1437,10 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
break;
case TJC_PAGE_AUTO_HEATERBED_NEXT:
if (printer_heater_bed_target < 35) {
page_to(TJC_PAGE_AUTO_WARNING);
break;
}
auto_level_button_enabled = true;
printer_idle_timeout_state = "Printing";
start_auto_level();
@@ -2070,7 +2092,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
case TJC_PAGE_RESUME_PRINT:
switch(widget_id) {
case TJC_PAGE_RESUME_PRINT_YES:
page_to(TJC_PAGE_MAIN);
page_to(TJC_PAGE_RE_PRINTING);
send_gcode("RESUME_INTERRUPTED\n");
break;
@@ -2346,6 +2368,35 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
}
break;
case TJC_PAGE_AUTO_WARNING:
switch (widget_id)
{
case TJC_PAGE_AUTO_WARNING_YES:
page_to(TJC_PAGE_AUTO_HEATERBED);
break;
default:
break;
}
break;
case TJC_PAGE_CALIBRATE_WARNING:
switch (widget_id)
{
case TJC_PAGE_CALIBRATE_WARNING_NEXT:
manual_count = 4;
bed_calibrate();
break;
case TJC_PAGE_CALIBRATE_WARNING_BACK:
page_to(TJC_PAGE_LEVEL_MODE);
break;
default:
break;
}
break;
default:
break;
}