This commit is contained in:
suchmememanyskill
2024-10-27 19:08:21 +01:00
parent 75bb334b09
commit 6273e10e5a
6 changed files with 37 additions and 55 deletions

View File

@@ -33,7 +33,6 @@ lib_deps =
https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
bblanchon/ArduinoJson@^7.0.0
plageoj/UrlEncode@^1.0.1
erriez/ErriezCRC32 @ ^1.0.1
[env:esp32-3248S035C]
board = esp32-3248S035C
@@ -44,7 +43,6 @@ lib_deps =
https://github.com/OperatorB/gt911-arduino-fixed-reset.git
bblanchon/ArduinoJson@^7.0.0
plageoj/UrlEncode@^1.0.1
erriez/ErriezCRC32 @ ^1.0.1
[env:esp32-3248S035C-V]
board = esp32-3248S035C-vertical
@@ -55,7 +53,6 @@ lib_deps =
https://github.com/OperatorB/gt911-arduino-fixed-reset.git
bblanchon/ArduinoJson@^7.0.0
plageoj/UrlEncode@^1.0.1
erriez/ErriezCRC32 @ ^1.0.1
[env:esp32-2432S024C-SD]
board = esp32-2432S024C-smartdisplay

View File

@@ -38,11 +38,15 @@ static void on_state_change(void * s, lv_msg_t * m){
else {
nav_buttons_setup(PANEL_PROGRESS);
}
}
lv_msg_send(DATA_PRINTER_DATA, get_current_printer());
static void on_popup_message(void * s, lv_msg_t * m)
{
lv_create_popup_message(get_current_printer_data()->popup_message, 10000);
}
void main_ui_setup(){
lv_msg_subscribe(DATA_PRINTER_STATE, on_state_change, NULL);
lv_msg_subscribe(DATA_PRINTER_POPUP, on_popup_message, NULL);
on_state_change(NULL, NULL);
}

View File

@@ -1,10 +1,10 @@
#include "lvgl.h"
#include "panels/panel.h"
#include "../core/data_setup.h"
#include "nav_buttons.h"
#include "ui_utils.h"
#include <stdio.h>
#include "../conf/global_config.h"
#include "../core/printer_integration.hpp"
static lv_style_t nav_button_style;
@@ -17,31 +17,31 @@ static lv_style_t nav_button_text_style;
static void update_printer_data_z_pos(lv_event_t * e) {
lv_obj_t * label = lv_event_get_target(e);
sprintf(z_pos_buffer, "Z%.2f", printer.position[2]);
sprintf(z_pos_buffer, "Z%.2f", get_current_printer_data()->position[2]);
lv_label_set_text(label, z_pos_buffer);
}
static void update_printer_data_temp(lv_event_t * e) {
lv_obj_t * label = lv_event_get_target(e);
sprintf(temp_buffer, "%.0f/%.0f", printer.extruder_temp, printer.bed_temp);
sprintf(temp_buffer, "%.0f/%.0f", get_current_printer_data()->temperatures[PrinterTemperatureDeviceIndex::PrinterTemperatureDeviceIndexNozzle1], get_current_printer_data()->temperatures[PrinterTemperatureDeviceIndex::PrinterTemperatureDeviceIndexBed]);
lv_label_set_text(label, temp_buffer);
}
static void update_printer_data_time(lv_event_t * e){
lv_obj_t * label = lv_event_get_target(e);
if (printer.state == PRINTER_STATE_IDLE){
if (get_current_printer_data()->state == PrinterState::PrinterStateIdle){
lv_label_set_text(label, "Idle");
return;
}
if (printer.state == PRINTER_STATE_PAUSED){
if (get_current_printer_data()->state == PrinterState::PrinterStatePaused){
lv_label_set_text(label, "Paused");
return;
}
unsigned long time = printer.remaining_time_s;
unsigned long time = get_current_printer_data()->remaining_time_s;
unsigned long hours = time / 3600;
unsigned long minutes = (time % 3600) / 60;
unsigned long seconds = (time % 3600) % 60;
@@ -136,9 +136,9 @@ void nav_buttons_setup(PANEL_TYPE active_panel){
#endif
if (printer.state > PRINTER_STATE_ERROR){
if (get_current_printer_data()->state > PrinterState::PrinterStateError){
// Files/Print
if (printer.state == PRINTER_STATE_IDLE)
if (get_current_printer_data()->state == PrinterState::PrinterStateIdle)
{
create_button(LV_SYMBOL_COPY, "Idle", btn_click_files, update_printer_data_time, root_panel);
}
@@ -148,12 +148,12 @@ void nav_buttons_setup(PANEL_TYPE active_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);
create_button(get_current_printer_data()->state == PrinterState::PrinterStatePrinting ? LV_SYMBOL_EDIT : LV_SYMBOL_CHARGE, "Z?", btn_click_move, update_printer_data_z_pos, root_panel);
// Extrude/Temp
create_button(LV_SYMBOL_WARNING, "?/?", btn_click_extrude, update_printer_data_temp, root_panel);
}
else if (printer.state == PRINTER_STATE_ERROR) {
else if (get_current_printer_data()->state == PrinterState::PrinterStateError) {
// Error UI
create_button(LV_SYMBOL_WARNING, "Error", btn_click_err, NULL, root_panel);
}
@@ -208,7 +208,7 @@ void nav_buttons_setup(PANEL_TYPE active_panel){
break;
}
lv_msg_send(DATA_PRINTER_DATA, &printer);
lv_msg_send(DATA_PRINTER_DATA, get_current_printer());
}
void nav_style_setup(){

View File

@@ -5,9 +5,6 @@
#include "../core/data_setup.h"
#include "../conf/global_config.h"
#include "ota_setup.h"
#include "../core/macros_query.h"
#include "../core/files_query.h"
#include "gcode_img.h"
//const char *ota_url = "https://gist.githubusercontent.com/suchmememanyskill/ece418fe199e155340de6c224a0badf2/raw/0d6762d68bc807cbecc71e40d55b76692397a7b3/update.json"; // Test url
const char *ota_url = "https://suchmememanyskill.github.io/CYD-Klipper/OTA.json"; // Prod url
@@ -77,11 +74,6 @@ void ota_do_update(bool variant_automatic)
lv_timer_handler();
lv_task_handler();
macros_clear();
power_devices_clear();
clear_files();
clear_img_mem();
ota_pull.SetCallback(do_update_callback);
ota_pull.CheckForOTAUpdate(ota_url, REPO_VERSION, ESP32OTAPull::ActionType::UPDATE_AND_BOOT);
}

View File

@@ -4,6 +4,7 @@
#include <cstring>
#include "../../conf/global_config.h"
#include "../switch_printer.h"
#include "../../core/printer_integration.hpp"
namespace serial_console {
@@ -94,20 +95,20 @@ void sets(String argv[])
Serial.printf("erase ssid\n");
}
if(get_current_printer_config()->ip_configured)
if(get_current_printer()->printer_config->ip_configured)
{
Serial.printf("ip %s %d\n",get_current_printer_config()->klipper_host, get_current_printer_config()->klipper_port);
Serial.printf("ip %s %d\n",get_current_printer()->printer_config->klipper_host, get_current_printer()->printer_config->klipper_port);
}
else
{
Serial.printf("erase ip\n");
}
if(get_current_printer_config()->auth_configured)
if(get_current_printer()->printer_config->auth_configured)
{
Serial.printf("key %s\n",
#if DISPLAY_SECRETS
get_current_printer_config()->klipper_auth
get_current_printer()->printer_config->klipper_auth
#else
"[redacted]"
#endif
@@ -135,9 +136,9 @@ void sets(String argv[])
void settings(String argv[])
{
if(get_current_printer_config()->printer_name[0] != 0)
if(get_current_printer()->printer_config->printer_name[0] != 0)
{
Serial.printf("Current printer# %d name: %s",global_config.printer_index, get_current_printer_config()->printer_name);
Serial.printf("Current printer# %d name: %s",global_config.printer_index, get_current_printer()->printer_config->printer_name);
}
else
{
@@ -162,20 +163,20 @@ void settings(String argv[])
Serial.printf("Wifi not configured\n");
}
if(get_current_printer_config()->ip_configured)
if(get_current_printer()->printer_config->ip_configured)
{
Serial.printf("Moonraker address: %s:%d\n",get_current_printer_config()->klipper_host, get_current_printer_config()->klipper_port);
Serial.printf("Moonraker address: %s:%d\n",get_current_printer()->printer_config->klipper_host, get_current_printer()->printer_config->klipper_port);
}
else
{
Serial.printf("Moonraker address not configured\n");
}
if(get_current_printer_config()->auth_configured)
if(get_current_printer()->printer_config->auth_configured)
{
Serial.printf("Moonraker API key: %s\n",
#if DISPLAY_SECRETS
get_current_printer_config()->klipper_auth
get_current_printer()->printer_config->klipper_auth
#else
"[redacted]"
#endif
@@ -205,14 +206,14 @@ void erase_one(const String arg)
{
if(arg == "key")
{
get_current_printer_config()->auth_configured = false;
get_current_printer()->printer_config->auth_configured = false;
// overwrite the key to make it unrecoverable for 3rd parties
memset(get_current_printer_config()->klipper_auth,0,32);
memset(get_current_printer()->printer_config->klipper_auth,0,32);
write_global_config();
}
else if(arg == "ip")
{
get_current_printer_config()->ip_configured = false;
get_current_printer()->printer_config->ip_configured = false;
write_global_config();
}
else if(arg == "touch")
@@ -257,8 +258,8 @@ void key(String argv[])
return;
}
get_current_printer_config()->auth_configured = true;
strncpy(get_current_printer_config()->klipper_auth, argv[1].c_str(), sizeof(global_config.printer_config[0].klipper_auth));
get_current_printer()->printer_config->auth_configured = true;
strncpy(get_current_printer()->printer_config->klipper_auth, argv[1].c_str(), sizeof(global_config.printer_config[0].klipper_auth));
write_global_config();
}
@@ -282,9 +283,9 @@ void ssid(String argv[])
void ip(String argv[])
{
strncpy(get_current_printer_config()->klipper_host, argv[1].c_str(), sizeof(global_config.printer_config[0].klipper_host)-1);
get_current_printer_config()->klipper_port = argv[2].toInt();
get_current_printer_config()->ip_configured = true;
strncpy(get_current_printer()->printer_config->klipper_host, argv[1].c_str(), sizeof(global_config.printer_config[0].klipper_host)-1);
get_current_printer()->printer_config->klipper_port = argv[2].toInt();
get_current_printer()->printer_config->ip_configured = true;
write_global_config();
}

View File

@@ -2,7 +2,7 @@
#include "ui_utils.h"
#include "../core/data_setup.h"
#include "../core/lv_setup.h"
#include <ErriezCRC32.h>
#include "../core/printer_integration.hpp"
lv_obj_t* lv_create_empty_panel(lv_obj_t* root) {
lv_obj_t* panel = lv_obj_create(root);
@@ -234,7 +234,6 @@ void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, c
lv_create_custom_menu_entry(label_text, label, root_panel, false);
}
uint32_t message_hash = 0;
lv_timer_t* timer = NULL;
void on_timer_destroy(lv_event_t * e)
@@ -256,15 +255,6 @@ void lv_create_popup_message(const char* message, uint16_t timeout_ms)
return;
}
uint32_t new_hash = crc32String(message);
if (new_hash == message_hash)
{
return;
}
message_hash = new_hash;
lv_obj_t* panel = lv_obj_create(lv_scr_act());
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, LV_SIZE_CONTENT);
@@ -278,8 +268,6 @@ void lv_create_popup_message(const char* message, uint16_t timeout_ms)
lv_label_set_text_fmt(label, "%s", message);
lv_obj_set_size(label, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 6, LV_SIZE_CONTENT);
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
timer = lv_timer_create(timer_callback, timeout_ms, panel);
}
lv_obj_t * lv_label_btn_create(lv_obj_t * parent, lv_event_cb_t btn_callback, void* user_data)