mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 13:43:25 +00:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c46764c7c | ||
|
|
6ebaf68cf1 | ||
|
|
41aa073ae0 | ||
|
|
19cfaefd36 | ||
|
|
04d890227e | ||
|
|
e2c2a38b20 | ||
|
|
5d2571ef83 | ||
|
|
d4645f4fa1 | ||
|
|
4ac87c8ffc | ||
|
|
d780c8d55e | ||
|
|
d69446a11b | ||
|
|
90fd1b0ab2 | ||
|
|
4a96f7db0b | ||
|
|
c640d7fade | ||
|
|
d22a9e1ee4 | ||
|
|
98c7364ce7 | ||
|
|
7815a0fbf4 | ||
|
|
bd32fcb81e | ||
|
|
bc0502745d | ||
|
|
d75cbb65dc | ||
|
|
e004456ee9 | ||
|
|
ae34e91530 | ||
|
|
cbd40414c8 | ||
|
|
06691df094 | ||
|
|
9b551915d7 | ||
|
|
73be7c6c9f | ||
|
|
e06ea214c4 | ||
|
|
9e739de731 | ||
|
|
29dcb4717a | ||
|
|
356c78ee5f | ||
|
|
dce6f70ef9 | ||
|
|
2e3ac7b02c | ||
|
|
2e5a2dfbeb | ||
|
|
4a4fdb77d6 | ||
|
|
db448ae401 | ||
|
|
9a9134da4a | ||
|
|
86a999253f | ||
|
|
1238b7ee37 | ||
|
|
f110feee1e | ||
|
|
41d0b77d17 | ||
|
|
364f1ee49c | ||
|
|
ad68095124 | ||
|
|
38a1acb7b1 | ||
|
|
f5f970afce | ||
|
|
e4dd146a96 | ||
|
|
ea8a6b561f | ||
|
|
a9a732daa6 | ||
|
|
713e04bfa5 | ||
|
|
0f472ae78b | ||
|
|
400e2ae266 | ||
|
|
315e066e27 | ||
|
|
c7c6b26730 | ||
|
|
6cde9cb887 | ||
|
|
44e57995fb | ||
|
|
56301d3d72 | ||
|
|
ae3348d61e |
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
_site/out/
|
||||
_site/OTA.json
|
||||
_site/esp32-*.json
|
||||
|
||||
pyvenv.cfg
|
||||
bin/
|
||||
out/
|
||||
lib
|
||||
lib64
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"'-D ILI9341_DEV_CONFIG_COLOR_SPACE=ESP_LCD_COLOR_SPACE_BGR'",
|
||||
"'-D ILI9341_DEV_CONFIG_BITS_PER_PIXEL=16'",
|
||||
"'-D ILI9341_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH=false'",
|
||||
"'-D ILI9341_DEV_CONFIG_VENDOR_CONFIG=NULL'",
|
||||
"'-D ILI9341_DEV_CONFIG_VENDOR_CONFIG=\"(ili9341_vendor_config_t[]){{.init_cmds=(ili9341_lcd_init_cmd_t[]){{.cmd=0xCF,.data=(uint8_t[]){0x00,0xC1,0x30},.data_bytes=3},{.cmd=0xED,.data=(uint8_t[]){0x64,0x03,0x12,0x81},.data_bytes=4},{.cmd=0xE8,.data=(uint8_t[]){0x85,0x00,0x78},.data_bytes=3},{.cmd=0xCB,.data=(uint8_t[]){0x39,0x2C,0x00,0x34,0x02},.data_bytes=5},{.cmd=0xF7,.data=(uint8_t[]){0x20},.data_bytes=1},{.cmd=0xEA,.data=(uint8_t[]){0x00,0x00},.data_bytes=2},{.cmd=0xC0,.data=(uint8_t[]){0x10},.data_bytes=1},{.cmd=0xC1,.data=(uint8_t[]){0x00},.data_bytes=1},{.cmd=0xC5,.data=(uint8_t[]){0x30,0x30},.data_bytes=2,},{.cmd=0xC7,.data=(uint8_t[]){0xB7},.data_bytes=1},{.cmd=0x3A,.data=(uint8_t[]){0x55},.data_bytes=1},{.cmd=0x36,.data=(uint8_t[]){0x08},.data_bytes=1},{.cmd=0xB1,.data=(uint8_t[]){0x00,0x1A},.data_bytes=2},{.cmd=0xB6,.data=(uint8_t[]){0x08,0x82,0x27},.data_bytes=3},{.cmd=0xF2,.data=(uint8_t[]){0x00},.data_bytes=1},{.cmd=0x26,.data=(uint8_t[]){0x01},.data_bytes=1},{.cmd=0xE0,.data=(uint8_t[]){0x0F,0x2A,0x28,0x08,0x0E,0x08,0x54,0xA9,0x43,0x0A,0x0F,0x00,0x00,0x00,0x00},.data_bytes=15},{.cmd=0xE1,.data=(uint8_t[]){0x00,0x15,0x17,0x07,0x11,0x06,0x2B,0x56,0x3C,0x05,0x10,0x0F,0x3F,0x3F,0x0F},.data_bytes=15},{.cmd=0x2B,.data=(uint8_t[]){0x00,0x00,0x01,0x3F},.data_bytes=4},{.cmd=0x2A,.data=(uint8_t[]){0x00,0x00,0x00,0xEF},.data_bytes=4},{.cmd=0x21},{.cmd=0x11,.delay_ms=120},{.cmd=0x29,.delay_ms=1}},.init_cmds_size=23}}\"'",
|
||||
"'-D LCD_SWAP_XY=false'",
|
||||
"'-D LCD_MIRROR_X=true'",
|
||||
"'-D LCD_MIRROR_Y=false'",
|
||||
|
||||
146
CYD-Klipper/boards/esp32-4827S043R-smartdisplay.json
Normal file
146
CYD-Klipper/boards/esp32-4827S043R-smartdisplay.json
Normal file
@@ -0,0 +1,146 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "default_16MB.csv",
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"'-D ARDUINO_ESP32S3_DEV'",
|
||||
"'-D BOARD_HAS_PSRAM'",
|
||||
"'-D ARDUINO_USB_MODE=1'",
|
||||
"'-D ARDUINO_RUNNING_CORE=1'",
|
||||
"'-D ARDUINO_EVENT_RUNNING_CORE=1'",
|
||||
"'-D ARDUINO_USB_CDC_ON_BOOT=0'",
|
||||
"'-D ESP32_4827S043R'",
|
||||
"'-D LCD_WIDTH=480'",
|
||||
"'-D LCD_HEIGHT=272'",
|
||||
"'-D LVGL_BUFFER_PIXELS=(LCD_WIDTH*LCD_HEIGHT)'",
|
||||
"'-D LVGL_BUFFER_MALLOC_FLAGS=(MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT)'",
|
||||
"'-D GPIO_BCKL=2'",
|
||||
"'-D LCD_ST7262_PAR'",
|
||||
"'-D ST7262_PANEL_CONFIG_CLK_SRC=LCD_CLK_SRC_PLL160M'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_PCLK_HZ=(8*1000000)'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_H_RES=LCD_WIDTH'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_V_RES=LCD_HEIGHT'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_HSYNC_PULSE_WIDTH=4'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_HSYNC_BACK_PORCH=43'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_HSYNC_FRONT_PORCH=8'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_VSYNC_PULSE_WIDTH=4'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_VSYNC_BACK_PORCH=12'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_VSYNC_FRONT_PORCH=8'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_FLAGS_HSYNC_IDLE_LOW=true'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_FLAGS_VSYNC_IDLE_LOW=true'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_FLAGS_DE_IDLE_HIGH=false'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_FLAGS_PCLK_ACTIVE_NEG=true'",
|
||||
"'-D ST7262_PANEL_CONFIG_TIMINGS_FLAGS_PCLK_IDLE_HIGH=false'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_WIDTH=16'",
|
||||
"'-D ST7262_PANEL_CONFIG_SRAM_TRANS_ALIGN=4'",
|
||||
"'-D ST7262_PANEL_CONFIG_PSRAM_TRANS_ALIGN=64'",
|
||||
"'-D ST7262_PANEL_CONFIG_HSYNC_GPIO_NUM=39'",
|
||||
"'-D ST7262_PANEL_CONFIG_VSYNC_GPIO_NUM=41'",
|
||||
"'-D ST7262_PANEL_CONFIG_DE_GPIO_NUM=40'",
|
||||
"'-D ST7262_PANEL_CONFIG_PCLK_GPIO_NUM=42'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_R0=8'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_R1=3'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_R2=46'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_R3=9'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_R4=1'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G0=5'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G1=6'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G2=7'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G3=15'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G4=16'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_G5=4'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_B0=45'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_B1=48'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_B2=47'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_B3=21'",
|
||||
"'-D ST7262_PANEL_CONFIG_DATA_GPIO_B4=14'",
|
||||
"'-D ST7262_PANEL_CONFIG_DISP_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7262_PANEL_CONFIG_FLAGS_DISP_ACTIVE_LOW=false'",
|
||||
"'-D ST7262_PANEL_CONFIG_FLAGS_RELAX_ON_IDLE=false'",
|
||||
"'-D ST7262_PANEL_CONFIG_FLAGS_FB_IN_PSRAM=true'",
|
||||
"'-D BOARD_HAS_TOUCH'",
|
||||
"'-D TOUCH_XPT2046_SPI'",
|
||||
"'-D XPT2046_SPI_HOST=SPI2_HOST'",
|
||||
"'-D XPT2046_SPI_DMA_CHANNEL=SPI_DMA_CH_AUTO'",
|
||||
"'-D XPT2046_SPI_BUS_MOSI_IO_NUM=11'",
|
||||
"'-D XPT2046_SPI_BUS_MISO_IO_NUM=13'",
|
||||
"'-D XPT2046_SPI_BUS_SCLK_IO_NUM=12'",
|
||||
"'-D XPT2046_SPI_BUS_QUADWP_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D XPT2046_SPI_BUS_QUADHD_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D XPT2046_SPI_CONFIG_CS_GPIO_NUM=38'",
|
||||
"'-D XPT2046_SPI_CONFIG_DC_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D XPT2046_SPI_CONFIG_SPI_MODE=SPI_MODE0'",
|
||||
"'-D XPT2046_SPI_CONFIG_PCLK_HZ=2000000'",
|
||||
"'-D XPT2046_SPI_CONFIG_TRANS_QUEUE_DEPTH=3'",
|
||||
"'-D XPT2046_SPI_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D XPT2046_SPI_CONFIG_LCD_PARAM_BITS=8'",
|
||||
"'-D XPT2046_SPI_CONFIG_FLAGS_DC_AS_CMD_PHASE=false'",
|
||||
"'-D XPT2046_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA=false'",
|
||||
"'-D XPT2046_SPI_CONFIG_FLAGS_OCTAL_MODE=false'",
|
||||
"'-D XPT2046_SPI_CONFIG_FLAGS_LSB_FIRST=false'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_X_MAX=LCD_WIDTH'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_Y_MAX=LCD_HEIGHT'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_RST_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_INT_GPIO_NUM=18'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_LEVELS_RESET=0'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_LEVELS_INTERRUPT=0'",
|
||||
"'-D TOUCH_SWAP_XY=false'",
|
||||
"'-D TOUCH_SWAP_X=false'",
|
||||
"'-D TOUCH_SWAP_Y=false'",
|
||||
"'-D BOARD_HAS_TF'",
|
||||
"'-D TF_CS=10'",
|
||||
"'-D TF_SPI_MOSI=11'",
|
||||
"'-D TF_SPI_SCLK=12'",
|
||||
"'-D TF_SPI_MISO=13'",
|
||||
|
||||
"'-DCYD_SCREEN_HEIGHT_PX=272'",
|
||||
"'-DCYD_SCREEN_WIDTH_PX=480'",
|
||||
"-DROTATION_INVERTED=LV_DISP_ROT_180",
|
||||
"-DROTATION_NORMAL=LV_DISP_ROT_NONE",
|
||||
"'-DCYD_SCREEN_GAP_PX=10'",
|
||||
"'-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=35'",
|
||||
"'-DCYD_SCREEN_MIN_BUTTON_WIDTH_PX=40'",
|
||||
"'-DCYD_SCREEN_FONT=lv_font_montserrat_16'",
|
||||
"'-DCYD_SCREEN_FONT_SMALL=lv_font_montserrat_12'",
|
||||
"'-DCYD_SCREEN_SIDEBAR_SIZE_PX=50'",
|
||||
"'-DCYD_SCREEN_DRIVER_ESP32_SMARTDISPLAY=1'"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"hwids": [
|
||||
[
|
||||
"0x303A",
|
||||
"0x1001"
|
||||
]
|
||||
],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "esp32-4827S043R-SD",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"use_1200bps_touch": true,
|
||||
"wait_for_upload_port": true,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.aliexpress.com/item/1005004788147691.html",
|
||||
"vendor": "Sunton"
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
platform = https://github.com/platformio/platform-espressif32#v6.4.0
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
@@ -78,5 +78,9 @@ board = esp32-3248S035C-smartdisplay
|
||||
[env:esp32-4827S043C-SD]
|
||||
board = esp32-4827S043C-smartdisplay
|
||||
|
||||
[env:esp32-4827S043R-SD]
|
||||
board = esp32-4827S043C-smartdisplay
|
||||
|
||||
[env:esp32-8048S043C-SD]
|
||||
board = esp32-8048S043C-smartdisplay
|
||||
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
#include "lvgl.h"
|
||||
|
||||
GLOBAL_CONFIG global_config = {0};
|
||||
TEMPORARY_CONFIG temporary_config = {0};
|
||||
|
||||
COLOR_DEF color_defs[] = {
|
||||
{LV_PALETTE_BLUE, 0, LV_PALETTE_RED},
|
||||
{LV_PALETTE_GREEN, 0, LV_PALETTE_PURPLE},
|
||||
{LV_PALETTE_LIME, -2, LV_PALETTE_PURPLE},
|
||||
{LV_PALETTE_GREY, 0, LV_PALETTE_CYAN},
|
||||
{LV_PALETTE_YELLOW, -2, LV_PALETTE_PINK},
|
||||
{LV_PALETTE_ORANGE, -2, LV_PALETTE_BLUE},
|
||||
{LV_PALETTE_RED, 0, LV_PALETTE_GREEN},
|
||||
{LV_PALETTE_PURPLE, 0, LV_PALETTE_GREY},
|
||||
{LV_PALETTE_RED, 0, LV_PALETTE_BLUE},
|
||||
{LV_PALETTE_PURPLE, 0, LV_PALETTE_CYAN},
|
||||
};
|
||||
|
||||
void write_global_config()
|
||||
@@ -30,9 +32,9 @@ void verify_version()
|
||||
|
||||
GLOBAL_CONFIG config = {0};
|
||||
preferences.getBytes("global_config", &config, sizeof(config));
|
||||
Serial.printf("Config version: %d\n", config.version);
|
||||
LOG_F(("Config version: %d\n", config.version))
|
||||
if (config.version != CONFIG_VERSION) {
|
||||
Serial.println("Clearing Global Config");
|
||||
LOG_LN("Clearing Global Config");
|
||||
preferences.clear();
|
||||
}
|
||||
|
||||
@@ -85,11 +87,18 @@ void set_printer_config_index(int index)
|
||||
|
||||
new_config->color_scheme = old_config->color_scheme;
|
||||
|
||||
// TODO: Replace with memcpy
|
||||
for (int i = 0; i < 3; i++){
|
||||
new_config->hotend_presets[i] = old_config->hotend_presets[i];
|
||||
new_config->bed_presets[i] = old_config->bed_presets[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
new_config->printer_move_x_steps[i] = old_config->printer_move_x_steps[i];
|
||||
new_config->printer_move_y_steps[i] = old_config->printer_move_y_steps[i];
|
||||
new_config->printer_move_z_steps[i] = old_config->printer_move_z_steps[i];
|
||||
}
|
||||
|
||||
write_global_config();
|
||||
ESP.restart();
|
||||
}
|
||||
@@ -108,9 +117,26 @@ void load_global_config()
|
||||
global_config.printer_config[0].bed_presets[0] = 0;
|
||||
global_config.printer_config[0].bed_presets[1] = 60;
|
||||
global_config.printer_config[0].bed_presets[2] = 70;
|
||||
global_config.printer_config[0].printer_move_x_steps[0] = 10;
|
||||
global_config.printer_config[0].printer_move_x_steps[1] = 100;
|
||||
global_config.printer_config[0].printer_move_x_steps[2] = 1000;
|
||||
global_config.printer_config[0].printer_move_y_steps[0] = 10;
|
||||
global_config.printer_config[0].printer_move_y_steps[1] = 100;
|
||||
global_config.printer_config[0].printer_move_y_steps[2] = 1000;
|
||||
global_config.printer_config[0].printer_move_z_steps[0] = 1;
|
||||
global_config.printer_config[0].printer_move_z_steps[1] = 10;
|
||||
global_config.printer_config[0].printer_move_z_steps[2] = 100;
|
||||
|
||||
verify_version();
|
||||
Preferences preferences;
|
||||
preferences.begin("global_config", true);
|
||||
preferences.getBytes("global_config", &global_config, sizeof(global_config));
|
||||
preferences.end();
|
||||
|
||||
#if defined REPO_DEVELOPMENT && REPO_DEVELOPMENT == 1
|
||||
temporary_config.debug = true;
|
||||
#else
|
||||
temporary_config.debug = false;
|
||||
#endif
|
||||
temporary_config.remote_echo = true;
|
||||
}
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#define CONFIG_VERSION 5
|
||||
#define CONFIG_VERSION 6
|
||||
#define PRINTER_CONFIG_COUNT 8
|
||||
#define DISPLAY_SECRETS 0
|
||||
|
||||
enum {
|
||||
REMAINING_TIME_CALC_PERCENTAGE = 0,
|
||||
@@ -12,6 +13,13 @@ enum {
|
||||
REMAINING_TIME_CALC_SLICER = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
SHOW_STATS_ON_PROGRESS_PANEL_NONE = 0,
|
||||
SHOW_STATS_ON_PROGRESS_PANEL_LAYER = 1,
|
||||
SHOW_STATS_ON_PROGRESS_PANEL_PARTIAL = 2,
|
||||
SHOW_STATS_ON_PROGRESS_PANEL_ALL = 3,
|
||||
};
|
||||
|
||||
typedef struct _PRINTER_CONFIG {
|
||||
union {
|
||||
unsigned int raw;
|
||||
@@ -24,6 +32,9 @@ typedef struct _PRINTER_CONFIG {
|
||||
bool light_mode : 1;
|
||||
bool invert_colors : 1;
|
||||
unsigned char remaining_time_calc_mode : 2;
|
||||
unsigned char show_stats_on_progress_panel : 2;
|
||||
|
||||
bool custom_filament_move_macros : 1;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -36,6 +47,10 @@ typedef struct _PRINTER_CONFIG {
|
||||
|
||||
unsigned short hotend_presets[3];
|
||||
unsigned short bed_presets[3];
|
||||
|
||||
unsigned short printer_move_x_steps[3];
|
||||
unsigned short printer_move_y_steps[3];
|
||||
unsigned short printer_move_z_steps[3];
|
||||
} PRINTER_CONFIG;
|
||||
|
||||
typedef struct _GLOBAL_CONFIG {
|
||||
@@ -52,6 +67,9 @@ typedef struct _GLOBAL_CONFIG {
|
||||
bool auto_ota_update : 1;
|
||||
bool multi_printer_mode : 1;
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -62,14 +80,21 @@ typedef struct _GLOBAL_CONFIG {
|
||||
float screen_cal_y_offset;
|
||||
float screen_cal_y_mult;
|
||||
|
||||
char wifi_SSID[32];
|
||||
char wifi_password[64];
|
||||
char wifi_SSID[33];
|
||||
char wifi_password[65];
|
||||
|
||||
unsigned char brightness;
|
||||
unsigned char screen_timeout;
|
||||
unsigned char printer_index;
|
||||
} GLOBAL_CONFIG;
|
||||
|
||||
// Volatile/temporary config that doesn't survive a reset
|
||||
typedef struct _TEMPORARY_CONFIG {
|
||||
bool debug : 1;
|
||||
bool remote_echo : 1;
|
||||
} TEMPORARY_CONFIG;
|
||||
|
||||
|
||||
typedef struct _COLOR_DEF {
|
||||
lv_palette_t primary_color;
|
||||
short primary_color_light;
|
||||
@@ -77,8 +102,13 @@ typedef struct _COLOR_DEF {
|
||||
} COLOR_DEF;
|
||||
|
||||
extern GLOBAL_CONFIG global_config;
|
||||
extern TEMPORARY_CONFIG temporary_config;
|
||||
extern COLOR_DEF color_defs[];
|
||||
|
||||
#define LOG(x) if(temporary_config.debug){ Serial.print(x);}
|
||||
#define LOG_LN(x) if(temporary_config.debug){ Serial.println(x);}
|
||||
#define LOG_F(x) if(temporary_config.debug){ Serial.printf x ;} // use with double braces, LOF_F(("x=%d\n",x));
|
||||
|
||||
void write_global_config();
|
||||
void verify_version();
|
||||
void load_global_config();
|
||||
|
||||
@@ -10,17 +10,13 @@
|
||||
#include "../ui/ui_utils.h"
|
||||
#include "macros_query.h"
|
||||
|
||||
const char *printer_state_messages[] = {
|
||||
"Error",
|
||||
"Idle",
|
||||
"Printing"};
|
||||
|
||||
Printer printer = {0};
|
||||
PrinterMinimal *printer_minimal;
|
||||
int klipper_request_consecutive_fail_count = 0;
|
||||
int klipper_request_consecutive_fail_count = 999;
|
||||
char filename_buff[512] = {0};
|
||||
SemaphoreHandle_t freezeRenderThreadSemaphore, freezeRequestThreadSemaphore;
|
||||
const long data_update_interval = 780;
|
||||
unsigned char lock_absolute_relative_mode_swap = 0;
|
||||
|
||||
void semaphore_init(){
|
||||
freezeRenderThreadSemaphore = xSemaphoreCreateMutex();
|
||||
@@ -47,7 +43,7 @@ void unfreeze_render_thread(){
|
||||
|
||||
void send_gcode(bool wait, const char *gcode)
|
||||
{
|
||||
Serial.printf("Sending gcode: %s\n", gcode);
|
||||
LOG_F(("Sending gcode: %s\n", gcode))
|
||||
|
||||
SETUP_HTTP_CLIENT_FULL("/printer/gcode/script?script=" + urlEncode(gcode), false, wait ? 5000 : 750);
|
||||
try
|
||||
@@ -56,7 +52,7 @@ void send_gcode(bool wait, const char *gcode)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Serial.println("Failed to send gcode");
|
||||
LOG_LN("Failed to send gcode");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +73,7 @@ int get_slicer_time_estimate_s()
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
int time_estimate_s = doc["result"]["estimated_time"];
|
||||
Serial.printf("Got slicer time estimate: %ds\n", time_estimate_s);
|
||||
LOG_F(("Got slicer time estimate: %ds\n", time_estimate_s))
|
||||
return time_estimate_s;
|
||||
}
|
||||
|
||||
@@ -87,25 +83,29 @@ void move_printer(const char* axis, float amount, bool relative) {
|
||||
|
||||
char gcode[64];
|
||||
const char* extra = (amount > 0) ? "+" : "";
|
||||
const char* start = "";
|
||||
const char* end = "";
|
||||
|
||||
bool absolute_coords = printer.absolute_coords;
|
||||
|
||||
if (absolute_coords && relative) {
|
||||
send_gcode(true, "G91");
|
||||
start = "G91\n";
|
||||
}
|
||||
else if (!absolute_coords && !relative) {
|
||||
send_gcode(true, "G90");
|
||||
start = "G90\n";
|
||||
}
|
||||
|
||||
sprintf(gcode, "G1 %s%s%.3f F6000", axis, extra, amount);
|
||||
send_gcode(true, gcode);
|
||||
|
||||
if (absolute_coords && relative) {
|
||||
send_gcode(true, "G90");
|
||||
end = "\nG90";
|
||||
}
|
||||
else if (!absolute_coords && !relative) {
|
||||
send_gcode(true, "G91");
|
||||
end = "\nG91";
|
||||
}
|
||||
|
||||
sprintf(gcode, "%sG1 %s%s%.3f F6000%s", start, axis, extra, amount, end);
|
||||
send_gcode(true, gcode);
|
||||
|
||||
lock_absolute_relative_mode_swap = 2;
|
||||
}
|
||||
|
||||
int last_slicer_time_query = -15000;
|
||||
@@ -120,12 +120,19 @@ void fetch_printer_data()
|
||||
delay(10);
|
||||
if (httpCode == 200)
|
||||
{
|
||||
int printer_state = printer.state;
|
||||
|
||||
if (printer.state == PRINTER_STATE_OFFLINE)
|
||||
{
|
||||
printer.state = PRINTER_STATE_ERROR;
|
||||
}
|
||||
|
||||
klipper_request_consecutive_fail_count = 0;
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto status = doc["result"]["status"];
|
||||
bool emit_state_update = false;
|
||||
int printer_state = printer.state;
|
||||
|
||||
delay(10);
|
||||
unfreeze_request_thread();
|
||||
freeze_render_thread();
|
||||
@@ -190,7 +197,16 @@ void fetch_printer_data()
|
||||
printer.gcode_offset[1] = status["gcode_move"]["homing_origin"][1];
|
||||
printer.gcode_offset[2] = status["gcode_move"]["homing_origin"][2];
|
||||
bool absolute_coords = status["gcode_move"]["absolute_coordinates"];
|
||||
|
||||
if (lock_absolute_relative_mode_swap > 0)
|
||||
{
|
||||
lock_absolute_relative_mode_swap--;
|
||||
}
|
||||
else
|
||||
{
|
||||
printer.absolute_coords = absolute_coords == true;
|
||||
}
|
||||
|
||||
printer.speed_mult = status["gcode_move"]["speed_factor"];
|
||||
printer.extrude_mult = status["gcode_move"]["extrude_factor"];
|
||||
printer.feedrate_mm_per_s = status["gcode_move"]["speed"];
|
||||
@@ -210,9 +226,10 @@ void fetch_printer_data()
|
||||
if (status.containsKey("print_stats"))
|
||||
{
|
||||
const char *filename = status["print_stats"]["filename"];
|
||||
strcpy(filename_buff, filename);
|
||||
strcpy(filename_buff, filename == NULL ? "" : filename);
|
||||
printer.print_filename = filename_buff;
|
||||
printer.elapsed_time_s = status["print_stats"]["print_duration"];
|
||||
printer.elapsed_time_s = status["print_stats"]["total_duration"];
|
||||
printer.printed_time_s = status["print_stats"]["print_duration"];
|
||||
printer.filament_used_mm = status["print_stats"]["filament_used"];
|
||||
printer.total_layers = status["print_stats"]["info"]["total_layer"];
|
||||
printer.current_layer = status["print_stats"]["info"]["current_layer"];
|
||||
@@ -221,7 +238,7 @@ void fetch_printer_data()
|
||||
|
||||
if (state == nullptr)
|
||||
{
|
||||
printer_state = PRINTER_STATE_ERROR;
|
||||
// Continue
|
||||
}
|
||||
else if (strcmp(state, "printing") == 0)
|
||||
{
|
||||
@@ -239,18 +256,23 @@ void fetch_printer_data()
|
||||
|
||||
if (status.containsKey("display_status"))
|
||||
{
|
||||
printer.print_progress = status["display_status"]["progress"];
|
||||
const char* message = status["display_status"]["message"];
|
||||
|
||||
if (!global_config.disable_m117_messaging)
|
||||
{
|
||||
lv_create_popup_message(message, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0)
|
||||
{
|
||||
float remaining_time_s_percentage = (printer.elapsed_time_s / printer.print_progress) - printer.elapsed_time_s;
|
||||
float remaining_time_s_percentage = (printer.printed_time_s / printer.print_progress) - printer.printed_time_s;
|
||||
float remaining_time_s_slicer = 0;
|
||||
|
||||
if (printer.slicer_estimated_print_time_s > 0)
|
||||
{
|
||||
remaining_time_s_slicer = printer.slicer_estimated_print_time_s - printer.elapsed_time_s;
|
||||
remaining_time_s_slicer = printer.slicer_estimated_print_time_s - printer.printed_time_s;
|
||||
}
|
||||
|
||||
if (remaining_time_s_slicer <= 0 || config->remaining_time_calc_mode == REMAINING_TIME_CALC_PERCENTAGE)
|
||||
@@ -297,9 +319,18 @@ void fetch_printer_data()
|
||||
}
|
||||
else
|
||||
{
|
||||
klipper_request_consecutive_fail_count++;
|
||||
Serial.printf("Failed to fetch printer data: %d\n", httpCode);
|
||||
unfreeze_request_thread();
|
||||
klipper_request_consecutive_fail_count++;
|
||||
|
||||
if (klipper_request_consecutive_fail_count == 5)
|
||||
{
|
||||
freeze_render_thread();
|
||||
printer.state = PRINTER_STATE_OFFLINE;
|
||||
lv_msg_send(DATA_PRINTER_STATE, &printer);
|
||||
unfreeze_render_thread();
|
||||
}
|
||||
|
||||
LOG_F(("Failed to fetch printer data: %d\n", httpCode))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,21 +343,25 @@ void fetch_printer_data_minimal()
|
||||
|
||||
if (!config->ip_configured)
|
||||
{
|
||||
data[i].online = false;
|
||||
data[i].state = PRINTER_STATE_OFFLINE;
|
||||
continue;
|
||||
}
|
||||
|
||||
delay(10);
|
||||
HTTPClient client;
|
||||
configure_http_client(client, get_full_url("/printer/objects/query?webhooks&print_stats&virtual_sdcard", config), true, 1000);
|
||||
configure_http_client(client, get_full_url("/printer/objects/query?webhooks&print_stats&virtual_sdcard", config), true, 1000, config);
|
||||
freeze_request_thread();
|
||||
|
||||
int httpCode = client.GET();
|
||||
delay(10);
|
||||
if (httpCode == 200)
|
||||
{
|
||||
data[i].online = true;
|
||||
data[i].power_devices = 0;
|
||||
if (data[i].state == PRINTER_STATE_OFFLINE)
|
||||
{
|
||||
data[i].state = PRINTER_STATE_ERROR;
|
||||
}
|
||||
|
||||
data[i].power_devices = power_devices_count(config);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto status = doc["result"]["status"];
|
||||
@@ -379,7 +414,7 @@ void fetch_printer_data_minimal()
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i].online = false;
|
||||
data[i].state = PRINTER_STATE_OFFLINE;
|
||||
data[i].power_devices = power_devices_count(config);
|
||||
unfreeze_request_thread();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
enum {
|
||||
PRINTER_STATE_ERROR = 0,
|
||||
PRINTER_STATE_IDLE = 1,
|
||||
PRINTER_STATE_PRINTING = 2,
|
||||
PRINTER_STATE_PAUSED = 3,
|
||||
PRINTER_STATE_OFFLINE = 0,
|
||||
PRINTER_STATE_ERROR = 1,
|
||||
PRINTER_STATE_IDLE = 2,
|
||||
PRINTER_STATE_PRINTING = 3,
|
||||
PRINTER_STATE_PAUSED = 4,
|
||||
};
|
||||
|
||||
extern const char* printer_state_messages[];
|
||||
|
||||
typedef struct _Printer {
|
||||
unsigned char state;
|
||||
char* state_message;
|
||||
@@ -21,6 +20,7 @@ typedef struct _Printer {
|
||||
unsigned char homed_axis;
|
||||
unsigned char absolute_coords;
|
||||
float elapsed_time_s;
|
||||
float printed_time_s;
|
||||
float remaining_time_s;
|
||||
float filament_used_mm;
|
||||
char* print_filename;
|
||||
@@ -38,7 +38,6 @@ typedef struct _Printer {
|
||||
} Printer;
|
||||
|
||||
typedef struct _PrinterMinimal {
|
||||
bool online;
|
||||
unsigned char state;
|
||||
float print_progress; // 0 -> 1
|
||||
unsigned int power_devices;
|
||||
|
||||
@@ -80,6 +80,15 @@ void screen_setup()
|
||||
|
||||
tft.init();
|
||||
|
||||
if (global_config.display_mode) {
|
||||
// <3 https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/cyd.md#the-display-doesnt-look-as-good
|
||||
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
|
||||
tft.writedata(2);
|
||||
delay(120);
|
||||
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
|
||||
tft.writedata(1);
|
||||
}
|
||||
|
||||
ledcSetup(0, 5000, 12);
|
||||
ledcAttachPin(21, 0);
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
// Always has +1 entry with a null'd name
|
||||
FILESYSTEM_FILE* last_query = NULL;
|
||||
|
||||
FILESYSTEM_FILE* get_files(int limit){
|
||||
freeze_request_thread();
|
||||
|
||||
void clear_files()
|
||||
{
|
||||
if (last_query != NULL){
|
||||
FILESYSTEM_FILE* current = last_query;
|
||||
|
||||
@@ -21,9 +20,16 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
}
|
||||
|
||||
free(last_query);
|
||||
last_query = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Serial.printf("Heap space pre-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||
FILESYSTEM_FILE* get_files(int limit)
|
||||
{
|
||||
freeze_request_thread();
|
||||
clear_files();
|
||||
|
||||
LOG_F(("Heap space pre-file-parse: %d bytes\n", esp_get_free_heap_size()))
|
||||
std::list<FILESYSTEM_FILE> files;
|
||||
|
||||
auto timer_request = millis();
|
||||
@@ -35,7 +41,7 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
if (httpCode == 200){
|
||||
JsonDocument doc;
|
||||
auto parseResult = deserializeJson(doc, client.getStream());
|
||||
Serial.printf("Json parse: %s\n", parseResult.c_str());
|
||||
LOG_F(("Json parse: %s\n", parseResult.c_str()))
|
||||
auto result = doc["result"].as<JsonArray>();
|
||||
|
||||
for (auto file : result){
|
||||
@@ -56,7 +62,7 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
|
||||
f.name = (char*)malloc(strlen(path) + 1);
|
||||
if (f.name == NULL){
|
||||
Serial.println("Failed to allocate memory");
|
||||
LOG_LN("Failed to allocate memory");
|
||||
continue;
|
||||
}
|
||||
strcpy(f.name, path);
|
||||
@@ -82,7 +88,7 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
FILESYSTEM_FILE* result = (FILESYSTEM_FILE*)malloc(size);
|
||||
|
||||
if (result == NULL){
|
||||
Serial.println("Failed to allocate memory");
|
||||
LOG_LN("Failed to allocate memory");
|
||||
|
||||
for (auto file : files){
|
||||
free(file.name);
|
||||
@@ -100,8 +106,8 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
result += 1;
|
||||
}
|
||||
|
||||
Serial.printf("Heap space post-file-parse: %d bytes\n", esp_get_free_heap_size());
|
||||
Serial.printf("Got %d files. Request took %dms, parsing took %dms\n", files.size(), timer_parse - timer_request, millis() - timer_parse);
|
||||
LOG_F(("Heap space post-file-parse: %d bytes\n", esp_get_free_heap_size()))
|
||||
LOG_F(("Got %d files. Request took %dms, parsing took %dms\n", files.size(), timer_parse - timer_request, millis() - timer_parse))
|
||||
unfreeze_request_thread();
|
||||
return last_query;
|
||||
}
|
||||
@@ -20,3 +20,4 @@ typedef struct _FILESYSTEM_FILE {
|
||||
} FILESYSTEM_FILE;
|
||||
|
||||
FILESYSTEM_FILE* get_files(int limit);
|
||||
void clear_files();
|
||||
@@ -2,16 +2,19 @@
|
||||
|
||||
String get_full_url(String url_part, PRINTER_CONFIG * config)
|
||||
{
|
||||
if (config == NULL){
|
||||
config = get_current_printer_config();
|
||||
}
|
||||
|
||||
return "http://" + String(config->klipper_host) + ":" + String(config->klipper_port) + url_part;
|
||||
}
|
||||
|
||||
String get_full_url(String url_part)
|
||||
void configure_http_client(HTTPClient &client, String url, bool stream, int timeout, PRINTER_CONFIG * config)
|
||||
{
|
||||
return "http://" + String(get_current_printer_config()->klipper_host) + ":" + String(get_current_printer_config()->klipper_port) + url_part;
|
||||
if (config == NULL){
|
||||
config = get_current_printer_config();
|
||||
}
|
||||
|
||||
void configure_http_client(HTTPClient &client, String url, bool stream, int timeout)
|
||||
{
|
||||
if (stream){
|
||||
client.useHTTP10(true);
|
||||
}
|
||||
@@ -23,7 +26,7 @@ void configure_http_client(HTTPClient &client, String url, bool stream, int time
|
||||
|
||||
client.begin(url);
|
||||
|
||||
if (get_current_printer_config()->auth_configured) {
|
||||
client.addHeader("X-Api-Key", get_current_printer_config()->klipper_auth);
|
||||
if (config->auth_configured) {
|
||||
client.addHeader("X-Api-Key", config->klipper_auth);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,8 @@
|
||||
#include <HTTPClient.h>
|
||||
#include "../conf/global_config.h"
|
||||
|
||||
String get_full_url(String url_part);
|
||||
String get_full_url(String url_part, PRINTER_CONFIG * config);
|
||||
|
||||
void configure_http_client(HTTPClient &client, String url, bool stream = true, int timeout = 1000);
|
||||
String get_full_url(String url_part, PRINTER_CONFIG * config = NULL);
|
||||
void configure_http_client(HTTPClient &client, String url, bool stream = true, int timeout = 1000, PRINTER_CONFIG * config = NULL);
|
||||
|
||||
#define SETUP_HTTP_CLIENT(url_part) HTTPClient client; configure_http_client(client, get_full_url(url_part));
|
||||
|
||||
#define SETUP_HTTP_CLIENT_FULL(url_part, stream, timeout) HTTPClient client; configure_http_client(client, get_full_url(url_part), stream, timeout);
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "lvgl.h"
|
||||
#include "../ui/ui_utils.h"
|
||||
#include <Esp.h>
|
||||
#include "../ui/serial/serial_console.h"
|
||||
|
||||
#ifndef CPU_FREQ_HIGH
|
||||
#define CPU_FREQ_HIGH 240
|
||||
@@ -12,6 +13,27 @@
|
||||
#define CPU_FREQ_LOW 80
|
||||
#endif
|
||||
|
||||
unsigned long last_milis = 0;
|
||||
|
||||
void lv_handler()
|
||||
{
|
||||
#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
if (digitalRead(0) == HIGH)
|
||||
{
|
||||
last_milis = millis();
|
||||
}
|
||||
else if (millis() - last_milis > 8000)
|
||||
{
|
||||
global_config.screen_calibrated = false;
|
||||
write_global_config();
|
||||
ESP.restart();
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
}
|
||||
|
||||
typedef void (*lv_indev_drv_read_cb_t)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
|
||||
bool is_screen_in_sleep = false;
|
||||
@@ -95,8 +117,8 @@ void lv_do_calibration(){
|
||||
#endif
|
||||
|
||||
while (true){
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
lv_handler();
|
||||
serial_console::run();
|
||||
|
||||
if (point[0] != 0 && point[1] != 0){
|
||||
break;
|
||||
@@ -130,8 +152,7 @@ void lv_do_calibration(){
|
||||
#endif
|
||||
|
||||
while (true){
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
lv_handler();
|
||||
|
||||
if (point[0] != 0 && point[1] != 0){
|
||||
break;
|
||||
@@ -156,7 +177,7 @@ void lv_do_calibration(){
|
||||
global_config.screen_cal_y_offset = 10.0 - ((float)y1 * global_config.screen_cal_y_mult);
|
||||
|
||||
if (global_config.screen_cal_x_mult == std::numeric_limits<float>::infinity() || global_config.screen_cal_y_mult == std::numeric_limits<float>::infinity()){
|
||||
Serial.println("Calibration failed, please try again");
|
||||
LOG_LN("Calibration failed, please try again");
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
@@ -164,7 +185,7 @@ void lv_do_calibration(){
|
||||
write_global_config();
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
Serial.printf("Calibration done: X*%.2f + %.2f, Y*%.2f + %.2f\n", global_config.screen_cal_x_mult, global_config.screen_cal_x_offset, global_config.screen_cal_y_mult, global_config.screen_cal_y_offset);
|
||||
LOG_F(("Calibration done: X*%.2f + %.2f, Y*%.2f + %.2f\n", global_config.screen_cal_x_mult, global_config.screen_cal_x_offset, global_config.screen_cal_y_mult, global_config.screen_cal_y_offset))
|
||||
}
|
||||
|
||||
void set_screen_brightness()
|
||||
@@ -189,7 +210,7 @@ void screen_timer_wake()
|
||||
|
||||
// Reset cpu freq
|
||||
setCpuFrequencyMhz(CPU_FREQ_HIGH);
|
||||
Serial.printf("CPU Speed: %d MHz\n", ESP.getCpuFreqMHz());
|
||||
LOG_F(("CPU Speed: %d MHz\n", ESP.getCpuFreqMHz()))
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -201,7 +222,7 @@ void screen_timer_sleep(lv_timer_t *timer)
|
||||
|
||||
// Screen is off, no need to make the cpu run fast, the user won't notice ;)
|
||||
setCpuFrequencyMhz(CPU_FREQ_LOW);
|
||||
Serial.printf("CPU Speed: %d MHz\n", ESP.getCpuFreqMHz());
|
||||
LOG_F(("CPU Speed: %d MHz\n", ESP.getCpuFreqMHz()))
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -8,3 +8,4 @@ void screen_timer_stop();
|
||||
void set_color_scheme();
|
||||
void lv_setup();
|
||||
bool is_screen_asleep();
|
||||
void lv_handler();
|
||||
@@ -12,6 +12,15 @@ static char* power_devices[16] = {0};
|
||||
static bool power_device_states[16] = {0};
|
||||
static unsigned int stored_power_devices_count = 0;
|
||||
|
||||
void macros_clear()
|
||||
{
|
||||
for (int i = 0; i < macros_count; i++){
|
||||
free(macros[i]);
|
||||
}
|
||||
|
||||
macros_count = 0;
|
||||
}
|
||||
|
||||
MACROSQUERY macros_query(PRINTER_CONFIG * config)
|
||||
{
|
||||
HTTPClient client;
|
||||
@@ -24,11 +33,7 @@ MACROSQUERY macros_query(PRINTER_CONFIG * config)
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto result = doc["result"].as<JsonObject>();
|
||||
|
||||
for (int i = 0; i < macros_count; i++){
|
||||
free(macros[i]);
|
||||
}
|
||||
|
||||
macros_count = 0;
|
||||
macros_clear();
|
||||
|
||||
for (JsonPair i : result){
|
||||
const char *key = i.key().c_str();
|
||||
@@ -40,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 {
|
||||
@@ -85,6 +97,15 @@ unsigned int macro_count()
|
||||
return macro_count(get_current_printer_config());
|
||||
}
|
||||
|
||||
void power_devices_clear()
|
||||
{
|
||||
for (int i = 0; i < stored_power_devices_count; i++){
|
||||
free(power_devices[i]);
|
||||
}
|
||||
|
||||
stored_power_devices_count = 0;
|
||||
}
|
||||
|
||||
POWERQUERY power_devices_query(PRINTER_CONFIG * config)
|
||||
{
|
||||
HTTPClient client;
|
||||
@@ -97,11 +118,7 @@ POWERQUERY power_devices_query(PRINTER_CONFIG * config)
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto result = doc["result"]["devices"].as<JsonArray>();
|
||||
|
||||
for (int i = 0; i < stored_power_devices_count; i++){
|
||||
free(power_devices[i]);
|
||||
}
|
||||
|
||||
stored_power_devices_count = 0;
|
||||
power_devices_clear();
|
||||
|
||||
for (auto i : result){
|
||||
const char * device_name = i["device"];
|
||||
@@ -154,8 +171,6 @@ unsigned int power_devices_count()
|
||||
return power_devices_count(get_current_printer_config());
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool set_power_state(const char* device_name, bool state, PRINTER_CONFIG * config)
|
||||
{
|
||||
HTTPClient client;
|
||||
|
||||
@@ -23,3 +23,5 @@ unsigned int power_devices_count(PRINTER_CONFIG * config);
|
||||
unsigned int power_devices_count();
|
||||
bool set_power_state(const char* device_name, bool state, PRINTER_CONFIG * config);
|
||||
bool set_power_state(const char* device_name, bool state);
|
||||
void macros_clear();
|
||||
void power_devices_clear();
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
size_t bytes_written = Update.write(buff, bytes_read);
|
||||
if (bytes_read != bytes_written)
|
||||
{
|
||||
// Serial.printf("Unexpected error in OTA: %d %d %d\n", bytes_to_read, bytes_read, bytes_written);
|
||||
// LOG_F(("Unexpected error in OTA: %d %d %d\n", bytes_to_read, bytes_read, bytes_written))
|
||||
break;
|
||||
}
|
||||
offset += bytes_written;
|
||||
@@ -212,8 +212,8 @@ public:
|
||||
String CDevice = config["Device"].isNull() ? "" : (const char *)config["Device"];
|
||||
CVersion = config["Version"].isNull() ? "" : (const char *)config["Version"];
|
||||
String CConfig = config["Config"].isNull() ? "" : (const char *)config["Config"];
|
||||
//Serial.printf("Checking %s %s %s %s\n", CBoard.c_str(), CDevice.c_str(), CVersion.c_str(), CConfig.c_str());
|
||||
//Serial.printf("Against %s %s %s %s\n", BoardName.c_str(), DeviceName.c_str(), CurrentVersion, ConfigName.c_str());
|
||||
//LOG_F(("Checking %s %s %s %s\n", CBoard.c_str(), CDevice.c_str(), CVersion.c_str(), CConfig.c_str()))
|
||||
//LOG_F(("Against %s %s %s %s\n", BoardName.c_str(), DeviceName.c_str(), CurrentVersion, ConfigName.c_str()))
|
||||
if ((CBoard.isEmpty() || CBoard == BoardName) &&
|
||||
(CDevice.isEmpty() || CDevice == DeviceName) &&
|
||||
(CConfig.isEmpty() || CConfig == ConfigName))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "core/screen_driver.h"
|
||||
#include "ui/wifi_setup.h"
|
||||
#include "ui/ip_setup.h"
|
||||
#include "ui/serial/serial_console.h"
|
||||
#include "lvgl.h"
|
||||
#include "core/data_setup.h"
|
||||
#include "ui/main_ui.h"
|
||||
@@ -12,11 +13,11 @@
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Hello World");
|
||||
serial_console::greet();
|
||||
load_global_config();
|
||||
screen_setup();
|
||||
lv_setup();
|
||||
Serial.println("Screen init done");
|
||||
LOG_LN("Screen init done");
|
||||
|
||||
wifi_init();
|
||||
ota_init();
|
||||
@@ -29,10 +30,9 @@ void setup() {
|
||||
|
||||
void loop(){
|
||||
wifi_ok();
|
||||
ip_ok();
|
||||
data_loop();
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
lv_handler();
|
||||
serial_console::run();
|
||||
|
||||
if (is_ready_for_ota_update())
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
@@ -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");
|
||||
LOG_LN("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};
|
||||
LOG_LN("Exception while fetching gcode img location");
|
||||
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;
|
||||
|
||||
@@ -53,11 +52,15 @@ bool has_128_128_gcode(const char* filename)
|
||||
}
|
||||
|
||||
if (chosen_thumb != NULL){
|
||||
Serial.printf("Found 32x32 PNG gcode img at %s\n", filename);
|
||||
LOG_F(("Found 32x32 PNG gcode img at %s\n", filename))
|
||||
strcpy(img_filename_path, chosen_thumb);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_F(("Failed to fetch gcode image data: %d\n", httpCode))
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -67,18 +70,18 @@ lv_obj_t* draw_gcode_img()
|
||||
clear_img_mem();
|
||||
|
||||
if (img_filename_path[0] == 0){
|
||||
Serial.println("No gcode img path");
|
||||
LOG_LN("No gcode img path");
|
||||
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 {
|
||||
httpCode = client.GET();
|
||||
}
|
||||
catch (...){
|
||||
Serial.println("Exception while fetching gcode img");
|
||||
LOG_LN("Exception while fetching gcode img");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -87,13 +90,13 @@ lv_obj_t* draw_gcode_img()
|
||||
size_t len = client.getSize();
|
||||
if (len <= 0)
|
||||
{
|
||||
Serial.println("No gcode img data");
|
||||
LOG_LN("No gcode img data");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data_png = (unsigned char*)malloc(len + 1);
|
||||
if (len != client.getStream().readBytes(data_png, len)){
|
||||
Serial.println("Failed to read gcode img data");
|
||||
LOG_LN("Failed to read gcode img data");
|
||||
clear_img_mem();
|
||||
return NULL;
|
||||
}
|
||||
@@ -117,12 +120,12 @@ lv_obj_t* draw_gcode_img()
|
||||
lv_obj_t* show_gcode_img(const char* filename)
|
||||
{
|
||||
if (filename == NULL){
|
||||
Serial.println("No gcode filename");
|
||||
LOG_LN("No gcode filename");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!has_128_128_gcode(filename)){
|
||||
Serial.println("No 32x32 gcode img found");
|
||||
if (!has_32_32_gcode_img(filename)){
|
||||
LOG_LN("No 32x32 gcode img found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
@@ -9,13 +9,16 @@
|
||||
#include "../core/http_client.h"
|
||||
#include "switch_printer.h"
|
||||
#include "macros.h"
|
||||
#include "../core/lv_setup.h"
|
||||
#include "serial/serial_console.h"
|
||||
|
||||
bool connect_ok = false;
|
||||
int prev_power_device_count = 0;
|
||||
lv_obj_t * hostEntry;
|
||||
lv_obj_t * portEntry;
|
||||
lv_obj_t * label = NULL;
|
||||
|
||||
void show_ip_entry();
|
||||
void show_auth_entry();
|
||||
|
||||
/* Create a custom keyboard to allow hostnames or ip addresses (a-z, 0 - 9, and -) */
|
||||
static const char * kb_map[] = {
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", LV_SYMBOL_BACKSPACE, "\n",
|
||||
@@ -31,7 +34,19 @@ static const lv_btnmatrix_ctrl_t kb_ctrl[] = {
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, LV_KEYBOARD_CTRL_BTN_FLAGS | 6
|
||||
};
|
||||
|
||||
void ip_init_inner();
|
||||
static const char * hex_numpad_map[] = {
|
||||
"1", "2", "3", "f", LV_SYMBOL_BACKSPACE, "\n",
|
||||
"4", "5", "6", "e", LV_SYMBOL_OK, "\n",
|
||||
"7", "8", "9", "d", LV_SYMBOL_LEFT, "\n",
|
||||
"0", "a", "b", "c", LV_SYMBOL_RIGHT, NULL
|
||||
};
|
||||
|
||||
static const lv_btnmatrix_ctrl_t hex_numpad_ctrl[] = {
|
||||
1, 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 1,
|
||||
1, 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 1,
|
||||
1, 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 1,
|
||||
1, 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 1,
|
||||
};
|
||||
|
||||
enum connection_status_t {
|
||||
CONNECT_FAIL = 0,
|
||||
@@ -52,16 +67,30 @@ connection_status_t verify_ip(){
|
||||
return httpCode == 200 ? CONNECT_OK : CONNECT_FAIL;
|
||||
}
|
||||
catch (...) {
|
||||
Serial.println("Failed to connect");
|
||||
LOG_LN("Failed to connect");
|
||||
return CONNECT_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ta_event_cb(lv_event_t * e) {
|
||||
static void keyboard_event_ip_entry(lv_event_t * e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
lv_obj_t * kb = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
|
||||
if ((code == LV_EVENT_FOCUSED || code == LV_EVENT_DEFOCUSED) && ta != NULL)
|
||||
{
|
||||
// make sure we alter the keymap before taking actions that might
|
||||
// destroy the keyboard
|
||||
if (lv_obj_has_flag(ta, LV_OBJ_FLAG_USER_1))
|
||||
{
|
||||
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_USER_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
if(code == LV_EVENT_FOCUSED) {
|
||||
lv_keyboard_set_textarea(kb, ta);
|
||||
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -80,13 +109,10 @@ static void ta_event_cb(lv_event_t * e) {
|
||||
{
|
||||
get_current_printer_config()->ip_configured = true;
|
||||
write_global_config();
|
||||
connect_ok = true;
|
||||
}
|
||||
else if (status == CONNECT_AUTH_REQUIRED)
|
||||
{
|
||||
label = NULL;
|
||||
get_current_printer_config()->ip_configured = true;
|
||||
write_global_config();
|
||||
show_auth_entry();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,64 +123,7 @@ static void ta_event_cb(lv_event_t * e) {
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_obj_has_flag(ta, LV_OBJ_FLAG_USER_1))
|
||||
{
|
||||
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_USER_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_btn_event_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
get_current_printer_config()->ip_configured = false;
|
||||
ip_init_inner();
|
||||
}
|
||||
}
|
||||
|
||||
static void power_devices_button(lv_event_t * e) {
|
||||
macros_draw_power_fullscreen();
|
||||
}
|
||||
|
||||
void redraw_connect_screen(){
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Connecting to Klipper");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t * button_row = lv_create_empty_panel(lv_scr_act());
|
||||
lv_obj_set_size(button_row, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_layout_flex_row(button_row, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_align(button_row, LV_ALIGN_CENTER, 0, CYD_SCREEN_GAP_PX + CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * reset_btn = lv_btn_create(button_row);
|
||||
lv_obj_add_event_cb(reset_btn, reset_btn_event_handler, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_height(reset_btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * btn_label = lv_label_create(reset_btn);
|
||||
lv_label_set_text(btn_label, "Reset");
|
||||
lv_obj_center(btn_label);
|
||||
|
||||
if (prev_power_device_count >= 1){
|
||||
lv_obj_t * power_devices_btn = lv_btn_create(button_row);
|
||||
lv_obj_add_event_cb(power_devices_btn, power_devices_button, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_height(power_devices_btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
btn_label = lv_label_create(power_devices_btn);
|
||||
lv_label_set_text(btn_label, "Power Devices");
|
||||
lv_obj_center(btn_label);
|
||||
}
|
||||
|
||||
draw_switch_printer_button();
|
||||
}
|
||||
|
||||
static bool auth_entry_done = false;
|
||||
|
||||
static void keyboard_event_auth_entry(lv_event_t * e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
@@ -169,18 +138,26 @@ static void keyboard_event_auth_entry(lv_event_t * e) {
|
||||
{
|
||||
get_current_printer_config()->auth_configured = true;
|
||||
strcpy(get_current_printer_config()->klipper_auth, txt);
|
||||
|
||||
if (verify_ip() == CONNECT_OK)
|
||||
{
|
||||
get_current_printer_config()->ip_configured = true;
|
||||
write_global_config();
|
||||
auth_entry_done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(label, "Failed to connect");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (code == LV_EVENT_CANCEL)
|
||||
{
|
||||
auth_entry_done = true;
|
||||
show_ip_entry();
|
||||
}
|
||||
}
|
||||
|
||||
void handle_auth_entry(){
|
||||
auth_entry_done = false;
|
||||
void show_auth_entry()
|
||||
{
|
||||
get_current_printer_config()->klipper_auth[32] = 0;
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
@@ -194,7 +171,7 @@ void handle_auth_entry(){
|
||||
lv_obj_set_flex_grow(top_root, 1);
|
||||
lv_obj_set_style_pad_all(top_root, CYD_SCREEN_GAP_PX, 0);
|
||||
|
||||
lv_obj_t * label = lv_label_create(top_root);
|
||||
label = lv_label_create(top_root);
|
||||
lv_label_set_text(label, "Enter API Key");
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
|
||||
@@ -212,25 +189,13 @@ void handle_auth_entry(){
|
||||
lv_obj_add_event_cb(passEntry, keyboard_event_auth_entry, LV_EVENT_ALL, keyboard);
|
||||
lv_obj_set_flex_grow(passEntry, 1);
|
||||
|
||||
|
||||
lv_keyboard_set_textarea(keyboard, passEntry);
|
||||
lv_keyboard_set_map(keyboard, LV_KEYBOARD_MODE_USER_1, kb_map, kb_ctrl);
|
||||
lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_USER_1);
|
||||
|
||||
while (!auth_entry_done) {
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
}
|
||||
|
||||
redraw_connect_screen();
|
||||
}
|
||||
|
||||
void ip_init_inner(){
|
||||
if (get_current_printer_config()->ip_configured) {
|
||||
redraw_connect_screen();
|
||||
return;
|
||||
lv_keyboard_set_map(keyboard, LV_KEYBOARD_MODE_USER_2, hex_numpad_map, hex_numpad_ctrl);
|
||||
lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_USER_2);
|
||||
}
|
||||
|
||||
void show_ip_entry()
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t * root = lv_create_empty_panel(lv_scr_act());
|
||||
@@ -267,57 +232,28 @@ void ip_init_inner(){
|
||||
|
||||
lv_obj_t * keyboard = lv_keyboard_create(root);
|
||||
lv_keyboard_set_map(keyboard, LV_KEYBOARD_MODE_USER_1, kb_map, kb_ctrl);
|
||||
lv_obj_add_event_cb(hostEntry, ta_event_cb, LV_EVENT_ALL, keyboard);
|
||||
lv_obj_add_event_cb(portEntry, ta_event_cb, LV_EVENT_ALL, keyboard);
|
||||
lv_obj_add_event_cb(hostEntry, keyboard_event_ip_entry, LV_EVENT_ALL, keyboard);
|
||||
lv_obj_add_event_cb(portEntry, keyboard_event_ip_entry, LV_EVENT_ALL, keyboard);
|
||||
lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_USER_1);
|
||||
lv_keyboard_set_textarea(keyboard, hostEntry);
|
||||
}
|
||||
|
||||
long last_data_update_ip = -10000;
|
||||
const long data_update_interval_ip = 10000;
|
||||
int retry_count = 0;
|
||||
if (global_config.multi_printer_mode)
|
||||
{
|
||||
lv_obj_t * btn = draw_switch_printer_button();
|
||||
lv_obj_set_parent(btn, textbow_row);
|
||||
lv_obj_align(btn, LV_ALIGN_DEFAULT, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ip_init(){
|
||||
connect_ok = false;
|
||||
retry_count = 0;
|
||||
prev_power_device_count = 0;
|
||||
|
||||
ip_init_inner();
|
||||
|
||||
while (!connect_ok)
|
||||
if (!get_current_printer_config()->ip_configured)
|
||||
{
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
|
||||
if (!connect_ok && get_current_printer_config()->ip_configured && (millis() - last_data_update_ip) > data_update_interval_ip){
|
||||
connection_status_t status = verify_ip();
|
||||
|
||||
connect_ok = status == CONNECT_OK;
|
||||
last_data_update_ip = millis();
|
||||
retry_count++;
|
||||
if (label != NULL){
|
||||
String retry_count_text = "Connecting to Klipper (Try " + String(retry_count + 1) + ")";
|
||||
lv_label_set_text(label, retry_count_text.c_str());
|
||||
show_ip_entry();
|
||||
}
|
||||
|
||||
if (status == CONNECT_AUTH_REQUIRED)
|
||||
handle_auth_entry();
|
||||
|
||||
unsigned int power_device_count = power_devices_count();
|
||||
if (power_device_count != prev_power_device_count) {
|
||||
prev_power_device_count = power_device_count;
|
||||
redraw_connect_screen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ip_ok(){
|
||||
if (klipper_request_consecutive_fail_count > 5){
|
||||
freeze_request_thread();
|
||||
ip_init();
|
||||
unfreeze_request_thread();
|
||||
klipper_request_consecutive_fail_count = 0;
|
||||
lv_msg_send(DATA_PRINTER_STATE, &printer);
|
||||
while (!get_current_printer_config()->ip_configured)
|
||||
{
|
||||
lv_handler();
|
||||
serial_console::run();
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void ip_init();
|
||||
void ip_ok();
|
||||
@@ -8,7 +8,7 @@ PRINTER_CONFIG * curernt_config = NULL;
|
||||
static void btn_press(lv_event_t * e){
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
const char* macro = (const char*)lv_event_get_user_data(e);
|
||||
Serial.printf("Macro: %s\n", macro);
|
||||
LOG_F(("Macro: %s\n", macro))
|
||||
send_gcode(false, macro);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ static void power_device_toggle(lv_event_t * e)
|
||||
auto state = lv_obj_get_state(lv_event_get_target(e));
|
||||
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
|
||||
const char* power_device_name = (const char*)lv_event_get_user_data(e);
|
||||
Serial.printf("Power Device: %s, State: %d -> %d\n", power_device_name, !checked, checked);
|
||||
LOG_F(("Power Device: %s, State: %d -> %d\n", power_device_name, !checked, checked))
|
||||
|
||||
if (curernt_config != NULL)
|
||||
set_power_state(power_device_name, checked, curernt_config);
|
||||
|
||||
@@ -24,11 +24,17 @@ void check_if_screen_needs_to_be_disabled(){
|
||||
static void on_state_change(void * s, lv_msg_t * m){
|
||||
check_if_screen_needs_to_be_disabled();
|
||||
|
||||
if (printer.state == PRINTER_STATE_ERROR){
|
||||
if (printer.state == PRINTER_STATE_OFFLINE){
|
||||
nav_buttons_setup(PANEL_CONNECTING);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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){
|
||||
@@ -85,6 +89,10 @@ static void btn_click_err(lv_event_t * e){
|
||||
nav_buttons_setup(PANEL_ERROR);
|
||||
}
|
||||
|
||||
static void btn_click_conn(lv_event_t * e){
|
||||
nav_buttons_setup(PANEL_CONNECTING);
|
||||
}
|
||||
|
||||
void create_button(const char* icon, const char* name, lv_event_cb_t button_click, lv_event_cb_t label_update, lv_obj_t * root){
|
||||
lv_obj_t* btn = lv_btn_create(root);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
@@ -111,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);
|
||||
|
||||
@@ -128,9 +136,16 @@ void nav_buttons_setup(unsigned char active_panel){
|
||||
|
||||
#endif
|
||||
|
||||
if (printer.state != PRINTER_STATE_ERROR){
|
||||
if (printer.state > PRINTER_STATE_ERROR){
|
||||
// Files/Print
|
||||
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);
|
||||
@@ -138,10 +153,14 @@ void nav_buttons_setup(unsigned char active_panel){
|
||||
// Extrude/Temp
|
||||
create_button(LV_SYMBOL_WARNING, "?/?", btn_click_extrude, update_printer_data_temp, root_panel);
|
||||
}
|
||||
else {
|
||||
else if (printer.state == PRINTER_STATE_ERROR) {
|
||||
// Error UI
|
||||
create_button(LV_SYMBOL_WARNING, "Error", btn_click_err, NULL, root_panel);
|
||||
}
|
||||
else {
|
||||
// Connecting
|
||||
create_button(LV_SYMBOL_REFRESH, "Link", btn_click_conn, NULL, root_panel);
|
||||
}
|
||||
|
||||
// Macros
|
||||
create_button(LV_SYMBOL_GPS, "Macro", btn_click_macros, NULL, root_panel);
|
||||
@@ -157,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);
|
||||
@@ -181,6 +200,12 @@ void nav_buttons_setup(unsigned char active_panel){
|
||||
case PANEL_ERROR:
|
||||
error_panel_init(panel);
|
||||
break;
|
||||
case PANEL_CONNECTING:
|
||||
connecting_panel_init(panel);
|
||||
break;
|
||||
case PANEL_PROGRESS:
|
||||
progress_panel_init(panel);
|
||||
break;
|
||||
}
|
||||
|
||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||
|
||||
@@ -1,13 +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
|
||||
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();
|
||||
@@ -5,6 +5,9 @@
|
||||
#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
|
||||
@@ -46,7 +49,7 @@ void do_update_callback(int offset, int totallength)
|
||||
|
||||
void ota_do_update(bool variant_automatic)
|
||||
{
|
||||
Serial.println("Starting OTA Update");
|
||||
LOG_LN("Starting OTA Update");
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t *panel = lv_create_empty_panel(lv_scr_act());
|
||||
@@ -64,7 +67,7 @@ void ota_do_update(bool variant_automatic)
|
||||
lv_label_set_text(update_label, "0/0");
|
||||
|
||||
if (!variant_automatic) {
|
||||
Serial.println("Freezing Background Tasks");
|
||||
LOG_LN("Freezing Background Tasks");
|
||||
screen_timer_wake();
|
||||
screen_timer_stop();
|
||||
freeze_request_thread();
|
||||
@@ -74,6 +77,11 @@ 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);
|
||||
}
|
||||
@@ -82,7 +90,7 @@ void ota_init()
|
||||
{
|
||||
//ota_pull.AllowDowngrades(true);
|
||||
int result = ota_pull.CheckForOTAUpdate(ota_url, REPO_VERSION, ESP32OTAPull::ActionType::DONT_DO_UPDATE);
|
||||
Serial.printf("OTA Update Result: %d\n", result);
|
||||
LOG_F(("OTA Update Result: %d\n", result))
|
||||
update_available = result == ESP32OTAPull::UPDATE_AVAILABLE;
|
||||
|
||||
if (global_config.auto_ota_update && update_available)
|
||||
|
||||
9
CYD-Klipper/src/ui/panels/connecting_panel.cpp
Normal file
9
CYD-Klipper/src/ui/panels/connecting_panel.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "panel.h"
|
||||
#include "../../conf/global_config.h"
|
||||
|
||||
void connecting_panel_init(lv_obj_t* panel)
|
||||
{
|
||||
lv_obj_t* label = lv_label_create(panel);
|
||||
lv_label_set_text_fmt(label, "Connecting to %s...", (get_current_printer_config()->printer_name[0] == 0) ? get_current_printer_config()->klipper_host : get_current_printer_config()->printer_name);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
@@ -19,10 +19,14 @@ static void btn_print_file(lv_event_t * e){
|
||||
SETUP_HTTP_CLIENT("/printer/print/start?filename=" + urlEncode(selected_file->name));
|
||||
|
||||
int httpCode = client.POST("");
|
||||
Serial.printf("Print start: HTTP %d\n", httpCode);
|
||||
LOG_F(("Print start: HTTP %d\n", httpCode))
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -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);
|
||||
@@ -22,14 +22,8 @@ void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS " Screen Settings");
|
||||
lv_obj_center(label);
|
||||
|
||||
MACROSQUERY query = macros_query();
|
||||
MACROSQUERY macros = macros_query();
|
||||
POWERQUERY power = power_devices_query();
|
||||
if (query.count == 0 && power.count == 0){
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "No macros found.\nMacros with the description\n\"CYD_SCREEN_MACRO\"\nwill show up here.");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_t * root_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_set_scrollbar_mode(root_panel, LV_SCROLLBAR_MODE_OFF);
|
||||
@@ -38,5 +32,17 @@ void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_layout_flex_column(root_panel);
|
||||
|
||||
macros_add_power_devices_to_panel(root_panel, power);
|
||||
macros_add_macros_to_panel(root_panel, query);
|
||||
|
||||
if (macros.count == 0){
|
||||
label = lv_label_create(root_panel);
|
||||
lv_label_set_text(label, "No macros found.\nMacros with the description\n\"CYD_SCREEN_MACRO\"\nwill show up here.");
|
||||
|
||||
if (power.count == 0){
|
||||
lv_layout_flex_column(root_panel, LV_FLEX_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
macros_add_macros_to_panel(root_panel, macros);
|
||||
}
|
||||
@@ -4,47 +4,157 @@
|
||||
#include "../nav_buttons.h"
|
||||
#include "../ui_utils.h"
|
||||
#include <stdio.h>
|
||||
#include <Esp.h>
|
||||
|
||||
static bool last_homing_state = false;
|
||||
static bool move_edit_mode = false;
|
||||
|
||||
float x_offsets[6] = {0};
|
||||
float y_offsets[6] = {0};
|
||||
float z_offsets[6] = {0};
|
||||
|
||||
#define OFFSET_LABEL_SIZE 7
|
||||
|
||||
char x_offset_labels[6 * OFFSET_LABEL_SIZE] = {0};
|
||||
char y_offset_labels[6 * OFFSET_LABEL_SIZE] = {0};
|
||||
char z_offset_labels[6 * OFFSET_LABEL_SIZE] = {0};
|
||||
|
||||
static void calculate_offsets_from_current_printer()
|
||||
{
|
||||
unsigned short* items[] = {get_current_printer_config()->printer_move_x_steps, get_current_printer_config()->printer_move_y_steps, get_current_printer_config()->printer_move_z_steps};
|
||||
float* offsets[] = {(float*)x_offsets, (float*)y_offsets, (float*)z_offsets};
|
||||
char * labels[] = {(char*)x_offset_labels, (char*)y_offset_labels, (char*)z_offset_labels};
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
offsets[i][0] = items[i][2] / 10.0f * -1;
|
||||
offsets[i][1] = items[i][1] / 10.0f * -1;
|
||||
offsets[i][2] = items[i][0] / 10.0f * -1;
|
||||
offsets[i][3] = items[i][0] / 10.0f;
|
||||
offsets[i][4] = items[i][1] / 10.0f;
|
||||
offsets[i][5] = items[i][2] / 10.0f;
|
||||
|
||||
for (int j = 0; j < 6; j++) {
|
||||
const char * formats[] = {"%.0f", "%.1f", "+%.0f", "+%.1f"};
|
||||
const char ** format = formats;
|
||||
|
||||
if (offsets[i][j] != (int)offsets[i][j])
|
||||
{
|
||||
format += 1;
|
||||
}
|
||||
|
||||
if (j >= 3)
|
||||
{
|
||||
format += 2;
|
||||
}
|
||||
|
||||
sprintf(labels[i] + OFFSET_LABEL_SIZE * j, *format, offsets[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int selected_column = 0;
|
||||
static int selected_row = 0;
|
||||
|
||||
static void keyboard_cb_edit_move_increment(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
lv_obj_t * kb = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
const char * text = lv_textarea_get_text(ta);
|
||||
|
||||
float increment = atof(text);
|
||||
|
||||
if (increment < 0)
|
||||
{
|
||||
increment *= -1;
|
||||
}
|
||||
|
||||
if (increment == 0 || increment > 999)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned short* items[] = {get_current_printer_config()->printer_move_x_steps, get_current_printer_config()->printer_move_y_steps, get_current_printer_config()->printer_move_z_steps};
|
||||
LOG_F(("Setting increment %d %d %f\n", selected_column, selected_row, increment))
|
||||
items[selected_column][selected_row] = increment * 10;
|
||||
write_global_config();
|
||||
nav_buttons_setup(PANEL_MOVE);
|
||||
}
|
||||
|
||||
static void edit_move_increment(int column, float* idx)
|
||||
{
|
||||
float* offsets[] = {(float*)x_offsets, (float*)y_offsets, (float*)z_offsets};
|
||||
int row = idx - offsets[column];
|
||||
|
||||
if (row < 3)
|
||||
{
|
||||
selected_row = 2 - row;
|
||||
}
|
||||
else
|
||||
{
|
||||
selected_row = row - 3;
|
||||
}
|
||||
|
||||
selected_column = column;
|
||||
lv_create_keyboard_text_entry(keyboard_cb_edit_move_increment, "Set increment", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
}
|
||||
|
||||
static void x_line_button_press(lv_event_t * e) {
|
||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||
|
||||
if (move_edit_mode)
|
||||
{
|
||||
edit_move_increment(0, data_pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
float data = *data_pointer;
|
||||
move_printer("X", data, true);
|
||||
}
|
||||
|
||||
static void y_line_button_press(lv_event_t * e) {
|
||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||
|
||||
if (move_edit_mode)
|
||||
{
|
||||
edit_move_increment(1, data_pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
float data = *data_pointer;
|
||||
move_printer("Y", data, true);
|
||||
}
|
||||
|
||||
static void z_line_button_press(lv_event_t * e) {
|
||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||
|
||||
if (move_edit_mode)
|
||||
{
|
||||
edit_move_increment(2, data_pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
float data = *data_pointer;
|
||||
move_printer("Z", data, true);
|
||||
}
|
||||
|
||||
char x_pos_buff[12];
|
||||
|
||||
static void x_pos_update(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char x_pos_buff[12];
|
||||
sprintf(x_pos_buff, "X: %.1f", printer.position[0]);
|
||||
lv_label_set_text(label, x_pos_buff);
|
||||
}
|
||||
|
||||
char y_pos_buff[12];
|
||||
|
||||
static void y_pos_update(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char y_pos_buff[12];
|
||||
sprintf(y_pos_buff, "Y: %.1f", printer.position[1]);
|
||||
lv_label_set_text(label, y_pos_buff);
|
||||
}
|
||||
|
||||
char z_pos_buff[12];
|
||||
|
||||
static void z_pos_update(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char z_pos_buff[12];
|
||||
sprintf(z_pos_buff, "Z: %.2f", printer.position[2]);
|
||||
lv_label_set_text(label, z_pos_buff);
|
||||
}
|
||||
@@ -52,23 +162,6 @@ static void z_pos_update(lv_event_t * e){
|
||||
lv_event_cb_t button_callbacks[] = {x_line_button_press, y_line_button_press, z_line_button_press};
|
||||
lv_event_cb_t position_callbacks[] = {x_pos_update, y_pos_update, z_pos_update};
|
||||
|
||||
const float xy_offsets[] = {-100, -10, -1, 1, 10, 100};
|
||||
const float z_offsets[] = {-10, -1, -0.1, 0.1, 1, 10};
|
||||
const float* offsets[] = {
|
||||
xy_offsets,
|
||||
xy_offsets,
|
||||
z_offsets
|
||||
};
|
||||
|
||||
const char* xy_offset_labels[] = {"-100", "-10", "-1", "+1", "+10", "+100"};
|
||||
const char* z_offset_labels[] = {"-10", "-1", "-0.1", "+0.1", "+1", "+10"};
|
||||
|
||||
const char** offset_labels[] = {
|
||||
xy_offset_labels,
|
||||
xy_offset_labels,
|
||||
z_offset_labels
|
||||
};
|
||||
|
||||
static void home_button_click(lv_event_t * e) {
|
||||
if (printer.state == PRINTER_STATE_PRINTING)
|
||||
return;
|
||||
@@ -88,6 +181,51 @@ static void switch_to_stat_panel(lv_event_t * e) {
|
||||
nav_buttons_setup(PANEL_STATS);
|
||||
}
|
||||
|
||||
static void move_edit_toggle(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
move_edit_mode = lv_obj_get_state(btn) & LV_STATE_CHECKED;
|
||||
}
|
||||
|
||||
static void line_custom_set(const char * axis, const char *text)
|
||||
{
|
||||
float pos = atof(text);
|
||||
|
||||
if (pos < 0 || pos > 500)
|
||||
return;
|
||||
|
||||
move_printer(axis, pos, false);
|
||||
}
|
||||
|
||||
static void x_line_custom_callback(lv_event_t * e) {
|
||||
const char * text = lv_textarea_get_text(lv_event_get_target(e));
|
||||
line_custom_set("X", text);
|
||||
}
|
||||
|
||||
static void y_line_custom_callback(lv_event_t * e) {
|
||||
const char * text = lv_textarea_get_text(lv_event_get_target(e));
|
||||
line_custom_set("Y", text);
|
||||
}
|
||||
|
||||
static void z_line_custom_callback(lv_event_t * e) {
|
||||
const char * text = lv_textarea_get_text(lv_event_get_target(e));
|
||||
line_custom_set("Z", text);
|
||||
}
|
||||
|
||||
static void x_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(x_line_custom_callback, "Set X position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
}
|
||||
|
||||
static void y_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(y_line_custom_callback, "Set Y position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
}
|
||||
|
||||
static void z_line_custom(lv_event_t * e) {
|
||||
lv_create_keyboard_text_entry(z_line_custom_callback, "Set Z position", LV_KEYBOARD_MODE_NUMBER, CYD_SCREEN_PANEL_WIDTH_PX / 2, 6);
|
||||
}
|
||||
|
||||
lv_event_cb_t custom_callbacks[] = {x_line_custom, y_line_custom, z_line_custom};
|
||||
|
||||
inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
const auto width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2;
|
||||
|
||||
@@ -115,7 +253,7 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Unlock");
|
||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE "Free");
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(home_button_row);
|
||||
@@ -124,11 +262,29 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EDIT " Params");
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS "Param");
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(home_button_row);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(btn, move_edit_toggle, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_flag(btn, LV_OBJ_FLAG_CHECKABLE);
|
||||
|
||||
if (move_edit_mode)
|
||||
{
|
||||
lv_obj_add_state(btn, LV_STATE_CHECKED);
|
||||
}
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EDIT);
|
||||
lv_obj_center(label);
|
||||
|
||||
float* offsets[] = {(float*)x_offsets, (float*)y_offsets, (float*)z_offsets};
|
||||
char * labels[] = {(char*)x_offset_labels, (char*)y_offset_labels, (char*)z_offset_labels};
|
||||
|
||||
for (int row = 0; row < 3; row++) {
|
||||
label = lv_label_create(panel);
|
||||
label = lv_label_btn_create(panel, custom_callbacks[row]);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_set_width(label, width);
|
||||
lv_obj_add_event_cb(label, position_callbacks[row], LV_EVENT_MSG_RECEIVED, NULL);
|
||||
@@ -146,7 +302,7 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, offset_labels[row][col]);
|
||||
lv_label_set_text(label, labels[row] + OFFSET_LABEL_SIZE * col);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
@@ -156,19 +312,30 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
inline void root_panel_steppers_unlocked(lv_obj_t * root_panel){
|
||||
lv_obj_t * panel = lv_create_empty_panel(root_panel);
|
||||
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_PANEL_HEIGHT_PX);
|
||||
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_layout_flex_column(panel, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Steppers unlocked");
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(panel);
|
||||
lv_obj_t * btn_row = lv_create_empty_panel(panel);
|
||||
lv_obj_set_size(btn_row, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_layout_flex_row(btn_row, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(btn_row);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(btn, home_button_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_HOME "Home Axis");
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(btn_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);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS "Parameters");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
static void root_panel_state_update(lv_event_t * e){
|
||||
@@ -192,6 +359,7 @@ void move_panel_init(lv_obj_t* panel){
|
||||
return;
|
||||
}
|
||||
|
||||
calculate_offsets_from_current_printer();
|
||||
last_homing_state = !printer.homed_axis;
|
||||
|
||||
lv_obj_add_event_cb(panel, root_panel_state_update, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
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);
|
||||
void stats_panel_init(lv_obj_t* panel);
|
||||
void printer_panel_init(lv_obj_t* panel);
|
||||
void error_panel_init(lv_obj_t* panel);
|
||||
void connecting_panel_init(lv_obj_t* panel);
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../macros.h"
|
||||
|
||||
const char * printer_status[] = {
|
||||
"Offline",
|
||||
"Error",
|
||||
"Idle",
|
||||
"Printing",
|
||||
@@ -41,7 +42,7 @@ static void update_printer_status_text(lv_event_t * e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!printer->online)
|
||||
if (printer->state == PRINTER_STATE_OFFLINE)
|
||||
{
|
||||
lv_label_set_text(label, "Offline");
|
||||
return;
|
||||
@@ -50,6 +51,21 @@ static void update_printer_status_text(lv_event_t * e)
|
||||
lv_label_set_text(label, printer_status[printer->state]);
|
||||
}
|
||||
|
||||
static void update_printer_label_visible_active_printer(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
|
||||
|
||||
if (config == get_current_printer_config())
|
||||
{
|
||||
lv_label_set_text(label, LV_SYMBOL_WIFI);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(label, "");
|
||||
}
|
||||
}
|
||||
|
||||
static void update_printer_percentage_bar(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * percentage = lv_event_get_target(e);
|
||||
@@ -57,7 +73,7 @@ static void update_printer_percentage_bar(lv_event_t * e)
|
||||
int index = config - global_config.printer_config;
|
||||
PrinterMinimal * printer = &printer_minimal[index];
|
||||
|
||||
if (printer->online && (printer->state == PRINTER_STATE_PRINTING || printer->state == PRINTER_STATE_PAUSED)){
|
||||
if (printer->state != PRINTER_STATE_OFFLINE && (printer->state == PRINTER_STATE_PRINTING || printer->state == PRINTER_STATE_PAUSED)){
|
||||
lv_bar_set_value(percentage, printer->print_progress * 100, LV_ANIM_OFF);
|
||||
}
|
||||
else {
|
||||
@@ -72,7 +88,7 @@ static void update_printer_percentage_text(lv_event_t * e)
|
||||
int index = config - global_config.printer_config;
|
||||
PrinterMinimal * printer = &printer_minimal[index];
|
||||
|
||||
if (printer->online && (printer->state == PRINTER_STATE_PRINTING || printer->state == PRINTER_STATE_PAUSED))
|
||||
if (printer->state != PRINTER_STATE_OFFLINE && (printer->state == PRINTER_STATE_PRINTING || printer->state == PRINTER_STATE_PAUSED))
|
||||
{
|
||||
char percentage_buffer[12];
|
||||
sprintf(percentage_buffer, "%.2f%%", printer->print_progress * 100);
|
||||
@@ -91,7 +107,7 @@ static void update_printer_control_button_text(lv_event_t * e)
|
||||
int index = config - global_config.printer_config;
|
||||
PrinterMinimal * printer = &printer_minimal[index];
|
||||
|
||||
if (!printer->online && printer->power_devices > 0)
|
||||
if (printer->power_devices > 0 && (config == get_current_printer_config() || printer->state == PRINTER_STATE_OFFLINE))
|
||||
{
|
||||
lv_label_set_text(label, "Power");
|
||||
}
|
||||
@@ -101,20 +117,18 @@ static void update_printer_control_button_text(lv_event_t * e)
|
||||
}
|
||||
}
|
||||
|
||||
static void btn_enable_delete(lv_event_t * e)
|
||||
static void btn_set_secondary_button_text(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
|
||||
|
||||
if (config == get_current_printer_config())
|
||||
{
|
||||
// Disable
|
||||
lv_obj_add_state(btn, LV_STATE_DISABLED);
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable
|
||||
lv_obj_clear_state(btn, LV_STATE_DISABLED);
|
||||
lv_label_set_text(label, LV_SYMBOL_TRASH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +139,7 @@ static void btn_enable_control(lv_event_t * e)
|
||||
int index = config - global_config.printer_config;
|
||||
PrinterMinimal * printer = &printer_minimal[index];
|
||||
|
||||
if (config == get_current_printer_config() || (!printer->online && printer->power_devices <= 0))
|
||||
if ((config == get_current_printer_config() || printer->state == PRINTER_STATE_OFFLINE) && printer->power_devices <= 0)
|
||||
{
|
||||
// Disable
|
||||
lv_obj_add_state(btn, LV_STATE_DISABLED);
|
||||
@@ -150,13 +164,14 @@ static void keyboard_callback(lv_event_t * e){
|
||||
lv_msg_send(DATA_PRINTER_MINIMAL, NULL);
|
||||
}
|
||||
|
||||
static void btn_printer_delete(lv_event_t * e)
|
||||
static void btn_printer_secondary(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
|
||||
|
||||
if (config == get_current_printer_config())
|
||||
{
|
||||
nav_buttons_setup(PANEL_SETTINGS);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,11 +181,10 @@ static void btn_printer_delete(lv_event_t * e)
|
||||
nav_buttons_setup(PANEL_PRINTER);
|
||||
}
|
||||
|
||||
// TODO: Extract this from temp/print panel and combine
|
||||
static void btn_printer_rename(lv_event_t * e)
|
||||
{
|
||||
keyboard_config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
|
||||
lv_create_keyboard_text_entry(keyboard_callback, LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 24, keyboard_config->printer_name, false);
|
||||
lv_create_keyboard_text_entry(keyboard_callback, "Rename Printer", LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 24, keyboard_config->printer_name, false);
|
||||
}
|
||||
|
||||
static void btn_printer_activate(lv_event_t * e)
|
||||
@@ -180,7 +194,7 @@ static void btn_printer_activate(lv_event_t * e)
|
||||
int index = config - global_config.printer_config;
|
||||
PrinterMinimal * printer = &printer_minimal[index];
|
||||
|
||||
if (!printer->online)
|
||||
if (printer->power_devices > 0 && (config == get_current_printer_config() || printer->state == PRINTER_STATE_OFFLINE))
|
||||
{
|
||||
macros_draw_power_fullscreen(config);
|
||||
return;
|
||||
@@ -208,6 +222,10 @@ void create_printer_ui(PRINTER_CONFIG * config, lv_obj_t * root)
|
||||
lv_obj_add_event_cb(label, update_printer_name_text, LV_EVENT_MSG_RECEIVED, config);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_MINIMAL, label, config);
|
||||
|
||||
label = lv_label_create(data_row_name);
|
||||
lv_obj_add_event_cb(label, update_printer_label_visible_active_printer, LV_EVENT_MSG_RECEIVED, config);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_MINIMAL, label, config);
|
||||
|
||||
label = lv_label_create(data_row_name);
|
||||
lv_obj_add_event_cb(label, update_printer_status_text, LV_EVENT_MSG_RECEIVED, config);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_MINIMAL, label, config);
|
||||
@@ -232,13 +250,12 @@ void create_printer_ui(PRINTER_CONFIG * config, lv_obj_t * root)
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(button_row);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_add_event_cb(btn, btn_printer_delete, LV_EVENT_CLICKED, config);
|
||||
lv_obj_add_event_cb(btn, btn_enable_delete, LV_EVENT_MSG_RECEIVED, config);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_MINIMAL, btn, config);
|
||||
lv_obj_add_event_cb(btn, btn_printer_secondary, LV_EVENT_CLICKED, config);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_TRASH);
|
||||
lv_obj_center(label);
|
||||
lv_obj_add_event_cb(label, btn_set_secondary_button_text, LV_EVENT_MSG_RECEIVED, config);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_MINIMAL, label, config);
|
||||
|
||||
btn = lv_btn_create(button_row);
|
||||
lv_obj_set_flex_grow(btn, 2);
|
||||
|
||||
@@ -28,6 +28,28 @@ static void update_printer_data_remaining_time(lv_event_t * e){
|
||||
lv_label_set_text(label, time_display(printer.remaining_time_s));
|
||||
}
|
||||
|
||||
static void update_printer_data_stats(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char buff[256] = {0};
|
||||
|
||||
switch (get_current_printer_config()->show_stats_on_progress_panel)
|
||||
{
|
||||
case SHOW_STATS_ON_PROGRESS_PANEL_LAYER:
|
||||
sprintf(buff, "Layer %d of %d", printer.current_layer, printer.total_layers);
|
||||
break;
|
||||
case SHOW_STATS_ON_PROGRESS_PANEL_PARTIAL:
|
||||
sprintf(buff, "Position: X%.2f Y%.2f\nFeedrate: %d mm/s\nFilament Used: %.2f m\nLayer %d of %d",
|
||||
printer.position[0], printer.position[1], printer.feedrate_mm_per_s, printer.filament_used_mm / 1000, printer.current_layer, printer.total_layers);
|
||||
break;
|
||||
case SHOW_STATS_ON_PROGRESS_PANEL_ALL:
|
||||
sprintf(buff, "Pressure Advance: %.3f (%.2fs)\nPosition: X%.2f Y%.2f Z%.2f\nFeedrate: %d mm/s\nFilament Used: %.2f m\nFan: %.0f%%\nSpeed: %.0f%%\nFlow: %.0f%%\nLayer %d of %d",
|
||||
printer.pressure_advance, printer.smooth_time, printer.position[0], printer.position[1], printer.position[2], printer.feedrate_mm_per_s, printer.filament_used_mm / 1000, printer.fan_speed * 100, printer.speed_mult * 100, printer.extrude_mult * 100, printer.current_layer, printer.total_layers);
|
||||
break;
|
||||
}
|
||||
|
||||
lv_label_set_text(label, buff);
|
||||
}
|
||||
|
||||
static void update_printer_data_percentage(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char percentage_buffer[12];
|
||||
@@ -52,10 +74,28 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
const auto button_size_mult = 1.3f;
|
||||
|
||||
lv_obj_t * center_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_align(center_panel, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_size(center_panel, panel_width, LV_SIZE_CONTENT);
|
||||
lv_layout_flex_column(center_panel);
|
||||
|
||||
if (get_current_printer_config()->show_stats_on_progress_panel == SHOW_STATS_ON_PROGRESS_PANEL_ALL)
|
||||
{
|
||||
lv_obj_align(center_panel, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_GAP_PX);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_align(center_panel, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
if (get_current_printer_config()->show_stats_on_progress_panel == SHOW_STATS_ON_PROGRESS_PANEL_LAYER)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_GAP_PX);
|
||||
lv_obj_set_style_text_font(label, &CYD_SCREEN_FONT_SMALL, 0);
|
||||
lv_obj_add_event_cb(label, update_printer_data_stats, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_DATA, label, NULL);
|
||||
}
|
||||
|
||||
// Filename
|
||||
lv_obj_t * label = lv_label_create(center_panel);
|
||||
lv_label_set_text(label, printer.print_filename);
|
||||
@@ -124,4 +164,13 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
|
||||
lv_obj_align(btn, LV_ALIGN_BOTTOM_RIGHT, -2 * CYD_SCREEN_GAP_PX - CYD_SCREEN_MIN_BUTTON_WIDTH_PX * button_size_mult, -1 * CYD_SCREEN_GAP_PX);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * button_size_mult, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * button_size_mult);
|
||||
|
||||
if (get_current_printer_config()->show_stats_on_progress_panel >= SHOW_STATS_ON_PROGRESS_PANEL_PARTIAL)
|
||||
{
|
||||
label = lv_label_create(panel);
|
||||
lv_obj_align(label, LV_ALIGN_BOTTOM_LEFT, CYD_SCREEN_GAP_PX, -1 * CYD_SCREEN_GAP_PX);
|
||||
lv_obj_set_style_text_font(label, &CYD_SCREEN_FONT_SMALL, 0);
|
||||
lv_obj_add_event_cb(label, update_printer_data_stats, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_DATA, label, NULL);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ static void reset_calibration_click(lv_event_t * e){
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
static void reset_click(lv_event_t * e){
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
static void reset_wifi_click(lv_event_t * e){
|
||||
global_config.wifi_configured = false;
|
||||
write_global_config();
|
||||
@@ -48,6 +52,19 @@ static void light_mode_switch(lv_event_t * e){
|
||||
set_color_scheme();
|
||||
}
|
||||
|
||||
static void filament_move_mode_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);
|
||||
get_current_printer_config()->custom_filament_move_macros = checked;
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
static void show_stats_on_progress_panel_dropdown(lv_event_t * e){
|
||||
auto selected = lv_dropdown_get_selected(lv_event_get_target(e));
|
||||
get_current_printer_config()->show_stats_on_progress_panel = selected;
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
static void theme_dropdown(lv_event_t * e){
|
||||
lv_obj_t * dropdown = lv_event_get_target(e);
|
||||
auto selected = lv_dropdown_get_selected(dropdown);
|
||||
@@ -78,6 +95,28 @@ static void wake_timeout_dropdown(lv_event_t * e){
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
static void dualusb_screen_fix_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.display_mode = checked;
|
||||
write_global_config();
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
static void disable_m117_messaging_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.disable_m117_messaging = checked;
|
||||
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);
|
||||
@@ -122,46 +161,35 @@ static void estimated_time_dropdown(lv_event_t * e){
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
void settings_panel_init(lv_obj_t* panel){
|
||||
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_layout_flex_column(panel);
|
||||
lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF);
|
||||
#define PRINTER_SPECIFIC_SETTING global_config.multi_printer_mode ? "Stored per printer" : NULL
|
||||
|
||||
if (global_config.multi_printer_mode)
|
||||
void settings_section_theming(lv_obj_t* panel)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "Printer Specific Settings");
|
||||
}
|
||||
lv_label_set_text(label, "Theming");
|
||||
|
||||
lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer_config()->remaining_time_calc_mode);
|
||||
lv_create_custom_menu_dropdown("Theme", panel, theme_dropdown, "Blue\nGreen\nGrey\nYellow\nOrange\nRed\nPurple", get_current_printer_config()->color_scheme);
|
||||
lv_create_custom_menu_dropdown("Theme", panel, theme_dropdown, "Blue\nGreen\nLime\nGrey\nYellow\nOrange\nRed\nPurple", get_current_printer_config()->color_scheme, NULL, PRINTER_SPECIFIC_SETTING);
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
lv_create_custom_menu_switch("Invert Colors", panel, invert_color_switch, get_current_printer_config()->invert_colors);
|
||||
lv_create_custom_menu_switch("Invert Colors", panel, invert_color_switch, get_current_printer_config()->invert_colors, NULL, (global_config.multi_printer_mode) ? "Stored per printer"
|
||||
#ifdef CYD_SCREEN_DRIVER_ESP32_2432S028R
|
||||
"\nIntended for the 2.8\" dual USB model screen" : "Intended for the 2.8\" dual USB model screen"
|
||||
#else
|
||||
: NULL
|
||||
#endif
|
||||
);
|
||||
#endif // CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
|
||||
lv_create_custom_menu_switch("Light Mode", panel, light_mode_switch, get_current_printer_config()->light_mode);
|
||||
lv_create_custom_menu_button("Configure IP", panel, reset_ip_click, "Restart");
|
||||
lv_create_custom_menu_switch("Light Mode", panel, light_mode_switch, get_current_printer_config()->light_mode, NULL, PRINTER_SPECIFIC_SETTING);
|
||||
}
|
||||
|
||||
if (global_config.multi_printer_mode)
|
||||
void settings_section_behaviour(lv_obj_t* panel)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "\nGlobal Settings");
|
||||
}
|
||||
lv_label_set_text(label, "\nBehaviour");
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
lv_create_custom_menu_switch("Screen On During Print", panel, on_during_print_switch, global_config.on_during_print);
|
||||
#endif
|
||||
|
||||
int brightness_settings_index = 0;
|
||||
for (int i = 0; i < SIZEOF(brightness_options_values); i++){
|
||||
if (brightness_options_values[i] == global_config.brightness){
|
||||
brightness_settings_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_create_custom_menu_dropdown("Brightness", panel, brightness_dropdown, brightness_options, brightness_settings_index);
|
||||
lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer_config()->remaining_time_calc_mode, NULL, PRINTER_SPECIFIC_SETTING);
|
||||
lv_create_custom_menu_dropdown("Stats in Progress Screen", panel, show_stats_on_progress_panel_dropdown, "None\nLayers\nPartial\nAll", get_current_printer_config()->show_stats_on_progress_panel, NULL, PRINTER_SPECIFIC_SETTING);
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
int wake_timeout_settings_index = 0;
|
||||
@@ -175,8 +203,47 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
lv_create_custom_menu_dropdown("Wake Timeout", panel, wake_timeout_dropdown, wake_timeout_options, wake_timeout_settings_index);
|
||||
#endif
|
||||
|
||||
lv_create_custom_menu_switch("Rotate Screen", panel, rotate_screen_switch, global_config.rotate_screen);
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
lv_create_custom_menu_switch("Screen On During Print", panel, on_during_print_switch, global_config.on_during_print);
|
||||
#endif
|
||||
|
||||
lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode);
|
||||
lv_create_custom_menu_switch("Disable M117 Messaging", panel, disable_m117_messaging_switch, global_config.disable_m117_messaging);
|
||||
lv_create_custom_menu_button("Configure Printer IP", panel, reset_ip_click, "Restart");
|
||||
|
||||
lv_create_custom_menu_switch("Custom Filament Move Macros", panel, filament_move_mode_switch, get_current_printer_config()->custom_filament_move_macros, NULL,
|
||||
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)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "\nDevice");
|
||||
|
||||
int brightness_settings_index = 0;
|
||||
for (int i = 0; i < SIZEOF(brightness_options_values); i++){
|
||||
if (brightness_options_values[i] == global_config.brightness){
|
||||
brightness_settings_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_create_custom_menu_dropdown("Brightness", panel, brightness_dropdown, brightness_options, brightness_settings_index);
|
||||
|
||||
#ifdef CYD_SCREEN_DRIVER_ESP32_2432S028R
|
||||
lv_create_custom_menu_switch("Screen Color Fix", panel, dualusb_screen_fix_switch, global_config.display_mode, NULL, "ONLY for the 2.8\" dual USB model screen");
|
||||
#endif
|
||||
|
||||
#if defined(CYD_SCREEN_DRIVER_ESP32_SMARTDISPLAY) && !defined(CYD_SCREEN_DISABLE_TOUCH_CALIBRATION)
|
||||
// TODO: Rotating screen requires different calibration points.
|
||||
#else
|
||||
lv_create_custom_menu_switch("Rotate Screen", panel, rotate_screen_switch, global_config.rotate_screen);
|
||||
#endif
|
||||
|
||||
lv_create_custom_menu_switch("Auto Update", panel, auto_ota_update_switch, global_config.auto_ota_update);
|
||||
lv_create_custom_menu_label("Version", panel, REPO_VERSION " ");
|
||||
|
||||
@@ -199,4 +266,15 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
|
||||
lv_create_custom_menu_button("Configure WiFi", panel, reset_wifi_click, "Restart");
|
||||
lv_create_custom_menu_button("Restart ESP", panel, reset_click, "Restart");
|
||||
}
|
||||
|
||||
void settings_panel_init(lv_obj_t* panel){
|
||||
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_layout_flex_column(panel);
|
||||
lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF);
|
||||
|
||||
settings_section_theming(panel);
|
||||
settings_section_behaviour(panel);
|
||||
settings_section_device(panel);
|
||||
}
|
||||
@@ -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];
|
||||
@@ -249,6 +254,16 @@ void stats_panel_init(lv_obj_t* panel) {
|
||||
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);
|
||||
create_state_button(right_panel, set_speed_mult_text, open_speed_mult_panel);
|
||||
|
||||
@@ -18,7 +18,7 @@ enum temp_target{
|
||||
static temp_target keyboard_target;
|
||||
static char hotend_buff[40];
|
||||
static char bed_buff[40];
|
||||
static bool edit_mode = false;
|
||||
static bool temp_edit_mode = false;
|
||||
lv_obj_t* root_panel;
|
||||
|
||||
static void update_printer_data_hotend_temp(lv_event_t * e){
|
||||
@@ -117,12 +117,12 @@ static void keyboard_callback(lv_event_t * e){
|
||||
|
||||
static void show_keyboard_with_hotend(lv_event_t * e){
|
||||
keyboard_target = TARGET_HOTEND;
|
||||
lv_create_keyboard_text_entry(keyboard_callback);
|
||||
lv_create_keyboard_text_entry(keyboard_callback, "Set Hotend Temp");
|
||||
}
|
||||
|
||||
static void show_keyboard_with_bed(lv_event_t * e){
|
||||
keyboard_target = TARGET_BED;
|
||||
lv_create_keyboard_text_entry(keyboard_callback);
|
||||
lv_create_keyboard_text_entry(keyboard_callback, "Set Bed Temp");
|
||||
}
|
||||
|
||||
static void cooldown_temp(lv_event_t * e){
|
||||
@@ -139,17 +139,24 @@ static void btn_extrude(lv_event_t * e){
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_current_printer_config()->custom_filament_move_macros)
|
||||
{
|
||||
send_gcode(true, "FILAMENT_EXTRUDE");
|
||||
}
|
||||
else
|
||||
{
|
||||
send_gcode(true, "M83");
|
||||
send_gcode(true, "G1 E25 F300");
|
||||
}
|
||||
}
|
||||
|
||||
static void set_temp_via_preset(lv_event_t * e){
|
||||
int target = static_cast<int>(reinterpret_cast<intptr_t>(lv_event_get_user_data(e)));
|
||||
int value = get_temp_preset(target);
|
||||
|
||||
if (edit_mode) {
|
||||
if (temp_edit_mode) {
|
||||
keyboard_target = (temp_target)target;
|
||||
lv_create_keyboard_text_entry(keyboard_callback);
|
||||
lv_create_keyboard_text_entry(keyboard_callback, "Set Preset Temp");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,7 +172,7 @@ static void set_temp_via_preset(lv_event_t * e){
|
||||
static void btn_toggleable_edit(lv_event_t * e){
|
||||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
auto state = lv_obj_get_state(btn);
|
||||
edit_mode = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
|
||||
temp_edit_mode = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
|
||||
}
|
||||
|
||||
static void btn_retract(lv_event_t * e){
|
||||
@@ -173,9 +180,16 @@ static void btn_retract(lv_event_t * e){
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_current_printer_config()->custom_filament_move_macros)
|
||||
{
|
||||
send_gcode(true, "FILAMENT_RETRACT");
|
||||
}
|
||||
else
|
||||
{
|
||||
send_gcode(true, "M83");
|
||||
send_gcode(true, "G1 E-25 F300");
|
||||
}
|
||||
}
|
||||
|
||||
static void set_chart_range(lv_event_t * e) {
|
||||
lv_obj_t * chart_obj = lv_event_get_target(e);
|
||||
@@ -301,7 +315,7 @@ void create_temp_buttons(lv_obj_t * root, lv_obj_t * panel)
|
||||
void temp_panel_init(lv_obj_t * panel){
|
||||
const auto element_width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2;
|
||||
root_panel = panel;
|
||||
edit_mode = false;
|
||||
temp_edit_mode = false;
|
||||
|
||||
lv_obj_t * root_temp_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_set_size(root_temp_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_PANEL_HEIGHT_PX);
|
||||
|
||||
370
CYD-Klipper/src/ui/serial/serial_commands.cpp
Normal file
370
CYD-Klipper/src/ui/serial/serial_commands.cpp
Normal file
@@ -0,0 +1,370 @@
|
||||
#include "serial_commands.h"
|
||||
#include <HardwareSerial.h>
|
||||
#include <Esp.h>
|
||||
#include <cstring>
|
||||
#include "../../conf/global_config.h"
|
||||
#include "../switch_printer.h"
|
||||
|
||||
namespace serial_console {
|
||||
|
||||
/* How to add a new command:
|
||||
- add the handler; function signature must be like: void handler(String argv[])
|
||||
- add {"command_name", &handler_name, argc} to commandHandlers
|
||||
(argc = num of args + 1; argv[0] is always the command name)
|
||||
- add the handler signature to serial_command.h
|
||||
- add description to help()
|
||||
- optionally add handling the new preference to sets() and settings() if it modifies global_config
|
||||
*/
|
||||
|
||||
HANDLER commandHandlers[] = {
|
||||
{"help", &help, 1},
|
||||
{"reset", &reset, 1},
|
||||
{"settings", &settings, 1},
|
||||
{"sets", &sets, 1},
|
||||
{"erase", &erase, 2},
|
||||
{"key", &key, 2},
|
||||
{"touch", &touch, 5},
|
||||
{"ssid", &ssid, 3},
|
||||
{"ip", &ip, 3},
|
||||
{"rotation", &rotation, 2},
|
||||
{"brightness", &brightness, 2},
|
||||
{"printer", &printer, 2},
|
||||
{"debug", &debug, 2},
|
||||
{"echo", &echo, 2}
|
||||
};
|
||||
|
||||
void help(String argv[])
|
||||
{
|
||||
Serial.println("Serial console commands:");
|
||||
Serial.println("");
|
||||
Serial.println("settings - show current settings");
|
||||
Serial.println("sets - show current settings as commands for copy-paste");
|
||||
Serial.println("erase [item] - unconfigure parameter (key|touch|ssid|ip|all)");
|
||||
Serial.println("reset - restart CYD-klipper");
|
||||
Serial.println("touch [xm xo ym yo] - set touchscreen multipliers and offsets");
|
||||
Serial.println("ssid [name pass] - set the network SSID and password to connect to");
|
||||
Serial.println("ip [address port] - set Moonraker address");
|
||||
Serial.println("key [key] - set the Moonraker API key");
|
||||
Serial.println("rotation [on|off] - set rotate screen 180 degrees");
|
||||
Serial.println("brightness [num] - set screen brightness");
|
||||
Serial.println("printer [num|-1] - set active printer#; -1 for multi-printer mode off");
|
||||
Serial.println("debug [on|off] - set printing of debug messages to serial console (not saved)");
|
||||
Serial.println("echo [on|off] - set remote echo (eecchhoo ooffff) (not saved)");
|
||||
Serial.println("help - this help");
|
||||
Serial.println("");
|
||||
Serial.println("Settings are saved immediately but come into effect after reset");
|
||||
Serial.println("Unlike GUI, serial console does not validate if settings");
|
||||
Serial.println("you enter work correctly. This is a double-edged sword.");
|
||||
}
|
||||
|
||||
// this must be here, because serial_console doesn't have a clue about sizeof(commandHandlers) at compile time
|
||||
int find_command(String cmd)
|
||||
{
|
||||
for(int i=0; i < sizeof(commandHandlers) / sizeof(HANDLER); ++i)
|
||||
{
|
||||
if(cmd == commandHandlers[i].name) return i;
|
||||
}
|
||||
Serial.println("Unknown command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void reset(String argv[])
|
||||
{
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
void sets(String argv[])
|
||||
{
|
||||
|
||||
Serial.printf("printer %d\n", global_config.multi_printer_mode?global_config.printer_index:-1);
|
||||
|
||||
if(global_config.wifi_configured)
|
||||
{
|
||||
Serial.printf("ssid %s %s\n",global_config.wifi_SSID,
|
||||
#if DISPLAY_SECRETS
|
||||
global_config.wifi_password
|
||||
#else
|
||||
"[redacted]"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("erase ssid\n");
|
||||
}
|
||||
|
||||
if(get_current_printer_config()->ip_configured)
|
||||
{
|
||||
Serial.printf("ip %s %d\n",get_current_printer_config()->klipper_host, get_current_printer_config()->klipper_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("erase ip\n");
|
||||
}
|
||||
|
||||
if(get_current_printer_config()->auth_configured)
|
||||
{
|
||||
Serial.printf("key %s\n",
|
||||
#if DISPLAY_SECRETS
|
||||
get_current_printer_config()->klipper_auth
|
||||
#else
|
||||
"[redacted]"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("erase key\n");
|
||||
}
|
||||
|
||||
if(global_config.screen_calibrated)
|
||||
{
|
||||
Serial.printf("touch %f %f %f %f\n",
|
||||
global_config.screen_cal_x_mult, global_config.screen_cal_x_offset, global_config.screen_cal_y_mult, global_config.screen_cal_y_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("erase touch\n");
|
||||
}
|
||||
|
||||
Serial.printf("rotation %s\n",global_config.rotate_screen?"on":"off");
|
||||
Serial.printf("brightness %d\n",global_config.brightness);
|
||||
}
|
||||
|
||||
void settings(String argv[])
|
||||
{
|
||||
|
||||
if(get_current_printer_config()->printer_name[0] != 0)
|
||||
{
|
||||
Serial.printf("Current printer# %d name: %s",global_config.printer_index, get_current_printer_config()->printer_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Current printer# %d",global_config.printer_index);
|
||||
}
|
||||
Serial.printf(" Multi-printer mode %s\n",global_config.multi_printer_mode?"enabled":"disabled");
|
||||
|
||||
|
||||
if(global_config.wifi_configured)
|
||||
{
|
||||
Serial.printf("SSID: %s Password: %s\n",global_config.wifi_SSID,
|
||||
#if DISPLAY_SECRETS
|
||||
global_config.wifi_password
|
||||
#else
|
||||
"[redacted]"
|
||||
#endif
|
||||
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Wifi not configured\n");
|
||||
}
|
||||
|
||||
if(get_current_printer_config()->ip_configured)
|
||||
{
|
||||
Serial.printf("Moonraker address: %s:%d\n",get_current_printer_config()->klipper_host, get_current_printer_config()->klipper_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Moonraker address not configured\n");
|
||||
}
|
||||
|
||||
if(get_current_printer_config()->auth_configured)
|
||||
{
|
||||
Serial.printf("Moonraker API key: %s\n",
|
||||
#if DISPLAY_SECRETS
|
||||
get_current_printer_config()->klipper_auth
|
||||
#else
|
||||
"[redacted]"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Moonraker API key not configured\n");
|
||||
}
|
||||
|
||||
if(global_config.screen_calibrated)
|
||||
{
|
||||
Serial.printf("Screen coefficients: x_screen = %f * x_touch + %f; y_screen = %f * y_touch + %f\n",
|
||||
global_config.screen_cal_x_mult, global_config.screen_cal_x_offset, global_config.screen_cal_y_mult, global_config.screen_cal_y_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("Screen not calibrated\n");
|
||||
}
|
||||
|
||||
Serial.printf("Screen orientation: %s\n",global_config.rotate_screen?"rotated":"normal");
|
||||
Serial.printf("Screen brightness: %d\n",global_config.brightness);
|
||||
}
|
||||
|
||||
|
||||
void erase_one(const String arg)
|
||||
{
|
||||
if(arg == "key")
|
||||
{
|
||||
get_current_printer_config()->auth_configured = false;
|
||||
// overwrite the key to make it unrecoverable for 3rd parties
|
||||
memset(get_current_printer_config()->klipper_auth,0,32);
|
||||
write_global_config();
|
||||
}
|
||||
else if(arg == "ip")
|
||||
{
|
||||
get_current_printer_config()->ip_configured = false;
|
||||
write_global_config();
|
||||
}
|
||||
else if(arg == "touch")
|
||||
{
|
||||
global_config.screen_calibrated = false;
|
||||
write_global_config();
|
||||
}
|
||||
else if(arg == "ssid")
|
||||
{
|
||||
global_config.wifi_configured = false;
|
||||
// overwrite the pass to make it unrecoverable for 3rd parties
|
||||
memset(global_config.wifi_password,0,64);
|
||||
write_global_config();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Unknown key");
|
||||
}
|
||||
}
|
||||
|
||||
void erase(String argv[])
|
||||
{
|
||||
const String& arg=argv[1];
|
||||
if(arg != "all")
|
||||
{
|
||||
erase_one(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
erase_one("key");
|
||||
erase_one("ip");
|
||||
erase_one("touch");
|
||||
erase_one("ssid");
|
||||
}
|
||||
}
|
||||
|
||||
void key(String argv[])
|
||||
{
|
||||
if (argv[1].length() != 32)
|
||||
{
|
||||
Serial.println("Key must be 32 characters");
|
||||
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));
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
void touch(String argv[])
|
||||
{
|
||||
global_config.screen_cal_x_mult = argv[1].toFloat();
|
||||
global_config.screen_cal_x_offset = argv[2].toFloat();
|
||||
global_config.screen_cal_y_mult = argv[3].toFloat();
|
||||
global_config.screen_cal_y_offset = argv[4].toFloat();
|
||||
global_config.screen_calibrated = true;
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
void ssid(String argv[])
|
||||
{
|
||||
strncpy(global_config.wifi_SSID, argv[1].c_str(), sizeof(global_config.wifi_SSID)-1);
|
||||
strncpy(global_config.wifi_password, argv[2].c_str(), sizeof(global_config.wifi_password)-1);
|
||||
global_config.wifi_configured = true;
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
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;
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
void rotation(String argv[])
|
||||
{
|
||||
if(argv[1] == "on")
|
||||
{
|
||||
global_config.rotate_screen = true;
|
||||
write_global_config();
|
||||
}
|
||||
else if (argv[1] == "off")
|
||||
{
|
||||
global_config.rotate_screen = false;
|
||||
write_global_config();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Rotation can be on or off");
|
||||
}
|
||||
}
|
||||
|
||||
void brightness(String argv[])
|
||||
{
|
||||
global_config.brightness = argv[1].toInt();
|
||||
write_global_config();
|
||||
}
|
||||
|
||||
|
||||
void printer(String argv[])
|
||||
{
|
||||
int ndx = argv[1].toInt();
|
||||
if(ndx == -1)
|
||||
{
|
||||
global_config.multi_printer_mode = false;
|
||||
switch_printer(0);
|
||||
}
|
||||
else if( ndx >=0 && ndx < PRINTER_CONFIG_COUNT)
|
||||
{
|
||||
global_config.multi_printer_mode = true;
|
||||
switch_printer(ndx);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Printer index out of range");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void debug(String argv[])
|
||||
{
|
||||
if(argv[1] == "on")
|
||||
{
|
||||
temporary_config.debug = true;
|
||||
|
||||
}
|
||||
else if (argv[1] == "off")
|
||||
{
|
||||
temporary_config.debug = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("debug can be on or off");
|
||||
}
|
||||
}
|
||||
|
||||
void echo(String argv[])
|
||||
{
|
||||
if(argv[1] == "on")
|
||||
{
|
||||
temporary_config.remote_echo = true;
|
||||
}
|
||||
else if (argv[1] == "off")
|
||||
{
|
||||
temporary_config.remote_echo = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Echo can be on or off");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
CYD-Klipper/src/ui/serial/serial_commands.h
Normal file
29
CYD-Klipper/src/ui/serial/serial_commands.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <WString.h>
|
||||
|
||||
namespace serial_console {
|
||||
|
||||
typedef struct _HANDLER {
|
||||
const char* name;
|
||||
void (* function)(String argv[]);
|
||||
int argc;
|
||||
} HANDLER;
|
||||
|
||||
extern HANDLER commandHandlers[];
|
||||
|
||||
void help(String argv[]);
|
||||
void reset(String argv[]);
|
||||
void settings(String argv[]);
|
||||
void sets(String argv[]);
|
||||
void erase(String argv[]);
|
||||
void key(String argv[]);
|
||||
void touch(String argv[]);
|
||||
void ssid(String argv[]);
|
||||
void ip(String argv[]);
|
||||
void rotation(String argv[]);
|
||||
void brightness(String argv[]);
|
||||
void printer(String argv[]);
|
||||
void debug(String argv[]);
|
||||
void echo(String argv[]);
|
||||
|
||||
int find_command(String cmd);
|
||||
}
|
||||
153
CYD-Klipper/src/ui/serial/serial_console.cpp
Normal file
153
CYD-Klipper/src/ui/serial/serial_console.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include "serial_commands.h"
|
||||
#include "../../conf/global_config.h"
|
||||
#include <HardwareSerial.h>
|
||||
#include <WString.h>
|
||||
|
||||
#define MAX_COMDLINE_SIZE 80
|
||||
#define MAX_WORDS 6
|
||||
|
||||
namespace serial_console
|
||||
{
|
||||
|
||||
/*
|
||||
* read_string_until: Non-blocking replacement for Serial.readStringUntil()..
|
||||
* With delimeter '\n' acts as 'read line'.
|
||||
* If input (line) size exceeds provided buffer's size, that entire input (until next delimeter) is silently discarded.
|
||||
* Serial.available() can return true without \n being ever in the buffer, so we don't trust it here.
|
||||
*/
|
||||
|
||||
bool read_string_until(char delimiter, char *result, int max_len)
|
||||
{
|
||||
static int index = 0;
|
||||
int c; // read character, -1 if none
|
||||
int cnt = 100; // limit on amount of iterations in one go; we're supposed to be non-blocking!
|
||||
|
||||
while ((c = Serial.read()) != -1 && cnt > 0)
|
||||
{
|
||||
--cnt;
|
||||
|
||||
// backspace
|
||||
if (c == 8)
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
if(temporary_config.remote_echo) Serial.print("\x08 \x08"); // overwrite last character with space and move cursor 1 back.
|
||||
index--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(temporary_config.remote_echo) Serial.print((char)c); // echo
|
||||
|
||||
// Buffer overflow handling:
|
||||
// start treating current buffer as invalid:
|
||||
// - stop collecting more data
|
||||
// - return false on delimeter, flushing everything collected,
|
||||
// - restart collection from scratch after delimeter,
|
||||
// - return control as normal.
|
||||
|
||||
if (index >= max_len - 1)
|
||||
{
|
||||
if (c == delimiter) // got delimeter: flush buffer quietly, restart collection.
|
||||
{
|
||||
index = 0;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
continue; // discard any data past the end of the buffer, keep reading
|
||||
}
|
||||
|
||||
result[index++] = c;
|
||||
|
||||
// delimiter was found
|
||||
if (c == delimiter)
|
||||
{
|
||||
result[index] = '\0'; // Null-terminate the string
|
||||
index = 0;
|
||||
return true; // Success: Delimiter found
|
||||
}
|
||||
}
|
||||
|
||||
return false; // still waiting for delimeter
|
||||
}
|
||||
|
||||
// split input into words.
|
||||
// assumes input ends with '\n', also ends parsing if found MAX_WORDS already.
|
||||
int tokenize(String results[], char *input)
|
||||
{
|
||||
int index = 0;
|
||||
int word_count = 0;
|
||||
String word = "";
|
||||
do
|
||||
{
|
||||
if (input[index] == '\t' || input[index] == ' ' || input[index] == '\n' || input[index] == '\r' || input[index] == '\0')
|
||||
{
|
||||
if (word.length() > 0)
|
||||
{
|
||||
results[word_count] = word;
|
||||
++word_count;
|
||||
if (word_count >= MAX_WORDS)
|
||||
{
|
||||
return word_count;
|
||||
}
|
||||
word = "";
|
||||
}
|
||||
|
||||
if (input[index] == '\n' || input[index] == '\0')
|
||||
{
|
||||
return word_count;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
word += input[index];
|
||||
index++;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
void greet()
|
||||
{
|
||||
Serial.println("CYD-Klipper " REPO_VERSION);
|
||||
Serial.println("Type 'help' for serial console command list");
|
||||
Serial.print("> ");
|
||||
}
|
||||
|
||||
bool verify_arg_count(int got, int expected)
|
||||
{
|
||||
if (got != expected)
|
||||
{
|
||||
Serial.printf("Command expects %d argument%s, %d given.\n", expected - 1, expected == 2 ? "" : "s", got - 1);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// main "engine": non-blockingly read until newline found, parse, execute.
|
||||
void run()
|
||||
{
|
||||
static char cmdline[MAX_COMDLINE_SIZE + 1] = {0};
|
||||
if (!read_string_until('\n', cmdline, MAX_COMDLINE_SIZE))
|
||||
return;
|
||||
|
||||
String argv[MAX_WORDS];
|
||||
int argc = tokenize(argv, cmdline);
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
int cmd_id = find_command(argv[0]);
|
||||
if (cmd_id == -1)
|
||||
break;
|
||||
if (!verify_arg_count(argc, commandHandlers[cmd_id].argc))
|
||||
break;
|
||||
commandHandlers[cmd_id].function(argv);
|
||||
} while (0);
|
||||
}
|
||||
|
||||
Serial.print("> ");
|
||||
}
|
||||
|
||||
}
|
||||
8
CYD-Klipper/src/ui/serial/serial_console.h
Normal file
8
CYD-Klipper/src/ui/serial/serial_console.h
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
namespace serial_console {
|
||||
|
||||
void greet();
|
||||
void run();
|
||||
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
#include "switch_printer.h"
|
||||
#include "lvgl.h"
|
||||
#include "../conf/global_config.h"
|
||||
#include "ui_utils.h"
|
||||
#include "../core/http_client.h"
|
||||
#include "../core/lv_setup.h"
|
||||
#include "../core/macros_query.h"
|
||||
#include "../core/screen_driver.h"
|
||||
#include "../core/data_setup.h"
|
||||
|
||||
void switch_printer(int index)
|
||||
{
|
||||
set_printer_config_index(index);
|
||||
set_color_scheme();
|
||||
set_invert_display();
|
||||
printer.slicer_estimated_print_time_s = 0;
|
||||
}
|
||||
|
||||
static void btn_switch_printer(lv_event_t *e){
|
||||
@@ -47,7 +48,7 @@ void switch_printer_init() {
|
||||
PRINTER_CONFIG * config = &global_config.printer_config[i];
|
||||
const char* printer_name = (config->printer_name[0] == 0) ? config->klipper_host : config->printer_name;
|
||||
|
||||
if (config == get_current_printer_config())
|
||||
if (config == get_current_printer_config() && config->ip_configured)
|
||||
{
|
||||
lv_create_custom_menu_label(printer_name, parent, "Active");
|
||||
continue;
|
||||
@@ -59,14 +60,7 @@ void switch_printer_init() {
|
||||
|
||||
|
||||
int httpCode = client.GET();
|
||||
if (httpCode == 200)
|
||||
{
|
||||
lv_create_custom_menu_button(printer_name, parent, btn_switch_printer, "Switch", config);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_create_custom_menu_label(printer_name, parent, "Offline");
|
||||
}
|
||||
lv_create_custom_menu_button(printer_name, parent, btn_switch_printer, (httpCode == 200) ? "Switch" : "Offline", config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,11 +69,11 @@ static void show_switch_printer_screen(lv_event_t * e){
|
||||
switch_printer_init();
|
||||
}
|
||||
|
||||
void draw_switch_printer_button()
|
||||
lv_obj_t * draw_switch_printer_button()
|
||||
{
|
||||
if (!global_config.multi_printer_mode)
|
||||
{
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||||
@@ -90,4 +84,6 @@ void draw_switch_printer_button()
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_HOME);
|
||||
lv_obj_center(label);
|
||||
|
||||
return btn;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "lvgl.h"
|
||||
|
||||
void switch_printer(int index);
|
||||
void switch_printer_init();
|
||||
void draw_switch_printer_button();
|
||||
lv_obj_t * draw_switch_printer_button();
|
||||
@@ -9,6 +9,7 @@ lv_obj_t* lv_create_empty_panel(lv_obj_t* root) {
|
||||
lv_obj_set_style_border_width(panel, 0, 0);
|
||||
lv_obj_set_style_bg_opa(panel, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_pad_all(panel, 0, 0);
|
||||
lv_obj_set_style_radius(panel, 0, 0);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ void lv_keyboard_text_entry_close(lv_event_t * e){
|
||||
}
|
||||
}
|
||||
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, lv_keyboard_mode_t keyboard_mode, lv_coord_t width, uint8_t max_length, const char* fill_text, bool contain_in_panel)
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char* title, lv_keyboard_mode_t keyboard_mode, lv_coord_t width, uint8_t max_length, const char* fill_text, bool contain_in_panel)
|
||||
{
|
||||
lv_obj_t * parent = lv_create_empty_panel(lv_scr_act());
|
||||
lv_obj_set_style_bg_opa(parent, LV_OPA_50, 0);
|
||||
@@ -116,6 +117,19 @@ void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, lv_keyboard_
|
||||
lv_obj_set_size(parent, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
}
|
||||
|
||||
if (title != nullptr)
|
||||
{
|
||||
lv_obj_t * empty_panel = lv_create_empty_panel(parent);
|
||||
lv_obj_set_size(empty_panel, 0, 0);
|
||||
|
||||
lv_obj_t * title_container = lv_obj_create(parent);
|
||||
lv_obj_set_style_pad_all(title_container, CYD_SCREEN_GAP_PX / 2, 0);
|
||||
lv_obj_set_size(title_container, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
|
||||
lv_obj_t * title_label = lv_label_create(title_container);
|
||||
lv_label_set_text(title_label, title);
|
||||
}
|
||||
|
||||
lv_obj_t * empty_panel = lv_create_empty_panel(parent);
|
||||
lv_obj_set_flex_grow(empty_panel, 1);
|
||||
|
||||
@@ -135,7 +149,7 @@ void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, lv_keyboard_
|
||||
|
||||
const static lv_point_t line_points[] = { {0, 0}, {(short int)((CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2) * 0.85f), 0} };
|
||||
|
||||
void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height)
|
||||
void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height, const char * comment)
|
||||
{
|
||||
lv_obj_t * panel = lv_create_empty_panel(root_panel);
|
||||
lv_layout_flex_row(panel, LV_FLEX_ALIGN_END);
|
||||
@@ -151,6 +165,13 @@ void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_ob
|
||||
if (set_height)
|
||||
lv_obj_set_height(object, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
if (comment != NULL)
|
||||
{
|
||||
lv_obj_t * comment_label = lv_label_create(root_panel);
|
||||
lv_label_set_text(comment_label, comment);
|
||||
lv_obj_set_style_text_font(comment_label, &CYD_SCREEN_FONT_SMALL, 0);
|
||||
}
|
||||
|
||||
lv_obj_t * line = lv_line_create(root_panel);
|
||||
lv_line_set_points(line, line_points, 2);
|
||||
lv_obj_set_style_line_width(line, 1, 0);
|
||||
@@ -160,7 +181,7 @@ void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_ob
|
||||
#define DROPDOWN_WIDTH CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 3.75
|
||||
#define TOGGLE_WIDTH CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2
|
||||
|
||||
void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_click, const char *btn_text, void * user_data)
|
||||
void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_click, const char *btn_text, void * user_data, const char * comment)
|
||||
{
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(btn, on_click, LV_EVENT_CLICKED, user_data);
|
||||
@@ -169,10 +190,10 @@ void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel,
|
||||
lv_label_set_text(label, btn_text);
|
||||
lv_obj_center(label);
|
||||
|
||||
lv_create_custom_menu_entry(label_text, btn, root_panel, true);
|
||||
lv_create_custom_menu_entry(label_text, btn, root_panel, true, comment);
|
||||
}
|
||||
|
||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data)
|
||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data, const char * comment)
|
||||
{
|
||||
lv_obj_t * toggle = lv_switch_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(toggle, on_toggle, LV_EVENT_VALUE_CHANGED, user_data);
|
||||
@@ -181,10 +202,10 @@ void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel,
|
||||
if (state)
|
||||
lv_obj_add_state(toggle, LV_STATE_CHECKED);
|
||||
|
||||
lv_create_custom_menu_entry(label_text, toggle, root_panel, true);
|
||||
lv_create_custom_menu_entry(label_text, toggle, root_panel, true, comment);
|
||||
}
|
||||
|
||||
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data)
|
||||
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data, const char * comment)
|
||||
{
|
||||
lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_options(dropdown, options);
|
||||
@@ -192,7 +213,7 @@ void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel
|
||||
lv_obj_set_width(dropdown, DROPDOWN_WIDTH);
|
||||
lv_obj_add_event_cb(dropdown, on_change, LV_EVENT_VALUE_CHANGED, user_data);
|
||||
|
||||
lv_create_custom_menu_entry(label_text, dropdown, root_panel, true);
|
||||
lv_create_custom_menu_entry(label_text, dropdown, root_panel, true, comment);
|
||||
}
|
||||
|
||||
void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, const char *text)
|
||||
@@ -239,6 +260,7 @@ void lv_create_popup_message(const char* message, uint16_t timeout_ms)
|
||||
lv_layout_flex_column(panel, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, -CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
||||
lv_obj_add_event_cb(panel, on_timer_destroy, LV_EVENT_DELETE, NULL);
|
||||
lv_obj_add_event_cb(panel, destroy_event_user_data, LV_EVENT_CLICKED, panel);
|
||||
lv_obj_set_style_border_color(panel, lv_color_hex(0xFF0000), 0);
|
||||
|
||||
lv_obj_t* label = lv_label_create(panel);
|
||||
@@ -248,3 +270,13 @@ void lv_create_popup_message(const char* message, uint16_t timeout_ms)
|
||||
|
||||
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)
|
||||
{
|
||||
lv_obj_t * panel = lv_create_empty_panel(parent);
|
||||
lv_obj_set_size(panel, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_add_event_cb(panel, btn_callback, LV_EVENT_CLICKED, user_data);
|
||||
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
return label;
|
||||
}
|
||||
@@ -38,10 +38,11 @@ void lv_layout_flex_column(lv_obj_t* obj, lv_flex_align_t allign = LV_FLEX_ALIGN
|
||||
void lv_layout_flex_row(lv_obj_t* obj, lv_flex_align_t allign = LV_FLEX_ALIGN_START, lv_coord_t pad_column = CYD_SCREEN_GAP_PX, lv_coord_t pad_row = CYD_SCREEN_GAP_PX);
|
||||
void lv_create_fullscreen_button_matrix_popup(lv_obj_t * root, lv_event_cb_t title, lv_button_column_t* columns, int column_count);
|
||||
void destroy_event_user_data(lv_event_t * e);
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, lv_keyboard_mode_t keyboard_mode = LV_KEYBOARD_MODE_NUMBER, lv_coord_t width = CYD_SCREEN_PANEL_WIDTH_PX / 2, uint8_t max_length = 3, const char* fill_text = "", bool contain_in_panel= true);
|
||||
void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height = true);
|
||||
void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_click, const char *btn_text, void * user_data = NULL);
|
||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data = NULL);
|
||||
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data = NULL);
|
||||
void lv_create_keyboard_text_entry(lv_event_cb_t keyboard_callback, const char* title = NULL, lv_keyboard_mode_t keyboard_mode = LV_KEYBOARD_MODE_NUMBER, lv_coord_t width = CYD_SCREEN_PANEL_WIDTH_PX / 2, uint8_t max_length = 3, const char* fill_text = "", bool contain_in_panel= true);
|
||||
void lv_create_custom_menu_entry(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height = true, const char * comment = NULL);
|
||||
void lv_create_custom_menu_button(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_click, const char *btn_text, void * user_data = NULL, const char * comment = NULL);
|
||||
void lv_create_custom_menu_switch(const char *label_text, lv_obj_t* root_panel, lv_event_cb_t on_toggle, bool state, void * user_data = NULL, const char * comment = NULL);
|
||||
void lv_create_custom_menu_dropdown(const char *label_text, lv_obj_t *root_panel, lv_event_cb_t on_change, const char *options, int index, void * user_data = NULL, const char * comment = NULL);
|
||||
void lv_create_custom_menu_label(const char *label_text, lv_obj_t* root_panel, const char *text);
|
||||
void lv_create_popup_message(const char* message, uint16_t timeout_ms);
|
||||
lv_obj_t * lv_label_btn_create(lv_obj_t * parent, lv_event_cb_t btn_callback, void* user_data = NULL);
|
||||
@@ -3,86 +3,107 @@
|
||||
#include "../conf/global_config.h"
|
||||
#include "ui_utils.h"
|
||||
#include "WiFi.h"
|
||||
#include "../core/data_setup.h"
|
||||
#include "../core/lv_setup.h"
|
||||
#include "serial/serial_console.h"
|
||||
|
||||
void wifi_init_inner();
|
||||
void wifi_pass_entry(const char* ssid);
|
||||
|
||||
const char * current_ssid_ptr = NULL;
|
||||
|
||||
static void reset_btn_event_handler(lv_event_t * e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
global_config.wifi_configured = false;
|
||||
wifi_init_inner();
|
||||
}
|
||||
}
|
||||
|
||||
static void refresh_btn_event_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
wifi_init_inner();
|
||||
}
|
||||
}
|
||||
|
||||
static void ta_event_cb(lv_event_t * e) {
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
static void keyboard_cb_enter_password(lv_event_t * e) {
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
|
||||
if (code == LV_EVENT_READY)
|
||||
{
|
||||
lv_obj_t * kb = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
const char * txt = lv_textarea_get_text(ta);
|
||||
int len = strlen(txt);
|
||||
if (len > 0)
|
||||
{
|
||||
global_config.wifi_configured = true;
|
||||
strcpy(global_config.wifi_SSID, current_ssid_ptr);
|
||||
strcpy(global_config.wifi_password, txt);
|
||||
write_global_config();
|
||||
wifi_init_inner();
|
||||
}
|
||||
}
|
||||
else if (code == LV_EVENT_CANCEL)
|
||||
|
||||
static void btn_reuse_password(lv_event_t * e)
|
||||
{
|
||||
wifi_init_inner();
|
||||
}
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
void wifi_pass_entry(const char* ssid){
|
||||
lv_obj_clean(lv_scr_act());
|
||||
static void btn_no_reuse_password(lv_event_t * e)
|
||||
{
|
||||
lv_create_keyboard_text_entry(keyboard_cb_enter_password, "Enter WiFi Password", LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 63, "", false);
|
||||
}
|
||||
|
||||
lv_obj_t * root = lv_create_empty_panel(lv_scr_act());
|
||||
lv_obj_set_size(root, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
lv_layout_flex_column(root);
|
||||
void ask_reuse_password(const char * ssid){
|
||||
lv_obj_t * root = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(root, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_align(root, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_layout_flex_column(root, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||
|
||||
lv_obj_t * top_root = lv_create_empty_panel(root);
|
||||
lv_obj_set_width(top_root, CYD_SCREEN_WIDTH_PX);
|
||||
lv_layout_flex_column(top_root);
|
||||
lv_obj_set_flex_grow(top_root, 1);
|
||||
lv_obj_set_style_pad_all(top_root, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_obj_t * label = lv_label_create(root);
|
||||
lv_label_set_text_fmt(label, "Reuse stored WiFi Password?\n(Password Length: %d)", strlen(global_config.wifi_password));
|
||||
|
||||
lv_obj_t * label = lv_label_create(top_root);
|
||||
lv_label_set_text(label, "Enter WiFi Password");
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_t * button_row = lv_create_empty_panel(root);
|
||||
lv_layout_flex_row(button_row, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||
lv_obj_set_size(button_row, lv_pct(100), CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * passEntry = lv_textarea_create(top_root);
|
||||
lv_textarea_set_one_line(passEntry, true);
|
||||
lv_textarea_set_text(passEntry, "");
|
||||
lv_obj_set_width(passEntry, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_add_event_cb(passEntry, ta_event_cb, LV_EVENT_ALL, NULL);
|
||||
lv_obj_set_flex_grow(passEntry, 1);
|
||||
lv_obj_t * no_btn = lv_btn_create(button_row);
|
||||
lv_obj_add_event_cb(no_btn, btn_no_reuse_password, LV_EVENT_CLICKED, (void*)ssid);
|
||||
lv_obj_add_event_cb(no_btn, destroy_event_user_data, LV_EVENT_CLICKED, root);
|
||||
lv_obj_set_height(no_btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_set_width(no_btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX);
|
||||
lv_obj_set_style_pad_all(no_btn, CYD_SCREEN_GAP_PX, 0);
|
||||
|
||||
lv_obj_t * keyboard = lv_keyboard_create(root);
|
||||
lv_keyboard_set_textarea(keyboard, passEntry);
|
||||
label = lv_label_create(no_btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE);
|
||||
lv_obj_center(label);
|
||||
|
||||
lv_obj_t * yes_btn = lv_btn_create(button_row);
|
||||
lv_obj_add_event_cb(yes_btn, btn_reuse_password, LV_EVENT_CLICKED, (void*)ssid);
|
||||
lv_obj_set_height(yes_btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_set_width(yes_btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX);
|
||||
lv_obj_set_style_pad_all(yes_btn, CYD_SCREEN_GAP_PX, 0);
|
||||
|
||||
label = lv_label_create(yes_btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_OK);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
void wifi_pass_entry(const char* ssid)
|
||||
{
|
||||
current_ssid_ptr = ssid;
|
||||
|
||||
if (strcmp(ssid, global_config.wifi_SSID) == 0){
|
||||
ask_reuse_password(ssid);
|
||||
return;
|
||||
}
|
||||
|
||||
btn_no_reuse_password(NULL);
|
||||
}
|
||||
|
||||
static void wifi_btn_event_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
delay(100);
|
||||
char* ssid = (char*)e->user_data;
|
||||
strcpy(global_config.wifi_SSID, ssid);
|
||||
Serial.println(ssid);
|
||||
LOG_LN(ssid);
|
||||
wifi_pass_entry(ssid);
|
||||
}
|
||||
|
||||
static void wifi_keyboard_cb_manual_ssid(lv_event_t * e){
|
||||
lv_obj_t * ta = lv_event_get_target(e);
|
||||
lv_obj_t * kb = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
const char * text = lv_textarea_get_text(ta);
|
||||
char * text_copy = (char*)malloc(strlen(text) + 1);
|
||||
strcpy(text_copy, text);
|
||||
LOG_LN(text_copy);
|
||||
wifi_pass_entry(text_copy);
|
||||
}
|
||||
|
||||
static void wifi_btn_manual_ssid(lv_event_t * e){
|
||||
lv_create_keyboard_text_entry(wifi_keyboard_cb_manual_ssid, "Enter SSID Manually", LV_KEYBOARD_MODE_TEXT_LOWER, CYD_SCREEN_WIDTH_PX * 0.75, 31, "", false);
|
||||
}
|
||||
|
||||
void wifi_init_inner(){
|
||||
@@ -90,7 +111,16 @@ void wifi_init_inner(){
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
if (global_config.wifi_configured){
|
||||
if (global_config.wifi_password[0] == '\0')
|
||||
{
|
||||
WiFi.begin(global_config.wifi_SSID);
|
||||
}
|
||||
else
|
||||
{
|
||||
WiFi.begin(global_config.wifi_SSID, global_config.wifi_password);
|
||||
}
|
||||
|
||||
LOG_F(("Connecting to %s with a password length of %d\n", global_config.wifi_SSID, strlen(global_config.wifi_password)))
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Connecting to WiFi");
|
||||
@@ -125,16 +155,25 @@ void wifi_init_inner(){
|
||||
|
||||
lv_obj_t * top_row = lv_create_empty_panel(root);
|
||||
lv_obj_set_size(top_row, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, LV_SIZE_CONTENT);
|
||||
lv_layout_flex_row(top_row, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||
lv_layout_flex_row(top_row);
|
||||
|
||||
label = lv_label_create(top_row);
|
||||
lv_label_set_text(label, "Select a network");
|
||||
lv_obj_set_flex_grow(label, 1);
|
||||
|
||||
lv_obj_t * refreshBtn = lv_btn_create(top_row);
|
||||
lv_obj_add_event_cb(refreshBtn, reset_btn_event_handler, LV_EVENT_ALL, NULL);
|
||||
lv_obj_set_size(refreshBtn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_t * btn = lv_btn_create(top_row);
|
||||
lv_obj_add_event_cb(btn, wifi_btn_manual_ssid, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create(refreshBtn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_KEYBOARD);
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(top_row);
|
||||
lv_obj_add_event_cb(btn, reset_btn_event_handler, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_REFRESH);
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -159,7 +198,7 @@ void wifi_init_inner(){
|
||||
ssid_copy[j] = '\0';
|
||||
|
||||
lv_obj_t * btn = lv_list_add_btn(list, LV_SYMBOL_WIFI, ssid_copy);
|
||||
lv_obj_add_event_cb(btn, wifi_btn_event_handler, LV_EVENT_ALL, (void*)ssid_copy);
|
||||
lv_obj_add_event_cb(btn, wifi_btn_event_handler, LV_EVENT_CLICKED, (void*)ssid_copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,16 +222,44 @@ void wifi_init(){
|
||||
while (!global_config.wifi_configured || WiFi.status() != WL_CONNECTED){
|
||||
if (millis() - print_timer > print_freq){
|
||||
print_timer = millis();
|
||||
Serial.printf("WiFi Status: %s\n", errs[WiFi.status()]);
|
||||
LOG_F(("WiFi Status: %s\n", errs[WiFi.status()]))
|
||||
}
|
||||
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
lv_handler();
|
||||
serial_console::run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ulong start_time_recovery = 0;
|
||||
|
||||
void wifi_ok(){
|
||||
if (WiFi.status() != WL_CONNECTED){
|
||||
LOG_LN("WiFi Connection Lost. Reconnecting...");
|
||||
freeze_request_thread();
|
||||
WiFi.disconnect();
|
||||
delay(5000); // Wait for the WiFi to disconnect
|
||||
|
||||
start_time_recovery = millis();
|
||||
|
||||
if (global_config.wifi_password[0] == '\0')
|
||||
{
|
||||
WiFi.begin(global_config.wifi_SSID);
|
||||
}
|
||||
else
|
||||
{
|
||||
WiFi.begin(global_config.wifi_SSID, global_config.wifi_password);
|
||||
}
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED){
|
||||
delay(1000);
|
||||
LOG_F(("WiFi Status: %s\n", errs[WiFi.status()]))
|
||||
if (millis() - start_time_recovery > 15000){
|
||||
LOG_LN("WiFi Connection failed to reconnect. Restarting...");
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
|
||||
unfreeze_request_thread();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,38 @@
|
||||
# Building
|
||||
# Manual install
|
||||
|
||||
## Running a developer build
|
||||
## Flashing a build via the commandline
|
||||
|
||||
On every change made in this repository, [Github Actions](https://github.com/suchmememanyskill/CYD-Klipper/actions) automatically builds the firmware images for various screens. You can run one of these images as follows:
|
||||
#### Release firmware image
|
||||
|
||||
1. Go to [the releases tab](https://github.com/suchmememanyskill/CYD-Klipper/releases), and download the latest `firmware.zip` release.
|
||||
2. Open the firmware.zip archive you just downloaded, open the corresponding folder for your screen, then extract `merged_firmware.bin`
|
||||
|
||||
This merged_firmware.bin file is a ready to flash image. Note that flashing this image does wipe your current configuration.
|
||||
|
||||
#### Developer firmware image
|
||||
On every change made in this repository, [Github Actions](https://github.com/suchmememanyskill/CYD-Klipper/actions) automatically builds the firmware images for various screens.
|
||||
|
||||
#### Getting a firmware image
|
||||
0. Make sure you are logged into github
|
||||
1. Go to a [Github Actions](https://github.com/suchmememanyskill/CYD-Klipper/actions) build summary, then download the `firmware` Artifact.
|
||||
2. Open the firmware.zip archive you just downloaded, open the corresponding folder for your screen, then extract `merged_firmware.bin`
|
||||
|
||||
This merged_firmware.bin file is a ready to flash image. Note that flashing this image does wipe your current configuration.
|
||||
|
||||
#### Flashing merged_firmware.bin
|
||||
### Flashing merged_firmware.bin
|
||||
1. Download and extract [esptool](https://github.com/espressif/esptool/releases) to a new folder
|
||||
- For windows, download `esptool-v4.7.0-win64.zip`
|
||||
2. Open a terminal window and navigate to this new folder containing esptool
|
||||
- In windows, you can type cmd and press enter in the address bar in explorer to jump to the folder in cmd 
|
||||
3. Move `merged-firmware.bin` into this new folder
|
||||
4. Connect the display to your computer
|
||||
5. Execute the command `esptool write_flash 0x0 merged-firmware.bin`
|
||||
5. Execute the command `esptool write_flash 0x0 merged_firmware.bin`
|
||||
- Don't forget to hold down the boot button on the display
|
||||
|
||||
## Building via PlatformIO
|
||||
## Building & Flashing via PlatformIO
|
||||
|
||||
0. Install [Visual Studio Code](https://code.visualstudio.com/) and install the PlatformIO IDE plugin.
|
||||
0. Install the following tools:
|
||||
- [Visual Studio Code](https://code.visualstudio.com/) and install the PlatformIO IDE plugin.
|
||||
- [Git](https://git-scm.com/download/win)
|
||||
1. Download the source code of CYD-Klipper
|
||||
- This can be done via the `git clone https://github.com/suchmememanyskill/CYD-Klipper` command or via the green `<> Code` button on Github
|
||||
2. Open the CYD-Klipper folder inside the CYD-Klipper folder in Visual Studio Code
|
||||
@@ -35,3 +44,5 @@ This merged_firmware.bin file is a ready to flash image. Note that flashing this
|
||||
6. Click 'Upload and Monitor'
|
||||
- This will start compiling the code, and after upload it to the display
|
||||
- Don't forget to hold the boot button while flashing. The screen will flash when the firmware is attempted to be flashed
|
||||
|
||||

|
||||
@@ -23,10 +23,11 @@ A ESP32-2432S028R is required to run this project. You can find out where to buy
|
||||
- Execute predefined gcode macros
|
||||
- Toggle Moonraker power devices
|
||||
- OTA updates
|
||||
- Serial console over USB (115200 8n1, echo off, LF/LF)
|
||||
|
||||
### Install
|
||||
|
||||
[There is a web-based installer available. This is only supported on Chrome, Edge or Opera, and only on Desktop.](https://suchmememanyskill.github.io/CYD-Klipper/)
|
||||
[There is a web-based installer available. This is only supported on Chrome, Edge, Arc or Opera, and only on Desktop.](https://suchmememanyskill.github.io/CYD-Klipper/)
|
||||
|
||||
On initial install, all data should be wiped. On updates, data should be able to be kept without issues.
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
TT {
|
||||
font-family: 'Terminal', monospace;
|
||||
background-color: #080a0b;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #181a1b;
|
||||
color: white;
|
||||
@@ -27,7 +32,7 @@
|
||||
color: #F44;
|
||||
}
|
||||
|
||||
.install {
|
||||
.configure {
|
||||
margin-bottom: 300px;
|
||||
}
|
||||
|
||||
@@ -80,12 +85,12 @@
|
||||
|
||||
<section class="issues">
|
||||
<h3><span class="iconify" data-icon="mdi-github" style="color: white; filter: drop-shadow(0 0 0.75rem gray);"></span> Report Issues</h3>
|
||||
<p>If you experience any issues with this project, or any feature requests for the project, please report them on the <a href="https://github.com/suchmememanyskill/CYD-Klipper/issues">issues tab on Github</a>.</p>
|
||||
<p>If you experience any issues with this project, or have any feature requests for the project, please report them on the <a href="https://github.com/suchmememanyskill/CYD-Klipper/issues">issues tab on Github</a>.</p>
|
||||
</section>
|
||||
|
||||
<section class="install">
|
||||
<h3><span class="iconify" data-icon="mdi-download"></span> Install</h3>
|
||||
<p>Select your device from the list below and click 'Connect'.<br>Note: You may need to hold the 'BOOT' button on the device while pressing install.<br>The 2.8" Resistive and 3.5" Capacitive models are best suited (in my opinion) for CYD-Klipper.</p>
|
||||
<p>Select your device from the list below and click 'Connect'.<br>Note: You may need to hold the 'BOOT' button on the device while pressing install.<br><br>The 2.8" Resistive and 3.5" Capacitive models are best suited (in my opinion) for CYD-Klipper.<br><br>Note for any resistive models: You can clear touch calibration by holding the BOOT button for 8 seconds while the screen is on.</p>
|
||||
<select id="select-install-btn" onchange="setInstallButton(getElementById('select-install-btn').value)">
|
||||
<option value="esp32-2432S024C-SD">ESP32-2432S024 (2.4" Capacitive)</option>
|
||||
<option selected value="esp32-2432S028R">ESP32-2432S028 (2.8" Resistive)</option>
|
||||
@@ -97,5 +102,13 @@
|
||||
</select>
|
||||
<span id="install-btn"></span>
|
||||
</section>
|
||||
|
||||
<section class="configure">
|
||||
<h3><span class="iconify" data-icon="mdi-wrench" style="color: cyan; filter: drop-shadow(0 0 0.75rem blue);"></span> Config</h3>
|
||||
<p> After installing CYD-Klipper, you can configure it using its touchscreen, or serial console. To use the serial console,
|
||||
click 'Connect', select the serial port, select "LOGS & CONSOLE" and reset the board without holding BOOT.<br>
|
||||
Type <tt>help</tt> for list of available commands. You're interested in <tt>ssid</tt>, <tt>ip</tt> and <tt>key</tt>. (while you <i>can</i> set <tt>touch</tt>, it's really better done using the touchscreen.)
|
||||
|
||||
</section>
|
||||
</section>
|
||||
</body>
|
||||
17
ci.py
17
ci.py
@@ -7,17 +7,25 @@ CYD_PORTS = [
|
||||
"esp32-8048S043C-SD",
|
||||
"esp32-2432S024C-SD",
|
||||
"esp32-4827S043C-SD",
|
||||
"esp32-3248S035C-V"
|
||||
"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):
|
||||
return {
|
||||
"name": f"to {device_name}",
|
||||
"funding_url": "https://ko-fi.com/suchmememanyskill",
|
||||
"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",
|
||||
@@ -79,7 +87,10 @@ for port in CYD_PORTS:
|
||||
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)
|
||||
|
||||
BIN
readme/platformio.png
Normal file
BIN
readme/platformio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Reference in New Issue
Block a user