Initial commit

This commit is contained in:
CChen616
2024-03-19 15:48:17 +08:00
parent 2ae601ba66
commit 1023fb5796
82 changed files with 43002 additions and 1 deletions

1207
include/HTTPRequest.hpp Normal file

File diff suppressed because it is too large Load Diff

60
include/KlippyGcodes.h Normal file
View File

@@ -0,0 +1,60 @@
#ifndef KLIPPY_GCODES_H
#define KILPPY_GCODES_H
#include <iostream>
#define AXIS_X "X"
#define AXIS_Y "Y"
#define AXIS_Z "Z"
#define HOME "G28"
#define HOME_X "G28 X"
#define HOME_Y "G28 Y"
#define HOME_Z "G28 Z"
#define HOME_XY "G28 X Y"
#define Z_TILT "Z_TILT_ADJUST"
#define QUAD_GANTRY_LEVEL "QUAD_GANTRY_LEVEL"
#define MOVE "G1"
#define MOVE_ABSOLUTE "G90"
#define MOVE_RELATIVE "G91"
#define EXTRUDE_ABS "M82"
#define EXTRUDE_REL "M83"
#define SET_EXT_TEMP "M104"
#define SET_BED_TEMP "M140"
#define SET_EXT_FACTOR "M221"
#define SET_FAN_SPEED "M106"
#define SET_SPD_FACTOR "M220"
#define PROBE_CALIBRATE "PROBE_CALIBRATE"
#define Z_ENDSTOP_CALIBRATE "Z_ENDSTOP_CALIBRATE"
#define TESTZ "TESTZ Z="
#define ABORT "ABORT"
#define ACCEPT "ACCEPT"
#define SAVE_CONFIG "SAVE_CONFIG"
#define RESTART "RESTART"
#define FIRMWARE_RESTART = "FIRMWARE_RESTART"
std::string set_bed_temp(int temp);
std::string set_ext_temp(int temp, int tool);
std::string set_heater_temp(std::string heater, int temp);
std::string set_temp_fan_temp(std::string temp_fan, int temp);
std::string set_fan_speed(int speed);
std::string set_fan0_speed(int speed);
std::string set_fan2_speed(int speed);
std::string set_fan3_speed(int speed);
std::string set_extrusion_rate(std::string rate);
std::string set_speed_rate(std::string rate);
std::string testz_move(std::string dist);
std::string extrude(std::string dist, int speed);
std::string bed_mesh_load(std::string profile);
std::string bed_mesh_remove(std::string profile);
std::string bed_mesh_save(std::string profile);
#endif

41
include/KlippyRest.h Normal file
View File

@@ -0,0 +1,41 @@
#ifndef KLIPPY_REST_H
#define KLIPPY_REST_H
#include <iostream>
#include "./HTTPRequest.hpp"
std::string get_server_files_list(std::string ip, std::string port);
std::string get_server_files_directory(std::string ip, std::string port);
std::string server_files_metadata(std::string ip, std::string port, std::string filename);
/* 打印机对象参数获取 */
std::string printer_objects_query(std::string ip, std::string port, std::string parameter);
/* 打印管理 */
// 打印文件
std::string printer_print_start(std::string ip, std::string port, std::string filename);
// 暂停打印
std::string printer_print_pause(std::string ip, std::string port);
// 继续打印
std::string printer_print_resume(std::string ip, std::string port);
// 取消打印
std::string printer_print_cancel(std::string ip, std::string port);
/* 打印机状态 */
std::string get_server_info(std::string ip, std::string port);
std::string get_oneshot_token(std::string ip, std::string port);
std::string get_printer_info(std::string ip, std::string port);
/* File Operations */
std::string delete_file_delete(std::string ip, std::string port, std::string filepath);
std::string get_thumbnail_stream(std::string ip, std::string port, std::string thumbnail);
std::string send_request(std::string ip, std::string port, std::string method, std::string request_type);
// std::string send_post_request(std::string ip, std::string port, std::string method);
#endif

137
include/MakerbaseClient.h Normal file
View File

@@ -0,0 +1,137 @@
#ifndef MAKERBASE_CLIENT_H
#define MAKERBASE_CLIENT_H
// 不包含TLS Client
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
// 包含TLS Client
// #include <websocketpp/config/asio_client.hpp>
// #include <websocketpp/client.hpp>
#include <websocketpp/common/thread.hpp>
#include <websocketpp/common/memory.hpp>
#include <string>
#include <locale>
#include <codecvt>
#include "./mks_log.h"
#include "./MoonrakerAPI.h"
#include "./MakerbaseParseMessage.h"
extern std::string message;
extern bool is_get_message;
typedef websocketpp::client<websocketpp::config::asio_client> client;
// 保存一个连接的metadata
class connection_metadata {
public:
typedef websocketpp::lib::shared_ptr<connection_metadata> ptr;
connection_metadata(websocketpp::connection_hdl hdl, std::string url) {
this->m_Hdl = hdl;
this->m_Status = "Connecting";
this->m_Url = url;
this->m_Server = "N/A";
}
void on_open(client * c, websocketpp::connection_hdl hdl) {
this->m_Status = "Open";
// c->get_alog().write(websocketpp::log::alevel::app, "Open client, the url is" + this->m_Url);
client::connection_ptr con = c->get_con_from_hdl(hdl);
m_Server = con->get_response_header("Server");
MKSLOG("websocket连接成功\n");
// std::cout << this->m_Status << "the m_Server is" + m_Server << std::endl;
}
void on_fail(client * c, websocketpp::connection_hdl hdl)
{
this->m_Status = "Failed";
c->get_alog().write(websocketpp::log::alevel::app, "Connection Failed");
client::connection_ptr con = c->get_con_from_hdl(hdl);
m_Server = con->get_response_header("Server");
m_Error_reason = con->get_ec().message();
// std::cout << this->m_Status << "the m_Server is " + m_Server << std::endl;
std::cout << "连接服务端失败,请重新连接" << std::endl;
}
void on_close(client * c, websocketpp::connection_hdl hdl)
{
this->m_Status = "Closed";
client::connection_ptr con = c->get_con_from_hdl(hdl);
std::stringstream s;
s << "close code: " << con->get_remote_close_code() << " ("
<< websocketpp::close::status::get_string(con->get_remote_close_code())
<< "), close reason: " << con->get_remote_close_reason();
m_Error_reason = s.str();
// std::cout << this->m_Status << "the m_Server is " + m_Server << std::endl;
}
void on_message(websocketpp::connection_hdl, client::message_ptr msg) {
if (msg->get_opcode() == websocketpp::frame::opcode::text) {
// std::string message = msg->get_payload();
// std::cout << "收到来自服务器的消息:" << message << std::endl;
// this->m_Message = msg->get_payload();
message = msg->get_payload();
is_get_message = true;
} else {
std::string message = websocketpp::utility::to_hex(msg->get_payload());
}
}
websocketpp::connection_hdl get_hdl() const {
return m_Hdl;
}
std::string get_status() const {
return m_Status;
}
private:
websocketpp::connection_hdl m_Hdl; // websocketpp表示连接的编号
std::string m_Status; // 连接自动状态
std::string m_Url; // 连接的URI
std::string m_Server; // 服务器信息
std::string m_Error_reason; // 错误原因
std::string m_Message; // 回收到的消息
bool is_recv_result = false; // 是否已经收到 result 为 "OK" 的回调信息
};
class MakerbaseClient
{
public:
MakerbaseClient(std::string host, std::string port);
virtual~MakerbaseClient();
public:
bool Connect(std::string const & url);
bool Close(std::string reason = "");
bool Send(std::string message);
bool GetIsConnected();
std::string GetStatus();
connection_metadata::ptr GetConnectionMetadataPtr();
std::string GetURL();
private:
bool is_connected = false; // 连接判断
std::string status = "none"; // 连接的状态,用字符串表示
std::string host; // 目标地址 host
std::string port; // 目标地址 port
std::string sending_message; // 发送的消息
connection_metadata::ptr m_ConnectionMetadataPtr;
client m_WebsocketClient;
websocketpp::lib::shared_ptr<websocketpp::lib::thread> m_Thread; // 线程
};
#endif // !MAKERBASE_CLIENT_H

261
include/MakerbaseCommand.h Normal file
View File

@@ -0,0 +1,261 @@
#ifndef MAKERBASE_COMMAND_H
#define MAKERBASE_COMMAND_H
#include <map>
/**
* @brief 接收的执行与API映射定义
*
*/
static std::map<int, std::string> method2command = {
{0x01, "server.connection.identify"},
{0x02, "server.websocket.id"},
{0x03, "printer.info"},
{0x04, "printer.emergency_stop"},
{0x05, "printer.restart"},
{0x06, "printer.firmware_restart"},
{0x11, "printer.objects.list"},
{0x12, "printer.objects.query"},
{0x13, "printer.objects.subscribe"},
{0x14, "printer.query_endstops.status"},
{0x15, "server.info"},
{0x16, "server.config"},
{0x17, "server.temperature_store"},
{0x18, "server.gcode_store"},
{0x19, "server.restart"},
{0x21, "printer.gcode.script"},
{0x22, "printer.gcode.help"},
{0x31, "printer.print.start"},
{0x32, "printer.print.pause"},
{0x33, "printer.print.resume"},
{0x34, "printer.print.cancel"},
{0x41, "machine.system_info"},
{0x42, "machine.shutdown"},
{0x43, "machine.reboot"},
{0x44, "machine.services.restart"},
{0x45, "machine.services.stop"},
{0x46, "machine.services.start"},
{0x47, "machine.proc_stats"},
{0x51, "server.files.list"},
{0x52, "server.files.metadata"},
{0x53, "server.files.get_directory"},
{0x54, "server.files.post_directory"},
{0x55, "server.files.delete_directory"},
{0x56, "server.files.move"},
{0x57, "server.files.copy"},
// 0x58 留给 文件下载 功能只有http请求可以用
// 0x59 留给 上传文件 功能只有http请求可以用
{0x5a, "server.files.delete_file"},
// 0x5b 留给 下载klippy.log 功能只有http请求可以用
// 0x5c 留给 下载moonraker.log 功能只有http请求可以用
// 0x61 登录用户
// 0x62 注销当前用户
// 0x63 获取当前用户
// 0x64 创建用户
// 0x65 删除用户
// 0x66 列出可用用户
// 0x67 重置用户密码
// 0x68 刷新 JSON Web 令牌
// 0x69 生成 Oneshot 令牌
// 0x6a 检索有关授权端点的信息
// 0x6b 获取当前 API 密钥
// 0x6c 生成新的 API 密钥
{0x71, "server.database.list"},
{0x72, "server.database.get_item"},
{0x73, "server.database.post_item"},
{0x74, "server.database.delete_item"},
{0x81, "server.job_queue.status"},
{0x82, "server.job_queue.post_job"},
{0x83, "server.job_queue.delete_job"},
{0x84, "server.job_queue.pause"},
{0x85, "server.job_queue.start"},
{0x86, "server.announcements.list"},
{0x87, "server.announcements.update"},
{0x88, "server.announcements.dismiss"},
{0x89, "server.announcements.feeds"},
{0x8a, "server.announcements.post_feed"},
{0x8b, "server.announcements.delete_feed"},
{0x8c, "machine.update.status"},
{0x90, "machine.update.full"},
{0x91, "machine.update.status"},
{0x92, "machine.update.moonraker"},
{0x93, "machine.update.klipper"},
{0x94, "machine.update.client"},
{0x95, "machine.update.system"},
{0x96, "machine.update.recover"},
{0xa1, "machine.device_power.devices"},
{0xa2, "machine.device_power.get_device"},
{0xa3, "machine.device_power.post_device"},
{0xa4, "machine.device_power.status"},
{0xa5, "machine.device_power.on"},
{0xa6, "machine.device_power.off"},
{0xb1, "machine.wled.strips"},
{0xb2, "machine.wled.status"},
{0xb3, "machine.wled.on"},
{0xb4, "machine.wled.off"},
{0xb5, "machine.wled.toggle"},
{0xb6, "machine.wled.get_strip"},
// OctoPrint API 模拟 暂不添加 0xc 字段保留
{0xd1, "server.history.list"},
{0xd2, "server.history.totals"},
{0xd3, "server.history.reset_totals"},
{0xd4, "server.history.get_job"},
{0xd5, "server.history.delete_job"},
{0xe1, "server.mqtt.publish"},
{0xe2, "server.mqtt.subscribe"},
{0x101, "server.webcams.list"},
{0x102, "server.webcams.get_item"},
{0x103, "server.webcams.post_item"},
{0x104, "server.webcams.delete_item"},
{0x105, "server.webcams.test"},
{0xf1, "server.extensions.list"},
{0xf2, "server.extensions.request"},
{0xf3, "connection.send_event"}
};
static std::map<int, int> method2id = {
{0x01, 4656},
{0x02, 4656},
{0x03, 5445},
{0x04, 4564},
{0x05, 4894},
{0x06, 8463},
{0x11, 1454},
{0x12, 4654},
{0x13, 5434},
{0x14, 3456},
{0x15, 9546},
{0x16, 5616},
{0x17, 2313},
{0x18, 7643},
{0x19, 4656},
{0x21, 7466},
{0x22, 4645},
{0x31, 4654},
{0x32, 4564},
{0x33, 1465},
{0x34, 2578},
{0x41, 4665},
{0x42, 4665},
{0x43, 4665},
{0x44, 4656},
{0x45, 4645},
{0x46, 4645},
{0x47, 7896},
{0x51, 4644},
{0x52, 3545},
{0x53, 5644},
{0x54, 6548},
{0x55, 6545},
{0x56, 5664},
{0x57, 5623},
// 0x58
// 0x59
{0x5a, 1323},
// 0x5b
// 0x5c
// 0x61 登录用户
// 0x62 注销当前用户
// 0x63 获取当前用户
// 0x64 创建用户
// 0x65 删除用户
// 0x66 列出可用用户
// 0x67 重置用户密码
// 0x68 刷新 JSON Web 令牌
// 0x69 生成 Oneshot 令牌
// 0x6a 检索有关授权端点的信息
// 0x6b 获取当前 API 密钥
// 0x6c 生成新的 API 密钥
{0x71, 8694},
{0x72, 5644},
{0x73, 4654},
{0x74, 4654},
{0x81, 4654},
{0x82, 4654},
{0x83, 4654},
{0x84, 4654},
{0x85, 4654},
{0x86, 4654},
{0x87, 4654},
{0x88, 4654},
{0x89, 4654},
{0x8a, 4654},
{0x8b, 4654},
{0x8c, 4644},
{0x90, 4645},
{0x91, 4644},
{0x92, 4645},
{0x93, 5745},
{0x94, 8546},
{0x95, 4564},
{0x96, 4564},
{0xa1, 5646},
{0xa2, 4564},
{0xa3, 4564},
{0xa4, 4564},
{0xa5, 4564},
{0xa6, 4564},
{0xb1, 7123},
{0xb2, 7124},
{0xb3, 7125},
{0xb4, 7126},
{0xb5, 7127},
{0xb6, 7128},
// OctoPrint API 模拟 暂不添加 0xc 字段保留
{0xd1, 5656},
{0xd2, 5656},
{0xd3, 5534},
{0xd4, 4564},
{0xd5, 5534},
{0xe1, 4564},
{0xe2, 4564},
{0xf1, 4564},
{0xf2, 4564},
// 0xf2 without id
{0x101, 4654},
{0x102, 4654},
{0x103, 4654},
{0x104, 4654},
{0x105, 4654}
};
#endif

39
include/MakerbaseIPC.h Normal file
View File

@@ -0,0 +1,39 @@
/**
* 进程间通信暂时不使用,此部分为消息队列,过程可能会出现阻塞现象,导致后面加载不起来
*
*/
#ifndef MAKERBASEIPC_H
#define MAKERBASEIPC_H
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <semaphore.h>
#define MKS_SEM_1_NAME "mkssem1" // 定义内部使用的信号量名称
#define MKS_SEM_2_NAME "mkssem2" // 定义内部使用的信号量名称
#define MKS_MSG_ID 318 // 定义消息队列 id
struct commandBuf
{
long mtype;
char mtext[1024];
};
struct commandBuf cmd_to_rcv;
int msqid;
int ret;
sem_t *sem1 = NULL; // 保存信号量地址
sem_t *sem2 = NULL; // 保存信号量地址
ssize_t rcv_bytes; // 保存从队列读取的字节数
#endif

View File

@@ -0,0 +1,9 @@
#ifndef MAKERBASE_NETWORK_H
#define MAKERBASE_NETWORK_H
#include <iostream>
#include "./MakerbaseShell.h"
std::string get_wlan0_ip();
#endif

20
include/MakerbasePanel.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef MAKERBASE_PANEL_H
#define MAKERBASE_PANEL_H
#include <iostream>
#include "nlohmann/json.hpp"
#define AXIS_X "X"
#define AXIS_Y "Y"
#define AXIS_Z "Z"
std::string home();
std::string homexy();
std::string z_tilt();
std::string quad_gantry_level();
std::string move(std::string axis, std::string dist, int speed);
std::string get_printer_object_status();
#endif

View File

@@ -0,0 +1,43 @@
#ifndef MAKERBASEPARSEINI_H
#define MAKERBASEPARSEINI_H
#define XINDI_PLUS 1
#define XINDI_MAX 0
#define XINDI_MINI 0
#include <iostream>
#include "./dictionary.h"
#include "./iniparser.h"
//#define INIPATH "/root/config.mksini"
#define INIPATH "/home/mks/klipper_config/config.mksini"
#ifdef XINDI_PLUS
#define VERSION_PATH "/root/xindi/version"
#elif XINDI_MAX
#define VERSION_PATH "/root/xindi/version-max"
#elif XINDI_MINI
#define VERSION_PATH "/root/xindi/version-4-3"
#endif
// std::string get_cfg_serial();
int mksini_load();
void mksini_free();
std::string mksini_getstring(std::string section, std::string key, std::string def);
int mksini_getint(std::string section, std::string key, int notfound);
double mksini_getdouble(std::string section, std::string key, double notfound);
bool mksini_getboolean(std::string section, std::string key, int notfound);
int mksini_set(std::string section, std::string key, std::string value);
void mksini_unset(std::string section, std::string key);
void mksini_save();
int mksversion_load();
void mksversion_free();
std::string mksversion_mcu(std::string def);
std::string mksversion_ui(std::string def);
std::string mksversion_soc(std::string def);
int updateini_load();
int progressini_load();
#endif

View File

@@ -0,0 +1,11 @@
#ifndef MAKERBASE_PARSE_MESSAGE
#define MAKERBASE_PARSE_MESSAGE
/**
* 通过发送的 method id 来获得相应的回调信息,使用不同的 response type id 可以通过
* switch 的方式,快速找到相应的解析方式
*
*/
void *json_parse(void *arg);
#endif

18
include/MakerbaseSerial.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef MAKERBASE_SERIAL_H
#define MAKERBASE_SERIAL_H
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <termios.h>
int set_option(int fd, int baudrate, int bits, unsigned char parity, unsigned char stopbit);
#endif

11
include/MakerbaseShell.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef MAKERBASE_SHELL_H
#define MAKERBASE_SHELL_H
#include <stdio.h>
#include <string.h>
#define MAX_FILE_LEN 1024*4
void execute_cmd(const char *cmd, char *result);
#endif

47
include/MakerbaseWiFi.h Normal file
View File

@@ -0,0 +1,47 @@
#ifndef MAKERBASE_WIFI_H
#define MAKERBASE_WIFI_H
#include "./MakerbaseShell.h"
void set_page_wifi_ssid_list(int pages);
void get_ssid_list_pages();
void get_wlan0_status();
bool detected_wlan0();
void split_scan_result(std::string result);
// void set_wpa_supplicant(std::string ssid, std::string psk);
// parse scan result
// std::string get_mac_from_result(std::string result);
// std::string get_frequency_from_result(std::string result);
// std::string get_signal_level_from_result(std::string result);
// std::string get_flags_from_result(std::string result);
// std::string get_ssid_from_result(std::string result);
//
void get_connected_ssid();
void get_current_wifi();
// void read_wpa_supplicant();
// std::string rescan();
std::string save_wpa_conf();
// void scan_results();
std::string wpa_cli(std::string command);
static std::string lookup(int freq);
/*
void mid_wifi_ssid_convert_utf8(unsigned char *ssid, char *bssid, int size);
unsigned char mid_wifi_ssid_convert_decimal(char ssid);
*/
size_t printf_decode(unsigned char *buf, size_t maxlen, const char *str);
int hex2byte(const char *hex);
static int hex2num(char c);
int parse_scan_results(char* scan_results);
#endif

170
include/MoonrakerAPI.h Normal file
View File

@@ -0,0 +1,170 @@
/**
* @file MoonrakerAPI.h
* @author Kenneth Lin (kenneth.lin.gd.cn@gmail.com)
* @brief Create APIs by reading moonraker.readthedocs.io
* @version 0.1
* @date 2022-07-06
*
* @copyright Copyright (c) 2022
*
*/
#ifndef MOONRAKERAPI_H
#define MOONRAKERAPI_H
#include <iostream>
#include "nlohmann/json.hpp"
nlohmann::json string2json(std::string response);
// API definition
// 👇 makerbase client 发起连接的json消息
#define STRING_IDENTIFY_CONNECTION "{\"jsonrpc\":\"2.0\",\"method\":\"server.connection.identify\",\"params\":{\"client_name\":\"makerbase-client\",\"version\":\"0.0.1\",\"type\":\"web\",\"url\":\"http://makerbase.com/test\"},\"id\":4656}"
#define STRING_GET_KLIPPY_HOST_INFORMATION "{\"jsonrpc\":\"2.0\",\"method\":\"printer.info\",\"id\":5445}"
// Function for creating json
inline std::string create_json_without_params(int cmd);
inline std::string create_json(int cmd, nlohmann::json params);
// Printer Administration
// std::string json_identify_connection(std::string client_name, std::string json_version, std::string type, std::string url);
std::string json_get_websocket_id();
std::string json_get_klippy_host_information();
std::string json_emergency_stop();
std::string json_host_restart();
std::string json_firmware_restart();
// Print Status
std::string json_list_available_printer_objects();
std::string json_query_printer_object_status(nlohmann::json objects);
std::string json_subscribe_to_printer_object_status(nlohmann::json objects);
std::string json_query_endstops();
std::string json_query_server_info();
std::string json_get_server_configuration();
std::string json_request_cached_temperature_data();
std::string json_request_cached_gcode_responses();
std::string json_restart_server();
// GCode APIs
std::string json_run_a_gcode(std::string script); // script 参数调用 KlippyGcodes.h 里面的相关函数执行
std::string json_get_gcode_help();
// Print Management
std::string json_print_a_file(std::string filename);
std::string json_pause_a_print();
std::string json_resume_a_print();
std::string json_cancel_a_print();
// Machine Commands
std::string json_get_system_info();
std::string json_shutdown_the_operating_system();
std::string json_reboot_the_operating_system();
std::string json_restart_a_system_service();
std::string json_stop_a_system_service();
std::string json_start_a_system_service();
std::string json_get_moonraker_process_stats();
// File Operations
std::string json_list_available_files();
std::string json_get_gcode_metadata(std::string path);
std::string json_get_directory_information(bool extended);
std::string json_create_directory(std::string path);
std::string json_delete_directory();
std::string json_move_a_file_or_directory();
std::string json_copy_a_file_or_directory();
std::string json_file_download();
std::string json_file_upload();
std::string json_file_delete(std::string path);
// std::string json_download_klippy_log();
// std::string json_download_moonraker_log();
// Authorization
// std::string json_login_user();
// std::string json_logout_current_user();
// std::string json_get_current_user();
// std::string json_create_user();
// std::string json_delete_user();
// std::string json_list_available_users();
// std::string json_reset_user_password();
// std::string json_generate_a_oneshot_token();
// std::string json_retrieve_information_about_authorization_endpoints();
// std::string json_get_the_current_api_key();
// std::string json_generate_a_new_api_key();
// Database APIs
std::string json_list_namespaces();
std::string json_get_database_item(std::string nsp, std::string key);
std::string json_add_database_item(std::string nsp, std::string key, int value);
std::string json_delete_database_item(std::string nsp, std::string key);
// Job Queue APIs
std::string json_retrieve_the_job_queue_status();
std::string json_enqueue_a_job(std::vector<std::string> filenames); // 需要传递字符串数组作为参数,后面再进行实现
std::string json_remove_a_job(std::vector<std::string> job_ids);
std::string json_pause_the_job_queue();
std::string json_start_the_job_queue();
// Announcement APIs
std::string json_list_announcements(bool incluede_dismissed);
std::string json_update_announcements();
std::string json_dismiss_an_announcement(std::string entry_id, int wake_time);
std::string json_list_announcement_feeds();
std::string json_add_an_announcement_feed(std::string name);
std::string json_remove_an_announcement_feed(std::string name);
// Webcam APIs
std::string json_list_webcams();
std::string json_get_webcam_information(std::string name);
std::string json_add_or_update_a_webcam(std::string name);
std::string json_delete_a_webcam(std::string name);
std::string json_test_a_webcam(std::string name);
// Update Manager APIs
std::string json_get_update_status(bool refresh);
// Perform a full update
std::string json_perform_a_full_update();
std::string json_update_moonraker();
std::string json_update_klipper();
std::string json_update_client(std::string name);
std::string json_update_system_packages();
std::string json_recover_a_corrupt_repo(std::string name, bool hard);
// Power APIs
std::string json_get_device_list();
std::string json_get_device_status(std::string device);
std::string json_get_device_state(std::string device, std::string action);
std::string json_get_batch_device_status(std::string dev_x[]);
std::string json_batch_power_on_devices(std::string dev_x[]); // 需要根据api做特殊处理
std::string json_batch_power_off_devices(std::string dev_x[]); // 需要根据api做特殊处理
// WLED APIs
std::string json_get_strips();
std::string json_get_strip_status();
std::string json_turn_strip_on();
std::string json_turn_strip_off();
std::string json_toggle_strip_on_off_state();
// std::string control_individual_strip_state(); // 这个比较特殊,后面再研究一下
// OctoPrint API emulation
// History APIs
std::string json_get_job_list(int limit, int start, float since, float before, std::string order = "desc");
std::string json_get_job_totals();
std::string json_reset_totals();
std::string json_get_a_single_job(std::string uid);
std::string json_delete_job(std::string uid);
// MQTT APIs
std::string json_publish_a_topic(std::string topic, std::string payload, int qos, bool retain, int timeout);
std::string json_subscribe_to_a_topic(std::string topic, int qos, int timeout);
// Extension APIs
// std::string json_list_extensions();
// std::string json_call_an_extension_method();
std::string json_send_an_agent_event();
// Websocket notifications
#endif

9
include/common.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef COMMON_H
#define COMMON_H
#include <iostream>
#include <vector>
void super_split(const std::string& s, std::vector<std::string>& v, const std::string& c);
#endif

173
include/dictionary.h Normal file
View File

@@ -0,0 +1,173 @@
/*-------------------------------------------------------------------------*/
/**
@file dictionary.h
@author N. Devillard
@brief Implements a dictionary for string variables.
This module implements a simple dictionary object, i.e. a list
of string/string associations. This object is useful to store e.g.
informations retrieved from a configuration file (ini files).
*/
/*--------------------------------------------------------------------------*/
#ifndef _DICTIONARY_H_
#define _DICTIONARY_H_
/*---------------------------------------------------------------------------
Includes
---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
New types
---------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
/**
@brief Dictionary object
This object contains a list of string/string associations. Each
association is identified by a unique string key. Looking up values
in the dictionary is speeded up by the use of a (hopefully collision-free)
hash function.
*/
/*-------------------------------------------------------------------------*/
typedef struct _dictionary_ {
int n ; /** Number of entries in dictionary */
ssize_t size ; /** Storage size */
char ** val ; /** List of string values */
char ** key ; /** List of string keys */
unsigned * hash ; /** List of hash values for keys */
} dictionary ;
/*---------------------------------------------------------------------------
Function prototypes
---------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
/**
@brief Compute the hash key for a string.
@param key Character string to use for key.
@return 1 unsigned int on at least 32 bits.
This hash function has been taken from an Article in Dr Dobbs Journal.
This is normally a collision-free function, distributing keys evenly.
The key is stored anyway in the struct so that collision can be avoided
by comparing the key itself in last resort.
*/
/*--------------------------------------------------------------------------*/
unsigned dictionary_hash(const char * key);
/*-------------------------------------------------------------------------*/
/**
@brief Create a new dictionary object.
@param size Optional initial size of the dictionary.
@return 1 newly allocated dictionary object.
This function allocates a new dictionary object of given size and returns
it. If you do not know in advance (roughly) the number of entries in the
dictionary, give size=0.
*/
/*--------------------------------------------------------------------------*/
dictionary * dictionary_new(size_t size);
/*-------------------------------------------------------------------------*/
/**
@brief Delete a dictionary object
@param d dictionary object to deallocate.
@return void
Deallocate a dictionary object and all memory associated to it.
*/
/*--------------------------------------------------------------------------*/
void dictionary_del(dictionary * vd);
/*-------------------------------------------------------------------------*/
/**
@brief Get a value from a dictionary.
@param d dictionary object to search.
@param key Key to look for in the dictionary.
@param def Default value to return if key not found.
@return 1 pointer to internally allocated character string.
This function locates a key in a dictionary and returns a pointer to its
value, or the passed 'def' pointer if no such key can be found in
dictionary. The returned character pointer points to data internal to the
dictionary object, you should not try to free it or modify it.
*/
/*--------------------------------------------------------------------------*/
const char * dictionary_get(const dictionary * d, const char * key, const char * def);
/*-------------------------------------------------------------------------*/
/**
@brief Set a value in a dictionary.
@param d dictionary object to modify.
@param key Key to modify or add.
@param val Value to add.
@return int 0 if Ok, anything else otherwise
If the given key is found in the dictionary, the associated value is
replaced by the provided one. If the key cannot be found in the
dictionary, it is added to it.
It is Ok to provide a NULL value for val, but NULL values for the dictionary
or the key are considered as errors: the function will return immediately
in such a case.
Notice that if you dictionary_set a variable to NULL, a call to
dictionary_get will return a NULL value: the variable will be found, and
its value (NULL) is returned. In other words, setting the variable
content to NULL is equivalent to deleting the variable from the
dictionary. It is not possible (in this implementation) to have a key in
the dictionary without value.
This function returns non-zero in case of failure.
*/
/*--------------------------------------------------------------------------*/
int dictionary_set(dictionary * vd, const char * key, const char * val);
/*-------------------------------------------------------------------------*/
/**
@brief Delete a key in a dictionary
@param d dictionary object to modify.
@param key Key to remove.
@return void
This function deletes a key in a dictionary. Nothing is done if the
key cannot be found.
*/
/*--------------------------------------------------------------------------*/
void dictionary_unset(dictionary * d, const char * key);
/*-------------------------------------------------------------------------*/
/**
@brief Dump a dictionary to an opened file pointer.
@param d Dictionary to dump
@param f Opened file pointer.
@return void
Dumps a dictionary onto an opened file pointer. Key pairs are printed out
as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
output file pointers.
*/
/*--------------------------------------------------------------------------*/
void dictionary_dump(const dictionary * d, FILE * out);
#ifdef __cplusplus
}
#endif
#endif

255
include/event.h Normal file
View File

@@ -0,0 +1,255 @@
#ifndef EVENT_H
#define EVENT_H
#include <vector>
void refresh_page_show();
void refresh_page_open_filament_video_2();
void refresh_page_open_leveling();
void refresh_page_wifi_keyboard();
void refresh_page_wifi_list();
void refresh_page_wifi_list_2();
void refresh_page_syntony_finish();
void refresh_page_auto_level();
void refresh_page_stopping();
void refresh_page_syntony_move();
void refresh_page_print_filament();
void refresh_page_auto_finish();
void refresh_page_auto_moving();
void refresh_page_move();
void refresh_page_offset(float intern_zoffset);
void refresh_page_printing_zoffset();
void refresh_page_printing();
void clear_page_printing_arg();
void refresh_page_preview();
void refresh_page_main();
void refresh_page_files_list();
void refresh_page_files(int pages);
void sub_object_status();
void get_object_status();
void get_file_estimated_time(std::string filename);
void delete_file(std::string filepath);
void start_printing(std::string filepath);
void set_target(std::string heater, int target);
void set_extruder_target(int target);
void set_heater_bed_target(int target);
void set_hot_target(int target);
void set_fan(int speed);
void set_fan0(int speed);
void set_fan2(int speed);
void set_fan3(int speed);
void set_target(std::string heater, int target);
void set_intern_zoffset(float offset);
void set_zoffset(bool positive);
void set_move_dist(float dist);
void set_printer_speed(int speed);
void set_printer_flow(int rate);
std::string show_time(int seconds);
void move_home();
void move_x_decrease();
void move_x_increase();
void move_y_decrease();
void move_y_increase();
void move_z_decrease();
void move_z_increase();
bool get_filament_detected();
bool get_filament_detected_enable();
bool get_print_pause_resume();
void set_print_pause_resume();
void set_print_pause();
void set_print_resume();
void cancel_print();
void sdcard_reset_file();
void set_auto_level_dist(float dist);
void open_calibrate_start();
void start_auto_level();
void start_auto_level_dist(bool positive);
void set_filament_extruder_target(bool positive);
void set_print_filament_dist(float dist);
void start_retract();
void start_extrude();
std::string get_ip(std::string net);
void move_home_tips();
void filament_tips();
void move_tips();
void reset_klipper();
void reset_firmware();
void finish_print();
void set_filament_sensor();
void motors_off();
void beep_on_off();
void led_on_off();
void shutdown_mcu();
void firmware_reset();
void go_to_page_power_off();
int get_mks_led_status();
void set_mks_led_status();
int get_mks_beep_status();
void set_mks_beep_status();
void get_mks_language_status();
void set_mks_language_status();
void get_mks_extruder_target();
void set_mks_extruder_target(int target);
void get_mks_heater_bed_target();
void set_mks_heater_bed_target(int target);
void get_mks_hot_target();
void set_mks_hot_target(int target);
void filament_extruder_target();
void filament_heater_bed_target();
void filament_hot_target();
void filament_fan0();
void filament_fan2();
void filament_fan3();
void go_to_reset();
void go_to_network();
void scan_ssid_and_show();
void get_wifi_list_ssid(int index);
void set_print_filament_target();
void complete_print();
void back_to_main();
void go_to_syntony_move();
void print_ssid_psk(char *psk);
void clear_page_preview();
void set_mks_babystep(std::string value);
void get_mks_babystep();
void clear_cp0_image();
void printer_set_babystep();
int get_mks_fila_status();
void set_mks_fila_status();
void init_mks_status();
int detect_disk();
void set_printing_shutdown();
void mks_get_version();
void wifi_save_config();
void disable_page_about_successed();
void finish_tjc_update();
void filament_load();
void filament_unload();
int get_cal_printed_time(int print_time);
int get_mks_total_printed_time();
void set_mks_total_printed_time(int printed_time);
void get_total_time();
void do_not_x_clear();
void do_x_clear();
void level_mode_printing_set_target();
void level_mode_printing_print_file();
void update_finished_tips();
bool get_mks_oobe_enabled();
void set_mks_oobe_enabled(bool enable);
void move_motors_off();
void open_more_level_finish();
void open_move_tip();
void open_set_print_filament_target();
void open_start_extrude();
void close_mcu_port();
void oobe_set_intern_zoffset(float offset);
void oobe_set_zoffset(bool positive);
void refresh_page_zoffset();
void refresh_page_auto_heaterbed();
void set_auto_level_heater_bed_target(bool positive);
void detect_error();
void clear_previous_data();
void print_start();
void open_heater_bed_up();
void refresh_page_open_heaterbed();
void refresh_page_open_leveling();
void bed_leveling_switch(bool positive);
void refresh_page_filament_pop();
void save_current_zoffset();
void check_filament_type();
void refresh_page_preview_pop();
//4.4.2 CLL mates适配霍尔耗材宽度检测器
void check_filament_width();
//4.4.2 CLL 文件列表新增本地、U盘切换按钮
void refresh_page_files_list_2();
//4.4.3 CLL 修改更新按钮始终显示
void go_to_update();
//4.4.3 CLL 新增恢复出厂设置按钮
void restore_config();
void refresh_page_open_calibrate();
void refresh_page_filament_set_fan();
void go_to_adjust();
void go_to_setting();
void refresh_page_common_setting();
void print_log();
std::string replaceCharacters(const std::string& path, const std::string& searchChars, const std::string& replacement);
void refresh_page_bed_moving();
void bed_calibrate();
void bed_adjust(bool status);
void go_to_file_list();
void send_gcode(std::string command);
void refresh_files_list_picture(std::string path, int pixel, int i);
void refresh_files_list_picture_2(std::string path, int size, int i);
void refresh_page_filament();
void get_mks_connection_method();
void set_mks_connection_method(int target);
void refresh_page_show_qr();
void go_to_showqr();
struct Server_config
{
std::string address;
std::string name;
};
void get_mks_selected_server();
void go_to_server_set(int n);
void updateServerConfig(std::vector<std::string> &lines, const Server_config &config);
void update_server(int choice);
void refresh_page_server_set();
void local_update();
std::string run_python_code(const char* cmd);
void check_online_version();
void online_update();
void *recevice_progress_handle(void *arg);
void refresh_page_auto_unload();
#endif

46
include/includes.h Normal file
View File

@@ -0,0 +1,46 @@
/*
* wpa_supplicant/hostapd - Default include files
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*
* This header file is included into all C files so that commonly used header
* files can be selected with OS specific ifdef blocks in one place instead of
* having to have OS/C library specific selection in many files.
*/
#ifndef INCLUDES_H
#define INCLUDES_H
/* Include possible build time configuration before including anything else */
// #include "build_config.h"
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#ifndef _WIN32_WCE
#include <signal.h>
#include <sys/types.h>
#include <errno.h>
#endif /* _WIN32_WCE */
#include <ctype.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif /* _MSC_VER */
#ifndef CONFIG_NATIVE_WINDOWS
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifndef __vxworks
#include <sys/uio.h>
#include <sys/time.h>
#endif /* __vxworks */
#endif /* CONFIG_NATIVE_WINDOWS */
#endif /* INCLUDES_H */

358
include/iniparser.h Normal file
View File

@@ -0,0 +1,358 @@
/*-------------------------------------------------------------------------*/
/**
@file iniparser.h
@author N. Devillard
@brief Parser for ini files.
*/
/*--------------------------------------------------------------------------*/
#ifndef _INIPARSER_H_
#define _INIPARSER_H_
/*---------------------------------------------------------------------------
Includes
---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* The following #include is necessary on many Unixes but not Linux.
* It is not needed for Windows platforms.
* Uncomment it if needed.
*/
/* #include <unistd.h> */
#include "dictionary.h"
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------------------*/
/**
@brief Configure a function to receive the error messages.
@param errback Function to call.
By default, the error will be printed on stderr. If a null pointer is passed
as errback the error callback will be switched back to default.
*/
/*--------------------------------------------------------------------------*/
void iniparser_set_error_callback(int (*errback)(const char *, ...));
/*-------------------------------------------------------------------------*/
/**
@brief Get number of sections in a dictionary
@param d Dictionary to examine
@return int Number of sections found in dictionary
This function returns the number of sections found in a dictionary.
The test to recognize sections is done on the string stored in the
dictionary: a section name is given as "section" whereas a key is
stored as "section:key", thus the test looks for entries that do not
contain a colon.
This clearly fails in the case a section name contains a colon, but
this should simply be avoided.
This function returns -1 in case of error.
*/
/*--------------------------------------------------------------------------*/
int iniparser_getnsec(const dictionary * d);
/*-------------------------------------------------------------------------*/
/**
@brief Get name for section n in a dictionary.
@param d Dictionary to examine
@param n Section number (from 0 to nsec-1).
@return Pointer to char string
This function locates the n-th section in a dictionary and returns
its name as a pointer to a string statically allocated inside the
dictionary. Do not free or modify the returned string!
This function returns NULL in case of error.
*/
/*--------------------------------------------------------------------------*/
const char * iniparser_getsecname(const dictionary * d, int n);
/*-------------------------------------------------------------------------*/
/**
@brief Save a dictionary to a loadable ini file
@param d Dictionary to dump
@param f Opened file pointer to dump to
@return void
This function dumps a given dictionary into a loadable ini file.
It is Ok to specify @c stderr or @c stdout as output files.
*/
/*--------------------------------------------------------------------------*/
void iniparser_dump_ini(const dictionary * d, FILE * f);
/*-------------------------------------------------------------------------*/
/**
@brief Save a dictionary section to a loadable ini file
@param d Dictionary to dump
@param s Section name of dictionary to dump
@param f Opened file pointer to dump to
@return void
This function dumps a given section of a given dictionary into a loadable ini
file. It is Ok to specify @c stderr or @c stdout as output files.
*/
/*--------------------------------------------------------------------------*/
void iniparser_dumpsection_ini(const dictionary * d, const char * s, FILE * f);
/*-------------------------------------------------------------------------*/
/**
@brief Dump a dictionary to an opened file pointer.
@param d Dictionary to dump.
@param f Opened file pointer to dump to.
@return void
This function prints out the contents of a dictionary, one element by
line, onto the provided file pointer. It is OK to specify @c stderr
or @c stdout as output files. This function is meant for debugging
purposes mostly.
*/
/*--------------------------------------------------------------------------*/
void iniparser_dump(const dictionary * d, FILE * f);
/*-------------------------------------------------------------------------*/
/**
@brief Get the number of keys in a section of a dictionary.
@param d Dictionary to examine
@param s Section name of dictionary to examine
@return Number of keys in section
*/
/*--------------------------------------------------------------------------*/
int iniparser_getsecnkeys(const dictionary * d, const char * s);
/*-------------------------------------------------------------------------*/
/**
@brief Get the number of keys in a section of a dictionary.
@param d Dictionary to examine
@param s Section name of dictionary to examine
@param keys Already allocated array to store the keys in
@return The pointer passed as `keys` argument or NULL in case of error
This function queries a dictionary and finds all keys in a given section.
The keys argument should be an array of pointers which size has been
determined by calling `iniparser_getsecnkeys` function prior to this one.
Each pointer in the returned char pointer-to-pointer is pointing to
a string allocated in the dictionary; do not free or modify them.
*/
/*--------------------------------------------------------------------------*/
const char ** iniparser_getseckeys(const dictionary * d, const char * s, const char ** keys);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key
@param d Dictionary to search
@param key Key string to look for
@param def Default value to return if key not found.
@return pointer to statically allocated character string
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the pointer passed as 'def' is returned.
The returned char pointer is pointing to a string allocated in
the dictionary, do not free or modify it.
*/
/*--------------------------------------------------------------------------*/
const char * iniparser_getstring(const dictionary * d, const char * key, const char * def);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to an int
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return integer
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
Supported values for integers include the usual C notation
so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
are supported. Examples:
- "42" -> 42
- "042" -> 34 (octal -> decimal)
- "0x42" -> 66 (hexa -> decimal)
Warning: the conversion may overflow in various ways. Conversion is
totally outsourced to strtol(), see the associated man page for overflow
handling.
Credits: Thanks to A. Becker for suggesting strtol()
*/
/*--------------------------------------------------------------------------*/
int iniparser_getint(const dictionary * d, const char * key, int notfound);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to an long int
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return integer
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
Supported values for integers include the usual C notation
so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
are supported. Examples:
- "42" -> 42
- "042" -> 34 (octal -> decimal)
- "0x42" -> 66 (hexa -> decimal)
Warning: the conversion may overflow in various ways. Conversion is
totally outsourced to strtol(), see the associated man page for overflow
handling.
*/
/*--------------------------------------------------------------------------*/
long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to a double
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return double
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
*/
/*--------------------------------------------------------------------------*/
double iniparser_getdouble(const dictionary * d, const char * key, double notfound);
/*-------------------------------------------------------------------------*/
/**
@brief Get the string associated to a key, convert to a boolean
@param d Dictionary to search
@param key Key string to look for
@param notfound Value to return in case of error
@return integer
This function queries a dictionary for a key. A key as read from an
ini file is given as "section:key". If the key cannot be found,
the notfound value is returned.
A true boolean is found if one of the following is matched:
- A string starting with 'y'
- A string starting with 'Y'
- A string starting with 't'
- A string starting with 'T'
- A string starting with '1'
A false boolean is found if one of the following is matched:
- A string starting with 'n'
- A string starting with 'N'
- A string starting with 'f'
- A string starting with 'F'
- A string starting with '0'
The notfound value returned if no boolean is identified, does not
necessarily have to be 0 or 1.
*/
/*--------------------------------------------------------------------------*/
int iniparser_getboolean(const dictionary * d, const char * key, int notfound);
/*-------------------------------------------------------------------------*/
/**
@brief Set an entry in a dictionary.
@param ini Dictionary to modify.
@param entry Entry to modify (entry name)
@param val New value to associate to the entry.
@return int 0 if Ok, -1 otherwise.
If the given entry can be found in the dictionary, it is modified to
contain the provided value. If it cannot be found, the entry is created.
It is Ok to set val to NULL.
*/
/*--------------------------------------------------------------------------*/
int iniparser_set(dictionary * ini, const char * entry, const char * val);
/*-------------------------------------------------------------------------*/
/**
@brief Delete an entry in a dictionary
@param ini Dictionary to modify
@param entry Entry to delete (entry name)
@return void
If the given entry can be found, it is deleted from the dictionary.
*/
/*--------------------------------------------------------------------------*/
void iniparser_unset(dictionary * ini, const char * entry);
/*-------------------------------------------------------------------------*/
/**
@brief Finds out if a given entry exists in a dictionary
@param ini Dictionary to search
@param entry Name of the entry to look for
@return integer 1 if entry exists, 0 otherwise
Finds out if a given entry exists in the dictionary. Since sections
are stored as keys with NULL associated values, this is the only way
of querying for the presence of sections in a dictionary.
*/
/*--------------------------------------------------------------------------*/
int iniparser_find_entry(const dictionary * ini, const char * entry) ;
/*-------------------------------------------------------------------------*/
/**
@brief Parse an ini file and return an allocated dictionary object
@param ininame Name of the ini file to read.
@return Pointer to newly allocated dictionary
This is the parser for ini files. This function is called, providing
the name of the file to be read. It returns a dictionary object that
should not be accessed directly, but through accessor functions
instead.
The returned dictionary must be freed using iniparser_freedict().
*/
/*--------------------------------------------------------------------------*/
dictionary * iniparser_load(const char * ininame);
/*-------------------------------------------------------------------------*/
/**
@brief Free all memory associated to an ini dictionary
@param d Dictionary to free
@return void
Free all memory associated to an ini dictionary.
It is mandatory to call this function before the dictionary object
gets out of the current context.
*/
/*--------------------------------------------------------------------------*/
void iniparser_freedict(dictionary * d);
#ifdef __cplusplus
}
#endif
#endif

24766
include/json.hpp Normal file

File diff suppressed because it is too large Load Diff

9
include/mks_error.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef MKS_ERROR_H
#define MKS_ERROR_H
#include "nlohmann/json.hpp"
#include "./mks_log.h"
void parse_error(nlohmann::json error);
#endif

31
include/mks_file.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef MKS_FILE_H
#define MKS_FILE_H
#include "./mks_log.h"
#include "nlohmann/json.hpp"
void parse_file_estimated_time(nlohmann::json response);
void parse_server_files_list(nlohmann::json result);
void parse_server_files_get_directory(nlohmann::json result);
void parse_server_files_metadata(nlohmann::json result);
void parse_create_directory(nlohmann::json result);
void parse_delete_directory(nlohmann::json result);
void parse_move_a_file_or_directory(nlohmann::json result);
void parse_copy_a_file_or_directory(nlohmann::json result);
void parse_file_delete(nlohmann::json result);
void get_page_files_filelist(std::string current_dir);
void set_page_files_show_list(int pages);
void get_sub_dir_files_list(int button);
void get_parenet_dir_files_list();
// void get_file_estimated_time(std::string filename, int *estimated_time);
void parse_file_estimated_time_send(nlohmann::json response);
std::string getParentDirectory(const std::string& path);
int output_imgdata(std::string thumbpath, int size);
int output_jpg(std::string thumbpath, int size);
std::string extractFileName(const std::string& filePath);
#endif

8
include/mks_gcode.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef MKS_GCODE_H
#define MKS_GCODE_H
#include "nlohmann/json.hpp"
void parse_gcode_response(nlohmann::json params);
#endif

13
include/mks_gpio.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef MKS_GPIO_H
#define MKS_GPIO_H
static int gpio_config(const char *attr, const char *val);
int set_GPIO1_C5_low();
int set_GPIO1_C5_high();
int init_GPIO1_B2();
void *monitor_GPIO1_B2(void *arg);
int init_GPIO1_C3();
void *monitor_GPIO1_C3(void *arg);
int set_GPIO1_B3_low();
#endif

18
include/mks_init.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef MKS_INIT_H
#define MKS_INIT_H
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
#include <errno.h>
#include <iostream>
#include <fstream>
bool get_by_id();
std::string generate_by_id();
bool FileStringReplace(std::ifstream &instream, std::ofstream &outstream);
std::string get_cfg_by_id();
#endif

6
include/mks_job.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef MKS_JOB_H
#define MKS_JOB_H
#include "./mks_log.h"
#endif

30
include/mks_log.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef MKS_LOG_H
#define MKS_LOG_H
#include <iostream>
#include <stdio.h>
#define LOG_RED "\033[31;1m"
#define LOG_YELLOW "\033[0;33m"
#define LOG_GREEN "\033[0;32m"
#define LOG_BLUE "\033[0;34m"
#define LOG_PURPLE "\033[0;35m"
#define LOG_SKYBLUE "\033[0;36m"
#define LOG_HIGHLIGHT "\033[7m\033[5m"
#define LOG_END "\033[0m"
#if 0
#define MKSLOG(fmt, ...) printf(("[%s][%s] %s: %d\n" fmt "\n"), __DATE__, __TIME__, __FILE__, __LINE__, ##__VA_ARGS__)
#define MKSLOG_RED(fmt, ...) printf(("%s[%s][%s] %s: %d\n" fmt "\n%s"), LOG_RED, __DATE__, __TIME__, __FILE__, __LINE__, ##__VA_ARGS__, LOG_END)
#define MKSLOG_YELLOW(fmt, ...) printf(("%s[%s][%s] %s: %d\n" fmt "\n%s"), LOG_YELLOW, __DATE__, __TIME__, __FILE__, __LINE__, ##__VA_ARGS__, LOG_END)
#define MKSLOG_BLUE(fmt, ...) printf(("%s[%s][%s] %s: %d\n" fmt "\n%s"), LOG_SKYBLUE, __DATE__, __TIME__, __FILE__, __LINE__, ##__VA_ARGS__, LOG_END)
#define MKSLOG_GREEN(fmt, ...) printf(("%s[%s][%s] %s: %d\n" fmt "\n%s"), LOG_GREEN, __DATE__, __TIME__, __FILE__, __LINE__, ##__VA_ARGS__, LOG_END)
#else
#define MKSLOG(fmt, ...) printf((fmt "\n"), ##__VA_ARGS__)
#define MKSLOG_RED(fmt, ...) printf(("%s" fmt "\n%s"), LOG_RED, ##__VA_ARGS__, LOG_END)
#define MKSLOG_YELLOW(fmt, ...) printf(("%s" fmt "\n%s"), LOG_YELLOW, ##__VA_ARGS__, LOG_END)
#define MKSLOG_BLUE(fmt, ...) printf(("%s" fmt "\n%s"), LOG_SKYBLUE, ##__VA_ARGS__, LOG_END)
#define MKSLOG_GREEN(fmt, ...) printf(("%s" fmt "\n%s"), LOG_GREEN, ##__VA_ARGS__, LOG_END)
#define MKSLOG_HIGHLIGHT(fmt, ...) printf(("%s" fmt "\n%s"), LOG_HIGHLIGHT, ##__VA_ARGS__, LOG_END)
#endif
#endif

12
include/mks_preview.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef MKS_PREVIEW_H
#define MKS_PREVIEW_H
#include <iostream>
#include <fstream>
#include <vector>
void generate_gimage(std::string filename);
void generate_simage(std::string filename);
#endif

40
include/mks_printer.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef MKS_PRINTER_H
#define MKS_PRINTER_H
#include "nlohmann/json.hpp"
#include "./mks_log.h"
void parse_server_history_totals(nlohmann::json totals);
void parse_printer_probe(nlohmann::json probe);
void parse_printer_beep(nlohmann::json beep);
void parse_printer_caselight(nlohmann::json caselight);
void parse_printer_heater_fan_my_nozzle_fan1(nlohmann::json heater_fan_my_nozzle_fan1);
void parse_printer_out_pin_fan0(nlohmann::json out_pin_fan0);
void parse_printer_out_pin_fan2(nlohmann::json out_pin_fan2);
void parse_printer_out_pin_fan3(nlohmann::json out_pin_fan3);
void parse_filament_switch_sensor_fila(nlohmann::json filament_switch_sensor);
void parse_idle_timeout(nlohmann::json idle_timeout);
void parse_bed_mesh(nlohmann::json bed_mesh);
void parse_webhooks(nlohmann::json webhooks);
void parse_gcode_move(nlohmann::json gcode_move);
void parse_toolhead(nlohmann::json toolhead);
void parse_extruder(nlohmann::json extruder);
void parse_heater_bed(nlohmann::json heater_bed);
void parse_heater_generic_hot(nlohmann::json heater_generic_hot);
void parse_fan(nlohmann::json fan);
void parse_heater_fan(nlohmann::json heater_fan);
void parse_print_stats(nlohmann::json print_stats);
void parse_display_status(nlohmann::json display_status);
void parse_pause_resume(nlohmann::json pause_resume);
void parse_subscribe_objects_status(nlohmann::json status);
nlohmann::json subscribe_objects_status();
int get_cal_printing_time(int print_time, int estimated_time, int progress);
void parse_printer_info(nlohmann::json result);
#endif

6
include/mks_system.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef MKS_SYSTEM_H
#define MKS_SYSTEM_H
#include "./mks_log.h"
#endif

19
include/mks_test.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef MKS_TEST_H
#define MKS_TEST_H
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <exception>
#include <string.h>
void *mks_test(void *arg);
bool testUSB();
bool moko_test_func();
bool network_test_func();
#endif

16
include/mks_update.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef MKS_UPDATE_H
#define MKS_UPDATE_H
int u_disk_update();
bool detect_update();
void start_update();
void download_to_screen();
void init_download_to_screen();
void back_to_screen_old();
#endif

106
include/mks_wpa_cli.h Normal file
View File

@@ -0,0 +1,106 @@
#ifndef MKS_WPA_CLI
#define MKS_WPA_CLI
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <wpa_ctrl.h>
struct mks_wifi_signal_poll_result_t {
char ack[1024];
int rssi;
int linkspeed;
int noise;
int frequency;
};
struct mks_wifi_status_result_t {
char ack[1024];
char bssid[18];
int freq;
char ssid[128];
int id;
char mode[16];
char pairwise_cipher[16];
char group_cipher[16];
char key_mgmt[16];
char wpa_state[32];
char ip_address[18];
char address[18];
char uuid[64];
};
struct mks_wifi_status_t {
char bssid[18];
int freq;
char ssid[128];
int id;
char mode[16];
char pairwise_cipher[16];
char group_cipher[16];
char key_mgmt[16];
char wpa_state[32];
char ip_address[18];
char address[18];
char uuid[64];
};
static void wpa_cli_msg_cb(char *msg, size_t len);
static int result_get(char *str, char *key, char *val, int val_len);
int mks_wifi_run_cmd_signal_poll(struct mks_wifi_signal_poll_result_t *result);
int mks_wifi_run_cmd(char const *cmd, char *result, size_t *len);
int mks_wifi_run_cmd_status(struct mks_wifi_status_result_t *result);
// void mks_wifi_set_config(char *ssid, char *psk);
// int mks_wifi_get_config(char *ssid, char *psk);
void test_wifi_run_cmd_signal(void);
void test_wifi_run_cmd_status(void);
int wifi_send_command(const char *cmd, char *reply, size_t *reply_len);
// int mks_wifi_connect_ap_fun(char *ssid, char *psk);
void *mks_wifi_hdlevent_thread(void *arg);
int mks_wpa_scan_scanresults();
// int mks_wifi_connect(char *ssid, char *psk);
int mks_set_ssid(char *ssid);
int mks_set_psk(char *psk);
int mks_disable_network();
int mks_enable_network();
int mks_save_config();
int mks_wpa_cli_open_connection();
int mks_wpa_cli_close_connection();
int mks_wpa_scan();
int mks_wpa_scan_results(char *mks_result);
int mks_wpa_get_status();
int mks_parse_status(struct mks_wifi_status_t *status);
#endif

55
include/send_jpg.h Normal file
View File

@@ -0,0 +1,55 @@
#ifndef SEND_JPG_H
#define SEND_JPG_H
#include <stdio.h>
#include <stdint.h>
#include <stdint.h>
#include "mks_log.h"
#include "send_msg.h"
// #define BLOCK_SIZE 3072
#define BLOCK_SIZE 3800
#define HEADER_SIZE 12
extern bool get_0xfe;
extern bool get_0x06;
extern bool get_0x05;
extern bool get_0xfd;
extern bool get_0x04;
extern bool get_0x24;
extern bool have_64_jpg[6];
extern std::string have_64_png_path[6];
extern bool begin_show_64_jpg;
extern bool begin_show_160_jpg;
extern bool begin_show_192_jpg;
extern bool show_192_jpg_complete;
#define LOG_RED "\033[31;1m"
#define LOG_YELLOW "\033[0;33m"
#define LOG_GREEN "\033[0;32m"
#define LOG_BLUE "\033[0;34m"
#define LOG_PURPLE "\033[0;35m"
#define LOG_SKYBLUE "\033[0;36m"
#define LOG_HIGHLIGHT "\033[7m\033[5m"
#define LOG_END "\033[0m"
void printHex(const uint8_t *data, size_t size);
// bool mks_send_jpg(char *path, int fd, int index);
void *sent_jpg_thread_handle(void *arg);
void delet_pic(std::string ram_path);
// void *sent_jpg_thread_handle(void *arg);
void png_to_64_jpg(std::string dir_path, std::string file_name, uint8_t i);
void png_to_160_jpg(std::string dir_path, std::string file_name);
void png_to_192_jpg(std::string dir_path, std::string file_name);
void delet_pic(std::string ram_path);
void delete_small_jpg();
bool sent_jpg_to_tjc(std::string ram_path, std::string pic_path);
#endif

99
include/send_msg.h Normal file
View File

@@ -0,0 +1,99 @@
#ifndef SEND_MSG_H
#define SEND_MSG_H
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void send_cmd_page(int fd, std::string pageid);
void send_cmd_ref(int fd, std::string obj);
void send_cmd_click(int fd, std::string obj, std::string event);
void send_cmd_get(int fd, std::string att);
void send_cmd_prints(int fd, std::string att, int lenth);
void send_cmd_printh(int fd, std::string hex);
void send_cmd_vis(int fd, std::string obj, std::string state);
void send_cmd_tsw(int fd, std::string obj, std::string state);
void send_cmd_randset(int fd, std::string minval, std::string maxval);
void send_cmd_add(int fd, std::string objid, std::string ch, std::string val);
void send_cmd_cle(int fd, std::string objid, std::string ch);
void send_cmd_addt(int fd, std::string objid, std::string ch, std::string qyt);
void send_cmd_doevents(int fd);
void send_cmd_sendme(int fd);
void send_cmd_covx(int fd, std::string att1, std::string att2, std::string lenth);
void send_cmd_strlen(int fd, std::string att0, std::string att1);
void send_cmd_btlen(int fd, std::string att0, std::string att1);
void send_cmd_substr(int fd, std::string att0, std::string att1, std::string star, std::string lenth);
void send_cmd_spstr(int fd, std::string src, std::string dec, std::string key, std::string indec);
void send_cmd_touch_j(int fd);
void send_cmd_ref_stop(int fd);
void send_cmd_ref_star(int fd);
void send_cmd_com_stop(int fd);
void send_cmd_com_star(int fd);
void send_cmd_code_c(int fd);
void send_cmd_rest(int fd);
void send_cmd_wepo(int fd, std::string att, std::string add);
void send_cmd_repo(int fd, std::string att, std::string add);
void send_cmd_wept(int fd, std::string add, std::string lenth);
void send_cmd_rept(int fd, std::string add, std::string lenth);
void send_cmd_cfgpio(int fd, std::string id, std::string state, std::string obj);
void send_cmd_crcrest(int fd, std::string crctype, std::string initval);
void send_cmd_crcputs(int fd, std::string att, std::string length);
void send_cmd_crcputh(int fd, std::string hex);
void send_cmd_crcputu(int fd, std::string star, std::string length);
void send_cmd_setlayer(int fd, std::string obj0, std::string obj1);
void send_cmd_move(int fd, std::string obj, std::string startx, std::string starty, std::string endx, std::string endy, std::string first, std::string time);
void send_cmd_play(int fd, std::string ch, std::string audio, std::string loop);
void send_cmd_twfile(int fd, std::string filepath, std::string filesize);
void send_cmd_delfile(int fd, std::string filepath);
void send_cmd_refile(int fd, std::string srcfilepath, std::string decfilepath);
void send_cmd_findfile(int fd, std::string filepath, std::string att);
void send_cmd_rdfile(int fd, std::string filepath, std::string addr, std::string size, std::string crc);
void send_cmd_newfile(int fd, std::string filepath, std::string size);
void send_cmd_newdir(int fd, std::string dir);
void send_cmd_deldir(int fd, std::string dir);
void send_cmd_redir(int fd, std::string srcdir, std::string decdir);
void send_cmd_finddir(int fd, std::string dir, std::string att);
void send_cmd_beep(int fd, std::string time);
void send_cmd_txt(int fd, std::string obj, std::string txt);
void send_cmd_pic(int fd, std::string obj, std::string pic);
void send_cmd_picc(int fd, std::string obj, std::string picc);
void send_cmd_picc2(int fd, std::string obj, std::string picc);
void send_cmd_val(int fd, std::string obj, std::string val);
void send_cmd_val(int fd, std::string obj, std::string val);
void send_cmd_pco(int fd, std::string obj, std::string poc);
void send_cmd_pco2(int fd, std::string obj, std::string poc2);
void send_cmd_bpic(int fd, std::string obj, std::string bpic);
void send_cmd_vid(int fd, std::string obj, std::string vid);
void send_cmd_cp(int fd, std::string obj);
void send_cmd_cp_write(int fd, std::string obj, std::string data);
void send_cmd_cp_end(int fd);
void send_cmd_cp_close(int fd, std::string obj);
void send_cmd_byte_data(int fd, char data);
void send_cmd_write(int fd, std::string obj);
void send_cmd_write_end(int fd);
void send_cmd_cp_image(int fd, std::string obj, std::string image);
void send_cmd_txt_start(int fd, std::string obj);
void send_cmd_txt_data(int fd, std::string txt);
void send_cmd_txt_end(int fd);
void send_cmd_txt_plus(int fd, std::string obj1, std::string obj2, std::string obj3);
void send_cmd_download(int fd, int filesize);
void send_cmd_download_data(int fd, std::string data);
void send_cmd_vid_en(int fd, std::string obj, int value);
void send_cmd_bauds(int fd, int bauds);
void send_cmd_baud(int fd, int baud);
void send_var_value(int fd, std::string var, int value);
#endif

428
include/ui.h Normal file
View File

@@ -0,0 +1,428 @@
#ifndef UI_H
#define UI_H
//所有页面的下方跳转按钮的发送比特均一致
#define TJC_PAGE_ALL_TO_MAIN 0x1e
#define TJC_PAGE_ALL_TO_ADJUST 0x1f
#define TJC_PAGE_ALL_TO_FILE_LIST 0x20
#define TJC_PAGE_ALL_TO_SETTING 0x21
#define TJC_PAGE_LOGO 0
#define TJC_PAGE_RESTART 1
#define TJC_PAGE_SHUTDOWN 2
#define TJC_PAGE_OPEN_LANGUAGE 3
#define TJC_PAGE_OPEN_LANGUAGE_NEXT 0x00
#define TJC_PAGE_OPEN_LANGUAGE_SKIP 0x01
#define TJC_PAGE_OPEN_POP 4
#define TJC_PAGE_OPEN_POP_YES 0x00
#define TJC_PAGE_OPEN_POP_NO 0x01
#define TJC_PAGE_OPEN_VIDEO_1 5
#define TJC_PAGE_OPEN_VIDEO_1_NEXT 0x00
#define TJC_PAGE_OPEN_VIDEO_2 6
#define TJC_PAGE_OPEN_VIDEO_2_NEXT 0x00
#define TJC_PAGE_OPEN_WARNING 7
#define TJC_PAGE_OPEN_WARNING_NEXT 0x00
#define TJC_PAGE_OPEN_VIDEO_3 8
#define TJC_PAGE_OPEN_VIDEO_3_NEXT 0x00
#define TJC_PAGE_OPEN_VIDEO_3_UP 0x01
#define TJC_PAGE_OPEN_VIDEO_3_DOWN 0x02
#define TJC_PAGE_OPEN_HEATERBED 9
#define TJC_PAGE_OPEN_HEATERBED_ON_OFF 0x00
#define TJC_PAGE_OPEN_HEATERBED_UP 0x01
#define TJC_PAGE_OPEN_HEATERBED_DOWN 0x02
#define TJC_PAGE_OPEN_HEATERBED_NEXT 0x03
#define TJC_PAGE_OPEN_CALIBRATE 10
#define TJC_PAGE_OPEN_FILAMENTVIDEO_0 72
#define TJC_PAGE_OPEN_FILAMENTVIDEO_0_NEXT 0x00
#define TJC_PAGE_OPEN_FILAMENTVIDEO_1 11
#define TJC_PAGE_OPEN_FILAMENTVIDEO_1_NEXT 0x00
#define TJC_PAGE_OPEN_FILAMENTVIDEO_2 12
#define TJC_PAGE_OPEN_FILAMENTVIDEO_2_DOWN 0x00
#define TJC_PAGE_OPEN_FILAMENTVIDEO_2_UP 0x01
#define TJC_PAGE_OPEN_FILAMENTVIDEO_2_NEXT 0x02
#define TJC_PAGE_OPEN_FILAMENTVIDEO_2_ON_OFF 0x03
#define TJC_PAGE_OPEN_FILAMENTVIDEO_3 13
#define TJC_PAGE_OPEN_FILAMENTVIDEO_3_NEXT 0x00
#define TJC_PAGE_OPEN_FILAMENTVIDEO_3_EXTRUDE 0x01
#define TJC_PAGE_OPEN_FINISH 14
#define TJC_PAGE_OPEN_FINISH_YES 0x00
#define TJC_PAGE_MAIN 15
#define TJC_PAGE_MAIN_CASELIGHT 0x00
#define TJC_PAGE_MAIN_BEEP 0x01
#define TJC_PAGE_MAIN_STOP 0x02
#define TJC_PAGE_MAIN_SET_TEMP 0x03
#define TJC_PAGE_MAIN_CACHE 0x06
#define TJC_PAGE_FILE_LIST 16
#define TJC_PAGE_FILE_LIST_BACK 0x00
#define TJC_PAGE_FILE_LIST_BTN_1 0x01
#define TJC_PAGE_FILE_LIST_BTN_2 0x02
#define TJC_PAGE_FILE_LIST_BTN_3 0x03
#define TJC_PAGE_FILE_LIST_BTN_4 0x04
#define TJC_PAGE_FILE_LIST_BTN_5 0x05
#define TJC_PAGE_FILE_LIST_PREVIOUS 0x0a
#define TJC_PAGE_FILE_LIST_NEXT 0x0b
#define TJC_PAGE_FILE_LIST_LOCAL 0x0c
#define TJC_PAGE_FILE_LIST_USB 0x0d
#define TJC_PAGE_PREVIEW 17
#define TJC_PAGE_PREVIEW_BACK 0x00
#define TJC_PAGE_PREVIEW_START 0x01
#define TJC_PAGE_PREVIEW_BED_LEVELING 0x02
#define TJC_PAGE_PREVIEW_POP_1 18
#define TJC_PAGE_PREVIEW_POP_2 19
#define TJC_PAGE_PREVIEW_POP_YES 0x00
//4.4.1 CLL 耗材确认弹窗新增不再提示按钮
#define TJC_PAGE_PREVIEW_POP_NO_POP 0x01
#define TJC_PAGE_PRINTING 20
#define TJC_PAGE_PRINTING_EXTRUDER 0x00
#define TJC_PAGE_PRINTING_HEATER_BED 0x01
#define TJC_PAGE_PRINTING_NEXT 0x02
#define TJC_PAGE_PRINTING_CASE_LIGHT 0x03
#define TJC_PAGE_PRINTING_FAN_1 0x04
#define TJC_PAGE_PRINTING_FAN_2 0x05
#define TJC_PAGE_PRINTING_FAN_3 0x06
#define TJC_PAGE_PRINTING_HOT 0x07
#define TJC_PAGE_PRINTING_PAUSE_RESUME 0x0a
#define TJC_PAGE_PRINTING_STOP 0x0b
#define TJC_PAGE_PRINTING_KB 21
#define TJC_PAGE_PRINTING_KB_BACK 0x00
#define TJC_PAGE_PRINTING_KB_PAUSE_RESUME 0x0a
#define TJC_PAGE_PRINTING_KB_STOP 0x0b
#define TJC_PAGE_PRINT_ZOFFSET 22
#define TJC_PAGE_PRINT_ZOFFSET_BACK 0x00
#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_UP 0x05
#define TJC_PAGE_PRINT_ZOFFSET_DOWN 0x06
#define TJC_PAGE_PRINT_ZOFFSET_PAUSE_RESUME 0x0a
#define TJC_PAGE_PRINT_ZOFFSET_STOP 0x0b
#define TJC_PAGE_PRINT_FILAMENT 23
#define TJC_PAGE_PRINT_FILAMENT_ON_OFF 0x00
#define TJC_PAGE_PRINT_FILAMENT_T_UP 0x01
#define TJC_PAGE_PRINT_FILAMENT_T_DOWN 0x02
#define TJC_PAGE_PRINT_FILAMENT_LOAD 0x03
#define TJC_PAGE_PRINT_FILAMENT_UNLOAD 0x04
#define TJC_PAGE_PRINT_FILAMENT_RETRACT 0x05
#define TJC_PAGE_PRINT_FILAMENT_EXTRUDE 0x06
#define TJC_PAGE_PRINT_FILAMENT_PAUSE_RESUME 0x0a
#define TJC_PAGE_PRINT_FILAMENT_STOP 0x0b
#define TJC_PAGE_PRINTING_2 24
#define TJC_PAGE_PRINTING_2_BACK 0x00
#define TJC_PAGE_PRINTING_2_ZOFFSET 0x01
#define TJC_PAGE_PRINTING_2_SPEED 0x02
#define TJC_PAGE_PRINTING_2_FLOW 0x03
#define TJC_PAGE_PRINTING_2_PAUSE_RESUME 0x0a
#define TJC_PAGE_PRINTING_2_STOP 0x0b
#define TJC_PAGE_PRINT_FINISH 25
#define TJC_PAGE_PRINT_FINISH_YES 0x00
#define TJC_PAGE_PRINT_STOP 26
#define TJC_PAGE_PRINT_STOP_YES 0x00
#define TJC_PAGE_PRINT_STOP_NO 0x01
#define TJC_PAGE_PRINT_STOPPING 27
#define TJC_PAGE_PRINT_NO_FILAMENT 28
#define TJC_PAGE_PRINT_NO_FILAMENT_YES 0x00
#define TJC_PAGE_PRINT_LOW_TEMP 29
#define TJC_PAGE_PRINT_LOW_TEMP_YES 0x00
#define TJC_PAGE_MOVE 30
#define TJC_PAGE_MOVE_SET_01 0x00
#define TJC_PAGE_MOVE_SET_1 0x01
#define TJC_PAGE_MOVE_SET_10 0x02
#define TJC_PAGE_MOVE_Z_UP 0x03
#define TJC_PAGE_MOVE_MOTOR 0x04
#define TJC_PAGE_MOVE_Z_DOWN 0x05
#define TJC_PAGE_MOVE_Y_UP 0x06
#define TJC_PAGE_MOVE_Y_DOWN 0x07
#define TJC_PAGE_MOVE_X_DOWN 0x08
#define TJC_PAGE_MOVE_X_UP 0x09
#define TJC_PAGE_MOVE_HOME 0x0a
#define TJC_PAGE_MOVE_TO_FILAMENT 0x16
#define TJC_PAGE_MOVE_POP_1 31
#define TJC_PAGE_MOVE_POP_1_YES 0x00
#define TJC_PAGE_MOVE_POP_2 32
#define TJC_PAGE_MOVE_POP_2_YES 0x00
#define TJC_PAGE_MOVE_POP_2_NO 0x01
#define TJC_PAGE_FILAMENT_SET_FAN 33
#define TJC_PAGE_FILAMENT_SET_FAN_BACK 0x00
#define TJC_PAGE_FILAMENT_SET_FAN_SETTING 0x01
#define TJC_PAGE_FILAMENT_KB 34
#define TJC_PAGE_FILAMENT_KB_BACK 0x00
#define TJC_PAGE_FILAMENT_POP_1 35
#define TJC_PAGE_FILAMENT_POP_1_YES 0x00
#define TJC_PAGE_FILAMENT_POP_2 36
#define TJC_PAGE_FILAMENT_POP_2_YES 0x00
#define TJC_PAGE_FILAMENT_POP_2_TO_LOAD 0x01
#define TJC_PAGE_FILAMENT_POP_2_NEXT 0x02
#define TJC_PAGE_FILAMENT_POP_2_BACK 0x03
#define TJC_PAGE_FILAMENT_POP_3 37
#define TJC_PAGE_FILAMENT_POP_3_YES 0x00
#define TJC_PAGE_FILAMENT_POP_3_RETRY 0x01
#define TJC_PAGE_FILAMENT_POP_3_NEXT 0x02
#define TJC_PAGE_FILAMENT_POP_3_BACK 0x03
#define TJC_PAGE_FILAMENT_UNLOAD_FINISH 38
#define TJC_PAGE_FILAMENT_UNLOAD_FINISH_YES 0x00
#define TJC_PAGE_LEVEL_MODE 39
#define TJC_PAGE_LEVEL_MODE_AUTO_LEVEL 0x00
#define TJC_PAGE_LEVEL_MODE_SYNTONY 0x01
#define TJC_PAGE_LEVEL_MODE_BED_CALIBRATION 0x02
#define TJC_PAGE_LEVEL_MODE_TO_COMMON_SETTING 0x17
#define TJC_PAGE_LEVEL_MODE_ZOFFSET 0x18
#define TJC_PAGE_ZOFFSET 40
#define TJC_PAGE_ZOFFSET_BACK 0x00
#define TJC_PAGE_AUTO_HEATERBED 41
#define TJC_PAGE_AUTO_HEATERBED_DOWN 0x00
#define TJC_PAGE_AUTO_HEATERBED_UP 0x01
#define TJC_PAGE_AUTO_HEATERBED_ON_OFF 0x02
#define TJC_PAGE_AUTO_HEATERBED_BACK 0x03
#define TJC_PAGE_AUTO_HEATERBED_NEXT 0x04
#define TJC_PAGE_AUTO_MOVING 42
#define TJC_PAGE_AUTO_FINISH 43
#define TJC_PAGE_AUTO_FINISH_YES 0x00
#define TJC_PAGE_PRE_BED_CALIBRATION 44
#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_UP 0x04
#define TJC_PAGE_PRE_BED_CALIBRATION_DOWN 0x05
#define TJC_PAGE_PRE_BED_CALIBRATION_ENTER 0x06
#define TJC_PAGE_BED_MOVING 45
#define TJC_PAGE_BED_CALIBRATION 46
#define TJC_PAGE_BED_CALIBRATION_NEXT 0x00
#define TJC_PAGE_BED_FINISH 47
#define TJC_PAGE_BED_FINISH_OK 0x00
#define TJC_PAGE_BED_FINISH_SCREW1 0x01
#define TJC_PAGE_BED_FINISH_SCREW2 0x02
#define TJC_PAGE_BED_FINISH_SCREW3 0x03
#define TJC_PAGE_BED_FINISH_Z_TILT 0x04
#define TJC_PAGE_SYNTONY_MOVE 48
#define TJC_PAGE_SYNTONY_MOVE_JUMP_OUT 0x00
#define TJC_PAGE_SYNTONY_FINISH 49
#define TJC_PAGE_SYNTONY_FINISH_YES 0x00
#define TJC_PAGE_INTERNET 50
#define TJC_PAGE_INTERNET_REFRESH 0x00
#define TJC_PAGE_INTERNET_TO_WIFI 0x16
#define TJC_PAGE_INTERNET_TO_SETTING 0x17
#define TJC_PAGE_WIFI_LIST 51
#define TJC_PAGE_WIFI_LIST_SSID_1 0x00
#define TJC_PAGE_WIFI_LIST_SSID_2 0x01
#define TJC_PAGE_WIFI_LIST_SSID_3 0x02
#define TJC_PAGE_WIFI_LIST_SSID_4 0x03
#define TJC_PAGE_WIFI_LIST_SSID_5 0x04
#define TJC_PAGE_WIFI_LIST_REFRESH 0x07
#define TJC_PAGE_WIFI_LIST_PREVIOUS 0x05
#define TJC_PAGE_WIFI_LIST_NEXT 0x06
#define TJC_PAGE_WIFI_LIST_TO_WIFI 0x16
#define TJC_PAGE_WIFI_LIST_TO_SETTING 0x17
#define TJC_PAGE_WIFI_CONNECT 52
#define TJC_PAGE_WIFI_SAVING 53
#define TJC_PAGE_WIFI_SUCCESS 54
#define TJC_PAGE_WIFI_SUCCESS_YES 0x00
#define TJC_PAGE_WIFI_FAILED 55
#define TJC_PAGE_WIFI_FAILED_YES 0x00
#define TJC_PAGE_WIFI_KB 56
#define TJC_PAGE_WIFI_KB_BACK 0x00
#define TJC_PAGE_COMMON_SETTING 57
#define TJC_PAGE_COMMON_SETTING_LANGUAGE 0x00
#define TJC_PAGE_COMMON_SETTING_WIFI 0x01
#define TJC_PAGE_COMMON_SETTING_SYSTEM 0x02
#define TJC_PAGE_COMMON_SETTING_SERVICE 0x03
#define TJC_PAGE_COMMON_SETTING_SCREEN_SLEEP 0x04
#define TJC_PAGE_COMMON_SETTING_UPDATE 0x05
#define TJC_PAGE_COMMON_SETTING_RESTORE 0x06
#define TJC_PAGE_COMMON_SETTING_OOBE_OFF 0x07
#define TJC_PAGE_COMMON_SETTING_TO_LEVEL_MODE 0x16
#define TJC_PAGE_COMMON_SETTING_OOBE_ON 0x17
// CLL 以下几个页面需要xindi执行的功能相似所以统一执行响应函数其他功能主要由UI内置程序实现
#define TJC_PAGE_LANGUAGE 58
#define TJC_PAGE_SYS_OK 59
#define TJC_PAGE_RESET 60
#define TJC_PAGE_SERVICE 61
#define TJC_PAGE_SLEEP_MODE 62
#define TJC_PAGE_BACK_TO_COMMON_SETTING 0x00
#define TJC_PAGE_RESET_PRINT_LOG 0x01
#define TJC_PAGE_RESET_RESTART_KLIPPER 0x02
#define TJC_PAGE_RESET_RESTART_FIRMWARE 0x03
#define TJC_PAGE_UPDATE_FOUND 63
#define TJC_PAGE_UPDATE_FOUND_YES 0x00
#define TJC_PAGE_UPDATE_FOUND_NO 0x01
#define TJC_PAGE_UPDATE_NOT_FOUND 64
#define TJC_PAGE_UPDATE_NOT_FOUND_YES 0x00
#define TJC_PAGE_UPDATE_FINISH 65
#define TJC_PAGE_UPDATE_SUCCESS 66
#define TJC_PAGE_UPDATE_SUCCESS_YES 0x00
#define TJC_PAGE_RESTORE_CONFIG 67
#define TJC_PAGE_RESTORE_CONFIG_YES 0x00
#define TJC_PAGE_RESTORE_CONFIG_NO 0x01
#define TJC_PAGE_PRINT_LOG_S 68
#define TJC_PAGE_PRINT_LOG_F 69
#define TJC_PAGE_PRINT_LOG_YES 0x00
#define TJC_PAGE_DETECT_ERROR 70
#define TJC_PAGE_DETECT_ERROR_YES 0x00
#define TJC_PAGE_GCODE_ERROR 71
#define TJC_PAGE_GCODE_ERROR_YES 0x00
//4.4.2 CLL 新增息屏功能
#define TJC_PAGE_SCREEN_SLEEP 73
#define TJC_PAGE_SCREEN_SLEEP_ENTER 0x01
#define TJC_PAGE_SCREEN_SLEEP_EXIT 0x00
#define TJC_PAGE_LEVEL_ERROR 74
#define TJC_PAGE_LEVEL_ERROR_YES 0x00
#define TJC_PAGE_FILAMENT 75
#define TJC_PAGE_FILAMENT_SET_EXTRUDER 0x00
#define TJC_PAGE_FILAMENT_SET_HEATERBED 0x01
#define TJC_PAGE_FILAMENT_EXTRUDER_ON_OFF 0x02
#define TJC_PAGE_FILAMENT_HEATERBED_ON_OFF 0x03
#define TJC_PAGE_FILAMENT_TO_FAN 0x04
#define TJC_PAGE_FILAMENT_LOAD 0x05
#define TJC_PAGE_FILAMENT_UNLOAD 0x06
#define TJC_PAGE_FILAMENT_EXTRUDER_UP 0x07
#define TJC_PAGE_FILAMENT_EXTRUDER_DOWN 0x08
#define TJC_PAGE_FILAMENT_SET_10 0x09
#define TJC_PAGE_FILAMENT_SET_50 0x0a
#define TJC_PAGE_FILAMENT_SET_100 0x0b
#define TJC_PAGE_FILAMENT_SET_FAN_1 0x0c
#define TJC_PAGE_FILAMENT_SET_FAN_2 0x0d
#define TJC_PAGE_FILAMENT_SET_FAN_3 0x0e
#define TJC_PAGE_FILAMENT_HOT_ON_OFF 0x0f
#define TJC_PAGE_FILAMENT_SET_HOT 0x10
#define TJC_PAGE_FILAMENT_TO_FILAMENT 0x16
#define TJC_PAGE_FILAMENT_TO_MOVE 0x17
#define TJC_PAGE_PRINT_NO_FILAMENT_2 76
#define TJC_PAGE_PRINT_NO_FILAMENT_2_YES 0x00
#define TJC_PAGE_MEMORY_WARNING 77
#define TJC_PAGE_MEMORY_WARNING_YES 0x00
#define TJC_PAGE_UPDATING 78
#define TJC_PAGE_PRE_HEAT 79
#define TJC_PAGE_PRE_HEAT_SET_220 0x00
#define TJC_PAGE_PRE_HEAT_SET_250 0x01
#define TJC_PAGE_PRE_HEAT_SET_300 0x02
#define TJC_PAGE_PRE_HEAT_BACK 0x04
#define TJC_PAGE_RESUME_PRINT 80
#define TJC_PAGE_RESUME_PRINT_YES 0x00
#define TJC_PAGE_RESUME_PRINT_NO 0x01
#define TJC_PAGE_SHOW_QR 81
#define TJC_PAGE_SHOW_QR_REFRESH 0x00
#define TJC_PAGE_SHOW_QR_BACK 0x01
#define TJC_PAGE_SHOW_QR_WIFI 0x02
#define TJC_PAGE_SHOW_QR_SET 0x03
#define TJC_PAGE_SERVER_SET 82
#define TJC_PAGE_SERVER_SET_REFRESH 0x00
#define TJC_PAGE_SERVER_SET_BACK 0x01
#define TJC_PAGE_SERVER_SET_LOCAL 0x02
#define TJC_PAGE_SERVER_SET_PREVIOUS 0x03
#define TJC_PAGE_SERVER_SET_NEXT 0x04
#define TJC_PAGE_SERVER_SET_1 0x05
#define TJC_PAGE_SERVER_SET_2 0x06
#define TJC_PAGE_SERVER_SET_3 0x07
#define TJC_PAGE_SERVER_SET_4 0x08
#define TJC_PAGE_UPDATE_MODE 83
#define TJC_PAGE_UPDATE_MODE_BACK 0x00
#define TJC_PAGE_UPDATE_MODE_LOCAL 0x01
#define TJC_PAGE_UPDATE_MODE_ONLINE 0x02
#define TJC_PAGE_ONLINE_UPDATE 84
#define TJC_PAGE_ONLINE_UPDATE_BACK 0x00
#define TJC_PAGE_ONLINE_UPDATE_YES 0x01
#define TJC_PAGE_ONLINE_UPDATE_NO 0x02
#define TJC_PAGE_SEARCH_SERVER 85
#define TJC_PAGE_UNLOAD_MODE 86
#define TJC_PAGE_UNLOAD_MODE_MANUAL 0x00
#define TJC_PAGE_UNLOAD_MODE_AUTO 0x01
#define TJC_PAGE_UNLOAD_MODE_BACK 0x02
#define TJC_PAGE_AUTO_UNLOAD 87
#define TJC_PAGE_AUTO_UNLOAD_TO_LOAD 0x00
#define TJC_PAGE_AUTO_UNLOAD_YES 0x01
#define TJC_PAGE_OPEN_LANGUAGE2 88
#define TJC_PAGE_LANGUAGE2 89
#define TJC_PAGE_INSTALLING 90
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);
void tjc_event_setted_handler(int page_id, int widget_id, unsigned char first, unsigned char second);
void tjc_event_keyboard(char *cmd);
#endif