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
|
||||
https://github.com/Bodmer/TFT_eSPI.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 =
|
||||
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||
-DUSER_SETUP_LOADED=1
|
||||
|
||||
@@ -70,14 +70,14 @@ void fetch_printer_data()
|
||||
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);
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(buff);
|
||||
int httpCode = client.GET();
|
||||
if (httpCode == 200)
|
||||
{
|
||||
klipper_request_consecutive_fail_count = 0;
|
||||
String payload = client.getString();
|
||||
DynamicJsonDocument doc(4096);
|
||||
deserializeJson(doc, payload);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto status = doc["result"]["status"];
|
||||
bool emit_state_update = false;
|
||||
int printer_state = printer.state;
|
||||
|
||||
@@ -22,24 +22,28 @@ FILESYSTEM_FILE* get_files(){
|
||||
|
||||
free(last_query);
|
||||
}
|
||||
|
||||
Serial.printf("Heap space pre-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||
std::list<FILESYSTEM_FILE> files;
|
||||
char buff[256] = {};
|
||||
sprintf(buff, "http://%s:%d/server/files/list", global_config.klipperHost, global_config.klipperPort);
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(buff);
|
||||
int httpCode = client.GET();
|
||||
int count = 0;
|
||||
if (httpCode == 200){
|
||||
String payload = client.getString();
|
||||
DynamicJsonDocument doc(60000);
|
||||
auto a = deserializeJson(doc, payload);
|
||||
Serial.printf("JSON PARSE: %s\n", a.c_str());
|
||||
JsonDocument doc;
|
||||
auto parseResult = deserializeJson(doc, client.getStream());
|
||||
Serial.printf("Json parse: %s\n", parseResult.c_str());
|
||||
auto result = doc["result"].as<JsonArray>();
|
||||
for (auto file : result){
|
||||
FILESYSTEM_FILE f = {0};
|
||||
const char* path = file["path"];
|
||||
f.name = (char*)malloc(strlen(path) + 1);
|
||||
if (f.name == NULL){
|
||||
Serial.println("Failed to allocate memory");
|
||||
continue;
|
||||
}
|
||||
strcpy(f.name, path);
|
||||
f.modified = file["modified"];
|
||||
files.push_back(f);
|
||||
@@ -62,6 +66,7 @@ FILESYSTEM_FILE* get_files(){
|
||||
result += 1;
|
||||
}
|
||||
|
||||
Serial.printf("Heap space post-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||
unfreeze_request_thread();
|
||||
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";
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(url.c_str());
|
||||
int httpCode = client.GET();
|
||||
if (httpCode == 200){
|
||||
String payload = client.getString();
|
||||
DynamicJsonDocument doc(16384);
|
||||
deserializeJson(doc, payload);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto result = doc["result"].as<JsonObject>();
|
||||
|
||||
for (int i = 0; i < macros_count; i++){
|
||||
|
||||
Reference in New Issue
Block a user