V4.4.18 update

This commit is contained in:
CChen616
2024-04-09 15:18:07 +08:00
parent d627567d0f
commit 474b134e40
15 changed files with 416 additions and 194 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -5,5 +5,6 @@
#include "./MakerbaseShell.h"
std::string get_wlan0_ip();
std::string get_eth0_ip();
#endif

View File

@@ -252,4 +252,7 @@ void *recevice_progress_handle(void *arg);
void refresh_page_auto_unload();
int get_mks_ethernet();
void set_mks_ethernet(int target);
#endif

View File

@@ -114,7 +114,7 @@
#define TJC_PAGE_PRINT_ZOFFSET_SET_001 0x01
#define TJC_PAGE_PRINT_ZOFFSET_SET_005 0x02
#define TJC_PAGE_PRINT_ZOFFSET_SET_01 0x03
#define TJC_PAGE_PRINT_ZOFFSET_SET_1 0x04
#define TJC_PAGE_PRINT_ZOFFSET_SET_05 0x04
#define TJC_PAGE_PRINT_ZOFFSET_UP 0x05
#define TJC_PAGE_PRINT_ZOFFSET_DOWN 0x06
#define TJC_PAGE_PRINT_ZOFFSET_PAUSE_RESUME 0x0a
@@ -226,7 +226,7 @@
#define TJC_PAGE_PRE_BED_CALIBRATION_SET_001 0x00
#define TJC_PAGE_PRE_BED_CALIBRATION_SET_005 0x01
#define TJC_PAGE_PRE_BED_CALIBRATION_SET_01 0x02
#define TJC_PAGE_PRE_BED_CALIBRATION_SET_1 0x03
#define TJC_PAGE_PRE_BED_CALIBRATION_SET_05 0x03
#define TJC_PAGE_PRE_BED_CALIBRATION_UP 0x04
#define TJC_PAGE_PRE_BED_CALIBRATION_DOWN 0x05
#define TJC_PAGE_PRE_BED_CALIBRATION_ENTER 0x06
@@ -380,6 +380,7 @@
#define TJC_PAGE_SHOW_QR_BACK 0x01
#define TJC_PAGE_SHOW_QR_WIFI 0x02
#define TJC_PAGE_SHOW_QR_SET 0x03
#define TJC_PAGE_SHOW_QR_ETHERNET 0x04
#define TJC_PAGE_SERVER_SET 82
#define TJC_PAGE_SERVER_SET_REFRESH 0x00

View File

@@ -1,5 +1,6 @@
#include <fstream>
#include <wpa_ctrl.h>
#include "include/MakerbaseClient.h"
@@ -129,6 +130,39 @@ int main(int argc, char** argv) {
system("bash /home/mks/gcode_files/sda1/mks-super.sh");
}
}
//4.4.15 CCW 添加开机检测c_helper.so文件
const char *sourceFile = "/home/mks/klipper/klippy/chelper/c_helper.so";
const char *destFile = "/root/etc/c_helper.so";
std::ifstream file(sourceFile, std::ifstream::binary | std::ifstream::ate);
long size = 0;
if (!file) {
std::printf("File does not exist or could not open file: %s\n", sourceFile);
size = -1;
} else {
size = file.tellg();
}
file.close();
// 检查c_helper.so文件是否正常
if (size < 10240) {
std::printf("File %s does not exist or is less than 10KB\n", sourceFile);
std::ifstream src(destFile, std::ios::binary);
std::ofstream dst(sourceFile, std::ios::binary);
if (!src || !dst) {
std::printf("Failed to open source or destination file\n");
} else {
dst << src.rdbuf(); // Copy file content
std::printf("File %s has been replaced with %s\n", sourceFile, destFile);
}
} else {
std::printf("File %s exists and is not less than 10KB, no action taken\n", sourceFile);
}
// pthread_t monitor_thread;
// pthread_t monitor_C3_thread;
pthread_t wpa_recv_thread;
@@ -148,7 +182,6 @@ int main(int argc, char** argv) {
std::string host = "localhost";
std::string url = "ws://localhost:7125/websocket?";
MKSLOG("%s", url.data());
MKSLOG_RED("TEST");
if (argc == 2) {
host = argv[1];
@@ -207,7 +240,7 @@ int main(int argc, char** argv) {
mks_get_version();
sleep(3);
send_cmd_val(tty_fd, "logo.version", "14"); // CLL 检测UI与SOC版本是否匹配4.4.14版本输出标记数字为14
send_cmd_val(tty_fd, "logo.version", "18"); // CLL 检测UI与SOC版本是否匹配4.4.18版本输出标记数字为18
if (find_screen_tft_file == false) {
previous_page_id = TJC_PAGE_LOGO;
if (get_mks_oobe_enabled() == true) {

View File

@@ -7,3 +7,11 @@ std::string get_wlan0_ip() {
printf("%s", result);
return result;
}
std::string get_eth0_ip() {
char result[MAX_FILE_LEN] = {0};
std::string cmd = "ifconfig eth0 | awk 'NR==2{print $2}' | tr -d '\n\r'";
execute_cmd(cmd.data(), result);
printf("%s", result);
return result;
}

View File

@@ -501,9 +501,11 @@ int parse_scan_results(char* scan_results) {
level_list.clear();
ssid_list.clear();
char* lines[1024] = {0};
char buffer[4096];
strcpy(buffer, scan_results);
char* lines[128] = {0};
int num_lines = 0;
char* line = strtok(scan_results, "\n");
char* line = strtok(buffer, "\n");
while (line != NULL) {
lines[num_lines++] = line;
line = strtok(NULL, "\n");
@@ -513,7 +515,7 @@ int parse_scan_results(char* scan_results) {
char* fields[5] = {0};
int num_fields = 0;
char ssid_line[128] = {0};
char ssid_line[256] = {0};
memset(ssid_line, 0x00, sizeof(ssid_line));
strcpy(ssid_line, lines[i]);
int ssid_line_index = 0;
@@ -533,8 +535,8 @@ int parse_scan_results(char* scan_results) {
printf("Invalid scan result: %s\n", lines[i]);
continue;
} else {
unsigned char ssid_name[64];
printf_decode(ssid_name, 64, ssid_line + ssid_line_index);
unsigned char ssid_name[192];
printf_decode(ssid_name, 192, ssid_line + ssid_line_index);
if (ssid_name[0] == '\x00') {
} else {

View File

@@ -38,6 +38,7 @@
#include "../include/MakerbasePanel.h"
#include "../include/MakerbaseParseIni.h"
#include "../include/MakerbaseWiFi.h"
#include "../include/MakerbaseNetwork.h"
#include "../include/ui.h"
#include "../include/send_jpg.h"
@@ -393,6 +394,8 @@ bool open_qr_refreshed = false; // CLL 第一次开机刷新时不使用脚本
extern bool qr_refreshed;
bool open_reprint_asked = false; // CLL 开机后进入主页面发出检测断电续打指令
int mks_ethernet;
/* 更新页面处理 */
void refresh_page_show() {
// CLL 以下if检测函数为无条件跳转其在改变为true之前已经经过函数判断(跳转页面前需将对应变量置为false,否则会陷入死循环)
@@ -751,7 +754,7 @@ void refresh_page_auto_level() {
send_cmd_picc2(tty_fd, "b1", "115");
send_cmd_picc2(tty_fd, "b2", "116");
send_cmd_picc2(tty_fd, "b3", "115");
} else if (auto_level_dist == (float)1) {
} else if (auto_level_dist == (float)0.5) {
send_cmd_picc(tty_fd, "b0", "114");
send_cmd_picc(tty_fd, "b1", "114");
send_cmd_picc(tty_fd, "b2", "114");
@@ -784,6 +787,7 @@ void refresh_page_syntony_move() {
if (step_1 == true) {
sleep(15);
page_to(TJC_PAGE_SYNTONY_FINISH);
step_1 = false;
}
}
@@ -948,6 +952,44 @@ void refresh_page_printing_zoffset() {
send_cmd_txt(tty_fd, "t1", show_time(get_cal_printing_time((int)(printer_print_stats_print_duration), file_metadata_estimated_time, printer_display_status_progress)));
send_cmd_val(tty_fd, "j0", std::to_string(printer_display_status_progress));
if (printer_set_offset == (float)0.01) {
send_cmd_picc(tty_fd, "b1", std::to_string(57));
send_cmd_picc2(tty_fd, "b1", std::to_string(60));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)0.05) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(57));
send_cmd_picc2(tty_fd, "b2", std::to_string(60));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)0.1) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(57));
send_cmd_picc2(tty_fd, "b3", std::to_string(60));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)0.5) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(57));
send_cmd_picc2(tty_fd, "b4", std::to_string(60));
}
if (printer_print_stats_state == "printing") {
printer_ready = true;
}
@@ -995,44 +1037,6 @@ void refresh_page_printing_zoffset() {
clear_previous_data();
send_cmd_txt(tty_fd , "t0", "gcode error:" + error_message);
}
if (printer_set_offset == (float)0.01) {
send_cmd_picc(tty_fd, "b1", std::to_string(57));
send_cmd_picc2(tty_fd, "b1", std::to_string(60));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)0.05) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(57));
send_cmd_picc2(tty_fd, "b2", std::to_string(60));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)0.1) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(57));
send_cmd_picc2(tty_fd, "b3", std::to_string(60));
send_cmd_picc(tty_fd, "b4", std::to_string(58));
send_cmd_picc2(tty_fd, "b4", std::to_string(59));
} else if (printer_set_offset == (float)1) {
send_cmd_picc(tty_fd, "b1", std::to_string(58));
send_cmd_picc2(tty_fd, "b1", std::to_string(59));
send_cmd_picc(tty_fd, "b2", std::to_string(58));
send_cmd_picc2(tty_fd, "b2", std::to_string(59));
send_cmd_picc(tty_fd, "b3", std::to_string(58));
send_cmd_picc2(tty_fd, "b3", std::to_string(59));
send_cmd_picc(tty_fd, "b4", std::to_string(57));
send_cmd_picc2(tty_fd, "b4", std::to_string(60));
}
}
void refresh_page_printing() {
@@ -1630,7 +1634,7 @@ void set_heater_bed_target(int target) {
}
void set_hot_target(int target) {
set_target("chamber", target);
ep->Send(json_run_a_gcode("M141 S" + std::to_string(target)));
}
void set_fan(int speed) {
@@ -1655,6 +1659,13 @@ void set_intern_zoffset(float offset) {
}
void set_zoffset(bool positive) {
// std::string command;
// if (positive) {
// command = "curl -s -X POST http://127.0.0.1:7125/printer/modifybabystep?ADJUST=" + std::to_string(printer_set_offset);
// } else {
// command = "curl -s -X POST http://127.0.0.1:7125/printer/modifybabystep?ADJUST=-" + std::to_string(printer_set_offset);
// }
// system(command.c_str());
if (positive == true) {
ep->Send(json_run_a_gcode("SET_GCODE_OFFSET Z_ADJUST=+" + std::to_string(printer_set_offset) + " MOVE=1"));
} else {
@@ -1737,6 +1748,8 @@ void set_print_resume() {
void cancel_print() {
printer_print_stats_filename = "";
system("curl -X POST http://127.0.0.1:7125/printer/breakmacro");
system("curl -X POST http://127.0.0.1:7125/printer/breakheater");
ep->Send(json_run_a_gcode("CANCEL_PRINT"));
int printed_minutes = get_cal_printed_time((int)(printer_print_stats_print_duration));
get_mks_total_printed_time();
@@ -1827,10 +1840,18 @@ void move_home_tips() {
}
void filament_tips() {
if (current_page_id == TJC_PAGE_PRINT_FILAMENT) {
switch (current_page_id)
{
case TJC_PAGE_OPEN_FILAMENTVIDEO_3:
break;
case TJC_PAGE_PRINT_FILAMENT:
jump_to_print_low_temp = true;
} else {
break;
default:
jump_to_filament_pop_1 = true;
break;
}
}
@@ -2063,7 +2084,19 @@ void go_to_reset() {
if (printer_webhooks_state == "shutdown") {
page_to(TJC_PAGE_RESET);
} else {
std::ifstream infile("/dev_info.txt");
if (!infile) {
std::cerr << "无法打开文件 " << "/dev_info.txt" << std::endl;
return;
}
std::stringstream buffer;
buffer << infile.rdbuf();
std::string machine_type = buffer.str();
infile.close();
machine_type = machine_type.substr(machine_type.find("@") + 1);
page_to(TJC_PAGE_SYS_OK);
std::cout << "machine_type:" << machine_type << std::endl;
send_cmd_txt(tty_fd, "t2", machine_type);
}
}
@@ -2092,12 +2125,16 @@ void go_to_network() {
}
void scan_ssid_and_show() {
get_wlan0_status();
mks_wpa_scan_scanresults();
get_ssid_list_pages();
page_wifi_current_pages = 0;
set_page_wifi_ssid_list(page_wifi_current_pages);
refresh_page_wifi_list();
if (access("/var/run/wpa_supplicant/wlan0", F_OK) == 0){
get_wlan0_status();
mks_wpa_scan_scanresults();
get_ssid_list_pages();
page_wifi_current_pages = 0;
set_page_wifi_ssid_list(page_wifi_current_pages);
refresh_page_wifi_list();
} else {
page_to(TJC_PAGE_INTERNET);
}
}
void refresh_page_wifi_list() {
@@ -2284,6 +2321,7 @@ void init_mks_status() {
get_mks_total_printed_time();
get_mks_babystep();
get_mks_connection_method();
get_mks_ethernet();
// 不再使用xindi获取zoffset
// printer_set_babystep();
/*
@@ -3012,8 +3050,12 @@ void print_log() {
page_to(TJC_PAGE_PRINT_LOG_F); // CLL 若U盘未插入提示导出失败请客户检查U盘插入
} else {
system("mkdir /home/mks/gcode_files/sda1/QD_Log");
system("cp /home/mks/klipper_logs/klippy.log /home/mks/gcode_files/sda1/QD_Log/klippy.log\n");
system("cp /home/mks/klipper_logs/moonraker.log /home/mks/gcode_files/sda1/QD_Log/moonraker.log\n");
system("bash -c 'cp /home/mks/klipper_logs/klippy.log* /home/mks/gcode_files/sda1/QD_Log/'");
system("bash -c 'cp /home/mks/klipper_logs/moonraker.log* /home/mks/gcode_files/sda1/QD_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");
page_to(TJC_PAGE_PRINT_LOG_S);
}
}
@@ -3168,19 +3210,39 @@ void set_mks_connection_method(int target) {
}
void refresh_page_show_qr() {
send_cmd_txt(tty_fd, "t0", status_result.ip_address);
if (mks_ethernet == 0) {
send_cmd_txt(tty_fd, "t0", status_result.ip_address);
send_cmd_picc(tty_fd, "b4", "268");
send_cmd_picc2(tty_fd, "b4", "214");
} else {
std::string local_ip = get_eth0_ip();
send_cmd_txt(tty_fd, "t0", local_ip);
send_cmd_picc(tty_fd, "b4", "269");
send_cmd_picc2(tty_fd, "b4", "215");
}
}
void go_to_showqr() {
std::string qrmessage;
get_mks_connection_method();
page_to(TJC_PAGE_SHOW_QR);
if (strcmp(status_result.wpa_state, "COMPLETED") == 0) {
if (strcmp(status_result.wpa_state, "COMPLETED") == 0 || mks_ethernet) {
if (qr_refreshed == false) {
if (open_qr_refreshed == true || access("/home/mks/qrcode/qrcode.jpg", F_OK) == -1)
system("python3 /home/mks/qrcode/qrcode_QD.py 176\n");
open_qr_refreshed = true;
refresh_files_list_picture("/home/mks/qrcode/qrcode.jpg", 176, 0);
qr_refreshed = true;
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);
qr_refreshed = true;
}
}
} else {
send_cmd_vis(tty_fd, "t4", "1");
@@ -3199,7 +3261,7 @@ void go_to_server_set(int n) {
current_server_page = n;
total_server_count = 0;
serverConfigs.clear();
if (connection_method == 1) {
if (connection_method == 1 && strcmp(status_result.wpa_state, "COMPLETED") == 0) {
page_to(TJC_PAGE_SEARCH_SERVER);
update_server(0);
get_mks_selected_server();
@@ -3329,12 +3391,23 @@ void update_server(int choice)
}
void refresh_page_server_set() {
if (connection_method == 0) {
if (connection_method == 0 || strcmp(status_result.wpa_state, "COMPLETED") != 0) {
send_cmd_picc(tty_fd, "b2", "217");
send_cmd_picc2(tty_fd, "b2", "220");
send_cmd_vis(tty_fd, "t3", "1");
send_cmd_vis(tty_fd, "t0", "0");
send_cmd_vis(tty_fd, "b3", "0");
send_cmd_vis(tty_fd, "b4", "0");
send_cmd_vis(tty_fd, "b0", "0");
} else {
send_cmd_picc(tty_fd, "b2", "218");
send_cmd_picc2(tty_fd, "b2", "219");
send_cmd_vis(tty_fd, "t3", "0");
send_cmd_vis(tty_fd, "t0", "1");
send_cmd_vis(tty_fd, "b3", "1");
send_cmd_vis(tty_fd, "b4", "1");
send_cmd_vis(tty_fd, "b0", "1");
}
if (current_server_page == 0) {
@@ -3493,4 +3566,20 @@ void refresh_page_auto_unload() {
send_cmd_vis(tty_fd, "b0", "1");
send_cmd_vis(tty_fd, "b1", "1");
}
}
int get_mks_ethernet() {
mksini_load();
mks_ethernet = mksini_getboolean("mks_ethernet", "enable", 0);
mksini_free();
return mks_ethernet;
}
void set_mks_ethernet(int target) {
std::cout << "设置以太网:" << target << std::endl;
mksini_load();
mksini_set("mks_ethernet", "enable", std::to_string(target));
mksini_save();
mksini_free();
mks_ethernet = target;
}

View File

@@ -177,6 +177,8 @@ void parse_gcode_response(nlohmann::json params) {
}
} else if (params0 == "!! Insufficient disk space, unable to read the file.") {
jump_to_memory_warning = true;
} else if (params0.find("!! Printer is not ready") != -1) {
// CLL 不做处理
} else if (params0.substr(0, 2) == "!!") {
error_message = params0;
detect_error();

View File

@@ -122,38 +122,65 @@ bool detect_update()
// 4.4.3 CLL 新增deb文件也能更新
int fd_soc_deb;
fd_soc_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC", F_OK);
if (fd_soc_data == 0)
{
detected_soc_data = true;
}
else
{
detected_soc_data = false;
fd_soc_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC", F_OK);
if (fd_soc_data == 0)
{
detected_q1_soc_data = true;
}
else
{
detected_q1_soc_data = false;
}
}
// fd_soc_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC", F_OK);
// if (fd_soc_data == 0)
// {
// detected_soc_data = true;
// }
// else
// {
// detected_soc_data = false;
// fd_soc_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC", F_OK);
// if (fd_soc_data == 0)
// {
// detected_q1_soc_data = true;
// }
// else
// {
// detected_q1_soc_data = false;
// }
// }
if ((dir = opendir(base_path.c_str())) != nullptr)
{
while ((entry = readdir(dir)) != nullptr)
{
std::string filename = entry->d_name;
// 跳过以 .bak 结尾的文件
if (filename.rfind(".bak") == filename.length() - 4) {
continue;
}
if (filename.find("QD_Q1_PATCH") == 0)
{
detected_q1_patch_data = true; // 找到 QD_Q1_PATCH 开头文件
break;
detected_q1_patch_data = true;
continue;
}
if (filename.find("QD_Q1_UI") == 0)
{
detected_q1_ui_data = true;
continue;
}
if (filename.find("QD_Q1_SOC") == 0)
{
detected_q1_soc_data = true;
continue;
}
if (filename.find("QD_Mates3_UI") == 0)
{
detected_ui_data = true;
continue;
}
if (filename.find("QD_Mates3_SOC") == 0)
{
detected_soc_data = true;
continue;
}
}
closedir(dir);
}
else
printf("Usb device path not found: %s\n", base_path.c_str());
fd_mcu_data = access("/home/mks/gcode_files/sda1/QD_MCU/MCU", F_OK);
if (fd_mcu_data == 0)
@@ -165,25 +192,25 @@ bool detect_update()
detected_mcu_data = false;
}
fd_ui_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI", F_OK);
// fd_ui_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI", F_OK);
if (fd_ui_data == 0)
{
detected_ui_data = true;
}
else
{
detected_ui_data = false;
fd_ui_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI", F_OK);
if (fd_ui_data == 0)
{
detected_q1_ui_data = true;
}
else
{
detected_q1_ui_data = false;
}
}
// if (fd_ui_data == 0)
// {
// detected_ui_data = true;
// }
// else
// {
// detected_ui_data = false;
// fd_ui_data = access("/home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI", F_OK);
// if (fd_ui_data == 0)
// {
// detected_q1_ui_data = true;
// }
// else
// {
// detected_q1_ui_data = false;
// }
// }
fd_gcode_cfg = access("/home/mks/gcode_files/sda1/QD_Update/gcode_macro.cfg", F_OK);
if (fd_gcode_cfg == 0)
@@ -246,6 +273,11 @@ void start_update()
{
system("rm /home/mks/gcode_files/.cache/*");
bool factory_mode = (
access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) != -1 ||
access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) != -1
);
if (detected_mcu_data == true)
{
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
@@ -282,42 +314,42 @@ void start_update()
}
}
if (detected_ui_data == true)
{
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; sync");
}
else
{
if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; sync");
}
else
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI.bak; sync");
}
}
}
else if (detected_q1_ui_data == true)
{
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; sync");
}
else
{
if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; sync");
}
else
{
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI.bak; sync");
}
}
}
// if (detected_ui_data == true)
// {
// if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; sync");
// }
// else
// {
// if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; sync");
// }
// else
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /root/800_480.tft; mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_UI.bak; sync");
// }
// }
// }
// else if (detected_q1_ui_data == true)
// {
// if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; sync");
// }
// else
// {
// if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; sync");
// }
// else
// {
// system("cp /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /root/800_480.tft; mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI /home/mks/gcode_files/sda1/QD_Update/QD_Q1_UI.bak; sync");
// }
// }
// }
if (detected_gcode_cfg == true)
{
@@ -386,17 +418,49 @@ void start_update()
system("cp /home/mks/gcode_files/sda1/QD_Update/QD_gcode/*.gcode /home/mks/gcode_files; chmod 777 /home/mks/gcode_files/*.gcode; sync");
}
// 检测到补丁文件
if (detected_q1_patch_data)
// 检测到UI文件
if (detected_ui_data || detected_q1_ui_data) {
if ((dir = opendir(base_path.c_str())) != nullptr)
{
while ((entry = readdir(dir)) != nullptr)
{
std::string filename = entry->d_name;
// 模糊匹配UI文件
if (filename.find("QD_Q1_UI") == 0 || filename.find("QD_Mates3_UI") == 0)
{
std::string filePath = base_path + filename;
std::string command = "cp " + filePath + " /root/800_480.tft; ";
if (!factory_mode) {
command += "mv " + filePath + " " + filePath + ".bak; ";
}
command += "sync";
system(command.c_str());
break; // 每次更新只处理一个UI文件
}
}
closedir(dir);
}
else
{
printf("Directory not found: %s\n", base_path.c_str());
}
}
// 检测到SOC或者PATCH文件
if (detected_q1_patch_data || detected_q1_soc_data || detected_soc_data)
{
bool factory_mode = (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) != -1);
if ((dir = opendir(base_path.c_str())) != nullptr)
{
while ((entry = readdir(dir)) != nullptr)
{
std::string filename = entry->d_name;
if (filename.find("QD_Q1_PATCH") == 0)
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)
{
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;";
@@ -415,57 +479,62 @@ void start_update()
}
closedir(dir);
}
else
{
printf("Directory not found: %s\n", base_path.c_str());
}
}
if (detected_soc_data == true)
{
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
{
std::cout << "检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC; sync;");
}
else
{
if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
{
std::cout << "检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC; sync;");
}
else
{
std::cout << "没有检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC.bak; sync;");
}
}
}
else if (detected_soc_deb == true)
// if (detected_soc_data == true)
// {
// if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
// {
// std::cout << "检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC; sync;");
// }
// else
// {
// if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
// {
// std::cout << "检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC; sync;");
// }
// else
// {
// std::cout << "没有检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Mates3_SOC.bak; sync;");
// }
// }
// }
// else if (detected_soc_deb == true)
if (detected_soc_deb == true)
{ // 4.4.3 CLL 修改deb文件可以更新
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
{
system("dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb;sync");
}
}
else if (detected_q1_soc_data == true)
{
if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
{
std::cout << "检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC; sync;");
}
else
{
if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
{
std::cout << "检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC; sync;");
}
else
{
std::cout << "没有检测到qidi文件" << std::endl;
system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC.bak; sync;");
}
}
}
// else if (detected_q1_soc_data == true)
// {
// if (access("/home/mks/gcode_files/sda1/QD_factory_mode.txt", F_OK) == 0)
// {
// std::cout << "检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC; sync;");
// }
// else
// {
// if (access("/home/mks/gcode_files/sda1/QD_Update/QD_factory_mode.txt", F_OK) == 0)
// {
// std::cout << "检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC; sync;");
// }
// else
// {
// std::cout << "没有检测到qidi文件" << std::endl;
// system("mv /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC /home/mks/gcode_files/sda1/QD_Update/mks.deb; dpkg -i --force-overwrite /home/mks/gcode_files/sda1/QD_Update/mks.deb; mv /home/mks/gcode_files/sda1/QD_Update/mks.deb /home/mks/gcode_files/sda1/QD_Update/QD_Q1_SOC.bak; sync;");
// }
// }
// }
update_finished_tips();
}

View File

@@ -39,6 +39,7 @@ extern std::string str_gimage;
// preview
// wifi start
extern struct mks_wifi_status_result_t status_result;
extern int page_wifi_ssid_list_pages;
extern int page_wifi_current_pages;
// wifi end
@@ -155,6 +156,8 @@ extern int connection_method;
extern int current_server_page;
extern int total_server_count;
extern int mks_ethernet;
bool qr_refreshed = false; // CLL 此变量用于标记二维码刷新仅在切换wifi、切换本地/互联网连接、修改服务器后需要重新刷新
void parse_cmd_msg_from_tjc_screen(char *cmd) {
@@ -816,8 +819,8 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
set_intern_zoffset(0.1);
break;
case TJC_PAGE_PRINT_ZOFFSET_SET_1:
set_intern_zoffset(1);
case TJC_PAGE_PRINT_ZOFFSET_SET_05:
set_intern_zoffset(0.5);
break;
case TJC_PAGE_PRINT_ZOFFSET_UP:
@@ -1454,8 +1457,8 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
set_auto_level_dist(0.1);
break;
case TJC_PAGE_PRE_BED_CALIBRATION_SET_1:
set_auto_level_dist(1);
case TJC_PAGE_PRE_BED_CALIBRATION_SET_05:
set_auto_level_dist(0.5);
break;
case TJC_PAGE_PRE_BED_CALIBRATION_UP:
@@ -2119,6 +2122,15 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
case TJC_PAGE_SHOW_QR_WIFI:
go_to_network();
break;
case TJC_PAGE_SHOW_QR_ETHERNET:
if (mks_ethernet == 1)
set_mks_ethernet(0);
else
set_mks_ethernet(1);
qr_refreshed = false;
go_to_showqr();
break;
default:
break;
@@ -2151,6 +2163,8 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
break;
case TJC_PAGE_SERVER_SET_LOCAL:
if (strcmp(status_result.wpa_state, "COMPLETED") != 0)
break;
if (connection_method == 1) {
set_mks_connection_method(0);
connection_method = 0;

View File

@@ -1,4 +1,4 @@
[version]
mcu = V0.10.0
ui = V4.4.14
soc = V4.4.14
ui = V4.4.18
soc = V4.4.18