mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 21:53:24 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c7d5ffacd | ||
|
|
1bc770a1cf | ||
|
|
b5ac6d045a | ||
|
|
c9f8935310 | ||
|
|
ff1c13602c | ||
|
|
5d3d32b116 | ||
|
|
edec1724e6 | ||
|
|
dd5e82d637 | ||
|
|
e5edabffa4 | ||
|
|
a1bb6a750f | ||
|
|
43cefaafd2 | ||
|
|
dcf32d6685 | ||
|
|
12c4319173 | ||
|
|
86be30034d | ||
|
|
4fc2316970 | ||
|
|
3dc241dbec | ||
|
|
cd58fcae4f | ||
|
|
87a9257e19 | ||
|
|
a436c6b5c7 | ||
|
|
2b92b8daee | ||
|
|
c443bb74d7 | ||
|
|
2fb83df0cf | ||
|
|
1c10d46a5e | ||
|
|
d3e7eec47a | ||
|
|
64266b1ff8 | ||
|
|
254d8453ad | ||
|
|
f05246f8c7 | ||
|
|
5bbdc9e509 | ||
|
|
4302c4492c |
13
.github/workflows/compile.yaml
vendored
13
.github/workflows/compile.yaml
vendored
@@ -4,7 +4,16 @@ permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags-ignore:
|
||||
- '*'
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -48,7 +57,7 @@ jobs:
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
|
||||
if: github.event_name == 'release' && github.event.action == 'created'
|
||||
steps:
|
||||
- name: Print GitHub event name
|
||||
run: |
|
||||
|
||||
6
CYD-Klipper/.vscode/settings.json
vendored
6
CYD-Klipper/.vscode/settings.json
vendored
@@ -12,6 +12,8 @@
|
||||
"algorithm": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"functional": "cpp",
|
||||
"*.tcc": "cpp"
|
||||
}
|
||||
"*.tcc": "cpp",
|
||||
"cmath": "cpp"
|
||||
},
|
||||
"cmake.configureOnOpen": false
|
||||
}
|
||||
126
CYD-Klipper/boards/esp32-2432S022C-smartdisplay.json
Normal file
126
CYD-Klipper/boards/esp32-2432S022C-smartdisplay.json
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"'-D ARDUINO_ESP32_DEV'",
|
||||
"'-D ESP32_2432S022C'",
|
||||
"'-D LCD_WIDTH=240'",
|
||||
"'-D LCD_HEIGHT=320'",
|
||||
"'-D LVGL_BUFFER_PIXELS=(LCD_WIDTH*LCD_HEIGHT/8)'",
|
||||
"'-D LVGL_BUFFER_MALLOC_FLAGS=(MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT)'",
|
||||
"'-D BCKL=0'",
|
||||
"'-D LCD_ST7789_I80'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_CLK_SRC=LCD_CLK_SRC_PLL160M'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DC=16'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_WR=4'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D8=15'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D9=13'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D10=12'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D11=14'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D12=27'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D13=25'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D14=33'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_DATA_GPIO_D15=32'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_BUS_WIDTH=8'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_MAX_TRANSFER_BYTES=(LVGL_BUFFER_PIXELS * sizeof(lv_color_t))'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_PSRAM_TRANS_ALIGN=64'",
|
||||
"'-D ST7789_I80_BUS_CONFIG_SRAM_TRANS_ALIGN=4'",
|
||||
"'-D ST7789_IO_I80_CONFIG_CS_GPIO_NUM=17'",
|
||||
"'-D ST7789_IO_I80_CONFIG_PCLK_HZ=55000000'",
|
||||
"'-D ST7789_IO_I80_CONFIG_TRANS_QUEUE_DEPTH=10'",
|
||||
"'-D ST7789_IO_I80_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D ST7789_IO_I80_CONFIG_LCD_PARAM_BITS=8'",
|
||||
"'-D ST7789_IO_I80_CONFIG_DC_LEVELS_DC_IDLE_LEVEL=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_DC_LEVELS_DC_CMD_LEVEL=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_DC_LEVELS_DC_DUMMY_LEVEL=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_DC_LEVELS_DC_DATA_LEVEL=1'",
|
||||
"'-D ST7789_IO_I80_CONFIG_FLAGS_CS_ACTIVE_HIGH=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_FLAGS_REVERSE_COLOR_BITS=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_FLAGS_SWAP_COLOR_BYTES=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_FLAGS_PCLK_ACTIVE_NEG=0'",
|
||||
"'-D ST7789_IO_I80_CONFIG_FLAGS_PCLK_IDLE_LOW=0'",
|
||||
"'-D ST7789_DEV_CONFIG_RESET_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7789_DEV_CONFIG_COLOR_SPACE=ESP_LCD_COLOR_SPACE_BGR'",
|
||||
"'-D ST7789_DEV_CONFIG_BITS_PER_PIXEL=16'",
|
||||
"'-D ST7789_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH=false'",
|
||||
"'-D ST7789_DEV_CONFIG_VENDOR_CONFIG=NULL'",
|
||||
"'-D ST7789_RD_GPIO=2'",
|
||||
"'-D LCD_SWAP_XY=false'",
|
||||
"'-D LCD_MIRROR_X=false'",
|
||||
"'-D LCD_MIRROR_Y=false'",
|
||||
"'-D BOARD_HAS_TOUCH'",
|
||||
"'-D TOUCH_CST816S_I2C'",
|
||||
"'-D CST816S_I2C_HOST=0'",
|
||||
"'-D CST816S_I2C_CONFIG_SDA_IO_NUM=21'",
|
||||
"'-D CST816S_I2C_CONFIG_SCL_IO_NUM=22'",
|
||||
"'-D CST816S_I2C_CONFIG_SDA_PULLUP_EN=GPIO_PULLUP_ENABLE'",
|
||||
"'-D CST816S_I2C_CONFIG_SCL_PULLUP_EN=GPIO_PULLUP_ENABLE'",
|
||||
"'-D CST816S_I2C_CONFIG_MASTER_CLK_SPEED=400000'",
|
||||
"'-D CST816S_I2C_CONFIG_CLK_FLAGS=0'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_DEV_ADDR=ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_CONTROL_PHASE_BYTES=1'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_DC_BIT_OFFSET=0'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_LCD_PARAM_BITS=0'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_FLAGS_DC_LOW_ON_DATA=false'",
|
||||
"'-D CST816S_IO_I2C_CONFIG_FLAGS_DISABLE_CONTROL_PHASE=true'",
|
||||
"'-D CST816S_TOUCH_CONFIG_X_MAX=LCD_WIDTH'",
|
||||
"'-D CST816S_TOUCH_CONFIG_Y_MAX=LCD_HEIGHT'",
|
||||
"'-D CST816S_TOUCH_CONFIG_RST_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D CST816S_TOUCH_CONFIG_INT_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D CST816S_TOUCH_CONFIG_LEVELS_RESET=0'",
|
||||
"'-D CST816S_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=5'",
|
||||
"'-D TF_SPI_MOSI=23'",
|
||||
"'-D TF_SPI_SCLK=18'",
|
||||
"'-D TF_SPI_MISO=19'",
|
||||
"'-D BOARD_HAS_SPEAK'",
|
||||
"'-D SPEAK=26'",
|
||||
|
||||
"-DCYD_SCREEN_GAP_PX=8",
|
||||
"-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=35",
|
||||
"-DCYD_SCREEN_MIN_BUTTON_WIDTH_PX=35",
|
||||
"-DCYD_SCREEN_FONT=lv_font_montserrat_14",
|
||||
"-DCYD_SCREEN_FONT_SMALL=lv_font_montserrat_10",
|
||||
"-DCYD_SCREEN_SIDEBAR_SIZE_PX=40",
|
||||
"-DCYD_SCREEN_DRIVER_ESP32_SMARTDISPLAY=1",
|
||||
"-DCYD_SCREEN_DISABLE_TOUCH_CALIBRATION=1",
|
||||
"-DCYD_SCREEN_DISABLE_INVERT_COLORS=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
"variant": "esp32"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"ethernet",
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_board": "esp-wroom-32.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "esp32-2432S022C",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.aliexpress.com/item/1005006284154750.html",
|
||||
"vendor": "Sunton"
|
||||
}
|
||||
126
CYD-Klipper/boards/esp32-2432S028R-smartdisplay.json
Normal file
126
CYD-Klipper/boards/esp32-2432S028R-smartdisplay.json
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"'-D ARDUINO_ESP32_DEV'",
|
||||
"'-D ESP32_2432S028Rv3'",
|
||||
"'-D LCD_WIDTH=240'",
|
||||
"'-D LCD_HEIGHT=320'",
|
||||
"'-D LVGL_BUFFER_PIXELS=(LCD_WIDTH*LCD_HEIGHT/4)'",
|
||||
"'-D LVGL_BUFFER_MALLOC_FLAGS=(MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT)'",
|
||||
"'-D BCKL=21'",
|
||||
"'-D LCD_ST7789_SPI'",
|
||||
"'-D ST7789_SPI_HOST=SPI2_HOST'",
|
||||
"'-D ST7789_SPI_DMA_CHANNEL=SPI_DMA_CH_AUTO'",
|
||||
"'-D ST7789_SPI_BUS_MOSI_IO_NUM=13'",
|
||||
"'-D ST7789_SPI_BUS_MISO_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7789_SPI_BUS_SCLK_IO_NUM=14'",
|
||||
"'-D ST7789_SPI_BUS_QUADWP_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7789_SPI_BUS_QUADHD_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7789_SPI_BUS_MAX_TRANSFER_SZ=0'",
|
||||
"'-D ST7789_SPI_BUS_FLAGS=0'",
|
||||
"'-D ST7789_SPI_BUS_INTR_FLAGS=0'",
|
||||
"'-D ST7789_SPI_CONFIG_CS_GPIO_NUM=15'",
|
||||
"'-D ST7789_SPI_CONFIG_DC_GPIO_NUM=2'",
|
||||
"'-D ST7789_SPI_CONFIG_SPI_MODE=SPI_MODE3'",
|
||||
"'-D ST7789_SPI_CONFIG_PCLK_HZ=55000000'",
|
||||
"'-D ST7789_SPI_CONFIG_TRANS_QUEUE_DEPTH=10'",
|
||||
"'-D ST7789_SPI_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D ST7789_SPI_CONFIG_LCD_PARAM_BITS=8'",
|
||||
"'-D ST7789_SPI_CONFIG_FLAGS_DC_AS_CMD_PHASE=false'",
|
||||
"'-D ST7789_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA=false'",
|
||||
"'-D ST7789_SPI_CONFIG_FLAGS_OCTAL_MODE=false'",
|
||||
"'-D ST7789_SPI_CONFIG_FLAGS_LSB_FIRST=false'",
|
||||
"'-D ST7789_DEV_CONFIG_RESET_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7789_DEV_CONFIG_COLOR_SPACE=ESP_LCD_COLOR_SPACE_RGB'",
|
||||
"'-D ST7789_DEV_CONFIG_BITS_PER_PIXEL=16'",
|
||||
"'-D ST7789_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH=false'",
|
||||
"'-D ST7789_DEV_CONFIG_VENDOR_CONFIG=NULL'",
|
||||
"'-D LCD_SWAP_XY=false'",
|
||||
"'-D LCD_MIRROR_X=false'",
|
||||
"'-D LCD_MIRROR_Y=false'",
|
||||
"'-D BOARD_HAS_TOUCH'",
|
||||
"'-D TOUCH_XPT2046_SPI'",
|
||||
"'-D XPT2046_SPI_HOST=SPI3_HOST'",
|
||||
"'-D XPT2046_SPI_DMA_CHANNEL=SPI_DMA_CH_AUTO'",
|
||||
"'-D XPT2046_SPI_BUS_MOSI_IO_NUM=32'",
|
||||
"'-D XPT2046_SPI_BUS_MISO_IO_NUM=39'",
|
||||
"'-D XPT2046_SPI_BUS_SCLK_IO_NUM=25'",
|
||||
"'-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=33'",
|
||||
"'-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=36'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_LEVELS_RESET=0'",
|
||||
"'-D XPT2046_TOUCH_CONFIG_LEVELS_INTERRUPT=0'",
|
||||
"'-D TOUCH_SWAP_XY=true'",
|
||||
"'-D TOUCH_SWAP_X=true'",
|
||||
"'-D TOUCH_SWAP_Y=false'",
|
||||
"'-D BOARD_HAS_TF'",
|
||||
"'-D TF_CS=5'",
|
||||
"'-D TF_SPI_MOSI=23'",
|
||||
"'-D TF_SPI_SCLK=18'",
|
||||
"'-D TF_SPI_MISO=19'",
|
||||
"'-D BOARD_HAS_RGB_LED'",
|
||||
"'-D RGB_LED_R=4'",
|
||||
"'-D RGB_LED_G=16'",
|
||||
"'-D RGB_LED_B=17'",
|
||||
"'-D BOARD_HAS_CDS'",
|
||||
"'-D CDS=34'",
|
||||
"'-D BOARD_HAS_SPEAK'",
|
||||
"'-D SPEAK=26'",
|
||||
|
||||
"-DCYD_SCREEN_GAP_PX=8",
|
||||
"-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=35",
|
||||
"-DCYD_SCREEN_MIN_BUTTON_WIDTH_PX=35",
|
||||
"-DCYD_SCREEN_FONT=lv_font_montserrat_14",
|
||||
"-DCYD_SCREEN_FONT_SMALL=lv_font_montserrat_10",
|
||||
"-DCYD_SCREEN_SIDEBAR_SIZE_PX=40",
|
||||
"-DCYD_SCREEN_DRIVER_ESP32_SMARTDISPLAY=1",
|
||||
"-DCYD_SCREEN_DISABLE_TOUCH_CALIBRATION=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
"flash_mode": "dio",
|
||||
"mcu": "esp32",
|
||||
"variant": "esp32"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"ethernet",
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"openocd_board": "esp-wroom-32.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "esp32-2432S028Rv3",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.aliexpress.com/item/1005004502250619.html",
|
||||
"vendor": "Sunton"
|
||||
}
|
||||
@@ -16,9 +16,6 @@
|
||||
"-DTFT_DC=2",
|
||||
"-DTFT_RST=-1",
|
||||
"-DLOAD_GCLD=1",
|
||||
"-DLOAD_FONT2=1",
|
||||
"-DLOAD_GFXFF=1",
|
||||
"-DSMOOTH_FONT=1",
|
||||
"-DSPI_FREQUENCY=55000000",
|
||||
"-DSPI_READ_FREQUENCY=20000000",
|
||||
"-DSPI_TOUCH_FREQUENCY=2500000",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"'-D ST7796_SPI_CONFIG_CS_GPIO_NUM=15'",
|
||||
"'-D ST7796_SPI_CONFIG_DC_GPIO_NUM=2'",
|
||||
"'-D ST7796_SPI_CONFIG_SPI_MODE=SPI_MODE0'",
|
||||
"'-D ST7796_SPI_CONFIG_PCLK_HZ=24000000'",
|
||||
"'-D ST7796_SPI_CONFIG_PCLK_HZ=80000000'",
|
||||
"'-D ST7796_SPI_CONFIG_TRANS_QUEUE_DEPTH=10'",
|
||||
"'-D ST7796_SPI_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D ST7796_SPI_CONFIG_LCD_PARAM_BITS=8'",
|
||||
@@ -74,7 +74,17 @@
|
||||
"'-D BOARD_HAS_CDS'",
|
||||
"'-D CDS=34'",
|
||||
"'-D BOARD_HAS_SPEAK'",
|
||||
"'-D SPEAK=26'"
|
||||
"'-D SPEAK=26'",
|
||||
|
||||
"-DCYD_SCREEN_GAP_PX=10",
|
||||
"-DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=40",
|
||||
"-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",
|
||||
"-DCYD_SCREEN_DISABLE_TOUCH_CALIBRATION=1",
|
||||
"-DCYD_SCREEN_DISABLE_INVERT_COLORS=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "40000000L",
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
"-DTFT_DC=2",
|
||||
"-DTFT_RST=-1",
|
||||
"-DLOAD_GCLD=1",
|
||||
"-DLOAD_FONT2=1",
|
||||
"-DLOAD_GFXFF=1",
|
||||
"-DSMOOTH_FONT=1",
|
||||
"-DSPI_FREQUENCY=55000000",
|
||||
"-DSPI_FREQUENCY=80000000",
|
||||
"-DSPI_READ_FREQUENCY=20000000",
|
||||
"-DSPI_TOUCH_FREQUENCY=2500000",
|
||||
"-DTOUCH_CS=-1",
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
import subprocess
|
||||
|
||||
def extract_commit() -> tuple[str, str]: # Version, Commit
|
||||
def extract_commit() -> str:
|
||||
git_describe_output = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip()
|
||||
split_output = git_describe_output.split("-")
|
||||
return split_output[0], split_output[2][1:]
|
||||
|
||||
if (len(split_output) >= 3):
|
||||
return f"{split_output[0]}\\ ({split_output[2][1:]})"
|
||||
else:
|
||||
return split_output[0]
|
||||
|
||||
try:
|
||||
data = extract_commit()
|
||||
version = f"{data[0]}\\ ({data[1]})"
|
||||
version = extract_commit()
|
||||
except:
|
||||
version = "Unknown"
|
||||
|
||||
|
||||
flag = "-D REPO_VERSION=\\\"" + version + "\\\""
|
||||
dev_flag = "-DREPO_DEVELOPMENT=1"
|
||||
print(f"Version: {version}")
|
||||
print(f"Flag: {flag}")
|
||||
|
||||
flags = [flag]
|
||||
|
||||
if ('(' in version):
|
||||
flags.append(dev_flag)
|
||||
|
||||
Import("env")
|
||||
|
||||
env.Append(
|
||||
BUILD_FLAGS=[flag]
|
||||
BUILD_FLAGS=flags
|
||||
)
|
||||
@@ -21,7 +21,7 @@ monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||
extra_scripts =
|
||||
pre:extract_commit.py
|
||||
pre:extract_commit.py
|
||||
|
||||
[env:esp32-2432S028R]
|
||||
board = esp32-2432S028R
|
||||
@@ -43,17 +43,8 @@ lib_deps =
|
||||
bblanchon/ArduinoJson@^7.0.0
|
||||
plageoj/UrlEncode@^1.0.1
|
||||
|
||||
# Terribly slow. Only use for development
|
||||
# [env:esp32-3248S035C-smartdisplay]
|
||||
# board = esp32-3248S035C-smartdisplay
|
||||
# build_flags =
|
||||
# -DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||
# -DCYD_SCREEN_HEIGHT_PX=320
|
||||
# -DCYD_SCREEN_WIDTH_PX=480
|
||||
# -DCYD_SCREEN_GAP_PX=10
|
||||
# -DCYD_SCREEN_MIN_BUTTON_HEIGHT_PX=40
|
||||
# -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
|
||||
[env:esp32-3248S035C-smartdisplay]
|
||||
board = esp32-3248S035C-smartdisplay
|
||||
|
||||
[env:esp32-2432S028R-smartdisplay]
|
||||
board = esp32-2432S028R-smartdisplay
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#define CONFIG_VERSION 3
|
||||
#define CONFIG_VERSION 4
|
||||
|
||||
enum {
|
||||
REMAINING_TIME_CALC_PERCENTAGE = 0,
|
||||
REMAINING_TIME_CALC_INTERPOLATED = 1,
|
||||
REMAINING_TIME_CALC_SLICER = 2,
|
||||
};
|
||||
|
||||
typedef struct _GLOBAL_CONFIG {
|
||||
unsigned char version;
|
||||
union {
|
||||
unsigned char raw;
|
||||
unsigned int raw;
|
||||
struct {
|
||||
// Internal
|
||||
bool screenCalibrated : 1;
|
||||
@@ -20,6 +26,11 @@ typedef struct _GLOBAL_CONFIG {
|
||||
bool invertColors : 1;
|
||||
bool rotateScreen : 1;
|
||||
bool onDuringPrint : 1;
|
||||
bool autoOtaUpdate : 1;
|
||||
unsigned char remaining_time_calc_mode : 2;
|
||||
|
||||
// Internal
|
||||
bool auth_configured : 1;
|
||||
};
|
||||
};
|
||||
float screenCalXOffset;
|
||||
@@ -39,6 +50,8 @@ typedef struct _GLOBAL_CONFIG {
|
||||
|
||||
unsigned short hotend_presets[3];
|
||||
unsigned short bed_presets[3];
|
||||
|
||||
char klipper_auth[33];
|
||||
} GLOBAL_CONFIG;
|
||||
|
||||
typedef struct _COLOR_DEF {
|
||||
|
||||
@@ -242,8 +242,12 @@
|
||||
* Others
|
||||
*-----------*/
|
||||
|
||||
#ifndef REPO_DEVELOPMENT
|
||||
#define REPO_DEVELOPMENT 0
|
||||
#endif
|
||||
|
||||
/*1: Show CPU usage and FPS count*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_PERF_MONITOR REPO_DEVELOPMENT
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
#endif
|
||||
@@ -363,7 +367,7 @@
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font*/
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
#define LV_FONT_DEFAULT &CYD_SCREEN_FONT
|
||||
|
||||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
@@ -497,7 +501,7 @@
|
||||
|
||||
#define LV_USE_MSG 1
|
||||
|
||||
#define LV_USE_CHART 0
|
||||
#define LV_USE_CHART 1
|
||||
|
||||
#define LV_USE_COLORWHEEL 0
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ void send_gcode(bool wait, const char *gcode)
|
||||
HTTPClient client;
|
||||
client.begin(buff);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
if (!wait)
|
||||
{
|
||||
client.setTimeout(1000);
|
||||
@@ -65,6 +68,63 @@ void send_gcode(bool wait, const char *gcode)
|
||||
}
|
||||
}
|
||||
|
||||
int get_slicer_time_estimate_s()
|
||||
{
|
||||
if (printer.state == PRINTER_STATE_IDLE)
|
||||
return 0;
|
||||
|
||||
delay(10);
|
||||
|
||||
char buff[256] = {};
|
||||
sprintf(buff, "http://%s:%d/server/files/metadata?filename=%s", global_config.klipperHost, global_config.klipperPort, urlEncode(printer.print_filename).c_str());
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(buff);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.GET();
|
||||
|
||||
if (httpCode != 200)
|
||||
return 0;
|
||||
|
||||
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);
|
||||
return time_estimate_s;
|
||||
}
|
||||
|
||||
void move_printer(const char* axis, float amount, bool relative) {
|
||||
if (!printer.homed_axis || printer.state == PRINTER_STATE_PRINTING)
|
||||
return;
|
||||
|
||||
char gcode[64];
|
||||
const char* extra = (amount > 0) ? "+" : "";
|
||||
|
||||
bool absolute_coords = printer.absolute_coords;
|
||||
|
||||
if (absolute_coords && relative) {
|
||||
send_gcode(true, "G91");
|
||||
}
|
||||
else if (!absolute_coords && !relative) {
|
||||
send_gcode(true, "G90");
|
||||
}
|
||||
|
||||
sprintf(gcode, "G1 %s%s%.3f F6000", axis, extra, amount);
|
||||
send_gcode(true, gcode);
|
||||
|
||||
if (absolute_coords && relative) {
|
||||
send_gcode(true, "G90");
|
||||
}
|
||||
else if (!absolute_coords && !relative) {
|
||||
send_gcode(true, "G91");
|
||||
}
|
||||
}
|
||||
|
||||
int last_slicer_time_query = -15000;
|
||||
|
||||
void fetch_printer_data()
|
||||
{
|
||||
freeze_request_thread();
|
||||
@@ -73,6 +133,10 @@ void fetch_printer_data()
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(buff);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.GET();
|
||||
delay(10);
|
||||
if (httpCode == 200)
|
||||
@@ -122,6 +186,7 @@ void fetch_printer_data()
|
||||
printer.extruder_target_temp = status["extruder"]["target"];
|
||||
bool can_extrude = status["extruder"]["can_extrude"];
|
||||
printer.pressure_advance = status["extruder"]["pressure_advance"];
|
||||
printer.smooth_time = status["extruder"]["smooth_time"];
|
||||
printer.can_extrude = can_extrude == true;
|
||||
}
|
||||
|
||||
@@ -175,7 +240,11 @@ void fetch_printer_data()
|
||||
|
||||
const char *state = status["print_stats"]["state"];
|
||||
|
||||
if (strcmp(state, "printing") == 0)
|
||||
if (state == nullptr)
|
||||
{
|
||||
printer_state = PRINTER_STATE_ERROR;
|
||||
}
|
||||
else if (strcmp(state, "printing") == 0)
|
||||
{
|
||||
printer_state = PRINTER_STATE_PRINTING;
|
||||
}
|
||||
@@ -194,7 +263,36 @@ void fetch_printer_data()
|
||||
|
||||
if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0)
|
||||
{
|
||||
printer.remaining_time_s = (printer.elapsed_time_s / printer.print_progress) - printer.elapsed_time_s;
|
||||
float remaining_time_s_percentage = (printer.elapsed_time_s / printer.print_progress) - printer.elapsed_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;
|
||||
}
|
||||
|
||||
if (remaining_time_s_slicer <= 0 || global_config.remaining_time_calc_mode == REMAINING_TIME_CALC_PERCENTAGE)
|
||||
{
|
||||
printer.remaining_time_s = remaining_time_s_percentage;
|
||||
}
|
||||
else if (global_config.remaining_time_calc_mode == REMAINING_TIME_CALC_INTERPOLATED)
|
||||
{
|
||||
printer.remaining_time_s = remaining_time_s_percentage * printer.print_progress + remaining_time_s_slicer * (1 - printer.print_progress);
|
||||
}
|
||||
else if (global_config.remaining_time_calc_mode == REMAINING_TIME_CALC_SLICER)
|
||||
{
|
||||
printer.remaining_time_s = remaining_time_s_slicer;
|
||||
}
|
||||
}
|
||||
|
||||
if (printer.remaining_time_s < 0)
|
||||
{
|
||||
printer.remaining_time_s = 0;
|
||||
}
|
||||
|
||||
if (printer.state == PRINTER_STATE_IDLE)
|
||||
{
|
||||
printer.slicer_estimated_print_time_s = 0;
|
||||
}
|
||||
|
||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||
@@ -205,6 +303,13 @@ void fetch_printer_data()
|
||||
printer.state = printer_state;
|
||||
lv_msg_send(DATA_PRINTER_STATE, &printer);
|
||||
}
|
||||
|
||||
if (printer.state == PRINTER_STATE_PRINTING && millis() - last_slicer_time_query > 30000 && printer.slicer_estimated_print_time_s <= 0)
|
||||
{
|
||||
delay(10);
|
||||
last_slicer_time_query = millis();
|
||||
printer.slicer_estimated_print_time_s = get_slicer_time_estimate_s();
|
||||
}
|
||||
|
||||
unfreeze_render_thread();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ typedef struct _Printer {
|
||||
float elapsed_time_s;
|
||||
float remaining_time_s;
|
||||
float filament_used_mm;
|
||||
char* print_filename; // 0 -> 1
|
||||
float print_progress;
|
||||
char* print_filename;
|
||||
float print_progress; // 0 -> 1
|
||||
float fan_speed; // 0 -> 1
|
||||
float gcode_offset[3];
|
||||
float speed_mult;
|
||||
@@ -32,7 +32,9 @@ typedef struct _Printer {
|
||||
int total_layers;
|
||||
int current_layer;
|
||||
float pressure_advance;
|
||||
float smooth_time;
|
||||
int feedrate_mm_per_s;
|
||||
int slicer_estimated_print_time_s;
|
||||
} Printer;
|
||||
|
||||
extern Printer printer;
|
||||
@@ -45,6 +47,7 @@ extern int klipper_request_consecutive_fail_count;
|
||||
void data_loop();
|
||||
void data_setup();
|
||||
void send_gcode(bool wait, const char* gcode);
|
||||
void move_printer(const char* axis, float amount, bool relative);
|
||||
|
||||
void freeze_request_thread();
|
||||
void unfreeze_request_thread();
|
||||
@@ -25,71 +25,6 @@ static lv_color_t buf[CYD_SCREEN_HEIGHT_PX * CYD_SCREEN_WIDTH_PX / 10];
|
||||
|
||||
TFT_eSPI tft = TFT_eSPI();
|
||||
|
||||
TS_Point touchscreen_point()
|
||||
{
|
||||
TS_Point p = touchscreen.getPoint();
|
||||
p.x = round((p.x * global_config.screenCalXMult) + global_config.screenCalXOffset);
|
||||
p.y = round((p.y * global_config.screenCalYMult) + global_config.screenCalYOffset);
|
||||
return p;
|
||||
}
|
||||
|
||||
void touchscreen_calibrate(bool force)
|
||||
{
|
||||
if (global_config.screenCalibrated && !force)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setCursor(20, 140);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextSize(2);
|
||||
tft.println("Calibrate Screen");
|
||||
|
||||
TS_Point p;
|
||||
int16_t x1, y1, x2, y2;
|
||||
|
||||
while (touchscreen.touched())
|
||||
;
|
||||
tft.drawFastHLine(0, 10, 20, ILI9341_WHITE);
|
||||
tft.drawFastVLine(10, 0, 20, ILI9341_WHITE);
|
||||
while (!touchscreen.touched())
|
||||
;
|
||||
delay(50);
|
||||
p = touchscreen.getPoint();
|
||||
x1 = p.x;
|
||||
y1 = p.y;
|
||||
tft.drawFastHLine(0, 10, 20, ILI9341_BLACK);
|
||||
tft.drawFastVLine(10, 0, 20, ILI9341_BLACK);
|
||||
delay(500);
|
||||
|
||||
while (touchscreen.touched())
|
||||
;
|
||||
tft.drawFastHLine(300, 230, 20, ILI9341_WHITE);
|
||||
tft.drawFastVLine(310, 220, 20, ILI9341_WHITE);
|
||||
|
||||
while (!touchscreen.touched())
|
||||
;
|
||||
delay(50);
|
||||
p = touchscreen.getPoint();
|
||||
x2 = p.x;
|
||||
y2 = p.y;
|
||||
tft.drawFastHLine(300, 230, 20, ILI9341_BLACK);
|
||||
tft.drawFastVLine(310, 220, 20, ILI9341_BLACK);
|
||||
|
||||
int16_t xDist = 320 - 40;
|
||||
int16_t yDist = 240 - 40;
|
||||
|
||||
global_config.screenCalXMult = (float)xDist / (float)(x2 - x1);
|
||||
global_config.screenCalXOffset = 20.0 - ((float)x1 * global_config.screenCalXMult);
|
||||
|
||||
global_config.screenCalYMult = (float)yDist / (float)(y2 - y1);
|
||||
global_config.screenCalYOffset = 20.0 - ((float)y1 * global_config.screenCalYMult);
|
||||
|
||||
global_config.screenCalibrated = true;
|
||||
WriteGlobalConfig();
|
||||
}
|
||||
|
||||
void screen_setBrightness(byte brightness)
|
||||
{
|
||||
// calculate duty, 4095 from 2 ^ 12 - 1
|
||||
@@ -116,7 +51,7 @@ void screen_lv_touchRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
if (touchscreen.tirqTouched() && touchscreen.touched())
|
||||
{
|
||||
TS_Point p = touchscreen_point();
|
||||
TS_Point p = touchscreen.getPoint();
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
data->point.x = p.x;
|
||||
data->point.y = p.y;
|
||||
@@ -152,8 +87,6 @@ void screen_setup()
|
||||
touchscreen_spi.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
|
||||
touchscreen.begin(touchscreen_spi);
|
||||
|
||||
touchscreen_calibrate(false);
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf, buf, NULL, CYD_SCREEN_HEIGHT_PX * CYD_SCREEN_WIDTH_PX / 10);
|
||||
|
||||
/*Initialize the display*/
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
#include "lvgl.h"
|
||||
#include "../lv_setup.h"
|
||||
|
||||
void touchscreen_calibrate(bool force)
|
||||
{
|
||||
// TODO: Stubbed
|
||||
return;
|
||||
}
|
||||
typedef void (*lv_disp_drv_t_flush_cb)(_lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p);
|
||||
static lv_disp_drv_t_flush_cb original_screen_driver;
|
||||
|
||||
void screen_setBrightness(byte brightness)
|
||||
{
|
||||
@@ -19,13 +16,34 @@ void screen_setBrightness(byte brightness)
|
||||
}
|
||||
|
||||
void set_invert_display(){
|
||||
// Stubbed
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
}
|
||||
|
||||
void lv_screen_intercept(_lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
if (global_config.invertColors) {
|
||||
uint32_t w = (area->x2 - area->x1 + 1);
|
||||
uint32_t h = (area->y2 - area->y1 + 1);
|
||||
|
||||
for (int i = 0 ; i < w * h; i++){
|
||||
color_p[i].full ^= 0xFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
original_screen_driver(disp_drv, area, color_p);
|
||||
}
|
||||
|
||||
void screen_setup()
|
||||
{
|
||||
smartdisplay_init();
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
if (original_screen_driver == NULL){
|
||||
original_screen_driver = lv_disp_get_default()->driver->flush_cb;
|
||||
lv_disp_get_default()->driver->flush_cb = lv_screen_intercept;
|
||||
}
|
||||
#endif // CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
|
||||
lv_disp_set_rotation(lv_disp_get_default(), (global_config.rotateScreen) ? LV_DISP_ROT_270 : LV_DISP_ROT_90);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ FILESYSTEM_FILE* get_files(int limit){
|
||||
client.useHTTP10(true);
|
||||
client.setTimeout(5000);
|
||||
client.begin(buff);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.GET();
|
||||
auto timer_parse = millis();
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "lv_setup.h"
|
||||
#include "screen_driver.h"
|
||||
#include "../conf/global_config.h"
|
||||
#include "lvgl.h"
|
||||
#include "../ui/ui_utils.h"
|
||||
#include <Esp.h>
|
||||
|
||||
#ifndef CPU_FREQ_HIGH
|
||||
@@ -10,9 +12,133 @@
|
||||
#define CPU_FREQ_LOW 80
|
||||
#endif
|
||||
|
||||
bool isScreenInSleep = false;
|
||||
lv_timer_t *screenSleepTimer;
|
||||
static lv_style_t default_label_style;
|
||||
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;
|
||||
lv_timer_t *screen_sleep_timer;
|
||||
lv_coord_t point[2] = {0};
|
||||
|
||||
static lv_indev_drv_read_cb_t original_touch_driver = NULL;
|
||||
|
||||
void lv_touch_intercept_calibration(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
original_touch_driver(indev_driver, data);
|
||||
|
||||
if (data->state == LV_INDEV_STATE_PR){
|
||||
point[0] = data->point.x;
|
||||
point[1] = data->point.y;
|
||||
|
||||
while (data->state == LV_INDEV_STATE_PR){
|
||||
original_touch_driver(indev_driver, data);
|
||||
delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
void lv_touch_intercept(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
original_touch_driver(indev_driver, data);
|
||||
|
||||
if (data->state == LV_INDEV_STATE_PR) {
|
||||
if (is_screen_asleep()) {
|
||||
while (data->state == LV_INDEV_STATE_PR) {
|
||||
original_touch_driver(indev_driver, data);
|
||||
delay(20);
|
||||
}
|
||||
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
screen_timer_wake();
|
||||
#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
data->point.x = round((data->point.x * global_config.screenCalXMult) + global_config.screenCalXOffset);
|
||||
data->point.y = round((data->point.y * global_config.screenCalYMult) + global_config.screenCalYOffset);
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
}
|
||||
}
|
||||
|
||||
void lv_do_calibration(){
|
||||
if (global_config.screenCalibrated){
|
||||
return;
|
||||
}
|
||||
|
||||
lv_indev_t * display_driver = lv_indev_get_next(NULL);
|
||||
display_driver->driver->read_cb = lv_touch_intercept_calibration;
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Calibrate Screen");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t * line = lv_line_create(lv_scr_act());
|
||||
static lv_point_t line_points_x[] = { {0, 10}, {21, 10} };
|
||||
static lv_point_t line_points_y[] = { {10, 0}, {10, 21} };
|
||||
|
||||
lv_line_set_points(line, line_points_x, 2);
|
||||
lv_obj_align(line, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_obj_set_style_line_width(line, 1, 0);
|
||||
|
||||
lv_obj_t * line2 = lv_line_create(lv_scr_act());
|
||||
lv_line_set_points(line2, line_points_y, 2);
|
||||
lv_obj_align(line2, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_obj_set_style_line_width(line2, 1, 0);
|
||||
|
||||
while (true){
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
|
||||
if (point[0] != 0 && point[1] != 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_coord_t x1 = point[0];
|
||||
lv_coord_t y1 = point[1];
|
||||
point[0] = 0;
|
||||
point[1] = 0;
|
||||
|
||||
lv_obj_del(line);
|
||||
lv_obj_del(line2);
|
||||
|
||||
line = lv_line_create(lv_scr_act());
|
||||
lv_line_set_points(line, line_points_x, 2);
|
||||
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, 1, -10);
|
||||
lv_obj_set_style_line_width(line, 1, 0);
|
||||
|
||||
line = lv_line_create(lv_scr_act());
|
||||
lv_line_set_points(line, line_points_y, 2);
|
||||
lv_obj_align(line, LV_ALIGN_BOTTOM_RIGHT, -10, 1);
|
||||
|
||||
while (true){
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
|
||||
if (point[0] != 0 && point[1] != 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_coord_t x2 = point[0];
|
||||
lv_coord_t y2 = point[1];
|
||||
|
||||
int16_t xDist = CYD_SCREEN_WIDTH_PX - 20;
|
||||
int16_t yDist = CYD_SCREEN_HEIGHT_PX - 20;
|
||||
|
||||
global_config.screenCalXMult = (float)xDist / (float)(x2 - x1);
|
||||
global_config.screenCalXOffset = 10.0 - ((float)x1 * global_config.screenCalXMult);
|
||||
|
||||
global_config.screenCalYMult = (float)yDist / (float)(y2 - y1);
|
||||
global_config.screenCalYOffset = 10.0 - ((float)y1 * global_config.screenCalYMult);
|
||||
|
||||
global_config.screenCalibrated = true;
|
||||
WriteGlobalConfig();
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void set_screen_brightness()
|
||||
{
|
||||
@@ -25,13 +151,13 @@ void set_screen_brightness()
|
||||
void screen_timer_wake()
|
||||
{
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
lv_timer_reset(screenSleepTimer);
|
||||
lv_timer_reset(screen_sleep_timer);
|
||||
|
||||
if (!isScreenInSleep){
|
||||
if (!is_screen_in_sleep){
|
||||
return;
|
||||
}
|
||||
|
||||
isScreenInSleep = false;
|
||||
is_screen_in_sleep = false;
|
||||
set_screen_brightness();
|
||||
|
||||
// Reset cpu freq
|
||||
@@ -44,7 +170,7 @@ void screen_timer_sleep(lv_timer_t *timer)
|
||||
{
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
screen_setBrightness(0);
|
||||
isScreenInSleep = true;
|
||||
is_screen_in_sleep = true;
|
||||
|
||||
// Screen is off, no need to make the cpu run fast, the user won't notice ;)
|
||||
setCpuFrequencyMhz(CPU_FREQ_LOW);
|
||||
@@ -54,23 +180,23 @@ void screen_timer_sleep(lv_timer_t *timer)
|
||||
|
||||
void screen_timer_setup()
|
||||
{
|
||||
screenSleepTimer = lv_timer_create(screen_timer_sleep, global_config.screenTimeout * 1000 * 60, NULL);
|
||||
lv_timer_pause(screenSleepTimer);
|
||||
screen_sleep_timer = lv_timer_create(screen_timer_sleep, global_config.screenTimeout * 1000 * 60, NULL);
|
||||
lv_timer_pause(screen_sleep_timer);
|
||||
}
|
||||
|
||||
void screen_timer_start()
|
||||
{
|
||||
lv_timer_resume(screenSleepTimer);
|
||||
lv_timer_resume(screen_sleep_timer);
|
||||
}
|
||||
|
||||
void screen_timer_stop()
|
||||
{
|
||||
lv_timer_pause(screenSleepTimer);
|
||||
lv_timer_pause(screen_sleep_timer);
|
||||
}
|
||||
|
||||
void screen_timer_period(unsigned int period)
|
||||
{
|
||||
lv_timer_set_period(screenSleepTimer, period);
|
||||
lv_timer_set_period(screen_sleep_timer, period);
|
||||
}
|
||||
|
||||
void set_screen_timer_period()
|
||||
@@ -98,49 +224,28 @@ void set_color_scheme()
|
||||
lv_disp_set_theme(dispp, theme);
|
||||
}
|
||||
|
||||
static lv_indev_drv_read_cb_t original_driver = NULL;
|
||||
|
||||
void lv_touch_intercept(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
original_driver(indev_driver, data);
|
||||
|
||||
if (data->state == LV_INDEV_STATE_PR) {
|
||||
if (is_screen_asleep()) {
|
||||
while (data->state == LV_INDEV_STATE_PR) {
|
||||
original_driver(indev_driver, data);
|
||||
delay(20);
|
||||
}
|
||||
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
screen_timer_wake();
|
||||
}
|
||||
}
|
||||
|
||||
void lv_setup()
|
||||
{
|
||||
lv_style_init(&default_label_style);
|
||||
lv_style_set_text_font(&default_label_style, &CYD_SCREEN_FONT);
|
||||
lv_indev_t * display_driver = lv_indev_get_next(NULL);
|
||||
|
||||
if (original_touch_driver == NULL)
|
||||
{
|
||||
original_touch_driver = display_driver->driver->read_cb;
|
||||
}
|
||||
|
||||
set_color_scheme();
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
lv_do_calibration();
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
|
||||
display_driver->driver->read_cb = lv_touch_intercept;
|
||||
|
||||
screen_timer_setup();
|
||||
screen_timer_start();
|
||||
set_color_scheme();
|
||||
|
||||
if (original_driver != NULL)
|
||||
return;
|
||||
|
||||
lv_indev_t * display_driver = lv_indev_get_next(NULL);
|
||||
original_driver = display_driver->driver->read_cb;
|
||||
display_driver->driver->read_cb = lv_touch_intercept;
|
||||
}
|
||||
|
||||
bool is_screen_asleep()
|
||||
{
|
||||
return isScreenInSleep;
|
||||
}
|
||||
|
||||
lv_style_t * get_default_label_style()
|
||||
{
|
||||
return &default_label_style;
|
||||
return is_screen_in_sleep;
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
typedef void (*lv_indev_drv_read_cb_t)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
|
||||
void set_screen_brightness();
|
||||
void set_screen_timer_period();
|
||||
void screen_timer_wake();
|
||||
@@ -11,6 +7,4 @@ void screen_timer_start();
|
||||
void screen_timer_stop();
|
||||
void set_color_scheme();
|
||||
void lv_setup();
|
||||
bool is_screen_asleep();
|
||||
|
||||
lv_style_t * get_default_label_style();
|
||||
bool is_screen_asleep();
|
||||
@@ -18,6 +18,10 @@ static void _macros_query_internal(){
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(url.c_str());
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.GET();
|
||||
if (httpCode == 200){
|
||||
JsonDocument doc;
|
||||
@@ -42,23 +46,32 @@ static void _macros_query_internal(){
|
||||
}
|
||||
}
|
||||
|
||||
void power_devices_clear(){
|
||||
for (int i = 0; i < power_devices_count; i++){
|
||||
free(power_devices[i]);
|
||||
}
|
||||
|
||||
power_devices_count = 0;
|
||||
}
|
||||
|
||||
void _power_devices_query_internal(){
|
||||
String url = "http://" + String(global_config.klipperHost) + ":" + String(global_config.klipperPort) + "/machine/device_power/devices";
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.setTimeout(500);
|
||||
client.setConnectTimeout(1000);
|
||||
client.begin(url.c_str());
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.GET();
|
||||
if (httpCode == 200){
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, client.getStream());
|
||||
auto result = doc["result"]["devices"].as<JsonArray>();
|
||||
|
||||
for (int i = 0; i < power_devices_count; i++){
|
||||
free(power_devices[i]);
|
||||
}
|
||||
|
||||
power_devices_count = 0;
|
||||
power_devices_clear();
|
||||
|
||||
for (auto i : result){
|
||||
const char * device_name = i["device"];
|
||||
@@ -85,6 +98,10 @@ bool set_power_state(const char* device_name, bool state) {
|
||||
HTTPClient client;
|
||||
client.useHTTP10(true);
|
||||
client.begin(url.c_str());
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
if (client.POST("") != 200)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -15,4 +15,5 @@ MACROSQUERY macros_query();
|
||||
POWERQUERY power_devices_query();
|
||||
void macros_query_setup();
|
||||
bool set_power_state(const char* device_name, bool state);
|
||||
void _power_devices_query_internal();
|
||||
void _power_devices_query_internal();
|
||||
void power_devices_clear();
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
// Adapted from https://github.com/xperiments-in/xtouch/blob/main/src/devices/2.8/screen.h
|
||||
|
||||
void touchscreen_calibrate(bool force = false);
|
||||
void screen_setBrightness(unsigned char brightness);
|
||||
void screen_setup();
|
||||
void set_invert_display();
|
||||
230
CYD-Klipper/src/lib/ESP32OTAPull.h
Normal file
230
CYD-Klipper/src/lib/ESP32OTAPull.h
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
ESP32-OTA-Pull - a library for doing "pull" based OTA ("Over The Air") firmware
|
||||
updates, where the image updates are posted on the web.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022-3 Mikal Hart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <Update.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
class ESP32OTAPull
|
||||
{
|
||||
public:
|
||||
enum ActionType { DONT_DO_UPDATE, UPDATE_BUT_NO_BOOT, UPDATE_AND_BOOT };
|
||||
|
||||
// Return codes from CheckForOTAUpdate
|
||||
enum ErrorCode { UPDATE_AVAILABLE = -3, NO_UPDATE_PROFILE_FOUND = -2, NO_UPDATE_AVAILABLE = -1, UPDATE_OK = 0, HTTP_FAILED = 1, WRITE_ERROR = 2, JSON_PROBLEM = 3, OTA_UPDATE_FAIL = 4 };
|
||||
|
||||
private:
|
||||
void (*Callback)(int offset, int totallength) = NULL;
|
||||
ActionType Action = UPDATE_AND_BOOT;
|
||||
String Board = ARDUINO_BOARD;
|
||||
String Device = "";
|
||||
String Config = "";
|
||||
String CVersion = "";
|
||||
bool DowngradesAllowed = false;
|
||||
|
||||
int DownloadJson(const char* URL, String& payload)
|
||||
{
|
||||
HTTPClient http;
|
||||
http.begin(URL);
|
||||
|
||||
// Send HTTP GET request
|
||||
int httpResponseCode = http.GET();
|
||||
|
||||
if (httpResponseCode == 200)
|
||||
{
|
||||
payload = http.getString();
|
||||
}
|
||||
|
||||
// Free resources
|
||||
http.end();
|
||||
return httpResponseCode;
|
||||
}
|
||||
|
||||
int DoOTAUpdate(const char* URL, ActionType Action)
|
||||
{
|
||||
HTTPClient http;
|
||||
http.begin(URL);
|
||||
|
||||
// Send HTTP GET request
|
||||
int httpResponseCode = http.GET();
|
||||
|
||||
if (httpResponseCode == 200)
|
||||
{
|
||||
int totalLength = http.getSize();
|
||||
|
||||
// this is required to start firmware update process
|
||||
if (!Update.begin(UPDATE_SIZE_UNKNOWN))
|
||||
return OTA_UPDATE_FAIL;
|
||||
|
||||
// create buffer for read
|
||||
uint8_t buff[1280] = { 0 };
|
||||
|
||||
// get tcp stream
|
||||
WiFiClient* stream = http.getStreamPtr();
|
||||
|
||||
// read all data from server
|
||||
int offset = 0;
|
||||
while (http.connected() && offset < totalLength)
|
||||
{
|
||||
size_t sizeAvail = stream->available();
|
||||
if (sizeAvail > 0)
|
||||
{
|
||||
size_t bytes_to_read = min(sizeAvail, sizeof(buff));
|
||||
size_t bytes_read = stream->readBytes(buff, bytes_to_read);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
offset += bytes_written;
|
||||
if (Callback != NULL)
|
||||
Callback(offset, totalLength);
|
||||
}
|
||||
}
|
||||
|
||||
if (offset == totalLength)
|
||||
{
|
||||
Update.end(true);
|
||||
delay(1000);
|
||||
|
||||
// Restart ESP32 to see changes
|
||||
if (Action == UPDATE_BUT_NO_BOOT)
|
||||
return UPDATE_OK;
|
||||
ESP.restart();
|
||||
}
|
||||
return WRITE_ERROR;
|
||||
}
|
||||
|
||||
http.end();
|
||||
return httpResponseCode;
|
||||
}
|
||||
|
||||
public:
|
||||
/// @brief Return the version string of the binary, as reported by the JSON
|
||||
/// @return The firmware version
|
||||
String GetVersion()
|
||||
{
|
||||
return CVersion;
|
||||
}
|
||||
|
||||
/// @brief Override the default "Device" id (MAC Address)
|
||||
/// @param device A string identifying the particular device (instance) (typically e.g., a MAC address)
|
||||
/// @return The current ESP32OTAPull object for chaining
|
||||
ESP32OTAPull &OverrideDevice(const char *device)
|
||||
{
|
||||
Device = device;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Override the default "Board" value of ARDUINO_BOARD
|
||||
/// @param board A string identifying the board (class) being targeted
|
||||
/// @return The current ESP32OTAPull object for chaining
|
||||
ESP32OTAPull &OverrideBoard(const char *board)
|
||||
{
|
||||
Board = board;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Specify a configuration string that must match any "Config" in JSON
|
||||
/// @param config An arbitrary string showing the current configuration
|
||||
/// @return The current ESP32OTAPull object for chaining
|
||||
ESP32OTAPull &SetConfig(const char *config)
|
||||
{
|
||||
Config = config;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Specify whether downgrades (posted version is lower) are allowed
|
||||
/// @param allow_downgrades true if downgrades are allowed
|
||||
/// @return The current ESP32OTAPull object for chaining
|
||||
ESP32OTAPull &AllowDowngrades(bool allow_downgrades)
|
||||
{
|
||||
DowngradesAllowed = allow_downgrades;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Specify a callback function to monitor update progress
|
||||
/// @param callback Pointer to a function that is called repeatedly during update
|
||||
/// @return The current ESP32OTAPull object for chaining
|
||||
ESP32OTAPull &SetCallback(void (*callback)(int offset, int totallength))
|
||||
{
|
||||
Callback = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief The main entry point for OTA Update
|
||||
/// @param JSON_URL The URL for the JSON filter file
|
||||
/// @param CurrentVersion The version # of the current (i.e. to be replaced) sketch
|
||||
/// @param ActionType The action to be performed. May be any of DONT_DO_UPDATE, UPDATE_BUT_NO_BOOT, UPDATE_AND_BOOT (default)
|
||||
/// @return ErrorCode or HTTP failure code (see enum above)
|
||||
int CheckForOTAUpdate(const char* JSON_URL, const char *CurrentVersion, ActionType Action = UPDATE_AND_BOOT)
|
||||
{
|
||||
CurrentVersion = CurrentVersion == NULL ? "" : CurrentVersion;
|
||||
|
||||
// Downloading OTA Json...
|
||||
String Payload;
|
||||
int httpResponseCode = DownloadJson(JSON_URL, Payload);
|
||||
if (httpResponseCode != 200)
|
||||
return httpResponseCode > 0 ? httpResponseCode : HTTP_FAILED;
|
||||
|
||||
// Deserialize the JSON file downloaded from user's site
|
||||
JsonDocument doc;
|
||||
DeserializationError deserialization = deserializeJson(doc, Payload.c_str());
|
||||
if (deserialization != DeserializationError::Ok)
|
||||
return JSON_PROBLEM;
|
||||
|
||||
String DeviceName = Device.isEmpty() ? WiFi.macAddress() : Device;
|
||||
String BoardName = Board.isEmpty() ? ARDUINO_BOARD : Board;
|
||||
String ConfigName = Config.isEmpty() ? "" : Config;
|
||||
bool foundProfile = false;
|
||||
|
||||
// Step through the configurations looking for a match
|
||||
for (auto config : doc["Configurations"].as<JsonArray>())
|
||||
{
|
||||
String CBoard = config["Board"].isNull() ? "" : (const char *)config["Board"];
|
||||
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());
|
||||
if ((CBoard.isEmpty() || CBoard == BoardName) &&
|
||||
(CDevice.isEmpty() || CDevice == DeviceName) &&
|
||||
(CConfig.isEmpty() || CConfig == ConfigName))
|
||||
{
|
||||
if (CVersion.isEmpty() || CVersion > String(CurrentVersion) ||
|
||||
(DowngradesAllowed && CVersion != String(CurrentVersion)))
|
||||
return Action == DONT_DO_UPDATE ? UPDATE_AVAILABLE : DoOTAUpdate(config["URL"], Action);
|
||||
foundProfile = true;
|
||||
}
|
||||
}
|
||||
return foundProfile ? NO_UPDATE_AVAILABLE : NO_UPDATE_PROFILE_FOUND;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "ui/nav_buttons.h"
|
||||
#include <Esp.h>
|
||||
#include "core/lv_setup.h"
|
||||
#include "ui/ota_setup.h"
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@@ -18,6 +19,7 @@ void setup() {
|
||||
Serial.println("Screen init done");
|
||||
|
||||
wifi_init();
|
||||
ota_init();
|
||||
ip_init();
|
||||
data_setup();
|
||||
|
||||
@@ -31,4 +33,9 @@ void loop(){
|
||||
data_loop();
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
|
||||
if (is_ready_for_ota_update())
|
||||
{
|
||||
ota_do_update();
|
||||
}
|
||||
}
|
||||
@@ -29,20 +29,35 @@ static const lv_btnmatrix_ctrl_t kb_ctrl[] = {
|
||||
|
||||
void ip_init_inner();
|
||||
|
||||
bool verify_ip(){
|
||||
enum connection_status_t {
|
||||
CONNECT_FAIL = 0,
|
||||
CONNECT_OK = 1,
|
||||
CONNECT_AUTH_REQUIRED = 2,
|
||||
};
|
||||
|
||||
connection_status_t verify_ip(){
|
||||
HTTPClient client;
|
||||
String url = "http://" + String(global_config.klipperHost) + ":" + String(global_config.klipperPort) + "/printer/info";
|
||||
int httpCode;
|
||||
try {
|
||||
Serial.println(url);
|
||||
client.setTimeout(500);
|
||||
client.setConnectTimeout(1000);
|
||||
client.begin(url.c_str());
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
httpCode = client.GET();
|
||||
return httpCode == 200;
|
||||
Serial.printf("%d %s\n", httpCode, url.c_str());
|
||||
|
||||
if (httpCode == 401)
|
||||
return CONNECT_AUTH_REQUIRED;
|
||||
|
||||
return httpCode == 200 ? CONNECT_OK : CONNECT_FAIL;
|
||||
}
|
||||
catch (...) {
|
||||
Serial.println("Failed to connect");
|
||||
return false;
|
||||
return CONNECT_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,12 +79,19 @@ static void ta_event_cb(lv_event_t * e) {
|
||||
strcpy(global_config.klipperHost, lv_textarea_get_text(hostEntry));
|
||||
global_config.klipperPort = atoi(lv_textarea_get_text(portEntry));
|
||||
|
||||
if (verify_ip())
|
||||
connection_status_t status = verify_ip();
|
||||
if (status == CONNECT_OK)
|
||||
{
|
||||
global_config.ipConfigured = true;
|
||||
WriteGlobalConfig();
|
||||
connect_ok = true;
|
||||
}
|
||||
else if (status == CONNECT_AUTH_REQUIRED)
|
||||
{
|
||||
label = NULL;
|
||||
global_config.ipConfigured = true;
|
||||
WriteGlobalConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text(label, "Failed to connect");
|
||||
@@ -110,7 +132,7 @@ static void power_devices_button(lv_event_t * e) {
|
||||
lv_obj_set_size(button, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(button, destroy_event_user_data, LV_EVENT_CLICKED, panel);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(button);
|
||||
lv_obj_t * label = lv_label_create(button);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE " Close");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -120,7 +142,7 @@ static void power_devices_button(lv_event_t * e) {
|
||||
void redraw_connect_screen(){
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
label = lv_label_create_ex(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);
|
||||
|
||||
@@ -133,7 +155,7 @@ void redraw_connect_screen(){
|
||||
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_ex(reset_btn);
|
||||
lv_obj_t * btn_label = lv_label_create(reset_btn);
|
||||
lv_label_set_text(btn_label, "Reset");
|
||||
lv_obj_center(btn_label);
|
||||
|
||||
@@ -142,12 +164,83 @@ void redraw_connect_screen(){
|
||||
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_ex(power_devices_btn);
|
||||
btn_label = lv_label_create(power_devices_btn);
|
||||
lv_label_set_text(btn_label, "Power Devices");
|
||||
lv_obj_center(btn_label);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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_READY)
|
||||
{
|
||||
const char * txt = lv_textarea_get_text(ta);
|
||||
int len = strlen(txt);
|
||||
if (len > 0)
|
||||
{
|
||||
global_config.auth_configured = true;
|
||||
strcpy(global_config.klipper_auth, txt);
|
||||
WriteGlobalConfig();
|
||||
auth_entry_done = true;
|
||||
}
|
||||
}
|
||||
else if (code == LV_EVENT_CANCEL)
|
||||
{
|
||||
auth_entry_done = true;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_auth_entry(){
|
||||
auth_entry_done = false;
|
||||
global_config.klipper_auth[32] = 0;
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
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);
|
||||
|
||||
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(top_root);
|
||||
lv_label_set_text(label, "Enter API Key");
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
|
||||
lv_obj_t * keyboard = lv_keyboard_create(root);
|
||||
lv_obj_t * passEntry = lv_textarea_create(top_root);
|
||||
lv_textarea_set_max_length(passEntry, 32);
|
||||
lv_textarea_set_one_line(passEntry, true);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
lv_textarea_set_text(passEntry, global_config.klipper_auth);
|
||||
else
|
||||
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, 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 (global_config.ipConfigured) {
|
||||
redraw_connect_screen();
|
||||
@@ -166,7 +259,7 @@ void ip_init_inner(){
|
||||
lv_obj_set_flex_grow(top_root, 1);
|
||||
lv_obj_set_style_pad_all(top_root, CYD_SCREEN_GAP_PX, 0);
|
||||
|
||||
label = lv_label_create_ex(top_root);
|
||||
label = lv_label_create(top_root);
|
||||
lv_label_set_text(label, "Enter Klipper IP/Hostname and Port");
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
|
||||
@@ -203,6 +296,7 @@ int retry_count = 0;
|
||||
void ip_init(){
|
||||
connect_ok = false;
|
||||
retry_count = 0;
|
||||
int prev_power_device_count = 0;
|
||||
|
||||
ip_init_inner();
|
||||
|
||||
@@ -212,15 +306,25 @@ void ip_init(){
|
||||
lv_task_handler();
|
||||
|
||||
if (!connect_ok && global_config.ipConfigured && (millis() - last_data_update_ip) > data_update_interval_ip){
|
||||
connect_ok = verify_ip();
|
||||
connection_status_t status = verify_ip();
|
||||
|
||||
connect_ok = status == CONNECT_OK;
|
||||
last_data_update_ip = millis();
|
||||
retry_count++;
|
||||
String retry_count_text = "Connecting to Klipper (Try " + String(retry_count + 1) + ")";
|
||||
lv_label_set_text(label, retry_count_text.c_str());
|
||||
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());
|
||||
}
|
||||
|
||||
_power_devices_query_internal();
|
||||
if (power_devices_query().count >= 1)
|
||||
if (status != CONNECT_AUTH_REQUIRED)
|
||||
_power_devices_query_internal();
|
||||
else
|
||||
handle_auth_entry();
|
||||
|
||||
if (power_devices_query().count != prev_power_device_count) {
|
||||
prev_power_device_count = power_devices_query().count;
|
||||
redraw_connect_screen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,6 +332,7 @@ void ip_init(){
|
||||
void ip_ok(){
|
||||
if (klipper_request_consecutive_fail_count > 5){
|
||||
freeze_request_thread();
|
||||
power_devices_clear();
|
||||
ip_init();
|
||||
unfreeze_request_thread();
|
||||
klipper_request_consecutive_fail_count = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@ void error_ui_macros_open(lv_event_t * e){
|
||||
lv_obj_set_size(button, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(button, destroy_event_user_data, LV_EVENT_CLICKED, panel);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(button);
|
||||
lv_obj_t * label = lv_label_create(button);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE " Close");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -49,10 +49,10 @@ void error_ui(){
|
||||
lv_obj_set_flex_align(panel, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create_ex(panel);
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, LV_SYMBOL_WARNING " Printer is not ready");
|
||||
|
||||
label = lv_label_create_ex(panel);
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, printer.state_message);
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_clear_flag(label, LV_OBJ_FLAG_SCROLLABLE);
|
||||
@@ -67,7 +67,7 @@ void error_ui(){
|
||||
lv_obj_add_event_cb(btn, btn_click_restart, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Restart");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -76,7 +76,7 @@ void error_ui(){
|
||||
lv_obj_add_event_cb(btn, btn_click_firmware_restart, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "FW Restart");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -86,7 +86,7 @@ void error_ui(){
|
||||
lv_obj_add_event_cb(btn, error_ui_macros_open, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Devices");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include "panels/panel.h"
|
||||
#include "../core/data_setup.h"
|
||||
#include "nav_buttons.h"
|
||||
#include <HTTPClient.h>
|
||||
#include "ui_utils.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static lv_style_t nav_button_style;
|
||||
|
||||
@@ -84,7 +84,7 @@ void create_button(const char* icon, const char* name, lv_event_cb_t button_clic
|
||||
if (button_click != NULL)
|
||||
lv_obj_add_event_cb(btn, button_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lv_obj_t* label = lv_label_create_ex(btn);
|
||||
lv_obj_t* label = lv_label_create(btn);
|
||||
lv_label_set_text(label, icon);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, -1 * CYD_SCREEN_GAP_PX);
|
||||
|
||||
@@ -137,6 +137,9 @@ void nav_buttons_setup(unsigned char active_panel){
|
||||
case 4:
|
||||
macros_panel_init(panel);
|
||||
break;
|
||||
case 5:
|
||||
stats_panel_init(panel);
|
||||
break;
|
||||
}
|
||||
|
||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||
|
||||
103
CYD-Klipper/src/ui/ota_setup.cpp
Normal file
103
CYD-Klipper/src/ui/ota_setup.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "../lib/ESP32OTAPull.h"
|
||||
#include "lvgl.h"
|
||||
#include "ui_utils.h"
|
||||
#include "../core/lv_setup.h"
|
||||
#include "../core/data_setup.h"
|
||||
#include "../conf/global_config.h"
|
||||
#include "ota_setup.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
|
||||
ESP32OTAPull ota_pull;
|
||||
static bool update_available;
|
||||
static bool ready_for_ota_update = false;
|
||||
|
||||
String ota_new_version_name()
|
||||
{
|
||||
return ota_pull.GetVersion();
|
||||
}
|
||||
|
||||
bool ota_has_update()
|
||||
{
|
||||
return update_available;
|
||||
}
|
||||
|
||||
static int last_callback_time = 0;
|
||||
lv_obj_t *percentage_bar;
|
||||
lv_obj_t *update_label;
|
||||
void do_update_callback(int offset, int totallength)
|
||||
{
|
||||
int now = millis();
|
||||
if (now - last_callback_time < 1000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
last_callback_time = now;
|
||||
|
||||
float percentage = (float)offset / (float)totallength; // 0 -> 1
|
||||
lv_bar_set_value(percentage_bar, percentage * 100, LV_ANIM_OFF);
|
||||
lv_label_set_text_fmt(update_label, "%d/%d bytes", offset, totallength);
|
||||
|
||||
lv_refr_now(NULL);
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
}
|
||||
|
||||
void ota_do_update(bool variant_automatic)
|
||||
{
|
||||
Serial.println("Starting OTA Update");
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t *panel = lv_create_empty_panel(lv_scr_act());
|
||||
lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
lv_obj_align(panel, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_layout_flex_column(panel, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t *label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "Updating OTA...");
|
||||
|
||||
percentage_bar = lv_bar_create(panel);
|
||||
lv_obj_set_size(percentage_bar, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * 0.75f);
|
||||
|
||||
update_label = lv_label_create(panel);
|
||||
lv_label_set_text(update_label, "0/0");
|
||||
|
||||
if (!variant_automatic) {
|
||||
Serial.println("Freezing Background Tasks");
|
||||
screen_timer_wake();
|
||||
screen_timer_stop();
|
||||
freeze_request_thread();
|
||||
}
|
||||
|
||||
lv_refr_now(NULL);
|
||||
lv_timer_handler();
|
||||
lv_task_handler();
|
||||
|
||||
ota_pull.SetCallback(do_update_callback);
|
||||
ota_pull.CheckForOTAUpdate(ota_url, REPO_VERSION, ESP32OTAPull::ActionType::UPDATE_AND_BOOT);
|
||||
}
|
||||
|
||||
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);
|
||||
update_available = result == ESP32OTAPull::UPDATE_AVAILABLE;
|
||||
|
||||
if (global_config.autoOtaUpdate && update_available)
|
||||
{
|
||||
ota_do_update(true);
|
||||
}
|
||||
}
|
||||
|
||||
void set_ready_for_ota_update()
|
||||
{
|
||||
ready_for_ota_update = true;
|
||||
}
|
||||
|
||||
bool is_ready_for_ota_update()
|
||||
{
|
||||
return ready_for_ota_update;
|
||||
}
|
||||
|
||||
8
CYD-Klipper/src/ui/ota_setup.h
Normal file
8
CYD-Klipper/src/ui/ota_setup.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
String ota_new_version_name();
|
||||
bool ota_has_update();
|
||||
void ota_do_update(bool variant_automatic = false);
|
||||
void ota_init();
|
||||
void set_ready_for_ota_update();
|
||||
bool is_ready_for_ota_update();
|
||||
@@ -28,7 +28,7 @@ void macros_panel_add_macros_to_panel(lv_obj_t * root_panel, MACROSQUERY query){
|
||||
lv_layout_flex_row(panel, LV_FLEX_ALIGN_END);
|
||||
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(panel);
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, macro);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_obj_set_flex_grow(label, 1);
|
||||
@@ -37,7 +37,7 @@ void macros_panel_add_macros_to_panel(lv_obj_t * root_panel, MACROSQUERY query){
|
||||
lv_obj_add_event_cb(btn, btn_press, LV_EVENT_CLICKED, (void*)macro);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Run");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -66,7 +66,7 @@ void macros_panel_add_power_devices_to_panel(lv_obj_t * root_panel, POWERQUERY q
|
||||
lv_layout_flex_row(panel, LV_FLEX_ALIGN_END);
|
||||
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(panel);
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, power_device_name);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_obj_set_flex_grow(label, 1);
|
||||
@@ -90,20 +90,21 @@ void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_GAP_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(btn);
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS " Screen Settings");
|
||||
lv_obj_center(label);
|
||||
|
||||
MACROSQUERY query = macros_query();
|
||||
POWERQUERY power = power_devices_query();
|
||||
if (query.count == 0 && power.count == 0){
|
||||
label = lv_label_create_ex(panel);
|
||||
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);
|
||||
lv_obj_set_size(root_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_MIN_BUTTON_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_align(root_panel, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX + CYD_SCREEN_GAP_PX * 2);
|
||||
lv_layout_flex_column(root_panel);
|
||||
|
||||
@@ -1,48 +1,28 @@
|
||||
#include "lvgl.h"
|
||||
#include "panel.h"
|
||||
#include "../../core/data_setup.h"
|
||||
#include "../nav_buttons.h"
|
||||
#include "../ui_utils.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static bool last_homing_state = false;
|
||||
|
||||
static void move_printer(const char* axis, float amount) {
|
||||
if (!printer.homed_axis || printer.state == PRINTER_STATE_PRINTING)
|
||||
return;
|
||||
|
||||
char gcode[64];
|
||||
const char* extra = (amount > 0) ? "+" : "";
|
||||
|
||||
bool absolute_coords = printer.absolute_coords;
|
||||
|
||||
if (absolute_coords) {
|
||||
send_gcode(true, "G91");
|
||||
}
|
||||
|
||||
sprintf(gcode, "G1 %s%s%.1f F6000", axis, extra, amount);
|
||||
send_gcode(true, gcode);
|
||||
|
||||
if (absolute_coords) {
|
||||
send_gcode(true, "G90");
|
||||
}
|
||||
}
|
||||
|
||||
static void x_line_button_press(lv_event_t * e) {
|
||||
float* data_pointer = (float*)lv_event_get_user_data(e);
|
||||
float data = *data_pointer;
|
||||
move_printer("X", data);
|
||||
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);
|
||||
float data = *data_pointer;
|
||||
move_printer("Y", data);
|
||||
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);
|
||||
float data = *data_pointer;
|
||||
move_printer("Z", data);
|
||||
move_printer("Z", data, true);
|
||||
}
|
||||
|
||||
char x_pos_buff[12];
|
||||
@@ -103,6 +83,11 @@ static void disable_steppers_click(lv_event_t * e) {
|
||||
send_gcode(true, "M18");
|
||||
}
|
||||
|
||||
static void switch_to_stat_panel(lv_event_t * e) {
|
||||
lv_obj_t * panel = lv_event_get_target(e);
|
||||
nav_buttons_setup(5);
|
||||
}
|
||||
|
||||
inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
const auto width = CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2;
|
||||
|
||||
@@ -120,8 +105,8 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_add_event_cb(btn, home_button_click, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_HOME "Home Axis");
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_HOME "Home");
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(home_button_row);
|
||||
@@ -129,12 +114,21 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_add_event_cb(btn, disable_steppers_click, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Disable Step");
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EYE_CLOSE " Unlock");
|
||||
lv_obj_center(label);
|
||||
|
||||
btn = lv_btn_create(home_button_row);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(btn, switch_to_stat_panel, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_EDIT " Params");
|
||||
lv_obj_center(label);
|
||||
|
||||
for (int row = 0; row < 3; row++) {
|
||||
label = lv_label_create_ex(panel);
|
||||
label = lv_label_create(panel);
|
||||
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);
|
||||
@@ -151,7 +145,7 @@ inline void root_panel_steppers_locked(lv_obj_t * root_panel){
|
||||
lv_obj_add_event_cb(btn, button_callbacks[row], LV_EVENT_CLICKED, (void*)(offsets[row] + col));
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, offset_labels[row][col]);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
@@ -165,14 +159,14 @@ inline void root_panel_steppers_unlocked(lv_obj_t * root_panel){
|
||||
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_ex(panel);
|
||||
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_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_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_HOME "Home Axis");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,10 @@ static void btn_print_file(lv_event_t * e){
|
||||
|
||||
HTTPClient client;
|
||||
client.begin(buff);
|
||||
|
||||
if (global_config.auth_configured)
|
||||
client.addHeader("X-Api-Key", global_config.klipper_auth);
|
||||
|
||||
int httpCode = client.POST("");
|
||||
Serial.printf("Print start: HTTP %d\n", httpCode);
|
||||
}
|
||||
@@ -52,11 +56,11 @@ static void btn_print_file_verify(lv_event_t * e){
|
||||
lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 4, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_GAP_PX * 3);
|
||||
lv_obj_align(panel, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(panel);
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "Print File");
|
||||
lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
|
||||
label = lv_label_create_ex(panel);
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, selected_file->name);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, -20);
|
||||
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 10);
|
||||
@@ -67,7 +71,7 @@ static void btn_print_file_verify(lv_event_t * e){
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * button_size_mult, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * button_size_mult);
|
||||
lv_obj_add_event_cb(btn, destroy_event_user_data, LV_EVENT_CLICKED, panel);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE);
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -76,7 +80,7 @@ static void btn_print_file_verify(lv_event_t * e){
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * button_size_mult, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * button_size_mult);
|
||||
lv_obj_add_event_cb(btn, btn_print_file, LV_EVENT_CLICKED, panel);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_OK);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
@@ -98,7 +102,6 @@ void print_panel_init(lv_obj_t* panel){
|
||||
int count = 0;
|
||||
while (files != NULL && files->name != NULL && count <= 20){
|
||||
lv_obj_t * btn = lv_list_add_btn(list, LV_SYMBOL_FILE, files->name);
|
||||
lv_obj_add_style(btn, get_default_label_style(), 0);
|
||||
lv_obj_set_style_bg_opa(btn, LV_OPA_TRANSP, 0);
|
||||
lv_obj_add_event_cb(btn, btn_print_file_verify, LV_EVENT_CLICKED, (void*)files);
|
||||
|
||||
@@ -108,7 +111,7 @@ void print_panel_init(lv_obj_t* panel){
|
||||
|
||||
if (count <= 0){
|
||||
lv_obj_del(list);
|
||||
lv_obj_t * label = lv_label_create_ex(panel);
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "Failed to read files.");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
lv_layout_flex_column(center_panel);
|
||||
|
||||
// Filename
|
||||
lv_obj_t * label = lv_label_create_ex(center_panel);
|
||||
lv_obj_t * label = lv_label_create(center_panel);
|
||||
lv_label_set_text(label, printer.print_filename);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_obj_set_width(label, panel_width);
|
||||
@@ -73,21 +73,21 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
lv_obj_set_size(time_est_panel, panel_width, LV_SIZE_CONTENT);
|
||||
|
||||
// Elapsed Time
|
||||
label = lv_label_create_ex(time_est_panel);
|
||||
label = lv_label_create(time_est_panel);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(label, update_printer_data_elapsed_time, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_DATA, label, NULL);
|
||||
|
||||
// Remaining Time
|
||||
label = lv_label_create_ex(time_est_panel);
|
||||
label = lv_label_create(time_est_panel);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_align(label, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(label, update_printer_data_remaining_time, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subsribe_obj(DATA_PRINTER_DATA, label, NULL);
|
||||
|
||||
// Percentage
|
||||
label = lv_label_create_ex(time_est_panel);
|
||||
label = lv_label_create(time_est_panel);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(label, update_printer_data_percentage, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
@@ -99,7 +99,7 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * button_size_mult, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * button_size_mult);
|
||||
lv_obj_add_event_cb(btn, btn_click_stop, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_STOP);
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -108,7 +108,7 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, btn_click_resume, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_PLAY);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void progress_panel_init(lv_obj_t* panel){
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, btn_click_pause, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_PAUSE);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "../ui_utils.h"
|
||||
#include <Esp.h>
|
||||
#include "../../core/lv_setup.h"
|
||||
#include "../ota_setup.h"
|
||||
|
||||
#ifndef REPO_VERSION
|
||||
#define REPO_VERSION "Unknown"
|
||||
@@ -28,6 +29,7 @@ static void reset_calibration_click(lv_event_t * e){
|
||||
static void reset_wifi_click(lv_event_t * e){
|
||||
global_config.wifiConfigured = false;
|
||||
global_config.ipConfigured = false;
|
||||
global_config.auth_configured = false;
|
||||
WriteGlobalConfig();
|
||||
ESP.restart();
|
||||
}
|
||||
@@ -87,13 +89,32 @@ static void on_during_print_switch(lv_event_t* e){
|
||||
WriteGlobalConfig();
|
||||
}
|
||||
|
||||
static void btn_ota_do_update(lv_event_t * e){
|
||||
set_ready_for_ota_update();
|
||||
}
|
||||
|
||||
static void auto_ota_update_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.autoOtaUpdate = checked;
|
||||
WriteGlobalConfig();
|
||||
}
|
||||
|
||||
const char* estimated_time_options = "Percentage\nInterpolated\nSlicer";
|
||||
|
||||
static void estimated_time_dropdown(lv_event_t * e){
|
||||
lv_obj_t * dropdown = lv_event_get_target(e);
|
||||
global_config.remaining_time_calc_mode = lv_dropdown_get_selected(dropdown);
|
||||
WriteGlobalConfig();
|
||||
}
|
||||
|
||||
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 create_settings_widget(const char* label_text, lv_obj_t* object, lv_obj_t* root_panel, bool set_height = true){
|
||||
lv_obj_t * panel = lv_create_empty_panel(root_panel);
|
||||
lv_obj_set_size(panel, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(panel);
|
||||
lv_obj_t * label = lv_label_create(panel);
|
||||
lv_label_set_text(label, label_text);
|
||||
lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
|
||||
@@ -110,13 +131,19 @@ void create_settings_widget(const char* label_text, lv_obj_t* object, lv_obj_t*
|
||||
}
|
||||
|
||||
void settings_panel_init(lv_obj_t* panel){
|
||||
lv_obj_t * toggle = NULL;
|
||||
lv_obj_t * btn = NULL;
|
||||
lv_obj_t * label = NULL;
|
||||
lv_obj_t * dropdown = NULL;
|
||||
|
||||
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);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(panel);
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, reset_wifi_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Restart");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -126,14 +153,15 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, reset_calibration_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Restart");
|
||||
lv_obj_center(label);
|
||||
|
||||
create_settings_widget("Calibrate Touch", btn, panel);
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
|
||||
lv_obj_t * toggle = lv_switch_create(panel);
|
||||
#ifndef CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
toggle = lv_switch_create(panel);
|
||||
lv_obj_set_width(toggle, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2);
|
||||
lv_obj_add_event_cb(toggle, invert_color_switch, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
@@ -141,7 +169,7 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
lv_obj_add_state(toggle, LV_STATE_CHECKED);
|
||||
|
||||
create_settings_widget("Invert Colors", toggle, panel);
|
||||
|
||||
#endif // CYD_SCREEN_DISABLE_INVERT_COLORS
|
||||
|
||||
toggle = lv_switch_create(panel);
|
||||
lv_obj_set_width(toggle, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2);
|
||||
@@ -152,17 +180,15 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
|
||||
create_settings_widget("Light Mode", toggle, panel);
|
||||
|
||||
lv_obj_t * dropdown = lv_dropdown_create(panel);
|
||||
dropdown = lv_dropdown_create(panel);
|
||||
lv_dropdown_set_options(dropdown, "Blue\nGreen\nGrey\nYellow\nOrange\nRed\nPurple");
|
||||
lv_dropdown_set_selected(dropdown, global_config.color_scheme);
|
||||
lv_obj_add_style(dropdown, get_default_label_style(), 0);
|
||||
lv_obj_add_event_cb(dropdown, theme_dropdown, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
create_settings_widget("Theme", dropdown, panel);
|
||||
|
||||
dropdown = lv_dropdown_create(panel);
|
||||
lv_dropdown_set_options(dropdown, brightness_options);
|
||||
lv_obj_add_style(dropdown, get_default_label_style(), 0);
|
||||
lv_obj_add_event_cb(dropdown, brightness_dropdown, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
for (int i = 0; i < SIZEOF(brightness_options_values); i++){
|
||||
@@ -177,7 +203,6 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
|
||||
dropdown = lv_dropdown_create(panel);
|
||||
lv_dropdown_set_options(dropdown, wake_timeout_options);
|
||||
lv_obj_add_style(dropdown, get_default_label_style(), 0);
|
||||
lv_obj_add_event_cb(dropdown, wake_timeout_dropdown, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
for (int i = 0; i < SIZEOF(wake_timeout_options_values); i++){
|
||||
@@ -190,6 +215,13 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
create_settings_widget("Wake Timeout", dropdown, panel);
|
||||
#endif
|
||||
|
||||
dropdown = lv_dropdown_create(panel);
|
||||
lv_dropdown_set_options(dropdown, estimated_time_options);
|
||||
lv_obj_add_event_cb(dropdown, estimated_time_dropdown, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
lv_dropdown_set_selected(dropdown, global_config.remaining_time_calc_mode);
|
||||
create_settings_widget("Estimated Time", dropdown, panel);
|
||||
|
||||
toggle = lv_switch_create(panel);
|
||||
lv_obj_set_width(toggle, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2);
|
||||
lv_obj_add_event_cb(toggle, rotate_screen_switch, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
@@ -210,8 +242,34 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
create_settings_widget("Screen On During Print", toggle, panel);
|
||||
#endif
|
||||
|
||||
label = lv_label_create_ex(panel);
|
||||
lv_label_set_text(label, REPO_VERSION " ");
|
||||
toggle = lv_switch_create(panel);
|
||||
lv_obj_set_width(toggle, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2);
|
||||
lv_obj_add_event_cb(toggle, auto_ota_update_switch, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
if (global_config.autoOtaUpdate)
|
||||
lv_obj_add_state(toggle, LV_STATE_CHECKED);
|
||||
|
||||
create_settings_widget("Auto Update", toggle, panel);
|
||||
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, REPO_VERSION " ");
|
||||
|
||||
create_settings_widget("Version", label, panel, false);
|
||||
|
||||
if (ota_has_update()){
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, btn_ota_do_update, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text_fmt(label, "Update to %s", ota_new_version_name().c_str());
|
||||
lv_obj_center(label);
|
||||
|
||||
create_settings_widget("Device", btn, panel);
|
||||
}
|
||||
else {
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, ARDUINO_BOARD " ");
|
||||
|
||||
create_settings_widget("Device", label, panel, false);
|
||||
}
|
||||
}
|
||||
@@ -36,19 +36,42 @@ static void set_zoffset_text(lv_event_t * e) {
|
||||
lv_label_set_text(label, data);
|
||||
}
|
||||
|
||||
static void set_zoffset_text_ex(lv_event_t * e) {
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char data[64];
|
||||
sprintf(data, "Z Offset: %.03f, Z: %.03f", printer.gcode_offset[2], printer.position[2]);
|
||||
lv_label_set_text(label, data);
|
||||
}
|
||||
|
||||
static void set_zoffset(lv_event_t * e){
|
||||
char* offset = (char*)lv_event_get_user_data(e);
|
||||
|
||||
char gcode[64];
|
||||
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s", offset);
|
||||
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s MOVE=1", offset);
|
||||
send_gcode(true, gcode);
|
||||
}
|
||||
|
||||
const char* zoffsets[] = { "-0.005", "-0.01", "-0.025", "-0.05" };
|
||||
const char* zoffsets_2[] = { "+0.005", "+0.01", "+0.025", "+0.05" };
|
||||
static void set_z(lv_event_t * e){
|
||||
void* ptr = lv_event_get_user_data(e);
|
||||
float value = *(float *)(&ptr);
|
||||
|
||||
if (value < 0) {
|
||||
send_gcode(true, "SET_GCODE_OFFSET Z=0 MOVE=1");
|
||||
return;
|
||||
}
|
||||
|
||||
move_printer("Z", value, false);
|
||||
}
|
||||
|
||||
const char* zoffsets[] = { "-0.01", "-0.025", "-0.05", "-0.2" };
|
||||
const char* zoffsets_2[] = { "+0.01", "+0.025", "+0.05", "+0.2" };
|
||||
const char* zabs[] = { "Z=0", "Z=0.1", "Z=1", "Clear" };
|
||||
const float zabsvalues[] = { 0, 0.1f, 1.0f, -1.0f };
|
||||
|
||||
lv_button_column_t zoffset_columns[] = {
|
||||
{ set_zoffset, zoffsets, (const void**)zoffsets, 4},
|
||||
{ set_zoffset, zoffsets_2, (const void**)zoffsets_2, 4}
|
||||
{ set_zoffset, zoffsets_2, (const void**)zoffsets_2, 4},
|
||||
{ set_z, zabs, (const void**)zabsvalues, 4}
|
||||
};
|
||||
|
||||
static void set_speed_mult_text(lv_event_t * e){
|
||||
@@ -126,7 +149,7 @@ static void open_fan_speed_panel(lv_event_t * e){
|
||||
}
|
||||
|
||||
static void open_zoffset_panel(lv_event_t * e){
|
||||
lv_create_fullscreen_button_matrix_popup(lv_scr_act(), set_zoffset_text, zoffset_columns, 2);
|
||||
lv_create_fullscreen_button_matrix_popup(lv_scr_act(), set_zoffset_text_ex, zoffset_columns, (printer.state == PRINTER_STATE_IDLE) ? 3 : 2);
|
||||
lv_msg_send(DATA_PRINTER_DATA, &printer);
|
||||
}
|
||||
|
||||
@@ -145,7 +168,7 @@ void create_state_button(lv_obj_t * root, lv_event_cb_t label, lv_event_cb_t but
|
||||
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, button, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lv_obj_t * label_obj = lv_label_create_ex(btn);
|
||||
lv_obj_t * label_obj = lv_label_create(btn);
|
||||
lv_obj_add_event_cb(label_obj, label, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subscribe_obj(DATA_PRINTER_DATA, label_obj, NULL);
|
||||
lv_obj_align(label_obj, LV_ALIGN_CENTER, 0, 0);
|
||||
@@ -175,7 +198,7 @@ static void label_total_layers(lv_event_t * e){
|
||||
static void label_pressure_advance(lv_event_t * e){
|
||||
lv_obj_t * label = lv_event_get_target(e);
|
||||
char pressure_buff[32];
|
||||
sprintf(pressure_buff, "%.3f", printer.pressure_advance);
|
||||
sprintf(pressure_buff, "%.3f (%.2fs)", printer.pressure_advance, printer.smooth_time);
|
||||
lv_label_set_text(label, pressure_buff);
|
||||
}
|
||||
|
||||
@@ -192,11 +215,11 @@ void create_stat_text_block(lv_obj_t * root, const char* label, lv_event_cb_t va
|
||||
lv_layout_flex_column(panel , LV_FLEX_ALIGN_START, CYD_SCREEN_GAP_PX / 2, CYD_SCREEN_GAP_PX / 2);
|
||||
lv_obj_set_flex_align(panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||
|
||||
lv_obj_t * label_obj = lv_label_create_ex(panel);
|
||||
lv_obj_t * label_obj = lv_label_create(panel);
|
||||
lv_label_set_text(label_obj, label);
|
||||
lv_obj_set_style_text_font(label_obj, &CYD_SCREEN_FONT_SMALL, 0);
|
||||
|
||||
lv_obj_t * value_obj = lv_label_create_ex(panel);
|
||||
lv_obj_t * value_obj = lv_label_create(panel);
|
||||
lv_obj_add_event_cb(value_obj, value, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subscribe_obj(DATA_PRINTER_DATA, value_obj, NULL);
|
||||
}
|
||||
@@ -211,8 +234,12 @@ void stats_panel_init(lv_obj_t* panel) {
|
||||
lv_obj_align(left_panel, LV_ALIGN_TOP_LEFT, CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX);
|
||||
|
||||
create_stat_text_block(left_panel, "Position:", label_pos);
|
||||
create_stat_text_block(left_panel, "Filament Used:", label_filament_used_m);
|
||||
create_stat_text_block(left_panel, "Layer:", label_total_layers);
|
||||
|
||||
if (printer.state != PRINTER_STATE_IDLE){
|
||||
create_stat_text_block(left_panel, "Filament Used:", label_filament_used_m);
|
||||
create_stat_text_block(left_panel, "Layer:", label_total_layers);
|
||||
}
|
||||
|
||||
create_stat_text_block(left_panel, "Pressure Advance:", label_pressure_advance);
|
||||
create_stat_text_block(left_panel, "Feedrate:", label_feedrate);
|
||||
|
||||
|
||||
@@ -119,21 +119,26 @@ static void keyboard_callback(lv_event_t * e){
|
||||
|
||||
if(code == LV_EVENT_DEFOCUSED || code == LV_EVENT_CANCEL || code == LV_EVENT_READY) {
|
||||
lv_keyboard_set_textarea(kb, NULL);
|
||||
lv_obj_del(kb);
|
||||
lv_obj_del(ta);
|
||||
lv_obj_del(lv_obj_get_parent(kb));
|
||||
}
|
||||
}
|
||||
|
||||
static void show_keyboard(lv_event_t * e){
|
||||
lv_obj_t * keyboard = lv_keyboard_create(root_panel);
|
||||
lv_obj_t * ta = lv_textarea_create(root_panel);
|
||||
// TODO: Hack, should be fixed before finishing porting
|
||||
lv_obj_set_size(ta, CYD_SCREEN_PANEL_WIDTH_PX, 120);
|
||||
lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 0);
|
||||
lv_obj_t * parent = lv_create_empty_panel(root_panel);
|
||||
lv_obj_set_style_bg_opa(parent, LV_OPA_50, 0);
|
||||
lv_obj_set_size(parent, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
lv_layout_flex_column(parent, LV_FLEX_ALIGN_SPACE_BETWEEN);
|
||||
|
||||
lv_obj_t * empty_panel = lv_create_empty_panel(parent);
|
||||
lv_obj_set_flex_grow(empty_panel, 1);
|
||||
|
||||
lv_obj_t * ta = lv_textarea_create(parent);
|
||||
lv_obj_t * keyboard = lv_keyboard_create(parent);
|
||||
|
||||
lv_obj_set_width(ta, CYD_SCREEN_PANEL_WIDTH_PX / 2);
|
||||
lv_textarea_set_max_length(ta, 3);
|
||||
//lv_textarea_set_one_line(ta, true);
|
||||
lv_textarea_set_one_line(ta, true);
|
||||
lv_textarea_set_text(ta, "");
|
||||
lv_textarea_set_align(ta, LV_TEXT_ALIGN_CENTER);
|
||||
lv_obj_add_event_cb(ta, keyboard_callback, LV_EVENT_ALL, keyboard);
|
||||
|
||||
lv_keyboard_set_mode(keyboard, LV_KEYBOARD_MODE_NUMBER);
|
||||
@@ -202,26 +207,104 @@ static void btn_retract(lv_event_t * e){
|
||||
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);
|
||||
lv_chart_t * chart = (lv_chart_t *)chart_obj;
|
||||
int max_temp = 0;
|
||||
lv_chart_series_t * prev = NULL;
|
||||
|
||||
do {
|
||||
prev = lv_chart_get_series_next(chart_obj, prev);
|
||||
|
||||
if (prev != NULL)
|
||||
for (int i = 0; i < chart->point_cnt; i++)
|
||||
if (prev->y_points[i] > max_temp)
|
||||
max_temp = prev->y_points[i];
|
||||
|
||||
} while (prev != NULL);
|
||||
|
||||
int range = ((max_temp + 49) / 50) * 50;
|
||||
|
||||
if (range < 100)
|
||||
range = 100;
|
||||
|
||||
lv_chart_set_range(chart_obj, LV_CHART_AXIS_PRIMARY_Y, 0, range);
|
||||
}
|
||||
|
||||
static void set_hotend_temp_chart(lv_event_t * e){
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
lv_chart_series_t * series = (lv_chart_series_t *)lv_event_get_user_data(e);
|
||||
lv_chart_set_next_value(chart, series, printer.extruder_temp);
|
||||
}
|
||||
|
||||
static void set_hotend_target_temp_chart(lv_event_t * e){
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
lv_chart_series_t * series = (lv_chart_series_t *)lv_event_get_user_data(e);
|
||||
lv_chart_set_next_value(chart, series, printer.extruder_target_temp);
|
||||
}
|
||||
|
||||
static void set_bed_temp_chart(lv_event_t * e){
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
lv_chart_series_t * series = (lv_chart_series_t *)lv_event_get_user_data(e);
|
||||
lv_chart_set_next_value(chart, series, printer.bed_temp);
|
||||
}
|
||||
|
||||
static void set_bed_target_temp_chart(lv_event_t * e){
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
lv_chart_series_t * series = (lv_chart_series_t *)lv_event_get_user_data(e);
|
||||
lv_chart_set_next_value(chart, series, printer.bed_target_temp);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
lv_obj_t * root_temp_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_set_size(root_temp_panel, CYD_SCREEN_PANEL_WIDTH_PX, LV_SIZE_CONTENT);
|
||||
lv_obj_set_size(root_temp_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||
lv_obj_align(root_temp_panel, LV_ALIGN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_style_pad_all(root_temp_panel, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_layout_flex_column(root_temp_panel);
|
||||
lv_obj_set_flex_align(root_temp_panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER);
|
||||
lv_obj_set_scrollbar_mode(root_temp_panel, LV_SCROLLBAR_MODE_OFF);
|
||||
|
||||
lv_obj_t * chart = lv_chart_create(root_temp_panel);
|
||||
lv_obj_set_size(chart, element_width - CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX * 3);
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_LINE);
|
||||
lv_chart_set_point_count(chart, 120);
|
||||
lv_obj_set_style_size(chart, 0, LV_PART_INDICATOR);
|
||||
lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, CYD_SCREEN_GAP_PX / 2, CYD_SCREEN_GAP_PX / 4, 4, 3, true, CYD_SCREEN_MIN_BUTTON_WIDTH_PX);
|
||||
lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_SHIFT);
|
||||
|
||||
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_ORANGE), LV_CHART_AXIS_PRIMARY_Y);
|
||||
lv_chart_set_all_value(chart, ser1, printer.extruder_target_temp);
|
||||
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y);
|
||||
lv_chart_set_all_value(chart, ser2, printer.extruder_temp);
|
||||
lv_chart_series_t * ser3 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_TEAL), LV_CHART_AXIS_PRIMARY_Y);
|
||||
lv_chart_set_all_value(chart, ser3, printer.bed_target_temp);
|
||||
lv_chart_series_t * ser4 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_BLUE), LV_CHART_AXIS_PRIMARY_Y);
|
||||
lv_chart_set_all_value(chart, ser4, printer.bed_temp);
|
||||
|
||||
lv_obj_add_event_cb(chart, set_hotend_target_temp_chart, LV_EVENT_MSG_RECEIVED, ser1);
|
||||
lv_obj_add_event_cb(chart, set_hotend_temp_chart, LV_EVENT_MSG_RECEIVED, ser2);
|
||||
lv_obj_add_event_cb(chart, set_bed_target_temp_chart, LV_EVENT_MSG_RECEIVED, ser3);
|
||||
lv_obj_add_event_cb(chart, set_bed_temp_chart, LV_EVENT_MSG_RECEIVED, ser4);
|
||||
lv_obj_add_event_cb(chart, set_chart_range, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subscribe_obj(DATA_PRINTER_DATA, chart, NULL);
|
||||
|
||||
lv_obj_t * single_screen_panel = lv_create_empty_panel(root_temp_panel);
|
||||
lv_obj_set_size(single_screen_panel, element_width, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2 - CYD_SCREEN_GAP_PX / 2);
|
||||
lv_layout_flex_column(single_screen_panel);
|
||||
|
||||
lv_obj_t * temp_rows[2] = {0};
|
||||
lv_obj_t * button_temp_rows[2] = {0};
|
||||
|
||||
for (int tempIter = 0; tempIter < 2; tempIter++){
|
||||
temp_rows[tempIter] = lv_create_empty_panel(root_temp_panel);
|
||||
temp_rows[tempIter] = lv_create_empty_panel(single_screen_panel);
|
||||
lv_layout_flex_column(temp_rows[tempIter]);
|
||||
lv_obj_set_size(temp_rows[tempIter], element_width, LV_SIZE_CONTENT);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(temp_rows[tempIter]);
|
||||
lv_obj_t * label = lv_label_create(temp_rows[tempIter]);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_add_event_cb(label, (tempIter == 0) ? update_printer_data_hotend_temp : update_printer_data_bed_temp, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
lv_msg_subscribe_obj(DATA_PRINTER_DATA, label, NULL);
|
||||
@@ -237,7 +320,7 @@ void temp_panel_init(lv_obj_t * panel){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "???");
|
||||
lv_obj_center(label);
|
||||
lv_obj_add_event_cb(label, update_temp_preset_label, LV_EVENT_MSG_RECEIVED, reinterpret_cast<void*>(TARGET_HOTEND_CONFIG_1 + buttonIter + tempIter * 3));
|
||||
@@ -249,27 +332,28 @@ void temp_panel_init(lv_obj_t * panel){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Set");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
lv_obj_t * bottom_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_set_size(bottom_panel, element_width, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(bottom_panel, LV_ALIGN_BOTTOM_MID, 0, -1 * CYD_SCREEN_GAP_PX);
|
||||
lv_layout_flex_row(bottom_panel, LV_FLEX_ALIGN_SPACE_EVENLY);
|
||||
lv_obj_t * gap = lv_create_empty_panel(single_screen_panel);
|
||||
lv_obj_set_flex_grow(gap, 1);
|
||||
|
||||
lv_obj_t * one_above_bottom_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_t * one_above_bottom_panel = lv_create_empty_panel(single_screen_panel);
|
||||
lv_obj_set_size(one_above_bottom_panel, element_width, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(one_above_bottom_panel, LV_ALIGN_BOTTOM_MID, 0, -1 * CYD_SCREEN_MIN_BUTTON_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_layout_flex_row(one_above_bottom_panel, LV_FLEX_ALIGN_SPACE_EVENLY);
|
||||
|
||||
lv_obj_t * bottom_panel = lv_create_empty_panel(single_screen_panel);
|
||||
lv_obj_set_size(bottom_panel, element_width, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_layout_flex_row(bottom_panel, LV_FLEX_ALIGN_SPACE_EVENLY);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(bottom_panel);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
lv_obj_add_event_cb(btn, btn_extrude, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(btn);
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_DOWN " Extrude");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -278,7 +362,7 @@ void temp_panel_init(lv_obj_t * panel){
|
||||
lv_obj_add_event_cb(btn, btn_retract, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_UP " Retract");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -287,7 +371,7 @@ void temp_panel_init(lv_obj_t * panel){
|
||||
lv_obj_add_event_cb(btn, cooldown_temp, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Cooldown");
|
||||
lv_obj_center(label);
|
||||
|
||||
@@ -297,9 +381,10 @@ void temp_panel_init(lv_obj_t * panel){
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_flag(btn, LV_OBJ_FLAG_CHECKABLE);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Edit Presets");
|
||||
lv_obj_center(label);
|
||||
|
||||
lv_obj_scroll_to_y(root_temp_panel, 9999, LV_ANIM_OFF);
|
||||
lv_msg_send(DATA_PRINTER_TEMP_PRESET, &printer);
|
||||
}
|
||||
@@ -3,13 +3,6 @@
|
||||
#include "../core/data_setup.h"
|
||||
#include "../core/lv_setup.h"
|
||||
|
||||
lv_obj_t* lv_label_create_ex(lv_obj_t* parent)
|
||||
{
|
||||
lv_obj_t* label = lv_label_create(parent);
|
||||
lv_obj_add_style(label, get_default_label_style(), 0);
|
||||
return label;
|
||||
}
|
||||
|
||||
lv_obj_t* lv_create_empty_panel(lv_obj_t* root) {
|
||||
lv_obj_t* panel = lv_obj_create(root);
|
||||
lv_obj_set_style_border_width(panel, 0, 0);
|
||||
@@ -61,11 +54,11 @@ void lv_create_fullscreen_button_matrix_popup(lv_obj_t * root, lv_event_cb_t tit
|
||||
lv_obj_align(btn, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(btn, destroy_event_user_data, LV_EVENT_CLICKED, panel);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(btn);
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE);
|
||||
lv_obj_center(label);
|
||||
|
||||
label = lv_label_create_ex(top_menu_row);
|
||||
label = lv_label_create(top_menu_row);
|
||||
lv_label_set_text(label, "-");
|
||||
lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(label, title, LV_EVENT_MSG_RECEIVED, NULL);
|
||||
@@ -87,7 +80,7 @@ void lv_create_fullscreen_button_matrix_popup(lv_obj_t * root, lv_event_cb_t tit
|
||||
lv_obj_set_size(btn, column_width, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(btn, columns[i].event, LV_EVENT_CLICKED, (void*)columns[i].data[j]);
|
||||
|
||||
label = lv_label_create_ex(btn);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, columns[i].labels[j]);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ typedef struct {
|
||||
int length;
|
||||
} lv_button_column_t;
|
||||
|
||||
lv_obj_t* lv_label_create_ex(lv_obj_t* parent);
|
||||
lv_obj_t* lv_create_empty_panel(lv_obj_t* root);
|
||||
void lv_layout_flex_column(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_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);
|
||||
|
||||
@@ -58,7 +58,7 @@ void wifi_pass_entry(const char* ssid){
|
||||
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_ex(top_root);
|
||||
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);
|
||||
|
||||
@@ -92,7 +92,7 @@ void wifi_init_inner(){
|
||||
if (global_config.wifiConfigured){
|
||||
WiFi.begin(global_config.wifiSSID, global_config.wifiPassword);
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(lv_scr_act());
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Connecting to WiFi");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -101,14 +101,14 @@ void wifi_init_inner(){
|
||||
lv_obj_set_height(resetBtn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(resetBtn, LV_ALIGN_CENTER, 0, CYD_SCREEN_GAP_PX + CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
|
||||
label = lv_label_create_ex(resetBtn);
|
||||
label = lv_label_create(resetBtn);
|
||||
lv_label_set_text(label, "Reset");
|
||||
lv_obj_center(label);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_t * label = lv_label_create_ex(lv_scr_act());
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Scanning for networks...");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -127,14 +127,14 @@ void wifi_init_inner(){
|
||||
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);
|
||||
|
||||
label = lv_label_create_ex(top_row);
|
||||
label = lv_label_create(top_row);
|
||||
lv_label_set_text(label, "Select a network");
|
||||
|
||||
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);
|
||||
|
||||
label = lv_label_create_ex(refreshBtn);
|
||||
label = lv_label_create(refreshBtn);
|
||||
lv_label_set_text(label, LV_SYMBOL_REFRESH);
|
||||
lv_obj_center(label);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ A ESP32-2432S028R is required to run this project. You can find out where to buy
|
||||
- Extrude/Retract filament
|
||||
- Execute predefined gcode macros
|
||||
- Toggle Moonraker power devices
|
||||
- OTA updates
|
||||
|
||||
### Install
|
||||
|
||||
@@ -29,7 +30,13 @@ A ESP32-2432S028R is required to run this project. You can find out where to buy
|
||||
|
||||
On initial install, all data should be wiped. On updates, data should be able to be kept without issues.
|
||||
|
||||
There are no 'over the air' updates. Each update has to be applied manually.
|
||||
When there is an update available, a button in the settings will appear that can be pressed to update. If automatic updates are preferred, there is a toggle in the settings to automatically update. This will right after connecting to wifi update the screen.
|
||||
|
||||
### Donate
|
||||
|
||||
If you found this project helpful, please consider a donation [to my Ko-Fi](https://ko-fi.com/suchmememanyskill). It would help out a lot in the development of this project, due to the need to buy the screens.
|
||||
|
||||
Thank you!
|
||||
|
||||
### Screenshots
|
||||
(Quite literally shots of the screen. I'm sorry)
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
color: green;
|
||||
filter: drop-shadow(0 0 0.75rem lime);
|
||||
}
|
||||
|
||||
#changelog-body {
|
||||
white-space: break-spaces;
|
||||
}
|
||||
</style>
|
||||
<script type="module" src="https://unpkg.com/esp-web-tools@9/dist/web/install-button.js?module"></script>
|
||||
<script src="//code.iconify.design/1/1.0.6/iconify.min.js"></script>
|
||||
|
||||
19
ci.py
19
ci.py
@@ -32,6 +32,20 @@ def get_manifest(base_path : str, device_name : str):
|
||||
]
|
||||
}
|
||||
|
||||
def extract_commit() -> str:
|
||||
git_describe_output = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip()
|
||||
return git_describe_output.split("-")[0]
|
||||
|
||||
repo_version = extract_commit()
|
||||
configurations = []
|
||||
|
||||
def add_configuration(board : str):
|
||||
configurations.append({
|
||||
"Board": board,
|
||||
"Version": repo_version,
|
||||
"URL": f"https://suchmememanyskill.github.io/CYD-Klipper/out/{board}/firmware.bin"
|
||||
})
|
||||
|
||||
if os.path.exists("out"):
|
||||
shutil.rmtree("out")
|
||||
|
||||
@@ -54,5 +68,10 @@ for port in CYD_PORTS:
|
||||
with open(f"./_site/{port}.json", "w") as f:
|
||||
json.dump(get_manifest(port_path, port), f)
|
||||
|
||||
add_configuration(port)
|
||||
|
||||
os.chdir(BASE_DIR)
|
||||
shutil.copytree("./out", "./_site/out")
|
||||
|
||||
with open("./_site/OTA.json", "w") as f:
|
||||
json.dump({"Configurations": configurations}, f)
|
||||
|
||||
Reference in New Issue
Block a user