From ec7e6f180ded67495e20790a0d38a6cf944cff8d Mon Sep 17 00:00:00 2001 From: Sims <38142618+suchmememanyskill@users.noreply.github.com> Date: Fri, 25 Oct 2024 08:28:26 +0200 Subject: [PATCH] Implement fetchdatamin --- CYD-Klipper/src/core/data_setup.cpp | 9 ++++++++- CYD-Klipper/src/core/printer_integration.cpp | 13 +++++++++++++ CYD-Klipper/src/core/printer_integration.hpp | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CYD-Klipper/src/core/data_setup.cpp b/CYD-Klipper/src/core/data_setup.cpp index dc6d5a3..38fd60f 100644 --- a/CYD-Klipper/src/core/data_setup.cpp +++ b/CYD-Klipper/src/core/data_setup.cpp @@ -156,7 +156,14 @@ void fetch_printer_data() void fetch_printer_data_minimal() { - // TODO + PrinterDataMinimal* data = (PrinterDataMinimal*)malloc(sizeof(PrinterDataMinimal) * get_printer_count()); + for (int i = 0; i < get_printer_count(); i++) + { + BasePrinter* printer = get_printer(i); + *(data + i) = printer->fetch_min(); + } + announce_printer_data_minimal(data); + free(data); } void data_loop() diff --git a/CYD-Klipper/src/core/printer_integration.cpp b/CYD-Klipper/src/core/printer_integration.cpp index 6fa2800..4f78e28 100644 --- a/CYD-Klipper/src/core/printer_integration.cpp +++ b/CYD-Klipper/src/core/printer_integration.cpp @@ -1,7 +1,9 @@ #include "printer_integration.hpp" unsigned char current_printer_index = 0; +unsigned char total_printers; BasePrinter* registered_printers; +PrinterDataMinimal* minimal_data_copy; PrinterData* printer_data_copy; BasePrinter::BasePrinter(unsigned char index) @@ -74,4 +76,15 @@ BasePrinter* get_printer(int idx) PrinterData* get_current_printer_data() { return printer_data_copy; +} + +unsigned int get_printer_count() +{ + return total_printers; +} + +void announce_printer_data_minimal(PrinterDataMinimal* printer_data) +{ + memcpy(printer_data_copy, printer_data, sizeof(PrinterDataMinimal) * total_printers); + lv_msg_send(DATA_PRINTER_MINIMAL, get_current_printer()); } \ No newline at end of file diff --git a/CYD-Klipper/src/core/printer_integration.hpp b/CYD-Klipper/src/core/printer_integration.hpp index 249d6e8..b2623d4 100644 --- a/CYD-Klipper/src/core/printer_integration.hpp +++ b/CYD-Klipper/src/core/printer_integration.hpp @@ -166,4 +166,6 @@ class BasePrinter BasePrinter* get_current_printer(); BasePrinter* get_printer(int idx); void initialize_printers(); -PrinterData* get_current_printer_data(); \ No newline at end of file +PrinterData* get_current_printer_data(); +unsigned int get_printer_count(); +void announce_printer_data_minimal(PrinterDataMinimal* printer_data); \ No newline at end of file