mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Extract display timeout from driver
This commit is contained in:
3
CYD-Klipper/boards/README.md
Normal file
3
CYD-Klipper/boards/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Boards
|
||||
|
||||
Contains specialised CYD definitions from [platformio-espressif32-sunton](https://github.com/rzeldent/platformio-espressif32-sunton)
|
||||
108
CYD-Klipper/boards/esp32-3248S035C.json
Normal file
108
CYD-Klipper/boards/esp32-3248S035C.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"'-D ARDUINO_ESP32_DEV'",
|
||||
"'-D ESP32_3248S035C'",
|
||||
"'-D LCD_WIDTH=320'",
|
||||
"'-D LCD_HEIGHT=480'",
|
||||
"'-D BCKL=27'",
|
||||
"'-D LCD_ST7796_SPI'",
|
||||
"'-D ST7796_SPI_HOST=SPI2_HOST'",
|
||||
"'-D ST7796_SPI_DMA_CHANNEL=SPI_DMA_CH_AUTO'",
|
||||
"'-D ST7796_SPI_BUS_MOSI_IO_NUM=13'",
|
||||
"'-D ST7796_SPI_BUS_MISO_IO_NUM=12'",
|
||||
"'-D ST7796_SPI_BUS_SCLK_IO_NUM=14'",
|
||||
"'-D ST7796_SPI_BUS_QUADWP_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7796_SPI_BUS_QUADHD_IO_NUM=GPIO_NUM_NC'",
|
||||
"'-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_TRANS_QUEUE_DEPTH=10'",
|
||||
"'-D ST7796_SPI_CONFIG_LCD_CMD_BITS=8'",
|
||||
"'-D ST7796_SPI_CONFIG_LCD_PARAM_BITS=8'",
|
||||
"'-D ST7796_SPI_CONFIG_FLAGS_DC_AS_CMD_PHASE=false'",
|
||||
"'-D ST7796_SPI_CONFIG_FLAGS_DC_LOW_ON_DATA=false'",
|
||||
"'-D ST7796_SPI_CONFIG_FLAGS_OCTAL_MODE=false'",
|
||||
"'-D ST7796_SPI_CONFIG_FLAGS_LSB_FIRST=false'",
|
||||
"'-D ST7796_DEV_CONFIG_RESET_GPIO_NUM=GPIO_NUM_NC'",
|
||||
"'-D ST7796_DEV_CONFIG_COLOR_SPACE=ESP_LCD_COLOR_SPACE_BGR'",
|
||||
"'-D ST7796_DEV_CONFIG_BITS_PER_PIXEL=16'",
|
||||
"'-D ST7796_DEV_CONFIG_FLAGS_RESET_ACTIVE_HIGH=false'",
|
||||
"'-D ST7796_DEV_CONFIG_VENDOR_CONFIG=NULL'",
|
||||
"'-D LCD_SWAP_XY=false'",
|
||||
"'-D LCD_MIRROR_X=true'",
|
||||
"'-D LCD_MIRROR_Y=false'",
|
||||
"'-D BOARD_HAS_TOUCH'",
|
||||
"'-D TOUCH_GT911_I2C'",
|
||||
"'-D GT911_I2C_HOST=0'",
|
||||
"'-D GT911_I2C_CONFIG_SDA_IO_NUM=33'",
|
||||
"'-D GT911_I2C_CONFIG_SCL_IO_NUM=32'",
|
||||
"'-D GT911_I2C_CONFIG_SDA_PULLUP_EN=GPIO_PULLUP_ENABLE'",
|
||||
"'-D GT911_I2C_CONFIG_SCL_PULLUP_EN=GPIO_PULLUP_ENABLE'",
|
||||
"'-D GT911_I2C_CONFIG_MASTER_CLK_SPEED=400000'",
|
||||
"'-D GT911_I2C_CONFIG_CLK_FLAGS=0'",
|
||||
"'-D GT911_IO_I2C_CONFIG_DEV_ADDR=ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS'",
|
||||
"'-D GT911_IO_I2C_CONFIG_CONTROL_PHASE_BYTES=1'",
|
||||
"'-D GT911_IO_I2C_CONFIG_DC_BIT_OFFSET=0'",
|
||||
"'-D GT911_IO_I2C_CONFIG_LCD_CMD_BITS=16'",
|
||||
"'-D GT911_IO_I2C_CONFIG_LCD_PARAM_BITS=0'",
|
||||
"'-D GT911_IO_I2C_CONFIG_FLAGS_DC_LOW_ON_DATA=false'",
|
||||
"'-D GT911_IO_I2C_CONFIG_FLAGS_DISABLE_CONTROL_PHASE=true'",
|
||||
"'-D GT911_TOUCH_CONFIG_X_MAX=LCD_WIDTH'",
|
||||
"'-D GT911_TOUCH_CONFIG_Y_MAX=LCD_HEIGHT'",
|
||||
"'-D GT911_TOUCH_CONFIG_RST_GPIO_NUM=25'",
|
||||
"'-D GT911_TOUCH_CONFIG_INT_GPIO_NUM=21'",
|
||||
"'-D GT911_TOUCH_CONFIG_LEVELS_RESET=0'",
|
||||
"'-D GT911_TOUCH_CONFIG_LEVELS_INTERRUPT=0'",
|
||||
"'-D TOUCH_SWAP_XY=true'",
|
||||
"'-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_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'"
|
||||
],
|
||||
"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-3248S035C",
|
||||
"upload": {
|
||||
"flash_size": "4MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 4194304,
|
||||
"require_upload_port": true,
|
||||
"speed": 460800
|
||||
},
|
||||
"url": "https://www.aliexpress.com/item/1005004632953455.html",
|
||||
"vendor": "Sunton"
|
||||
}
|
||||
@@ -98,8 +98,9 @@ build_flags =
|
||||
-DCYD_SCREEN_FONT_SMALL=&lv_font_montserrat_12
|
||||
-DCYD_SCREEN_SIDEBAR_SIZE_PX=50
|
||||
-DCYD_SCREEN_DRIVER_ESP32_3248S035C=1
|
||||
-DCYD_SCREEN_DISABLE_TOUCH_CALIBRATION=1
|
||||
|
||||
# Terribly slow. Driver also has issues
|
||||
# Terribly slow. Only use for development
|
||||
# [env:esp32-3248S035C-smartdisplay]
|
||||
# board = esp32-3248S035C
|
||||
# build_flags =
|
||||
@@ -113,4 +114,3 @@ build_flags =
|
||||
# -DCYD_SCREEN_FONT_SMALL=&lv_font_montserrat_12
|
||||
# -DCYD_SCREEN_SIDEBAR_SIZE_PX=50
|
||||
# -DCYD_SCREEN_DRIVER_ESP32_SMARTDISPLAY=1
|
||||
# -DCYD_SCREEN_DISABLE_TIMEOUT=1
|
||||
@@ -116,17 +116,6 @@ void screen_lv_touchRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
if (touchscreen.tirqTouched() && touchscreen.touched())
|
||||
{
|
||||
// dont pass first touch after power on
|
||||
if (is_screen_asleep())
|
||||
{
|
||||
screen_timer_wake();
|
||||
while (touchscreen.touched())
|
||||
;
|
||||
return;
|
||||
}
|
||||
|
||||
screen_timer_wake();
|
||||
|
||||
TS_Point p = touchscreen_point();
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
data->point.x = p.x;
|
||||
|
||||
@@ -55,17 +55,6 @@ void screen_lv_touchRead(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_screen_asleep())
|
||||
{
|
||||
screen_timer_wake();
|
||||
while (tp.isTouched) {
|
||||
tp.read();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
screen_timer_wake();
|
||||
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
for (int i = 0; i < tp.touches; i++)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,6 @@ void screen_setup()
|
||||
{
|
||||
smartdisplay_init();
|
||||
|
||||
// TODO: Touch input doesn't get translated when doing this
|
||||
lv_disp_set_rotation(lv_disp_get_default(), (global_config.rotateScreen) ? LV_DISP_ROT_270 : LV_DISP_ROT_90);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "lvgl.h"
|
||||
#include "lv_setup.h"
|
||||
#include "screen_driver.h"
|
||||
#include "../conf/global_config.h"
|
||||
#include <Esp.h>
|
||||
@@ -98,6 +98,26 @@ 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);
|
||||
@@ -106,6 +126,13 @@ void lv_setup()
|
||||
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()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#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();
|
||||
|
||||
@@ -117,6 +117,7 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
|
||||
create_settings_widget("Configure WiFi", btn, panel);
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, reset_calibration_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
@@ -125,6 +126,7 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
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);
|
||||
lv_obj_set_width(toggle, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2);
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<body>
|
||||
<section class="main">
|
||||
<h2>CYD-Klipper <span class="iconify" data-icon="mdi-printer-3d" style="color: orange;"></span></h2>
|
||||
<p>An implementation of a Klipper status display on an ESP32 + screen.<br>Uses Moonraker to fetch data.<br><a href="https://github.com/suchmememanyskill/CYD-Klipper">Source code is available on GitHub</a></p>
|
||||
<p>An implementation of a Klipper status display on an ESP32 + screen.<br>Uses Moonraker to fetch data.<br><a href="https://github.com/suchmememanyskill/CYD-Klipper">Source code is available on GitHub</a>.</p>
|
||||
|
||||
<section class="changelog">
|
||||
<h3 id="changelog-header"><span class="iconify" data-icon="mdi-hammer-wrench" style="color: grey;"></span> Changelog</h3>
|
||||
@@ -53,18 +53,18 @@
|
||||
|
||||
<section class="donate">
|
||||
<h3><span class="iconify" data-icon="mdi-heart" style="color:orangered; filter: drop-shadow(0 0 0.75rem crimson);"></span> Donate</h3>
|
||||
<p>If you found this project helpful, please consider a donation to <a href="https://ko-fi.com/suchmememanyskill">my Ko-Fi</a><br>It would help out a lot in the development of this project!<br>Thank you!</p>
|
||||
<p>If you found this project helpful, please consider a donation to <a href="https://ko-fi.com/suchmememanyskill">my Ko-Fi</a>.<br>It would help out a lot in the development of this project, due to the need to buy the screens.<br>Thank you!</p>
|
||||
</section>
|
||||
|
||||
<section class="install">
|
||||
<h3><span class="iconify" data-icon="mdi-download"></span> Install on ESP32-2432S028 (2.8" Resistive)</h3>
|
||||
<p>Note: You may need to hold the 'BOOT' button on the device while pressing install</p>
|
||||
<p>Note: You may need to hold the 'BOOT' button on the device while pressing install.</p>
|
||||
<esp-web-install-button
|
||||
manifest="https://suchmememanyskill.github.io/CYD-Klipper/esp32-2432S028R.json"></esp-web-install-button>
|
||||
</section>
|
||||
<section class="install">
|
||||
<h3><span class="iconify" data-icon="mdi-download"></span> Install on ESP32-3248S035 (3.5" Capacitive)</h3>
|
||||
<p>Note: You may need to hold the 'BOOT' button on the device while pressing install</p>
|
||||
<p>Note: You may need to hold the 'BOOT' button on the device while pressing install.</p>
|
||||
<esp-web-install-button
|
||||
manifest="https://suchmememanyskill.github.io/CYD-Klipper/esp32-3248S035C.json"></esp-web-install-button>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user