mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-20 21:23:25 +00:00
Optimalisations
This commit is contained in:
@@ -20,8 +20,10 @@ lib_deps =
|
||||
monitor_filters = esp32_exception_decoder
|
||||
build_flags =
|
||||
-DLV_CONF_PATH="../../../../src/conf/lv_conf.h"
|
||||
-O2
|
||||
extra_scripts =
|
||||
pre:extract_commit.py
|
||||
build_unflags = -Os
|
||||
|
||||
[env:esp32-2432S028R]
|
||||
board = esp32-2432S028R
|
||||
|
||||
@@ -15,16 +15,58 @@
|
||||
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;
|
||||
bool is_in_calibration_mode = 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;
|
||||
}
|
||||
|
||||
is_in_calibration_mode = true;
|
||||
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);
|
||||
|
||||
@@ -95,7 +137,6 @@ void lv_do_calibration(){
|
||||
global_config.screenCalibrated = true;
|
||||
WriteGlobalConfig();
|
||||
|
||||
is_in_calibration_mode = false;
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
@@ -183,58 +224,13 @@ void set_color_scheme()
|
||||
lv_disp_set_theme(dispp, theme);
|
||||
}
|
||||
|
||||
static lv_indev_drv_read_cb_t original_touch_driver = NULL;
|
||||
|
||||
void lv_touch_intercept(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
|
||||
{
|
||||
original_touch_driver(indev_driver, data);
|
||||
|
||||
#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
if (is_in_calibration_mode){
|
||||
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;
|
||||
return;
|
||||
}
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
|
||||
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
|
||||
if (data->state == LV_INDEV_STATE_PR) {
|
||||
//Serial.printf("Before: %d %d\n", data->point.x, data->point.y);
|
||||
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);
|
||||
//Serial.printf("After: %d %d\n", data->point.x, data->point.y);
|
||||
}
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
}
|
||||
|
||||
void lv_setup()
|
||||
{
|
||||
if (original_touch_driver == NULL) {
|
||||
lv_indev_t * display_driver = lv_indev_get_next(NULL);
|
||||
lv_indev_t * display_driver = lv_indev_get_next(NULL);
|
||||
|
||||
if (original_touch_driver == NULL)
|
||||
{
|
||||
original_touch_driver = display_driver->driver->read_cb;
|
||||
display_driver->driver->read_cb = lv_touch_intercept;
|
||||
}
|
||||
|
||||
set_color_scheme();
|
||||
@@ -243,6 +239,8 @@ void lv_setup()
|
||||
lv_do_calibration();
|
||||
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
|
||||
|
||||
display_driver->driver->read_cb = lv_touch_intercept;
|
||||
|
||||
screen_timer_setup();
|
||||
screen_timer_start();
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ void macros_panel_init(lv_obj_t* panel) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -129,6 +129,7 @@ void settings_panel_init(lv_obj_t* panel){
|
||||
|
||||
lv_obj_set_style_pad_all(panel, CYD_SCREEN_GAP_PX, 0);
|
||||
lv_layout_flex_column(panel);
|
||||
lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF);
|
||||
|
||||
btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, reset_wifi_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
@@ -46,10 +46,8 @@ static void set_zoffset_text_ex(lv_event_t * e) {
|
||||
static void set_zoffset(lv_event_t * e){
|
||||
char* offset = (char*)lv_event_get_user_data(e);
|
||||
|
||||
const char* extra = printer.state == PRINTER_STATE_IDLE ? " MOVE=1" : "";
|
||||
|
||||
char gcode[64];
|
||||
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s%s", offset, extra);
|
||||
sprintf(gcode, "SET_GCODE_OFFSET Z_ADJUST=%s MOVE=1", offset);
|
||||
send_gcode(true, gcode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user