Rework network loop to make one request

This commit is contained in:
suchmememanyskill
2023-11-12 23:31:08 +01:00
parent 86fca4ca16
commit ee9b48850d
6 changed files with 142 additions and 133 deletions

View File

@@ -44,19 +44,15 @@ static void update_printer_data_time(lv_event_t * e){
unsigned long minutes = (time % 3600) / 60;
unsigned long seconds = (time % 3600) % 60;
if (hours > 99){
lv_label_set_text(label, ">99h");
return;
}
if (hours >= 1){
sprintf(time_buffer, "%02luh%02lum", hours, minutes);
if (hours >= 10){
sprintf(time_buffer, "%luh", hours);
} else if (hours >= 1){
sprintf(time_buffer, "%luh%02lum", hours, minutes);
} else {
sprintf(time_buffer, "%02lum%02lus", minutes, seconds);
sprintf(time_buffer, "%02lum", minutes);
}
lv_label_set_text(label, time_buffer);
}
static void btn_click_files(lv_event_t * e){

View File

@@ -107,7 +107,7 @@ static void stepper_state_update(lv_event_t * e){
lv_label_set_text(label, printer.homed_axis ? LV_SYMBOL_HOME " Steppers locked" : LV_SYMBOL_EYE_CLOSE " Steppers unlocked");
}
void move_panel_data(lv_obj_t* panel){
void move_panel_init(lv_obj_t* panel){
lv_obj_clear_flag(panel, LV_OBJ_FLAG_SCROLLABLE);
const int button_size = 40;
const int button_size_vertical = 40;
@@ -205,11 +205,5 @@ void move_panel_data(lv_obj_t* panel){
y_pos += 60;
}
}
void move_panel_init(lv_obj_t* panel){
move_panel_data(panel);
lv_msg_send(DATA_PRINTER_DATA, &printer);
}

View File

@@ -3,7 +3,7 @@
#include "../../core/data_setup.h"
void print_panel_init(lv_obj_t* panel){
if (printer.state == PRINTER_STATE_PRINTING || printer.state == PRINTER_STATE_PAUSED || true){
if (printer.state == PRINTER_STATE_PRINTING || printer.state == PRINTER_STATE_PAUSED){
progress_panel_init(panel);
return;
}

View File

@@ -35,15 +35,15 @@ static void update_printer_data_percentage(lv_event_t * e){
}
static void btn_click_stop(lv_event_t * e){
// TODO: Implement
send_gcode(true, "CANCEL_PRINT");
}
static void btn_click_pause(lv_event_t * e){
// TODO: Implement
send_gcode(true, "PAUSE");
}
static void btn_click_resume(lv_event_t * e){
// TODO: Implement
send_gcode(true, "RESUME");
}
void progress_panel_init(lv_obj_t* panel){
@@ -117,4 +117,6 @@ void progress_panel_init(lv_obj_t* panel){
lv_label_set_text(label, LV_SYMBOL_PAUSE);
lv_obj_center(label);
}
lv_msg_send(DATA_PRINTER_DATA, &printer);
}

View File

@@ -79,16 +79,28 @@ static void show_keyboard_with_bed(lv_event_t * e){
}
static void cooldown_temp(lv_event_t * e){
if (printer.state == PRINTER_STATE_PRINTING){
return;
}
send_gcode(true, "M104%20S0");
send_gcode(true, "M140%20S0");
}
static void btn_extrude(lv_event_t * e){
if (printer.state == PRINTER_STATE_PRINTING){
return;
}
send_gcode(true, "M83");
send_gcode(true, "G1%20E25%20F300");
}
static void btn_retract(lv_event_t * e){
if (printer.state == PRINTER_STATE_PRINTING){
return;
}
send_gcode(true, "M83");
send_gcode(true, "G1%20E-25%20F300");
}
@@ -148,4 +160,6 @@ void temp_panel_init(lv_obj_t* panel){
label = lv_label_create(btn);
lv_label_set_text(label, LV_SYMBOL_UP " Retract");
lv_obj_center(label);
lv_msg_send(DATA_PRINTER_DATA, &printer);
}