mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Make stats panel accessible from move panel, improve Z offset menu
This commit is contained in:
6
CYD-Klipper/.vscode/settings.json
vendored
6
CYD-Klipper/.vscode/settings.json
vendored
@@ -12,6 +12,8 @@
|
|||||||
"algorithm": "cpp",
|
"algorithm": "cpp",
|
||||||
"cstddef": "cpp",
|
"cstddef": "cpp",
|
||||||
"functional": "cpp",
|
"functional": "cpp",
|
||||||
"*.tcc": "cpp"
|
"*.tcc": "cpp",
|
||||||
}
|
"cmath": "cpp"
|
||||||
|
},
|
||||||
|
"cmake.configureOnOpen": false
|
||||||
}
|
}
|
||||||
@@ -43,12 +43,8 @@ lib_deps =
|
|||||||
bblanchon/ArduinoJson@^7.0.0
|
bblanchon/ArduinoJson@^7.0.0
|
||||||
plageoj/UrlEncode@^1.0.1
|
plageoj/UrlEncode@^1.0.1
|
||||||
|
|
||||||
# Terribly slow. Only use for development
|
|
||||||
[env:esp32-3248S035C-smartdisplay]
|
[env:esp32-3248S035C-smartdisplay]
|
||||||
board = esp32-3248S035C-smartdisplay
|
board = esp32-3248S035C-smartdisplay
|
||||||
|
|
||||||
[env:esp32-2432S028R-smartdisplay]
|
[env:esp32-2432S028R-smartdisplay]
|
||||||
board = esp32-2432S028R-smartdisplay
|
board = esp32-2432S028R-smartdisplay
|
||||||
|
|
||||||
[env:esp32-2432S022C]
|
|
||||||
board = esp32-2432S022C-smartdisplay
|
|
||||||
@@ -65,6 +65,33 @@ void send_gcode(bool wait, const char *gcode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move_printer(const char* axis, float amount, bool relative) {
|
||||||
|
if (!printer.homed_axis || printer.state == PRINTER_STATE_PRINTING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char gcode[64];
|
||||||
|
const char* extra = (amount > 0) ? "+" : "";
|
||||||
|
|
||||||
|
bool absolute_coords = printer.absolute_coords;
|
||||||
|
|
||||||
|
if (absolute_coords && relative) {
|
||||||
|
send_gcode(true, "G91");
|
||||||
|
}
|
||||||
|
else if (!absolute_coords && !relative) {
|
||||||
|
send_gcode(true, "G90");
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(gcode, "G1 %s%s%.3f F6000", axis, extra, amount);
|
||||||
|
send_gcode(true, gcode);
|
||||||
|
|
||||||
|
if (absolute_coords && relative) {
|
||||||
|
send_gcode(true, "G90");
|
||||||
|
}
|
||||||
|
else if (!absolute_coords && !relative) {
|
||||||
|
send_gcode(true, "G91");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fetch_printer_data()
|
void fetch_printer_data()
|
||||||
{
|
{
|
||||||
freeze_request_thread();
|
freeze_request_thread();
|
||||||
@@ -122,6 +149,7 @@ void fetch_printer_data()
|
|||||||
printer.extruder_target_temp = status["extruder"]["target"];
|
printer.extruder_target_temp = status["extruder"]["target"];
|
||||||
bool can_extrude = status["extruder"]["can_extrude"];
|
bool can_extrude = status["extruder"]["can_extrude"];
|
||||||
printer.pressure_advance = status["extruder"]["pressure_advance"];
|
printer.pressure_advance = status["extruder"]["pressure_advance"];
|
||||||
|
printer.smooth_time = status["extruder"]["smooth_time"];
|
||||||
printer.can_extrude = can_extrude == true;
|
printer.can_extrude = can_extrude == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ typedef struct _Printer {
|
|||||||
int total_layers;
|
int total_layers;
|
||||||
int current_layer;
|
int current_layer;
|
||||||
float pressure_advance;
|
float pressure_advance;
|
||||||
|
float smooth_time;
|
||||||
int feedrate_mm_per_s;
|
int feedrate_mm_per_s;
|
||||||
} Printer;
|
} Printer;
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ extern int klipper_request_consecutive_fail_count;
|
|||||||
void data_loop();
|
void data_loop();
|
||||||
void data_setup();
|
void data_setup();
|
||||||
void send_gcode(bool wait, const char* gcode);
|
void send_gcode(bool wait, const char* gcode);
|
||||||
|
void move_printer(const char* axis, float amount, bool relative);
|
||||||
|
|
||||||
void freeze_request_thread();
|
void freeze_request_thread();
|
||||||
void unfreeze_request_thread();
|
void unfreeze_request_thread();
|
||||||
@@ -26,14 +26,15 @@ void lv_do_calibration(){
|
|||||||
|
|
||||||
is_in_calibration_mode = true;
|
is_in_calibration_mode = true;
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
|
lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
|
||||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||||
lv_label_set_text(label, "Calibrate Screen");
|
lv_label_set_text(label, "Calibrate Screen");
|
||||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
lv_obj_t * line = lv_line_create(lv_scr_act());
|
lv_obj_t * line = lv_line_create(lv_scr_act());
|
||||||
static lv_point_t line_points_x[] = { {0, 10}, {20, 10} };
|
static lv_point_t line_points_x[] = { {0, 10}, {21, 10} };
|
||||||
static lv_point_t line_points_y[] = { {10, 0}, {10, 20} };
|
static lv_point_t line_points_y[] = { {10, 0}, {10, 21} };
|
||||||
|
|
||||||
lv_line_set_points(line, line_points_x, 2);
|
lv_line_set_points(line, line_points_x, 2);
|
||||||
lv_obj_align(line, LV_ALIGN_TOP_LEFT, 0, 0);
|
lv_obj_align(line, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||||
@@ -63,12 +64,12 @@ void lv_do_calibration(){
|
|||||||
|
|
||||||
line = lv_line_create(lv_scr_act());
|
line = lv_line_create(lv_scr_act());
|
||||||
lv_line_set_points(line, line_points_x, 2);
|
lv_line_set_points(line, line_points_x, 2);
|
||||||
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, 0, -10);
|
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, 1, -10);
|
||||||
lv_obj_set_style_line_width(line, 1, 0);
|
lv_obj_set_style_line_width(line, 1, 0);
|
||||||
|
|
||||||
line = lv_line_create(lv_scr_act());
|
line = lv_line_create(lv_scr_act());
|
||||||
lv_line_set_points(line, line_points_y, 2);
|
lv_line_set_points(line, line_points_y, 2);
|
||||||
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, -10, 0);
|
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, -10, 1);
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ void nav_buttons_setup(unsigned char active_panel){
|
|||||||
case 4:
|
case 4:
|
||||||
macros_panel_init(panel);
|
macros_panel_init(panel);
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
stats_panel_init(panel);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||||
|
|||||||
@@ -1,48 +1,28 @@
|
|||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "../../core/data_setup.h"
|
#include "../../core/data_setup.h"
|
||||||
|
#include "../nav_buttons.h"
|
||||||
#include "../ui_utils.h"
|
#include "../ui_utils.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static bool last_homing_state = false;
|
static bool last_homing_state = false;
|
||||||
|
|
||||||
static void move_printer(const char* axis, float amount) {
|
|
||||||
if (!printer.homed_axis || printer.state == PRINTER_STATE_PRINTING)
|
|
||||||
return;
|
|
||||||
|
|
||||||
char gcode[64];
|
|
||||||
const char* extra = (amount > 0) ? "+" : "";
|
|
||||||
|
|
||||||
bool absolute_coords = printer.absolute_coords;
|
|
||||||
|
|
||||||
if (absolute_coords) {
|
|
||||||
send_gcode(true, "G91");
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(gcode, "G1 %s%s%.1f F6000", axis, extra, amount);
|
|
||||||
send_gcode(true, gcode);
|
|
||||||
|
|
||||||
if (absolute_coords) {
|
|
||||||
send_gcode(true, "G90");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void x_line_button_press(lv_event_t * e) {
|
static void x_line_button_press(lv_event_t * e) {
|
||||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||||
float data = *data_pointer;
|
float data = *data_pointer;
|
||||||
move_printer("X", data);
|
move_printer("X", data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void y_line_button_press(lv_event_t * e) {
|
static void y_line_button_press(lv_event_t * e) {
|
||||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||||
float data = *data_pointer;
|
float data = *data_pointer;
|
||||||
move_printer("Y", data);
|
move_printer("Y", data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void z_line_button_press(lv_event_t * e) {
|
static void z_line_button_press(lv_event_t * e) {
|
||||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||||
float data = *data_pointer;
|
float data = *data_pointer;
|
||||||
move_printer("Z", data);
|
move_printer("Z", data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
char x_pos_buff[12];
|
char x_pos_buff[12];
|
||||||
@@ -103,6 +83,11 @@ static void disable_steppers_click(lv_event_t * e) {
|
|||||||
send_gcode(true, "M18");
|
send_gcode(true, "M18");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void switch_to_stat_panel(lv_event_t * e) {
|
||||||
|
lv_obj_t * panel = lv_event_get_target(e);
|
||||||
|
nav_buttons_setup(5);
|
||||||
|
}
|
||||||
|
|
||||||
inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||||
const auto width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2;
|
const auto width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2;
|
||||||
|
|
||||||
@@ -121,7 +106,7 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
|||||||
lv_obj_set_flex_grow(btn, 1);
|
lv_obj_set_flex_grow(btn, 1);
|
||||||
|
|
||||||
lv_obj_t * label = lv_label_create(btn);
|
lv_obj_t * label = lv_label_create(btn);
|
||||||
lv_label_set_text(label, LV_SYMBOL_HOME "Home Axis");
|
lv_label_set_text(label, LV_SYMBOL_HOME "Home");
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
|
|
||||||
btn = lv_btn_create(home_button_row);
|
btn = lv_btn_create(home_button_row);
|
||||||
@@ -130,7 +115,16 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
|||||||
lv_obj_set_flex_grow(btn, 1);
|
lv_obj_set_flex_grow(btn, 1);
|
||||||
|
|
||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Disable Step");
|
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Unlock");
|
||||||
|
lv_obj_center(label);
|
||||||
|
|
||||||
|
btn = lv_btn_create(home_button_row);
|
||||||
|
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
|
lv_obj_add_event_cb(btn, switch_to_stat_panel, LV_EVENT_CLICKED, NULL);
|
||||||
|
lv_obj_set_flex_grow(btn, 1);
|
||||||
|
|
||||||
|
label = lv_label_create(btn);
|
||||||
|
lv_label_set_text(label, LV_SYMBOL_EDIT " Params");
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
|
|
||||||
for (int row = 0; row < 3; row++) {
|
for (int row = 0; row < 3; row++) {
|
||||||
|
|||||||
@@ -36,19 +36,38 @@ static void set_zoffset_text(lv_event_t * e) {
|
|||||||
lv_label_set_text(label, data);
|
lv_label_set_text(label, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_zoffset_text_ex(lv_event_t * e) {
|
||||||
|
lv_obj_t * label = lv_event_get_target(e);
|
||||||
|
char data[64];
|
||||||
|
sprintf(data, "Z Offset: %.03f, Z: %.03f", printer.gcode_offset[2], printer.position[2]);
|
||||||
|
lv_label_set_text(label, data);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_zoffset(lv_event_t * e){
|
static void set_zoffset(lv_event_t * e){
|
||||||
char* offset = (char*)lv_event_get_user_data(e);
|
char* offset = (char*)lv_event_get_user_data(e);
|
||||||
|
|
||||||
|
const char* extra = printer.state == PRINTER_STATE_IDLE ? " MOVE=1" : "";
|
||||||
|
|
||||||
char gcode[64];
|
char gcode[64];
|
||||||
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s", offset);
|
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s%s", offset, extra);
|
||||||
send_gcode(true, gcode);
|
send_gcode(true, gcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_z(lv_event_t * e){
|
||||||
|
bool is_zero = !strcmp((char*)lv_event_get_user_data(e), "Z=0");
|
||||||
|
char gcode[64];
|
||||||
|
|
||||||
|
move_printer("Z", is_zero ? 0 : 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
const char* zoffsets[] = { "-0.005", "-0.01", "-0.025", "-0.05" };
|
const char* zoffsets[] = { "-0.005", "-0.01", "-0.025", "-0.05" };
|
||||||
const char* zoffsets_2[] = { "+0.005", "+0.01", "+0.025", "+0.05" };
|
const char* zoffsets_2[] = { "+0.005", "+0.01", "+0.025", "+0.05" };
|
||||||
|
const char* z_set[] = { "Z=0", "Z=1" };
|
||||||
|
|
||||||
lv_button_column_t zoffset_columns[] = {
|
lv_button_column_t zoffset_columns[] = {
|
||||||
{ set_zoffset, zoffsets, (const void**)zoffsets, 4},
|
{ set_zoffset, zoffsets, (const void**)zoffsets, 4},
|
||||||
{ set_zoffset, zoffsets_2, (const void**)zoffsets_2, 4}
|
{ set_zoffset, zoffsets_2, (const void**)zoffsets_2, 4},
|
||||||
|
{ set_z, z_set, (const void**)z_set, 2}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_speed_mult_text(lv_event_t * e){
|
static void set_speed_mult_text(lv_event_t * e){
|
||||||
@@ -126,7 +145,7 @@ static void open_fan_speed_panel(lv_event_t * e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void open_zoffset_panel(lv_event_t * e){
|
static void open_zoffset_panel(lv_event_t * e){
|
||||||
lv_create_fullscreen_button_matrix_popup(lv_scr_act(), set_zoffset_text, zoffset_columns, 2);
|
lv_create_fullscreen_button_matrix_popup(lv_scr_act(), set_zoffset_text_ex, zoffset_columns, (printer.state == PRINTER_STATE_IDLE) ? 3 : 2);
|
||||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +194,7 @@ static void label_total_layers(lv_event_t * e){
|
|||||||
static void label_pressure_advance(lv_event_t * e){
|
static void label_pressure_advance(lv_event_t * e){
|
||||||
lv_obj_t * label = lv_event_get_target(e);
|
lv_obj_t * label = lv_event_get_target(e);
|
||||||
char pressure_buff[32];
|
char pressure_buff[32];
|
||||||
sprintf(pressure_buff, "%.3f", printer.pressure_advance);
|
sprintf(pressure_buff, "%.3f (%.2fs)", printer.pressure_advance, printer.smooth_time);
|
||||||
lv_label_set_text(label, pressure_buff);
|
lv_label_set_text(label, pressure_buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,8 +230,12 @@ void stats_panel_init(lv_obj_t* panel) {
|
|||||||
lv_obj_align(left_panel, LV_ALIGN_TOP_LEFT, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
lv_obj_align(left_panel, LV_ALIGN_TOP_LEFT, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
||||||
|
|
||||||
create_stat_text_block(left_panel, "Position:", label_pos);
|
create_stat_text_block(left_panel, "Position:", label_pos);
|
||||||
|
|
||||||
|
if (printer.state != PRINTER_STATE_IDLE){
|
||||||
create_stat_text_block(left_panel, "Filament Used:", label_filament_used_m);
|
create_stat_text_block(left_panel, "Filament Used:", label_filament_used_m);
|
||||||
create_stat_text_block(left_panel, "Layer:", label_total_layers);
|
create_stat_text_block(left_panel, "Layer:", label_total_layers);
|
||||||
|
}
|
||||||
|
|
||||||
create_stat_text_block(left_panel, "Pressure Advance:", label_pressure_advance);
|
create_stat_text_block(left_panel, "Pressure Advance:", label_pressure_advance);
|
||||||
create_stat_text_block(left_panel, "Feedrate:", label_feedrate);
|
create_stat_text_block(left_panel, "Feedrate:", label_feedrate);
|
||||||
|
|
||||||
|
|||||||
2
ci.py
2
ci.py
@@ -1,6 +1,6 @@
|
|||||||
import subprocess, os, shutil, json
|
import subprocess, os, shutil, json
|
||||||
|
|
||||||
CYD_PORTS = ["esp32-3248S035C", "esp32-2432S028R", "esp32-2432S022C"]
|
CYD_PORTS = ["esp32-3248S035C", "esp32-2432S028R"]
|
||||||
BASE_DIR = os.getcwd()
|
BASE_DIR = os.getcwd()
|
||||||
|
|
||||||
def get_manifest(base_path : str, device_name : str):
|
def get_manifest(base_path : str, device_name : str):
|
||||||
|
|||||||
Reference in New Issue
Block a user