Skip to content

Commit

Permalink
v1.6.4 (#113)
Browse files Browse the repository at this point in the history
* Fix gcode previews with special chars not loading

* Add .gitignore file (#108)

* Bulletproof ci.py (#107)

* Implement file sorting (implement #89)

* Set chip family to ESP32-S3 for specific models (fix #67)

* Add files menu to params panel while printing (implement #80)

* Update ci.py (#110)

Typo fix for ESP32-S3 boards array name

---------

Co-authored-by: Sebastian Göls <[email protected]>
Co-authored-by: Miroslav Zuzelka <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent c640d7f commit e2c2a38
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 34 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
_site/out/
_site/OTA.json
_site/esp32-*.json

pyvenv.cfg
bin/
out/
lib
lib64

1 change: 1 addition & 0 deletions CYD-Klipper/src/conf/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct _GLOBAL_CONFIG {
bool on_during_print : 1;
bool display_mode : 1; // Driver specifc usage. Currently only used on ESP32-2432S028R to fix the screen on the usb-c model
bool disable_m117_messaging : 1;
bool sort_macros : 1;
};
};

Expand Down
7 changes: 7 additions & 0 deletions CYD-Klipper/src/core/macros_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ MACROSQUERY macros_query(PRINTER_CONFIG * config)
}
}

if (global_config.sort_macros)
{
std::sort(macros, macros + macros_count, [](const char* a, const char* b) {
return strcmp(a, b) < 0;
});
}

return {(const char**)macros, (unsigned int)macros_count};
}
else {
Expand Down
19 changes: 11 additions & 8 deletions CYD-Klipper/src/ui/gcode_img.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "lvgl.h"
#include "ui_utils.h"
#include <Esp.h>
#include <UrlEncode.h>
#include <ArduinoJson.h>
#include "../conf/global_config.h"
#include "../core/http_client.h"
Expand All @@ -10,29 +11,27 @@ static unsigned char * data_png = NULL;
static char img_filename_path[256] = {0};
static lv_img_dsc_t img_header = {0};

bool has_128_128_gcode(const char* filename)
bool has_32_32_gcode_img(const char* filename)
{
if (filename == NULL){
Serial.println("No gcode filename");
return false;
}

SETUP_HTTP_CLIENT("/server/files/thumbnails?filename=" + String(filename));

SETUP_HTTP_CLIENT("/server/files/thumbnails?filename=" + urlEncode(filename));
int httpCode = 0;
try {
httpCode = client.GET();
}
catch (...){
Serial.println("Exception while fetching gcode img location");
return {0};
return false;
}

if (httpCode == 200)
{
String payload = client.getString();
JsonDocument doc;
deserializeJson(doc, payload);
deserializeJson(doc, client.getStream());
auto result = doc["result"].as<JsonArray>();
const char* chosen_thumb = NULL;

Expand All @@ -58,6 +57,10 @@ bool has_128_128_gcode(const char* filename)
return true;
}
}
else
{
Serial.printf("Failed to fetch gcode image data: %d\n", httpCode);
}

return false;
}
Expand All @@ -71,7 +74,7 @@ lv_obj_t* draw_gcode_img()
return NULL;
}

SETUP_HTTP_CLIENT_FULL("/server/files/gcodes/" + String(img_filename_path), false, 2000);
SETUP_HTTP_CLIENT_FULL("/server/files/gcodes/" + urlEncode(img_filename_path), false, 2000);

int httpCode = 0;
try {
Expand Down Expand Up @@ -121,7 +124,7 @@ lv_obj_t* show_gcode_img(const char* filename)
return NULL;
}

if (!has_128_128_gcode(filename)){
if (!has_32_32_gcode_img(filename)){
Serial.println("No 32x32 gcode img found");
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion CYD-Klipper/src/ui/gcode_img.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#include "lvgl.h"

lv_obj_t* show_gcode_img(const char* filename);
bool has_128_128_gcode(const char* filename);
bool has_32_32_gcode_img(const char* filename);
void clear_img_mem();
5 changes: 4 additions & 1 deletion CYD-Klipper/src/ui/main_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ static void on_state_change(void * s, lv_msg_t * m){
else if (printer.state == PRINTER_STATE_ERROR){
nav_buttons_setup(PANEL_ERROR);
}
else if (printer.state == PRINTER_STATE_IDLE) {
nav_buttons_setup(PANEL_FILES);
}
else {
nav_buttons_setup(PANEL_PRINT);
nav_buttons_setup(PANEL_PROGRESS);
}
}

Expand Down
24 changes: 19 additions & 5 deletions CYD-Klipper/src/ui/nav_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ static void update_printer_data_time(lv_event_t * e){
}

static void btn_click_files(lv_event_t * e){
nav_buttons_setup(PANEL_PRINT);
nav_buttons_setup(PANEL_FILES);
}

static void btn_click_progress(lv_event_t * e){
nav_buttons_setup(PANEL_PROGRESS);
}

static void btn_click_move(lv_event_t * e){
Expand Down Expand Up @@ -115,7 +119,7 @@ void create_button(const char* icon, const char* name, lv_event_cb_t button_clic
lv_obj_add_style(label, &nav_button_text_style, 0);
}

void nav_buttons_setup(unsigned char active_panel){
void nav_buttons_setup(PANEL_TYPE active_panel){
lv_obj_clean(lv_scr_act());
lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);

Expand All @@ -134,7 +138,14 @@ void nav_buttons_setup(unsigned char active_panel){

if (printer.state > PRINTER_STATE_ERROR){
// Files/Print
create_button(LV_SYMBOL_COPY, "Idle", btn_click_files, update_printer_data_time, root_panel);
if (printer.state == PRINTER_STATE_IDLE)
{
create_button(LV_SYMBOL_COPY, "Idle", btn_click_files, update_printer_data_time, root_panel);
}
else
{
create_button(LV_SYMBOL_FILE, "Paused", btn_click_progress, update_printer_data_time, root_panel);
}

// Move
create_button(printer.state == PRINTER_STATE_PRINTING ? LV_SYMBOL_EDIT : LV_SYMBOL_CHARGE, "Z?", btn_click_move, update_printer_data_z_pos, root_panel);
Expand Down Expand Up @@ -165,8 +176,8 @@ void nav_buttons_setup(unsigned char active_panel){
lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, 0, 0);

switch (active_panel){
case PANEL_PRINT:
print_panel_init(panel);
case PANEL_FILES:
files_panel_init(panel);
break;
case PANEL_MOVE:
move_panel_init(panel);
Expand All @@ -192,6 +203,9 @@ void nav_buttons_setup(unsigned char active_panel){
case PANEL_CONNECTING:
connecting_panel_init(panel);
break;
case PANEL_PROGRESS:
progress_panel_init(panel);
break;
}

lv_msg_send(DATA_PRINTER_DATA, &printer);
Expand Down
23 changes: 13 additions & 10 deletions CYD-Klipper/src/ui/nav_buttons.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#pragma once

#define PANEL_PRINT 0
#define PANEL_MOVE 1
#define PANEL_TEMP 2
#define PANEL_SETTINGS 3
#define PANEL_MACROS 4
#define PANEL_STATS 5
#define PANEL_PRINTER 6
#define PANEL_ERROR 7
#define PANEL_CONNECTING 8
enum PANEL_TYPE {
PANEL_FILES = 0,
PANEL_MOVE = 1,
PANEL_TEMP = 2,
PANEL_SETTINGS = 3,
PANEL_MACROS = 4,
PANEL_STATS = 5,
PANEL_PRINTER = 6,
PANEL_ERROR = 7,
PANEL_CONNECTING = 8,
PANEL_PROGRESS = 9,
};

void nav_buttons_setup(unsigned char active_panel);
void nav_buttons_setup(PANEL_TYPE active_panel);
void nav_style_setup();
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ static void btn_print_file(lv_event_t * e){
}

static void btn_print_file_verify(lv_event_t * e){
if (printer.state != PRINTER_STATE_IDLE){
return;
}

const auto button_size_mult = 1.3f;

lv_obj_t * btn = lv_event_get_target(e);
Expand Down Expand Up @@ -76,12 +80,7 @@ static void btn_print_file_verify(lv_event_t * e){
}
}

void print_panel_init(lv_obj_t* panel){
if (printer.state == PRINTER_STATE_PRINTING || printer.state == PRINTER_STATE_PAUSED){
progress_panel_init(panel);
return;
}

void files_panel_init(lv_obj_t* panel){
clear_img_mem();

lv_obj_t * list = lv_list_create(panel);
Expand Down
2 changes: 1 addition & 1 deletion CYD-Klipper/src/ui/panels/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void settings_panel_init(lv_obj_t* panel);
void temp_panel_init(lv_obj_t* panel);
void print_panel_init(lv_obj_t* panel);
void files_panel_init(lv_obj_t* panel);
void move_panel_init(lv_obj_t* panel);
void progress_panel_init(lv_obj_t* panel);
void macros_panel_init(lv_obj_t* panel);
Expand Down
9 changes: 9 additions & 0 deletions CYD-Klipper/src/ui/panels/settings_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ static void disable_m117_messaging_switch(lv_event_t* e){
write_global_config();
}

static void sort_macros_switch(lv_event_t* e){
auto state = lv_obj_get_state(lv_event_get_target(e));
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
global_config.sort_macros = checked;
write_global_config();
}

static void rotate_screen_switch(lv_event_t* e){
auto state = lv_obj_get_state(lv_event_get_target(e));
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
Expand Down Expand Up @@ -208,6 +215,8 @@ void settings_section_behaviour(lv_obj_t* panel)
global_config.multi_printer_mode
? "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled. Stored per printer."
: "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled");

lv_create_custom_menu_switch("Sort Macros A->Z", panel, sort_macros_switch, global_config.sort_macros);
}

void settings_section_device(lv_obj_t* panel)
Expand Down
15 changes: 15 additions & 0 deletions CYD-Klipper/src/ui/panels/stats_panel.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include "panel.h"
#include "../ui_utils.h"
#include "../../core/data_setup.h"
#include "../nav_buttons.h"
#include <stdio.h>
#include <Esp.h>

static void swap_to_files_menu(lv_event_t * e) {
nav_buttons_setup(PANEL_FILES);
}

static void set_fan_speed_text(lv_event_t * e) {
lv_obj_t * label = lv_event_get_target(e);
char data[64];
Expand Down Expand Up @@ -248,6 +253,16 @@ void stats_panel_init(lv_obj_t* panel) {
lv_obj_set_size(right_panel, panel_width, CYD_SCREEN_PANEL_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2);
lv_layout_flex_column(right_panel, LV_FLEX_ALIGN_CENTER);
lv_obj_align(right_panel, LV_ALIGN_TOP_RIGHT, -1 * CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);

if (printer.state >= PRINTER_STATE_PRINTING){
lv_obj_t * btn = lv_btn_create(right_panel);
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH_PX / 2 - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
lv_obj_add_event_cb(btn, swap_to_files_menu, LV_EVENT_CLICKED, NULL);

lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, "Files");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}

create_state_button(right_panel, set_fan_speed_text, open_fan_speed_panel);
create_state_button(right_panel, set_zoffset_text, open_zoffset_panel);
Expand Down
13 changes: 11 additions & 2 deletions ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"esp32-3248S035C-V",
#"esp32-4827S043R-SD",
]

ESP_S3_CHIPS = [
"esp32-8048S043C-SD",
"esp32-4827S043C-SD",
]

BASE_DIR = os.getcwd()

def get_manifest(base_path : str, device_name : str):
Expand All @@ -19,7 +25,7 @@ def get_manifest(base_path : str, device_name : str):
"new_install_prompt_erase": True,
"builds": [
{
"chipFamily": "ESP32",
"chipFamily": "ESP32-S3" if device_name in ESP_S3_CHIPS else "ESP32",
"parts": [
{
"path": f"{base_path}/bootloader.bin",
Expand Down Expand Up @@ -81,7 +87,10 @@ def add_configuration(board : str):
add_configuration(port)

os.chdir(BASE_DIR)
shutil.copytree("./out", "./_site/out")
out_dir = "./_site/out"
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
shutil.copytree("./out", out_dir)

with open("./_site/OTA.json", "w") as f:
json.dump({"Configurations": configurations}, f)

0 comments on commit e2c2a38

Please sign in to comment.