diff --git a/include/event.h b/include/event.h index faa1748..5bcbbc4 100644 --- a/include/event.h +++ b/include/event.h @@ -251,4 +251,13 @@ std::string replaceCharacters(const std::string& path, const std::string& search void restore_config(); void refresh_page_restoring(); +//4.2.10 CLL 新增输出日志功能 +void print_log(); + +//4.2.10 CLL 修改断料检测开关逻辑 +void filament_sensor_switch(bool status); + +//4.2.10 CLL 新增共振补偿超时强制跳转 +void send_gcode(std::string command); + #endif diff --git a/include/ui.h b/include/ui.h index 957f08d..8a14049 100644 --- a/include/ui.h +++ b/include/ui.h @@ -33,6 +33,8 @@ #define TJC_PAGE_OPEN_LEVELED_FINISH 0x02 #define TJC_PAGE_OPEN_SYNTONY 6 +//4.2.10 CLL 新增共振补偿超时强制跳转 +#define TJC_PAGE_OPEN_SYNTONY_JUMP_OUT 0x00 #define TJC_PAGE_OPEN_FILAMENT_1 7 // 作废 #define TJC_PAGE_OPEN_FILAMENT_1_NEXT 0x02 // 作废 @@ -348,6 +350,8 @@ #define TJC_PAGE_SET_ZOFFSET_B16 0x16 #define TJC_PAGE_SYNTONY_MOVE 42 +//4.2.10 CLL 新增共振补偿超时强制跳转 +#define TJC_PAGE_SYNTONY_MOVE_JUMP_OUT 0x00 #define TJC_PAGE_SYNTONY_FINISH 43 @@ -443,6 +447,8 @@ #define TJC_PAGE_ABOUT_OOBE 0x0e //4.2.7 CLL 新增恢复出厂设置功能 #define TJC_PAGE_ABOUT_RESTORE 0x0f +//4.2.10 CLL 新增输出日志功能 +#define TJC_PAGE_ABOUT_PRINT_LOG 0x10 #define TJC_PAGE_PRINT_F_POP 53 #define TJC_PAGE_PRINT_F_POP_YES 0x02 @@ -506,6 +512,8 @@ #define TJC_PAGE_NO_UPDATA_OOBE 0x0e //4.2.7 CLL 新增恢复出厂设置功能 #define TJC_PAGE_NO_UPDATA_RESTORE 0x0f +//4.2.10 CLL 新增输出日志功能 +#define TJC_PAGE_NO_UPDATA_PRINT_LOG 0x10 #define TJC_PAGE_KEYDBA 51 #define TJC_PAGE_KEYDBA_HOME 0x2c @@ -673,6 +681,11 @@ #define TJC_PAGE_RESTORING 116 +//4.2.10 CLL 新增输出日志功能 +#define TJC_PAGE_PRINT_LOG_S 117 +#define TJC_PAGE_PRINT_LOG_F 118 +#define TJC_PAGE_PRINT_LOG_YES 0x00 + #endif diff --git a/src/event.cpp b/src/event.cpp index 7a7210f..a7ce11a 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -387,6 +387,10 @@ void refresh_page_show() { if (printer_print_stats_state == "printing") { if (printer_print_stats_filename != "") { sleep(5); + //4.2.10 CLL 修改断料检测开关逻辑 + if (mks_fila_status == true) { + filament_sensor_switch(true); + } MKSLOG_BLUE("跳入到打印函数\n"); //4.2.5 CLL 新增息屏功能 if (previous_caselight_value == true) { @@ -1018,7 +1022,7 @@ void refresh_page_syntony_finish() { MKSLOG_BLUE("Printer webhooks state: %s", printer_webhooks_state.c_str()); if (page_syntony_finished == false) { page_syntony_finished = true; - ep->Send(json_run_a_gcode("SAVE_CONFIG")); + //ep->Send(json_run_a_gcode("SAVE_CONFIG")); all_level_saving = false; } @@ -1144,7 +1148,8 @@ void refresh_page_about() { //4.2.5 CLL 修复UI按下效果 void refresh_page_auto_level() { - send_cmd_txt(tty_fd, "t1", std::to_string(printer_gcode_move_homing_origin[2]).substr(0,5) + "mm"); + //4.2.10 使调平界面显示最终zoffset值 + send_cmd_txt(tty_fd, "t1", std::to_string(printer_gcode_move_homing_origin[2] - 0.15).substr(0,5) + "mm"); if (auto_level_dist == (float)0.01) { send_cmd_picc(tty_fd, "b3", "95"); send_cmd_picc2(tty_fd, "b3", "317"); @@ -1202,7 +1207,8 @@ void refresh_page_stopping() { //4.2.5 CLL 新增设置Z轴偏移页面 void refresh_page_set_zoffset_2() { - send_cmd_txt(tty_fd, "t1", std::to_string(printer_gcode_move_homing_origin[2]).substr(0,5) + "mm"); + //4.2.10 CLL 使调平界面显示最终zoffset值 + send_cmd_txt(tty_fd, "t1", std::to_string(printer_gcode_move_homing_origin[2] - 0.15).substr(0,5) + "mm"); if (auto_level_dist == (float)0.01) { send_cmd_picc(tty_fd, "b3", "95"); send_cmd_picc2(tty_fd, "b3", "317"); @@ -1423,8 +1429,12 @@ void refresh_page_print_filament() { //2023.4.20 网页暂停开始与UI相匹配 if (printer_print_stats_state == "printing") { if (printer_ready == true) { - page_to(TJC_PAGE_PRINTING); - printer_ready = false; + //4.2.10 CLL 修改断料检测开关逻辑 + if (mks_fila_status == true) { + filament_sensor_switch(true); + } + page_to(TJC_PAGE_PRINTING); + printer_ready = false; } } @@ -1794,7 +1804,8 @@ void refresh_page_filament() { send_cmd_picc2(tty_fd, "b22", "421"); } - if (filament_switch_sensor_fila_enabled == true) { + //if (filament_switch_sensor_fila_enabled == true) { + if (mks_fila_status == true) { send_cmd_picc(tty_fd, "b5", "422"); send_cmd_picc2(tty_fd, "b5", "421"); } else { @@ -1877,6 +1888,7 @@ void refresh_page_printing_zoffset() { //2023.4.20 网页暂停开始与UI相匹配 if (printer_print_stats_state == "paused") { if (printer_ready == true) { + filament_sensor_switch(false); page_to(TJC_PAGE_PRINT_FILAMENT); printer_ready = false; } @@ -1884,6 +1896,7 @@ void refresh_page_printing_zoffset() { if (printer_print_stats_state == "complete") { if (level_mode_printing_is_printing_level == false) { + filament_sensor_switch(false); complete_print(); //2.1.2 CLL 修复网页显示预览图bug clear_previous_data(); @@ -1901,12 +1914,14 @@ void refresh_page_printing_zoffset() { //2023.5.8 CLL 网页停止后将跳转至打印停止界面 if (printer_print_stats_state == "standby") { + filament_sensor_switch(false); page_to(TJC_PAGE_STOPPING); } //2023.5.8 CLL 报错弹窗 if (printer_print_stats_state == "error") { page_to(TJC_PAGE_GCODE_ERROR); send_cmd_txt(tty_fd, "t0", "gcode error:" + output_console); + filament_sensor_switch(false); } //2.1.2 CLL 在打印设置zoffset界面也会有断料提醒弹窗 if (filament_switch_sensor_fila_enabled == true) { @@ -2104,12 +2119,14 @@ void refresh_page_printing() { //2023.4.20 网页暂停开始与UI相匹配 if (printer_print_stats_state == "paused") { if (printer_ready == true) { + filament_sensor_switch(false); page_to(TJC_PAGE_PRINT_FILAMENT); printer_ready = false; } } if (printer_print_stats_state == "complete") { + filament_sensor_switch(false); complete_print(); //2.1.2 CLL 修复网页显示预览图bug clear_previous_data(); @@ -2123,6 +2140,7 @@ void refresh_page_printing() { //2023.5.8 CLL 网页停止后将跳转至打印停止界面 if (printer_print_stats_state == "standby") { + filament_sensor_switch(false); page_to(TJC_PAGE_STOPPING); } @@ -2130,6 +2148,7 @@ void refresh_page_printing() { if (printer_print_stats_state == "error") { page_to(TJC_PAGE_GCODE_ERROR); send_cmd_txt(tty_fd, "t0", "gcode error:" + output_console); + filament_sensor_switch(false); } if (filament_switch_sensor_fila_enabled == true) { @@ -2601,11 +2620,11 @@ void move_y_increase() { } void move_z_decrease() { - ep->Send(move(AXIS_Z, "-" + std::to_string(printer_move_dist), 130)); + ep->Send(move(AXIS_Z, "-" + std::to_string(printer_move_dist), 10)); } void move_z_increase() { - ep->Send(move(AXIS_Z, "+" + std::to_string(printer_move_dist), 130)); + ep->Send(move(AXIS_Z, "+" + std::to_string(printer_move_dist), 10)); } bool get_filament_detected() { @@ -2629,6 +2648,7 @@ void set_print_pause_resume() { } void set_print_pause() { + filament_sensor_switch(false); ep->Send(json_run_a_gcode("PAUSE")); // printer_pause_taget = printer_extruder_target; // ep->Send(json_run_a_gcode("G1 Z10\n")); @@ -2637,15 +2657,20 @@ void set_print_pause() { } void set_print_resume() { + if (get_mks_fila_status() == true) { + filament_sensor_switch(true); + } ep->Send(json_run_a_gcode("RESUME")); // set_extruder_target(printer_pause_taget); // printer_pause_taget = 0; } void cancel_print() { + filament_sensor_switch(false); printer_print_stats_filename = ""; clear_cp0_image(); /* 执行这个避免一直加热 */ + filament_sensor_switch(false); // ep->Send(json_run_a_gcode(set_heater_temp("extruder", 0))); // ep->Send(json_run_a_gcode(set_heater_temp("heater_bed", 0))); // ep->Send(json_run_a_gcode(set_heater_temp("hot", 0))); @@ -3020,13 +3045,15 @@ void finish_print() { void set_filament_sensor() { std::cout << "filament_switch_sensor fila = " << filament_switch_sensor_fila_enabled << std::endl; - if (filament_switch_sensor_fila_enabled == 0) { - ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=1\n")); - mks_fila_status = true; + //4.2.10 CLL 修改断料检测开关逻辑 + if (mks_fila_status == true) { + //if (filament_switch_sensor_fila_enabled == 0) { + //ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=1\n")); + mks_fila_status = false; set_mks_fila_status(); } else { - ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=0\n")); - mks_fila_status = false; + //ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=0\n")); + mks_fila_status = true; set_mks_fila_status(); } } @@ -3046,11 +3073,11 @@ void beep_on_off() { if (printer_out_pin_beep_value == 0) { ep->Send(json_run_a_gcode("beep_on")); mks_beep_status = true; - set_mks_beep_status(); + //set_mks_beep_status(); } else { ep->Send(json_run_a_gcode("beep_off")); mks_beep_status = false; - set_mks_beep_status(); + //set_mks_beep_status(); } } @@ -3058,13 +3085,13 @@ void led_on_off() { if (printer_caselight_value == 0) { ep->Send(json_run_a_gcode("SET_PIN PIN=caselight VALUE=1")); mks_led_status = true; - set_mks_led_status(); + //set_mks_led_status(); } else { ep->Send(json_run_a_gcode("SET_PIN PIN=caselight VALUE=0")); //4.2.8 CLL 息屏不保存状态 if (previous_caselight_value == false) { mks_led_status = false; - set_mks_led_status(); + //set_mks_led_status(); } } } @@ -3523,6 +3550,9 @@ void init_mks_status() { get_mks_total_printed_time(); get_mks_babystep(); printer_set_babystep(); + //4.2.10 开机自动设置声音关、灯开、断料检测关 + ep->Send(json_run_a_gcode("beep_off\nSET_PIN PIN=caselight VALUE=1\nSET_FILAMENT_SENSOR SENSOR=fila ENABLE=0\n")); + /* if (get_mks_beep_status() == 0) { MKSLOG_RED("关闭蜂鸣器"); if (get_mks_led_status() == 0) { @@ -3566,6 +3596,7 @@ void init_mks_status() { } } } + */ } void after_scan_refresh_page() { @@ -3762,7 +3793,7 @@ void open_syntony_finish() { MKSLOG_BLUE("Printer webhooks state: %s", printer_webhooks_state.c_str()); if (page_syntony_finished == false) { page_syntony_finished = true; - ep->Send(json_run_a_gcode("SAVE_CONFIG")); + //ep->Send(json_run_a_gcode("SAVE_CONFIG")); } if (printer_idle_timeout_state == "Ready" && printer_webhooks_state == "ready") { @@ -3963,7 +3994,8 @@ void refresh_page_open_heater_bed() { //2.1.2 CLL 修改开机引导流程 void open_heater_bed_up() { page_to(TJC_PAGE_OPEN_VIDEO_4); - ep->Send(json_run_a_gcode("G91\nG1 Z-150 F600\nG1 X-50 Y-50 F1200\nG90\n")); + //4.2.10 CLL 修改开机引导平台上移距离 + ep->Send(json_run_a_gcode("G91\nG1 Z-110 F600\nG1 X-120 Y-120 F1200\nG90\n")); } //2.1.2 CLL 新增热床调平 @@ -4122,9 +4154,11 @@ void refresh_page_open_level() { //4.2.7 CLL 新增恢复出厂设置功能 void restore_config() { system("cp /home/mks/klipper_config/config.mksini.bak /home/mks/klipper_config/config.mksini"); - ep->Send(json_run_a_gcode("BED_MESH_PROFILE REMOVE=\"default\"\nSAVE_CONFIG")); - sleep(1); - page_to(TJC_PAGE_RESTORING); + //ep->Send(json_run_a_gcode("BED_MESH_PROFILE REMOVE=\"default\"\nSAVE_CONFIG")); + //sleep(1); + //page_to(TJC_PAGE_RESTORING); + //4.2.10 CLL 恢复出厂设置不再清空热床调平数据 + page_to(TJC_PAGE_MAIN); } void refresh_page_restoring() { @@ -4132,3 +4166,29 @@ void refresh_page_restoring() { page_to(TJC_PAGE_MAIN); } } + +//4.2.10 CLL 新增输出日志文件功能 +void print_log() { + if (detect_disk() == -1) { + page_to(TJC_PAGE_PRINT_LOG_F); + } 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"); + page_to(TJC_PAGE_PRINT_LOG_S); + } +} + +//4.2.10 CLL 修改断料检测开关逻辑 +void filament_sensor_switch(bool status) { + if (status == true) { + ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=1\n")); + } else if (status == false) { + ep->Send(json_run_a_gcode("SET_FILAMENT_SENSOR SENSOR=fila ENABLE=0\n")); + } +} + +//4.2.10 CLL 新增共振补偿超时强制跳转 +void send_gcode(std::string command) { + ep->Send(json_run_a_gcode(command)); +} \ No newline at end of file diff --git a/src/mks_gcode.cpp b/src/mks_gcode.cpp index a0c8458..111332e 100644 --- a/src/mks_gcode.cpp +++ b/src/mks_gcode.cpp @@ -59,6 +59,8 @@ void parse_gcode_response(nlohmann::json params) { if (params0 == "// Klipper state: Ready") { MKSLOG("重启Klipper已准备就绪,发送订阅内容"); printer_webhooks_state = "ready"; + //4.2.10 CLL 修复跳转界面卡住问题 + printer_idle_timeout_state = "Ready"; printer_webhooks_state_message = "Klipper state: Ready"; // if (all_level_saving == false) { sleep(5); diff --git a/src/ui.cpp b/src/ui.cpp index 80154cb..f72eaae 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -809,46 +809,33 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { break; case TJC_PAGE_PREVIEW_BTN_START: - //2023.4.20 打印过文件标红 - //printed_file_path = page_files_print_files_path; std::cout << "文件路径:" << page_files_print_files_path << std::endl; - //4.2.7 CLL 防止在预览图界面卡死 + //4.3.7 CLL 防止在预览图界面卡死 if (printer_print_stats_state == "printing" || printer_print_stats_state == "paused") { page_to(TJC_PAGE_PRINTING); jump_to_print = false; } else if (show_preview_complete == true) { // 当且仅当预览加载完成才可以按下按钮 - show_preview_complete = false; - //2023.5.9 CLL 删除清理X轴动画 - //if (get_mks_total_printed_time() > 48000) { - // page_to(TJC_PAGE_X_CLEAR_PLUS3); - //} else { - if (get_filament_detected_enable() == true) { - if (get_filament_detected() == true) { - std::cout << "没有检测到断料" << std::endl; - //2.1.2 CLL 判断耗材种类并弹窗 - //page_to(TJC_PAGE_PRINTING); - check_filament_type(); - printer_print_stats_state = "printing"; - print_start(); - start_printing(page_files_print_files_path); - } else { - std::cout << "检测到断料" << std::endl; - page_to(TJC_PAGE_PRINT_F_POP); - } - } else { + //4.3.10 CLL 修改断料检测开关逻辑 + if (get_mks_fila_status() == true) { + if (get_filament_detected() == true) { + check_filament_type(); + printer_print_stats_state = "printing"; + filament_sensor_switch(true); print_start(); start_printing(page_files_print_files_path); - printer_print_stats_state = "printing"; - //2.1.2 CLL 判断耗材种类并弹窗 - //page_to(TJC_PAGE_PRINTING); - check_filament_type(); + } else { + std::cout << "检测到断料" << std::endl; + page_to(TJC_PAGE_PRINT_F_POP); } - //} - // clear_page_preview(); - // show_preview_gimage_completed = false; - show_preview_complete = false; - //2023.5.11 CLL 修复页面跳转bug + } else { + print_start(); + start_printing(page_files_print_files_path); + printer_print_stats_state = "printing"; + check_filament_type(); + //page_to(TJC_PAGE_PRINTING); + } printer_ready = false; + show_preview_complete = false; } break; @@ -2547,6 +2534,11 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { page_to(TJC_PAGE_RESTORE_CONFIG); break; + //4.2.10 CLL 新增输出日志功能 + case TJC_PAGE_ABOUT_PRINT_LOG: + print_log(); + break; + default: break; } @@ -2646,6 +2638,11 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { page_to(TJC_PAGE_RESTORE_CONFIG); break; + //4.2.10 CLL 新增输出日志功能 + case TJC_PAGE_NO_UPDATA_PRINT_LOG: + print_log(); + break; + default: break; } @@ -2886,6 +2883,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { default: break; } + break; case TJC_PAGE_SAVING: break; @@ -3292,6 +3290,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { preview_pop_2_on = false; } page_to(TJC_PAGE_PRINTING); + break; default: break; @@ -3325,6 +3324,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { get_object_status(); } else { page_to(previous_page_id); + get_object_status(); } if (previous_caselight_value == true) { led_on_off(); @@ -3354,6 +3354,46 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) { } break; + //4.2.10 CLL 新增输出日志功能 + case TJC_PAGE_PRINT_LOG_S: + case TJC_PAGE_PRINT_LOG_F: + switch(widget_id) + { + case TJC_PAGE_PRINT_LOG_YES: + go_to_about(); + break; + + default: + break; + } + break; + + case TJC_PAGE_OPEN_SYNTONY: + switch (widget_id) + { + case TJC_PAGE_OPEN_SYNTONY_JUMP_OUT: + send_gcode("SAVE_CONFIG\n"); + page_to(TJC_PAGE_SYNTONY_FINISH); + break; + + default: + break; + } + break; + + case TJC_PAGE_SYNTONY_MOVE: + switch (widget_id) + { + case TJC_PAGE_SYNTONY_MOVE_JUMP_OUT: + send_gcode("SAVE_CONFIG\n"); + page_to(TJC_PAGE_SYNTONY_FINISH); + break; + + default: + break; + } + break; + default: break; } diff --git a/version b/version index 0b992a2..fb5fa85 100644 --- a/version +++ b/version @@ -1,4 +1,4 @@ [version] mcu = V0.10.0 -ui = V4.2.8 -soc = V4.2.8 \ No newline at end of file +ui = V4.2.10 +soc = V4.2.10 \ No newline at end of file