Skip to content

Commit

Permalink
Fix some page redirection issues
Browse files Browse the repository at this point in the history
MAX3_V4.3.3
  • Loading branch information
Rainboooom committed Jun 21, 2023
1 parent 65348bf commit 375774f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 43 deletions.
3 changes: 3 additions & 0 deletions include/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@ void check_filament_type();

void refresh_page_preview_pop();

//4.3.2 CLL 修复无法读取文件名中有空格文件
std::string replaceCharacters(const std::string& path, const std::string& searchChars, const std::string& replacement);

#endif
5 changes: 3 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ int main(int argc, char** argv) {

page_to(current_page_id);

//4.3.2 CLL 修复开机读取不到参数
get_total_time();
sleep(1);
sleep(2);
sub_object_status(); // 订阅相关的参数

sleep(1);
sleep(2);

get_object_status(); // 主动获取必备的参数
sleep(2);
Expand Down
5 changes: 5 additions & 0 deletions src/KlippyRest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../include/KlippyRest.h"
#include "../include/mks_log.h"
#include "../include/event.h"

std::string server_files_metadata(std::string ip, std::string port, std::string filename) {
return send_request(ip, port, "server/files/metadata?filename=" + filename, "GET");
Expand Down Expand Up @@ -64,6 +65,10 @@ std::string get_thumbnail_stream(std::string ip, std::string port, std::string t
std::string send_request(std::string ip, std::string port, std::string method, std::string request_type) {
std::string url = "http://" + ip + ":" + port + "/" + method;
std::string str_response = "";

//4.3.2 CLL 修复无法读取文件名中有空格文件
url=replaceCharacters(url," ","%20");

MKSLOG_BLUE("Sending request to %s", url.data());
try
{
Expand Down
33 changes: 23 additions & 10 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,6 @@ void refresh_page_stopping() {
MKSLOG_BLUE("Printer ide_timeout state: %s", printer_idle_timeout_state.c_str());
MKSLOG_BLUE("Printer webhooks state: %s", printer_webhooks_state.c_str());
if (printer_idle_timeout_state == "Ready") {
//test
// sleep(2);
//3.1.2 CLL 修复网页显示预览图bug
clear_previous_data();
Expand Down Expand Up @@ -1157,19 +1156,19 @@ void refresh_page_set_zoffset() {
send_cmd_txt(tty_fd, "b20", std::to_string(page_set_zoffset_z_position[14]));
send_cmd_txt(tty_fd, "b21", std::to_string(page_set_zoffset_z_position[15]));
*/
//3.1.0 CLL 修改调平为至多25个点
std::string temp[5][5];
//4.3.3 CLL 修改调平为至多64个点
std::string temp[8][8];
for (int i = 0; i < printer_bed_mesh_profiles_mks_mesh_params_y_count; i++) {
if (i == 5) {
if (i == 8) {
break;
}
for (int j = 0; j < printer_bed_mesh_profiles_mks_mesh_params_x_count; j++) {
if (j == 5) {
if (j == 8) {
break;
}
temp[i][j] = std::to_string(printer_bed_mesh_profiles_mks_points[i][j]);
temp[i][j] = temp[i][j].substr(0, temp[i][j].find(".") + 4);
send_cmd_txt(tty_fd,"t"+std::to_string(i * 5 + j),temp[i][j]);
temp[i][j] = temp[i][j].substr(0, temp[i][j].find(".") + 3);
send_cmd_txt(tty_fd,"t"+std::to_string(i * 8 + j),temp[i][j]);
}
}
/*
Expand Down Expand Up @@ -2586,11 +2585,12 @@ void start_manual_level() {

/* 完成自动调平 */
void finish_auto_level() {
if ( auto_level_finished == false ) {
//4.3.3 CLL 修复自动调平完成页面卡住
if ( auto_level_finished == false || printer_idle_timeout_state == "Idle") {
// ep->Send(json_run_a_gcode("G1 X0 Y0 F6000\nSAVE_CONFIG\n"));
// ep->Send(json_run_a_gcode("G1 X0 Y0 F6000\nG91\nG1 Z200\nG90\nM1029\nSAVE_CONFIG"));
//2023.4.21-1 增加调平完成后移动平台
ep->Send(json_run_a_gcode("G0 X0 Y0 Z50 F5000\nM1029\nSAVE_CONFIG"));
//4.3.3 CLL 修改调平完成后平台移动
ep->Send(json_run_a_gcode("G0 Z50 F600\nG1 X0 Y0 G9000\nM1029\nSAVE_CONFIG"));
// ep->Send(json_run_a_gcode("SAVE_CONFIG\nBED_MESH_PROFILE LOAD=\"name\"\n"));
all_level_saving = false;
// sleep(7);
Expand Down Expand Up @@ -3818,3 +3818,16 @@ void refresh_page_preview_pop() {
}
}
}

//4.3.2 CLL 修复无法读取文件名中带空格文件
std::string replaceCharacters(const std::string& path, const std::string& searchChars, const std::string& replacement) {
std::string result = path;
for (char c : searchChars) {
std::size_t found = result.find(c);
while (found != std::string::npos) {
result.replace(found, 1, replacement);
found = result.find(c, found + replacement.length());
}
}
return result;
}
16 changes: 8 additions & 8 deletions src/mks_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ bool manual_level_finished = false;

float printer_bed_mesh_mesh_min[2] = {0.0, 0.0};
float printer_bed_mesh_mesh_max[2] = {0.0, 0.0};
//3.1.0 CLL 新增调平至多点为25个
//4.3.3 CLL 新增调平至多点为64个
//float printer_bed_mesh_profiles_mks_points[4][4] = {0.0};
float printer_bed_mesh_profiles_mks_points[5][5] = {0.0};
float printer_bed_mesh_profiles_mks_points[8][8] = {0.0};
float printer_bed_mesh_profiles_mks_mesh_params_tension = 0.0;
float printer_bed_mesh_profiles_mks_mesh_params_mesh_x_pps = 0;
std::string printer_bed_mesh_profiles_mks_mesh_params_algo = "";
Expand Down Expand Up @@ -325,13 +325,13 @@ void parse_bed_mesh(nlohmann::json bed_mesh) {
if (bed_mesh["profiles"]["default"]["mesh_params"]["max_y"] != nlohmann::detail::value_t::null) {
printer_bed_mesh_profiles_mks_mesh_params_max_y = bed_mesh["profiles"]["default"]["mesh_params"]["max_y"];
}
//3.1.0 CLL 调平修改为至多25个点
//4.3.3 CLL 调平修改为至多64个点
for (int i = 0; i < printer_bed_mesh_profiles_mks_mesh_params_y_count; i++) {
if (i == 5) {
if (i == 8) {
break;
}
for (int j = 0; j < printer_bed_mesh_profiles_mks_mesh_params_x_count; j++) {
if (j == 5) {
if (j == 8) {
break;
}
printer_bed_mesh_profiles_mks_points[i][j] = bed_mesh["profiles"]["default"]["points"][i][j];
Expand Down Expand Up @@ -501,9 +501,9 @@ void parse_subscribe_objects_status(nlohmann::json status) {
if (status["bed_mesh"] != nlohmann::detail::value_t::null) {
std::cout << status["bed_mesh"] << std::endl;
parse_bed_mesh(status["bed_mesh"]);
//3.1.0 CLL 修改调平点为25个
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
//4.3.3 CLL 修改调平点显示至多为64个
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
//for (int i = 0; i < 4; i++) {
// for (int j = 0; j < 4; j++) {
std::cout << "############# Points :" << i << ", " << j << " " << printer_bed_mesh_profiles_mks_points[i][j] << std::endl;
Expand Down
61 changes: 40 additions & 21 deletions src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,12 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
switch (widget_id)
{
case TJC_PAGE_OPEN_LEVELED_FINISH:
if (auto_level_button_enabled == true) {
//4.3.2 CLL 修复卡在自动调平完成页面
//if (auto_level_button_enabled == true) {
auto_level_button_enabled = false;
// page_to(TJC_PAGE_OPEN_SYNTONY);
open_go_to_syntony_move();
}
//}

// std::cout << "共振补偿按下按钮" << std::endl;
break;
Expand Down Expand Up @@ -399,7 +400,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
{
case TJC_PAGE_FILAMENT_VIDEO_1_RIGHT:
//3.1.0 CLL 防止点击过快报错
if (printer_idle_timeout_state == "Ready") {
if (printer_idle_timeout_state == "Ready" || printer_idle_timeout_state == "Idle") {
open_down_50();
page_to(TJC_PAGE_FILAMENT_VIDEO_2);
}
Expand Down Expand Up @@ -1103,13 +1104,15 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
{
case TJC_PAGE_MOVE_POP_1_YES:
move_home();
set_move_dist(0.1); // 恢复步长为0.1
page_to(TJC_PAGE_MOVE);
//4.3.3 CLL 修复显示bug
set_move_dist(0.1); // 恢复步长为0.1
break;

case TJC_PAGE_MOVE_POP_1_NO:
set_move_dist(0.1); // 恢复步长为0.1
page_to(TJC_PAGE_MOVE);
//4.3.3 CLL 修复显示bug
set_move_dist(0.1); // 恢复步长为0.1
break;

default:
Expand Down Expand Up @@ -1451,6 +1454,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {

//2023.4.21-5 修改调平数据显示
case TJC_PAGE_LEVEL_MODE_ZOFFSET:
get_object_status();
page_to(TJC_PAGE_SET_ZOFFSET);
break;

Expand Down Expand Up @@ -1643,7 +1647,8 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
switch (widget_id)
{
case TJC_PAGE_AUTO_FINISH_YES:
if (auto_level_button_enabled == true) {
//4.3.3 CLL 修复卡在自动调平完成页面
if (auto_level_button_enabled == true ||printer_idle_timeout_state == "Idle") {
auto_level_button_enabled = false;
std::cout << "自动调平已完成" << std::endl;
finish_auto_level();
Expand Down Expand Up @@ -1719,7 +1724,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
page_to(TJC_PAGE_PRINT_FILAMENT);
} else if (previous_page_id == TJC_PAGE_PREVIEW) {
page_to(TJC_PAGE_FILAMENT);
} else if (previous_page_id == TJC_PAGE_PRINT_FILAMENT) {
} else{//4.3.3 CLL 修复断料弹窗卡住bug
page_to(TJC_PAGE_PRINT_FILAMENT);
}
break;
Expand Down Expand Up @@ -2254,6 +2259,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
}
break;

//4.3.2 CLL 优化页面跳转
case TJC_PAGE_SERVICE:
switch (widget_id)
{
Expand All @@ -2276,6 +2282,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {


//if (detect_disk() == 0) { //3.1.0 CLL 去除U盘插入判断
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
page_to(TJC_PAGE_FILE_LIST_1);
// printer_set_babystep();
page_files_pages = 0;
Expand All @@ -2288,22 +2295,32 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
refresh_page_files_list_1();

get_object_status();
}
//} else {
// page_to(TJC_PAGE_DISK_DETECT_2);
//}

break;

case TJC_PAGE_SERVICE_BTN_HOME:
page_to(TJC_PAGE_MAIN);
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MAIN);
}
break;

case TJC_PAGE_SERVICE_BTN_TOOL:
page_to(TJC_PAGE_MOVE);
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MOVE);
}
break;

case TJC_PAGE_SERVICE_LANGUAGE:
page_to(TJC_PAGE_LANGUAGE);
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_LANGUAGE);
}
break;

case TJC_PAGE_SERVICE_RESET:
Expand All @@ -2318,7 +2335,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
}
break;

//2023.5.9 CLL 修复重启后温度显示异常
//4.3.1 CLL 优化页面跳转
case TJC_PAGE_RESET:
switch (widget_id)
{
Expand Down Expand Up @@ -2347,7 +2364,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
break;

case TJC_PAGE_RESET_SERVICE:
//page_to(TJC_PAGE_SERVICE);
page_to(TJC_PAGE_SERVICE);
break;

case TJC_PAGE_RESET_ABOUT:
Expand Down Expand Up @@ -2438,7 +2455,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
}
break;

//3.1.0 修复页面跳转bug
//4.3.2 CLL 优化页面跳转
case TJC_PAGE_ABOUT:
switch (widget_id)
{
Expand Down Expand Up @@ -2481,26 +2498,27 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {

case TJC_PAGE_ABOUT_BTN_HOME:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MAIN);
}
break;

case TJC_PAGE_ABOUT_BTN_TOOL:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MOVE);
}
break;

case TJC_PAGE_ABOUT_LANGUAGE:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_LANGUAGE);
}
break;

case TJC_PAGE_ABOUT_SERVICE:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
page_to(TJC_PAGE_SERVICE);
}
page_to(TJC_PAGE_SERVICE);
break;

case TJC_PAGE_ABOUT_RESET:
Expand Down Expand Up @@ -2533,7 +2551,7 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {
}
break;

//3.1.0 CLL 修复页面跳转bug
//4.3.2 CLL 优化页面跳转
case TJC_PAGE_NO_UPDATA:
switch (widget_id)
{
Expand Down Expand Up @@ -2576,30 +2594,31 @@ void tjc_event_clicked_handler(int page_id, int widget_id, int type_id) {

case TJC_PAGE_NO_UPDATA_BTN_HOME:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MAIN);
}
break;

case TJC_PAGE_NO_UPDATA_BTN_TOOL:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_MOVE);
}
break;

case TJC_PAGE_NO_UPDATA_LANGUAGE:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
get_object_status();
page_to(TJC_PAGE_LANGUAGE);
}
break;

case TJC_PAGE_NO_UPDATA_SERVICE:
if (printer_webhooks_state != "shutdown" && printer_webhooks_state != "error") {
page_to(TJC_PAGE_SERVICE);
}
page_to(TJC_PAGE_SERVICE);
break;

case TJC_PAGE_NO_UPDATA_RESET:
go_to_reset();
go_to_reset();
break;

//2023.5.9 CLL 隐藏开机引导
Expand Down
4 changes: 2 additions & 2 deletions version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[version]
mcu = V0.10.0
ui = V4.3.1
soc = V4.3.1
ui = V4.3.3
soc = V4.3.3

0 comments on commit 375774f

Please sign in to comment.