mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Fix #10
This commit is contained in:
@@ -18,7 +18,8 @@ lib_deps =
|
|||||||
lvgl/lvgl@^8.3.9
|
lvgl/lvgl@^8.3.9
|
||||||
https://github.com/Bodmer/TFT_eSPI.git
|
https://github.com/Bodmer/TFT_eSPI.git
|
||||||
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
|
||||||
bblanchon/ArduinoJson@^6.21.3
|
bblanchon/ArduinoJson@^7.0.0
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
build_flags =
|
build_flags =
|
||||||
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||||
-DUSER_SETUP_LOADED=1
|
-DUSER_SETUP_LOADED=1
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ void fetch_printer_data()
|
|||||||
char buff[256] = {};
|
char buff[256] = {};
|
||||||
sprintf(buff, "http://%s:%d/printer/objects/query?extruder&heater_bed&toolhead&gcode_move&virtual_sdcard&print_stats&webhooks", global_config.klipperHost, global_config.klipperPort);
|
sprintf(buff, "http://%s:%d/printer/objects/query?extruder&heater_bed&toolhead&gcode_move&virtual_sdcard&print_stats&webhooks", global_config.klipperHost, global_config.klipperPort);
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
|
client.useHTTP10(true);
|
||||||
client.begin(buff);
|
client.begin(buff);
|
||||||
int httpCode = client.GET();
|
int httpCode = client.GET();
|
||||||
if (httpCode == 200)
|
if (httpCode == 200)
|
||||||
{
|
{
|
||||||
klipper_request_consecutive_fail_count = 0;
|
klipper_request_consecutive_fail_count = 0;
|
||||||
String payload = client.getString();
|
JsonDocument doc;
|
||||||
DynamicJsonDocument doc(4096);
|
deserializeJson(doc, client.getStream());
|
||||||
deserializeJson(doc, payload);
|
|
||||||
auto status = doc["result"]["status"];
|
auto status = doc["result"]["status"];
|
||||||
bool emit_state_update = false;
|
bool emit_state_update = false;
|
||||||
int printer_state = printer.state;
|
int printer_state = printer.state;
|
||||||
|
|||||||
@@ -22,24 +22,28 @@ FILESYSTEM_FILE* get_files(){
|
|||||||
|
|
||||||
free(last_query);
|
free(last_query);
|
||||||
}
|
}
|
||||||
|
Serial.printf("Heap space pre-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||||
std::list<FILESYSTEM_FILE> files;
|
std::list<FILESYSTEM_FILE> files;
|
||||||
char buff[256] = {};
|
char buff[256] = {};
|
||||||
sprintf(buff, "http://%s:%d/server/files/list", global_config.klipperHost, global_config.klipperPort);
|
sprintf(buff, "http://%s:%d/server/files/list", global_config.klipperHost, global_config.klipperPort);
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
|
client.useHTTP10(true);
|
||||||
client.begin(buff);
|
client.begin(buff);
|
||||||
int httpCode = client.GET();
|
int httpCode = client.GET();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (httpCode == 200){
|
if (httpCode == 200){
|
||||||
String payload = client.getString();
|
JsonDocument doc;
|
||||||
DynamicJsonDocument doc(60000);
|
auto parseResult = deserializeJson(doc, client.getStream());
|
||||||
auto a = deserializeJson(doc, payload);
|
Serial.printf("Json parse: %s\n", parseResult.c_str());
|
||||||
Serial.printf("JSON PARSE: %s\n", a.c_str());
|
|
||||||
auto result = doc["result"].as<JsonArray>();
|
auto result = doc["result"].as<JsonArray>();
|
||||||
for (auto file : result){
|
for (auto file : result){
|
||||||
FILESYSTEM_FILE f = {0};
|
FILESYSTEM_FILE f = {0};
|
||||||
const char* path = file["path"];
|
const char* path = file["path"];
|
||||||
f.name = (char*)malloc(strlen(path) + 1);
|
f.name = (char*)malloc(strlen(path) + 1);
|
||||||
|
if (f.name == NULL){
|
||||||
|
Serial.println("Failed to allocate memory");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
strcpy(f.name, path);
|
strcpy(f.name, path);
|
||||||
f.modified = file["modified"];
|
f.modified = file["modified"];
|
||||||
files.push_back(f);
|
files.push_back(f);
|
||||||
@@ -62,6 +66,7 @@ FILESYSTEM_FILE* get_files(){
|
|||||||
result += 1;
|
result += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Serial.printf("Heap space post-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||||
unfreeze_request_thread();
|
unfreeze_request_thread();
|
||||||
return last_query;
|
return last_query;
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,12 @@ static void on_state_change(void * s, lv_msg_t * m) {
|
|||||||
|
|
||||||
String url = "http://" + String(global_config.klipperHost) + ":" + String(global_config.klipperPort) + "/printer/gcode/help";
|
String url = "http://" + String(global_config.klipperHost) + ":" + String(global_config.klipperPort) + "/printer/gcode/help";
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
|
client.useHTTP10(true);
|
||||||
client.begin(url.c_str());
|
client.begin(url.c_str());
|
||||||
int httpCode = client.GET();
|
int httpCode = client.GET();
|
||||||
if (httpCode == 200){
|
if (httpCode == 200){
|
||||||
String payload = client.getString();
|
JsonDocument doc;
|
||||||
DynamicJsonDocument doc(16384);
|
deserializeJson(doc, client.getStream());
|
||||||
deserializeJson(doc, payload);
|
|
||||||
auto result = doc["result"].as<JsonObject>();
|
auto result = doc["result"].as<JsonObject>();
|
||||||
|
|
||||||
for (int i = 0; i < macros_count; i++){
|
for (int i = 0; i < macros_count; i++){
|
||||||
|
|||||||
Reference in New Issue
Block a user