Skip to content

Commit

Permalink
Implement fetchdatamin
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Oct 25, 2024
1 parent 337a26b commit ec7e6f1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CYD-Klipper/src/core/data_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions CYD-Klipper/src/core/printer_integration.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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());
}
4 changes: 3 additions & 1 deletion CYD-Klipper/src/core/printer_integration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ class BasePrinter
BasePrinter* get_current_printer();
BasePrinter* get_printer(int idx);
void initialize_printers();
PrinterData* get_current_printer_data();
PrinterData* get_current_printer_data();
unsigned int get_printer_count();
void announce_printer_data_minimal(PrinterDataMinimal* printer_data);

0 comments on commit ec7e6f1

Please sign in to comment.