Add Touch Calibration screen (#20049)
This commit is contained in:
parent
90f647b6be
commit
3d9b453000
@ -2358,10 +2358,10 @@
|
||||
|
||||
#define TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
//#define XPT2046_X_CALIBRATION 12316
|
||||
//#define XPT2046_Y_CALIBRATION -8981
|
||||
//#define XPT2046_X_OFFSET -43
|
||||
//#define XPT2046_Y_OFFSET 257
|
||||
//#define TOUCH_CALIBRATION_X 12316
|
||||
//#define TOUCH_CALIBRATION_Y -8981
|
||||
//#define TOUCH_OFFSET_X -43
|
||||
//#define TOUCH_OFFSET_Y 257
|
||||
|
||||
#if ENABLED(TFT_COLOR_UI)
|
||||
//#define SINGLE_TOUCH_NAVIGATION
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
@ -147,15 +147,15 @@ SPIClass::SPIClass(uint32_t spi_num) {
|
||||
_currentSetting->state = SPI_STATE_IDLE;
|
||||
}
|
||||
|
||||
SPIClass::SPIClass(int8_t mosi, int8_t miso, int8_t sclk, int8_t ssel) {
|
||||
SPIClass::SPIClass(int8_t mosi, int8_t miso, int8_t sclk, int8_t ssel) : SPIClass(1) {
|
||||
#if BOARD_NR_SPI >= 1
|
||||
if (mosi == BOARD_SPI1_MOSI_PIN) SPIClass(1);
|
||||
if (mosi == BOARD_SPI1_MOSI_PIN) setModule(1);
|
||||
#endif
|
||||
#if BOARD_NR_SPI >= 2
|
||||
if (mosi == BOARD_SPI2_MOSI_PIN) SPIClass(2);
|
||||
if (mosi == BOARD_SPI2_MOSI_PIN) setModule(2);
|
||||
#endif
|
||||
#if BOARD_NR_SPI >= 3
|
||||
if (mosi == BOARD_SPI3_MOSI_PIN) SPIClass(3);
|
||||
if (mosi == BOARD_SPI3_MOSI_PIN) setModule(3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_XPT2046
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
@ -60,7 +60,7 @@
|
||||
#include "sd/cardreader.h"
|
||||
|
||||
#include "lcd/marlinui.h"
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
#include "lcd/touch/touch_buttons.h"
|
||||
#endif
|
||||
|
||||
@ -1109,7 +1109,7 @@ void setup() {
|
||||
SETUP_RUN(ethernet.init());
|
||||
#endif
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
SETUP_RUN(touch.init());
|
||||
#endif
|
||||
|
||||
@ -1307,6 +1307,10 @@ void setup() {
|
||||
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
|
||||
#endif
|
||||
|
||||
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
||||
ui.check_touch_calibration();
|
||||
#endif
|
||||
|
||||
marlin_state = MF_RUNNING;
|
||||
|
||||
SETUP_LOG("setup() completed.");
|
||||
|
@ -405,7 +405,7 @@ inline bool turn_on_heaters() {
|
||||
inline bool prime_nozzle() {
|
||||
|
||||
const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f;
|
||||
#if HAS_LCD_MENU && !HAS_TOUCH_XPT2046 // ui.button_pressed issue with touchscreen
|
||||
#if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen
|
||||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
float Total_Prime = 0.0;
|
||||
#endif
|
||||
|
@ -25,14 +25,23 @@
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../lcd/menu/menu.h"
|
||||
|
||||
#if ENABLED(TFT_LVGL_UI)
|
||||
#include "../../lcd/extui/lib/mks_ui/draw_touch_calibration.h"
|
||||
#else
|
||||
#include "../../lcd/menu/menu.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* M995: Touch screen calibration for TFT display
|
||||
*/
|
||||
void GcodeSuite::M995() {
|
||||
|
||||
ui.goto_screen(touch_screen_calibration);
|
||||
#if ENABLED(TFT_LVGL_UI)
|
||||
lv_draw_touch_calibration_screen();
|
||||
#else
|
||||
ui.goto_screen(touch_screen_calibration);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -1073,8 +1073,24 @@
|
||||
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
#if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
|
||||
#undef TOUCH_SCREEN
|
||||
#undef TOUCH_SCREEN_CALIBRATION
|
||||
#if !HAS_TFT_LVGL_UI
|
||||
#define HAS_TOUCH_XPT2046 1
|
||||
#define HAS_TOUCH_BUTTONS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// XPT2046_** Compatibility
|
||||
#if !(defined(TOUCH_CALIBRATION_X) || defined(TOUCH_CALIBRATION_Y) || defined(TOUCH_OFFSET_X) || defined(TOUCH_OFFSET_Y) || defined(TOUCH_ORIENTATION))
|
||||
#if defined(XPT2046_X_CALIBRATION) && defined(XPT2046_Y_CALIBRATION) && defined(XPT2046_X_OFFSET) && defined(XPT2046_Y_OFFSET)
|
||||
#define TOUCH_CALIBRATION_X XPT2046_X_CALIBRATION
|
||||
#define TOUCH_CALIBRATION_Y XPT2046_Y_CALIBRATION
|
||||
#define TOUCH_OFFSET_X XPT2046_X_OFFSET
|
||||
#define TOUCH_OFFSET_Y XPT2046_Y_OFFSET
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#else
|
||||
#define TOUCH_CALIBRATION_X 0
|
||||
#define TOUCH_CALIBRATION_Y 0
|
||||
#define TOUCH_OFFSET_X 0
|
||||
#define TOUCH_OFFSET_Y 0
|
||||
#define TOUCH_ORIENTATION TOUCH_ORIENTATION_NONE
|
||||
#endif
|
||||
#endif
|
||||
|
@ -364,7 +364,7 @@
|
||||
|
||||
// Touch Screen or "Touch Buttons" need XPT2046 pins
|
||||
// but they use different components
|
||||
#if EITHER(HAS_TFT_XPT2046, HAS_TOUCH_XPT2046)
|
||||
#if EITHER(HAS_TFT_XPT2046, HAS_TOUCH_BUTTONS)
|
||||
#define NEED_TOUCH_PINS 1
|
||||
#endif
|
||||
|
||||
|
@ -3172,17 +3172,17 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
|
||||
* Touch Buttons
|
||||
*/
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#error "XPT2046_X_CALIBRATION must be defined with TOUCH_SCREEN."
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#error "TOUCH_CALIBRATION_X must be defined with TOUCH_SCREEN."
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#error "XPT2046_Y_CALIBRATION must be defined with TOUCH_SCREEN."
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#error "TOUCH_CALIBRATION_Y must be defined with TOUCH_SCREEN."
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#error "XPT2046_X_OFFSET must be defined with TOUCH_SCREEN."
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#error "TOUCH_OFFSET_X must be defined with TOUCH_SCREEN."
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#error "XPT2046_Y_OFFSET must be defined with TOUCH_SCREEN."
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#error "TOUCH_OFFSET_Y must be defined with TOUCH_SCREEN."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -75,6 +75,11 @@ TFT_IO tftio;
|
||||
|
||||
#include "../touch/touch_buttons.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../tft_io/touch_calibration.h"
|
||||
#include "../marlinui.h"
|
||||
#endif
|
||||
|
||||
#define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1)
|
||||
#define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1)
|
||||
|
||||
@ -129,7 +134,7 @@ static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin,
|
||||
tftio.set_window(Xmin, Ymin, Xmax, Ymax);
|
||||
}
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
||||
static const uint8_t buttonD[] = {
|
||||
B01111111,B11111111,B11111111,B11111110,
|
||||
@ -302,7 +307,7 @@ static void setWindow(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin,
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_TOUCH_XPT2046
|
||||
#endif // HAS_TOUCH_BUTTONS
|
||||
|
||||
// Used to fill RGB565 (16bits) background
|
||||
inline void memset2(const void *ptr, uint16_t fill, size_t cnt) {
|
||||
@ -313,6 +318,27 @@ inline void memset2(const void *ptr, uint16_t fill, size_t cnt) {
|
||||
static bool preinit = true;
|
||||
static uint8_t page;
|
||||
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
static bool redrawTouchButtons = true;
|
||||
static void drawTouchButtons(u8g_t *u8g, u8g_dev_t *dev) {
|
||||
if (!redrawTouchButtons) return;
|
||||
redrawTouchButtons = false;
|
||||
|
||||
// Bottom buttons
|
||||
setWindow(u8g, dev, BUTTOND_X_LO, BUTTON_Y_LO, BUTTOND_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonD, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTCANCEL_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONA_X_LO, BUTTON_Y_LO, BUTTONA_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonA, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTARROWS_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONB_X_LO, BUTTON_Y_LO, BUTTONB_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonB, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTARROWS_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONC_X_LO, BUTTON_Y_LO, BUTTONC_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonC, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTOKMENU_COLOR);
|
||||
}
|
||||
#endif // HAS_TOUCH_BUTTONS
|
||||
|
||||
uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
@ -328,6 +354,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
||||
dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, nullptr);
|
||||
tftio.Init();
|
||||
tftio.InitTFT();
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
|
||||
|
||||
if (preinit) {
|
||||
preinit = false;
|
||||
@ -343,28 +370,13 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
||||
for (uint16_t i = 0; i < (TFT_HEIGHT) * sq(GRAPHICAL_TFT_UPSCALE); i++)
|
||||
u8g_WriteSequence(u8g, dev, (TFT_WIDTH) / 2, (uint8_t *)buffer);
|
||||
#endif
|
||||
|
||||
// Bottom buttons
|
||||
#if HAS_TOUCH_XPT2046
|
||||
setWindow(u8g, dev, BUTTOND_X_LO, BUTTON_Y_LO, BUTTOND_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonD, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTCANCEL_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONA_X_LO, BUTTON_Y_LO, BUTTONA_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonA, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTARROWS_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONB_X_LO, BUTTON_Y_LO, BUTTONB_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonB, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTARROWS_COLOR);
|
||||
|
||||
setWindow(u8g, dev, BUTTONC_X_LO, BUTTON_Y_LO, BUTTONC_X_HI, BUTTON_Y_HI);
|
||||
drawImage(buttonC, u8g, dev, BUTTON_DRAW_WIDTH, BUTTON_DRAW_HEIGHT, TFT_BTOKMENU_COLOR);
|
||||
#endif // HAS_TOUCH_XPT2046
|
||||
|
||||
return 0;
|
||||
|
||||
case U8G_DEV_MSG_STOP: preinit = true; break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
page = 0;
|
||||
TERN_(HAS_TOUCH_BUTTONS, drawTouchButtons(u8g, dev));
|
||||
setWindow(u8g, dev, TFT_PIXEL_OFFSET_X, TFT_PIXEL_OFFSET_Y, X_HI, Y_HI);
|
||||
break;
|
||||
|
||||
@ -456,4 +468,65 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p
|
||||
|
||||
U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tft_320x240_upscale_from_128x64_fn, U8G_COM_HAL_TFT_FN);
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
static void drawCross(uint16_t x, uint16_t y, uint16_t color) {
|
||||
tftio.set_window(x - 15, y, x + 15, y);
|
||||
tftio.WriteMultiple(color, 31);
|
||||
tftio.set_window(x, y - 15, x, y + 15);
|
||||
tftio.WriteMultiple(color, 31);
|
||||
}
|
||||
|
||||
void MarlinUI::touch_calibration_screen() {
|
||||
uint16_t x, y;
|
||||
calibrationState calibration_stage = touch_calibration.get_calibration_state();
|
||||
|
||||
if (calibration_stage == CALIBRATION_NONE) {
|
||||
// start and clear screen
|
||||
defer_status_screen(true);
|
||||
calibration_stage = touch_calibration.calibration_start();
|
||||
tftio.set_window(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
|
||||
tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT));
|
||||
}
|
||||
else {
|
||||
// clear last cross
|
||||
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
drawCross(x, y, TFT_MARLINBG_COLOR);
|
||||
}
|
||||
|
||||
const char *str = nullptr;
|
||||
if (calibration_stage < CALIBRATION_SUCCESS) {
|
||||
// handle current state
|
||||
switch (calibration_stage) {
|
||||
case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break;
|
||||
case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT(MSG_BOTTOM_RIGHT); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
x = touch_calibration.calibration_points[calibration_stage].x;
|
||||
y = touch_calibration.calibration_points[calibration_stage].y;
|
||||
drawCross(x, y, TFT_MARLINUI_COLOR);
|
||||
}
|
||||
else {
|
||||
// end calibration
|
||||
str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED);
|
||||
defer_status_screen(false);
|
||||
touch_calibration.calibration_end();
|
||||
TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
|
||||
}
|
||||
|
||||
// draw current message
|
||||
tftio.set_window(TFT_PIXEL_OFFSET_X, TFT_PIXEL_OFFSET_Y, X_HI, Y_HI);
|
||||
do {
|
||||
set_font(FONT_MENU);
|
||||
lcd_put_u8str(0, LCD_PIXEL_HEIGHT / 2, str);
|
||||
} while (u8g.nextPage());
|
||||
drawing_screen = false;
|
||||
}
|
||||
|
||||
#endif // TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
#endif // HAS_MARLINUI_U8GLIB && (FSMC_CS_PIN || HAS_SPI_GRAPHICAL_TFT)
|
||||
|
120
Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.cpp
Normal file
120
Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if BOTH(HAS_TFT_LVGL_UI, TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include "draw_touch_calibration.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../../inc/MarlinConfig.h"
|
||||
#include "../../../tft_io/touch_calibration.h"
|
||||
#include "SPI_TFT.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *status_label;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event);
|
||||
|
||||
enum {
|
||||
ID_TC_RETURN = 1
|
||||
};
|
||||
|
||||
static void drawCross(uint16_t x, uint16_t y, uint16_t color) {
|
||||
SPI_TFT.tftio.set_window(x - 15, y, x + 15, y);
|
||||
SPI_TFT.tftio.WriteMultiple(color, 31);
|
||||
SPI_TFT.tftio.set_window(x, y - 15, x, y + 15);
|
||||
SPI_TFT.tftio.WriteMultiple(color, 31);
|
||||
}
|
||||
|
||||
void lv_update_touch_calibration_screen() {
|
||||
uint16_t x, y;
|
||||
|
||||
calibrationState calibration_stage = touch_calibration.get_calibration_state();
|
||||
if (calibration_stage == CALIBRATION_NONE) {
|
||||
// start and clear screen
|
||||
calibration_stage = touch_calibration.calibration_start();
|
||||
}
|
||||
else {
|
||||
// clear last cross
|
||||
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
drawCross(x, y, LV_COLOR_BACKGROUND.full);
|
||||
}
|
||||
|
||||
const char *str = nullptr;
|
||||
if (calibration_stage < CALIBRATION_SUCCESS) {
|
||||
// handle current state
|
||||
switch (calibration_stage) {
|
||||
case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break;
|
||||
case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT(MSG_BOTTOM_RIGHT); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
x = touch_calibration.calibration_points[calibration_stage].x;
|
||||
y = touch_calibration.calibration_points[calibration_stage].y;
|
||||
drawCross(x, y, LV_COLOR_WHITE.full);
|
||||
}
|
||||
else {
|
||||
// end calibration
|
||||
str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED);
|
||||
touch_calibration.calibration_end();
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_TC_RETURN);
|
||||
}
|
||||
|
||||
// draw current message
|
||||
lv_label_set_text(status_label, str);
|
||||
lv_obj_align(status_label, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_TC_RETURN:
|
||||
TERN_(MKS_TEST, curent_disp_ui = 1);
|
||||
lv_clear_touch_calibration_screen();
|
||||
lv_draw_ready_print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_touch_calibration_screen() {
|
||||
disp_state_stack._disp_index = 0;
|
||||
ZERO(disp_state_stack._disp_state);
|
||||
scr = lv_screen_create(TOUCH_CALIBRATION_UI, "");
|
||||
|
||||
status_label = lv_label_create(scr, "");
|
||||
lv_obj_align(status_label, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_refr_now(lv_refr_get_disp_refreshing());
|
||||
|
||||
lv_update_touch_calibration_screen();
|
||||
}
|
||||
|
||||
void lv_clear_touch_calibration_screen() {
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && TOUCH_SCREEN_CALIBRATION
|
35
Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h
Normal file
35
Marlin/src/lcd/extui/lib/mks_ui/draw_touch_calibration.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
extern void lv_draw_touch_calibration_screen();
|
||||
extern void lv_clear_touch_calibration_screen();
|
||||
extern void lv_update_touch_calibration_screen();
|
||||
|
||||
//extern void disp_temp_ready_print();
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
@ -48,6 +48,10 @@
|
||||
#include "../../../../feature/pause.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "draw_touch_calibration.h"
|
||||
#endif
|
||||
|
||||
CFG_ITMES gCfgItems;
|
||||
UI_CFG uiCfg;
|
||||
DISP_STATE_STACK disp_state_stack;
|
||||
@ -1138,227 +1142,94 @@ void clear_cur_ui() {
|
||||
last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index];
|
||||
|
||||
switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
|
||||
case PRINT_READY_UI:
|
||||
//Get_Temperature_Flg = 0;
|
||||
lv_clear_ready_print();
|
||||
break;
|
||||
case PRINT_FILE_UI:
|
||||
lv_clear_print_file();
|
||||
break;
|
||||
case PRINTING_UI:
|
||||
lv_clear_printing();
|
||||
break;
|
||||
case MOVE_MOTOR_UI:
|
||||
lv_clear_move_motor();
|
||||
break;
|
||||
case OPERATE_UI:
|
||||
lv_clear_operation();
|
||||
break;
|
||||
case PAUSE_UI:
|
||||
//Clear_pause();
|
||||
break;
|
||||
case EXTRUSION_UI:
|
||||
lv_clear_extrusion();
|
||||
break;
|
||||
case PRE_HEAT_UI:
|
||||
lv_clear_preHeat();
|
||||
break;
|
||||
case CHANGE_SPEED_UI:
|
||||
lv_clear_change_speed();
|
||||
break;
|
||||
case FAN_UI:
|
||||
lv_clear_fan();
|
||||
break;
|
||||
case SET_UI:
|
||||
lv_clear_set();
|
||||
break;
|
||||
case ZERO_UI:
|
||||
lv_clear_home();
|
||||
break;
|
||||
case SPRAYER_UI:
|
||||
//Clear_Sprayer();
|
||||
break;
|
||||
case MACHINE_UI:
|
||||
//Clear_Machine();
|
||||
break;
|
||||
case LANGUAGE_UI:
|
||||
lv_clear_language();
|
||||
break;
|
||||
case ABOUT_UI:
|
||||
lv_clear_about();
|
||||
break;
|
||||
case LOG_UI:
|
||||
//Clear_Connect();
|
||||
break;
|
||||
case DISK_UI:
|
||||
//Clear_Disk();
|
||||
break;
|
||||
case PRINT_READY_UI: //Get_Temperature_Flg = 0;
|
||||
lv_clear_ready_print(); break;
|
||||
case PRINT_FILE_UI: lv_clear_print_file(); break;
|
||||
case PRINTING_UI: lv_clear_printing(); break;
|
||||
case MOVE_MOTOR_UI: lv_clear_move_motor(); break;
|
||||
case OPERATE_UI: lv_clear_operation(); break;
|
||||
case PAUSE_UI: /* Clear_pause(); */ break;
|
||||
case EXTRUSION_UI: lv_clear_extrusion(); break;
|
||||
case PRE_HEAT_UI: lv_clear_preHeat(); break;
|
||||
case CHANGE_SPEED_UI: lv_clear_change_speed(); break;
|
||||
case FAN_UI: lv_clear_fan(); break;
|
||||
case SET_UI: lv_clear_set(); break;
|
||||
case ZERO_UI: lv_clear_home(); break;
|
||||
case SPRAYER_UI: /* Clear_Sprayer(); */ break;
|
||||
case MACHINE_UI: /* Clear_Machine(); */ break;
|
||||
case LANGUAGE_UI: lv_clear_language(); break;
|
||||
case ABOUT_UI: lv_clear_about(); break;
|
||||
case LOG_UI: /* Clear_Connect(); */ break;
|
||||
case DISK_UI: /* Clear_Disk(); */ break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_UI:
|
||||
lv_clear_wifi();
|
||||
break;
|
||||
case WIFI_UI: lv_clear_wifi(); break;
|
||||
#endif
|
||||
case MORE_UI:
|
||||
//Clear_more();
|
||||
break;
|
||||
case FILETRANSFER_UI:
|
||||
//Clear_fileTransfer();
|
||||
break;
|
||||
case DIALOG_UI:
|
||||
lv_clear_dialog();
|
||||
break;
|
||||
case FILETRANSFERSTATE_UI:
|
||||
//Clear_WifiFileTransferdialog();
|
||||
break;
|
||||
case PRINT_MORE_UI:
|
||||
//Clear_Printmore();
|
||||
break;
|
||||
case FILAMENTCHANGE_UI:
|
||||
lv_clear_filament_change();
|
||||
break;
|
||||
case LEVELING_UI:
|
||||
lv_clear_manualLevel();
|
||||
break;
|
||||
case BIND_UI:
|
||||
//Clear_Bind();
|
||||
break;
|
||||
case MORE_UI: /* Clear_more(); */ break;
|
||||
case FILETRANSFER_UI: /* Clear_fileTransfer(); */ break;
|
||||
case DIALOG_UI: lv_clear_dialog(); break;
|
||||
case FILETRANSFERSTATE_UI: /* Clear_WifiFileTransferdialog(); */ break;
|
||||
case PRINT_MORE_UI: /* Clear_Printmore(); */ break;
|
||||
case FILAMENTCHANGE_UI: lv_clear_filament_change(); break;
|
||||
case LEVELING_UI: lv_clear_manualLevel(); break;
|
||||
case BIND_UI: /* Clear_Bind(); */ break;
|
||||
#if HAS_BED_PROBE
|
||||
case NOZZLE_PROBE_OFFSET_UI:
|
||||
lv_clear_auto_level_offset_settings();
|
||||
break;
|
||||
case NOZZLE_PROBE_OFFSET_UI: lv_clear_auto_level_offset_settings(); break;
|
||||
#endif
|
||||
case TOOL_UI:
|
||||
lv_clear_tool();
|
||||
break;
|
||||
case MESHLEVELING_UI:
|
||||
//Clear_MeshLeveling();
|
||||
break;
|
||||
case HARDWARE_TEST_UI:
|
||||
//Clear_Hardwaretest();
|
||||
break;
|
||||
case TOOL_UI: lv_clear_tool(); break;
|
||||
case MESHLEVELING_UI: /* Clear_MeshLeveling(); */ break;
|
||||
case HARDWARE_TEST_UI: /* Clear_Hardwaretest(); */ break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_LIST_UI:
|
||||
lv_clear_wifi_list();
|
||||
break;
|
||||
case WIFI_LIST_UI: lv_clear_wifi_list(); break;
|
||||
#endif
|
||||
case KEY_BOARD_UI:
|
||||
lv_clear_keyboard();
|
||||
break;
|
||||
case KEY_BOARD_UI: lv_clear_keyboard(); break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_TIPS_UI:
|
||||
lv_clear_wifi_tips();
|
||||
break;
|
||||
case WIFI_TIPS_UI: lv_clear_wifi_tips(); break;
|
||||
#endif
|
||||
case MACHINE_PARA_UI:
|
||||
lv_clear_machine_para();
|
||||
break;
|
||||
case MACHINE_SETTINGS_UI:
|
||||
lv_clear_machine_settings();
|
||||
break;
|
||||
case TEMPERATURE_SETTINGS_UI:
|
||||
//Clear_TemperatureSettings();
|
||||
break;
|
||||
case MOTOR_SETTINGS_UI:
|
||||
lv_clear_motor_settings();
|
||||
break;
|
||||
case MACHINETYPE_UI:
|
||||
//Clear_MachineType();
|
||||
break;
|
||||
case STROKE_UI:
|
||||
//Clear_Stroke();
|
||||
break;
|
||||
case HOME_DIR_UI:
|
||||
//Clear_HomeDir();
|
||||
break;
|
||||
case ENDSTOP_TYPE_UI:
|
||||
//Clear_EndstopType();
|
||||
break;
|
||||
case FILAMENT_SETTINGS_UI:
|
||||
lv_clear_filament_settings();
|
||||
break;
|
||||
case LEVELING_SETTIGNS_UI:
|
||||
//Clear_LevelingSettings();
|
||||
break;
|
||||
case LEVELING_PARA_UI:
|
||||
lv_clear_level_settings();
|
||||
break;
|
||||
case DELTA_LEVELING_PARA_UI:
|
||||
//Clear_DeltaLevelPara();
|
||||
break;
|
||||
case MANUAL_LEVELING_POSIGION_UI:
|
||||
lv_clear_manual_level_pos_settings();
|
||||
break;
|
||||
case MAXFEEDRATE_UI:
|
||||
lv_clear_max_feedrate_settings();
|
||||
break;
|
||||
case STEPS_UI:
|
||||
lv_clear_step_settings();
|
||||
break;
|
||||
case ACCELERATION_UI:
|
||||
lv_clear_acceleration_settings();
|
||||
break;
|
||||
case JERK_UI:
|
||||
#if HAS_CLASSIC_JERK
|
||||
lv_clear_jerk_settings();
|
||||
#endif
|
||||
break;
|
||||
case MOTORDIR_UI:
|
||||
//Clear_MotorDir();
|
||||
break;
|
||||
case HOMESPEED_UI:
|
||||
//Clear_HomeSpeed();
|
||||
break;
|
||||
case NOZZLE_CONFIG_UI:
|
||||
//Clear_NozzleConfig();
|
||||
break;
|
||||
case HOTBED_CONFIG_UI:
|
||||
//Clear_HotbedConfig();
|
||||
break;
|
||||
case ADVANCED_UI:
|
||||
lv_clear_advance_settings();
|
||||
break;
|
||||
case DOUBLE_Z_UI:
|
||||
//Clear_DoubleZ();
|
||||
break;
|
||||
case ENABLE_INVERT_UI:
|
||||
//Clear_EnableInvert();
|
||||
break;
|
||||
case NUMBER_KEY_UI:
|
||||
lv_clear_number_key();
|
||||
break;
|
||||
case BABY_STEP_UI:
|
||||
lv_clear_baby_stepping();
|
||||
break;
|
||||
case PAUSE_POS_UI:
|
||||
lv_clear_pause_position();
|
||||
break;
|
||||
case MACHINE_PARA_UI: lv_clear_machine_para(); break;
|
||||
case MACHINE_SETTINGS_UI: lv_clear_machine_settings(); break;
|
||||
case TEMPERATURE_SETTINGS_UI: /* Clear_TemperatureSettings(); */ break;
|
||||
case MOTOR_SETTINGS_UI: lv_clear_motor_settings(); break;
|
||||
case MACHINETYPE_UI: /* Clear_MachineType(); */ break;
|
||||
case STROKE_UI: /* Clear_Stroke(); */ break;
|
||||
case HOME_DIR_UI: /* Clear_HomeDir(); */ break;
|
||||
case ENDSTOP_TYPE_UI: /* Clear_EndstopType(); */ break;
|
||||
case FILAMENT_SETTINGS_UI: lv_clear_filament_settings(); break;
|
||||
case LEVELING_SETTIGNS_UI: /* Clear_LevelingSettings(); */ break;
|
||||
case LEVELING_PARA_UI: lv_clear_level_settings(); break;
|
||||
case DELTA_LEVELING_PARA_UI: /* Clear_DeltaLevelPara(); */ break;
|
||||
case MANUAL_LEVELING_POSIGION_UI: lv_clear_manual_level_pos_settings(); break;
|
||||
case MAXFEEDRATE_UI: lv_clear_max_feedrate_settings(); break;
|
||||
case STEPS_UI: lv_clear_step_settings(); break;
|
||||
case ACCELERATION_UI: lv_clear_acceleration_settings(); break;
|
||||
case JERK_UI: TERN_(HAS_CLASSIC_JERK, lv_clear_jerk_settings()); break;
|
||||
case MOTORDIR_UI: /* Clear_MotorDir(); */ break;
|
||||
case HOMESPEED_UI: /* Clear_HomeSpeed(); */ break;
|
||||
case NOZZLE_CONFIG_UI: /* Clear_NozzleConfig(); */ break;
|
||||
case HOTBED_CONFIG_UI: /* Clear_HotbedConfig(); */ break;
|
||||
case ADVANCED_UI: lv_clear_advance_settings(); break;
|
||||
case DOUBLE_Z_UI: /* Clear_DoubleZ(); */ break;
|
||||
case ENABLE_INVERT_UI: /* Clear_EnableInvert(); */ break;
|
||||
case NUMBER_KEY_UI: lv_clear_number_key(); break;
|
||||
case BABY_STEP_UI: lv_clear_baby_stepping(); break;
|
||||
case PAUSE_POS_UI: lv_clear_pause_position(); break;
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
case TMC_CURRENT_UI:
|
||||
lv_clear_tmc_current_settings();
|
||||
break;
|
||||
case TMC_CURRENT_UI: lv_clear_tmc_current_settings(); break;
|
||||
#endif
|
||||
case EEPROM_SETTINGS_UI:
|
||||
lv_clear_eeprom_settings();
|
||||
break;
|
||||
case EEPROM_SETTINGS_UI: lv_clear_eeprom_settings(); break;
|
||||
#if HAS_STEALTHCHOP
|
||||
case TMC_MODE_UI:
|
||||
lv_clear_tmc_step_mode_settings();
|
||||
break;
|
||||
case TMC_MODE_UI: lv_clear_tmc_step_mode_settings(); break;
|
||||
#endif
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_SETTINGS_UI:
|
||||
lv_clear_wifi_settings();
|
||||
break;
|
||||
case WIFI_SETTINGS_UI: lv_clear_wifi_settings(); break;
|
||||
#endif
|
||||
#if USE_SENSORLESS
|
||||
case HOMING_SENSITIVITY_UI:
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
break;
|
||||
case HOMING_SENSITIVITY_UI: lv_clear_homing_sensitivity_settings(); break;
|
||||
#endif
|
||||
#if HAS_ROTARY_ENCODER
|
||||
case ENCODER_SETTINGS_UI:
|
||||
lv_clear_encoder_settings();
|
||||
break;
|
||||
case ENCODER_SETTINGS_UI: lv_clear_encoder_settings(); break;
|
||||
#endif
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
case TOUCH_CALIBRATION_UI: lv_clear_touch_calibration_screen(); break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
@ -1370,227 +1241,98 @@ void draw_return_ui() {
|
||||
disp_state_stack._disp_index--;
|
||||
|
||||
switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
|
||||
case PRINT_READY_UI:
|
||||
lv_draw_ready_print();
|
||||
break;
|
||||
case PRINT_FILE_UI:
|
||||
lv_draw_print_file();
|
||||
break;
|
||||
case PRINTING_UI:
|
||||
if (gCfgItems.from_flash_pic) flash_preview_begin = true;
|
||||
else default_preview_flg = true;
|
||||
lv_draw_printing();
|
||||
break;
|
||||
case MOVE_MOTOR_UI:
|
||||
lv_draw_move_motor();
|
||||
break;
|
||||
case OPERATE_UI:
|
||||
lv_draw_operation();
|
||||
break;
|
||||
case PRINT_READY_UI: lv_draw_ready_print(); break;
|
||||
case PRINT_FILE_UI: lv_draw_print_file(); break;
|
||||
|
||||
#if 1
|
||||
case PAUSE_UI:
|
||||
//draw_pause();
|
||||
break;
|
||||
#endif
|
||||
case PRINTING_UI: if (gCfgItems.from_flash_pic)
|
||||
flash_preview_begin = true;
|
||||
else
|
||||
default_preview_flg = true;
|
||||
lv_draw_printing();
|
||||
break;
|
||||
|
||||
case EXTRUSION_UI:
|
||||
lv_draw_extrusion();
|
||||
break;
|
||||
case PRE_HEAT_UI:
|
||||
lv_draw_preHeat();
|
||||
break;
|
||||
case CHANGE_SPEED_UI:
|
||||
lv_draw_change_speed();
|
||||
break;
|
||||
case FAN_UI:
|
||||
lv_draw_fan();
|
||||
break;
|
||||
case SET_UI:
|
||||
lv_draw_set();
|
||||
break;
|
||||
case ZERO_UI:
|
||||
lv_draw_home();
|
||||
break;
|
||||
case SPRAYER_UI:
|
||||
//draw_Sprayer();
|
||||
break;
|
||||
case MACHINE_UI:
|
||||
//draw_Machine();
|
||||
break;
|
||||
case LANGUAGE_UI:
|
||||
lv_draw_language();
|
||||
break;
|
||||
case ABOUT_UI:
|
||||
lv_draw_about();
|
||||
break;
|
||||
case MOVE_MOTOR_UI: lv_draw_move_motor(); break;
|
||||
case OPERATE_UI: lv_draw_operation(); break;
|
||||
case PAUSE_UI: /* draw_pause(); */ break;
|
||||
case EXTRUSION_UI: lv_draw_extrusion(); break;
|
||||
case PRE_HEAT_UI: lv_draw_preHeat(); break;
|
||||
case CHANGE_SPEED_UI: lv_draw_change_speed(); break;
|
||||
case FAN_UI: lv_draw_fan(); break;
|
||||
case SET_UI: lv_draw_set(); break;
|
||||
case ZERO_UI: lv_draw_home(); break;
|
||||
case SPRAYER_UI: /* draw_Sprayer(); */ break;
|
||||
case MACHINE_UI: /* draw_Machine(); */ break;
|
||||
case LANGUAGE_UI: lv_draw_language(); break;
|
||||
case ABOUT_UI: lv_draw_about(); break;
|
||||
|
||||
case CALIBRATE_UI:
|
||||
//draw_calibrate();
|
||||
break;
|
||||
case DISK_UI:
|
||||
//draw_Disk();
|
||||
break;
|
||||
case CALIBRATE_UI: /* draw_calibrate(); */ break;
|
||||
case DISK_UI: /* draw_Disk(); */ break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_UI:
|
||||
lv_draw_wifi();
|
||||
break;
|
||||
case WIFI_UI: lv_draw_wifi(); break;
|
||||
#endif
|
||||
case MORE_UI:
|
||||
//draw_More();
|
||||
break;
|
||||
case PRINT_MORE_UI:
|
||||
//draw_printmore();
|
||||
break;
|
||||
case FILAMENTCHANGE_UI:
|
||||
lv_draw_filament_change();
|
||||
break;
|
||||
case LEVELING_UI:
|
||||
lv_draw_manualLevel();
|
||||
break;
|
||||
case BIND_UI:
|
||||
//draw_bind();
|
||||
break;
|
||||
case MORE_UI: /* draw_More(); */ break;
|
||||
case PRINT_MORE_UI: /* draw_printmore(); */ break;
|
||||
case FILAMENTCHANGE_UI: lv_draw_filament_change(); break;
|
||||
case LEVELING_UI: lv_draw_manualLevel(); break;
|
||||
case BIND_UI: /* draw_bind(); */ break;
|
||||
#if HAS_BED_PROBE
|
||||
case NOZZLE_PROBE_OFFSET_UI:
|
||||
lv_draw_auto_level_offset_settings();
|
||||
break;
|
||||
case NOZZLE_PROBE_OFFSET_UI: lv_draw_auto_level_offset_settings(); break;
|
||||
#endif
|
||||
case TOOL_UI:
|
||||
lv_draw_tool();
|
||||
break;
|
||||
case MESHLEVELING_UI:
|
||||
//draw_meshleveling();
|
||||
break;
|
||||
case HARDWARE_TEST_UI:
|
||||
//draw_Hardwaretest();
|
||||
break;
|
||||
case WIFI_LIST_UI:
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
lv_draw_wifi_list();
|
||||
#endif
|
||||
break;
|
||||
case KEY_BOARD_UI:
|
||||
lv_draw_keyboard();
|
||||
break;
|
||||
case WIFI_TIPS_UI:
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
lv_draw_wifi_tips();
|
||||
#endif
|
||||
break;
|
||||
case MACHINE_PARA_UI:
|
||||
lv_draw_machine_para();
|
||||
break;
|
||||
case MACHINE_SETTINGS_UI:
|
||||
lv_draw_machine_settings();
|
||||
break;
|
||||
case TEMPERATURE_SETTINGS_UI:
|
||||
//draw_TemperatureSettings();
|
||||
break;
|
||||
case MOTOR_SETTINGS_UI:
|
||||
lv_draw_motor_settings();
|
||||
break;
|
||||
case MACHINETYPE_UI:
|
||||
//draw_MachineType();
|
||||
break;
|
||||
case STROKE_UI:
|
||||
//draw_Stroke();
|
||||
break;
|
||||
case HOME_DIR_UI:
|
||||
//draw_HomeDir();
|
||||
break;
|
||||
case ENDSTOP_TYPE_UI:
|
||||
//draw_EndstopType();
|
||||
break;
|
||||
case FILAMENT_SETTINGS_UI:
|
||||
lv_draw_filament_settings();
|
||||
break;
|
||||
case LEVELING_SETTIGNS_UI:
|
||||
//draw_LevelingSettings();
|
||||
break;
|
||||
case LEVELING_PARA_UI:
|
||||
lv_draw_level_settings();
|
||||
break;
|
||||
case DELTA_LEVELING_PARA_UI:
|
||||
//draw_DeltaLevelPara();
|
||||
break;
|
||||
case MANUAL_LEVELING_POSIGION_UI:
|
||||
lv_draw_manual_level_pos_settings();
|
||||
break;
|
||||
case MAXFEEDRATE_UI:
|
||||
lv_draw_max_feedrate_settings();
|
||||
break;
|
||||
case STEPS_UI:
|
||||
lv_draw_step_settings();
|
||||
break;
|
||||
case ACCELERATION_UI:
|
||||
lv_draw_acceleration_settings();
|
||||
break;
|
||||
case JERK_UI:
|
||||
#if HAS_CLASSIC_JERK
|
||||
lv_draw_jerk_settings();
|
||||
#endif
|
||||
break;
|
||||
case MOTORDIR_UI:
|
||||
//draw_MotorDir();
|
||||
break;
|
||||
case HOMESPEED_UI:
|
||||
//draw_HomeSpeed();
|
||||
break;
|
||||
case NOZZLE_CONFIG_UI:
|
||||
//draw_NozzleConfig();
|
||||
break;
|
||||
case HOTBED_CONFIG_UI:
|
||||
//draw_HotbedConfig();
|
||||
break;
|
||||
case ADVANCED_UI:
|
||||
lv_draw_advance_settings();
|
||||
break;
|
||||
case DOUBLE_Z_UI:
|
||||
//draw_DoubleZ();
|
||||
break;
|
||||
case ENABLE_INVERT_UI:
|
||||
//draw_EnableInvert();
|
||||
break;
|
||||
case NUMBER_KEY_UI:
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case DIALOG_UI:
|
||||
//draw_dialog(uiCfg.dialogType);
|
||||
break;
|
||||
case BABY_STEP_UI:
|
||||
lv_draw_baby_stepping();
|
||||
break;
|
||||
case PAUSE_POS_UI:
|
||||
lv_draw_pause_position();
|
||||
break;
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
case TMC_CURRENT_UI:
|
||||
lv_draw_tmc_current_settings();
|
||||
break;
|
||||
#endif
|
||||
case EEPROM_SETTINGS_UI:
|
||||
lv_draw_eeprom_settings();
|
||||
break;
|
||||
case TOOL_UI: lv_draw_tool(); break;
|
||||
case MESHLEVELING_UI: /* draw_meshleveling(); */ break;
|
||||
case HARDWARE_TEST_UI: /* draw_Hardwaretest(); */ break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_LIST_UI: lv_draw_wifi_list(); break;
|
||||
#endif
|
||||
case KEY_BOARD_UI: lv_draw_keyboard(); break;
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_TIPS_UI: lv_draw_wifi_tips(); break;
|
||||
#endif
|
||||
case MACHINE_PARA_UI: lv_draw_machine_para(); break;
|
||||
case MACHINE_SETTINGS_UI: lv_draw_machine_settings(); break;
|
||||
case TEMPERATURE_SETTINGS_UI: /* draw_TemperatureSettings(); */ break;
|
||||
case MOTOR_SETTINGS_UI: lv_draw_motor_settings(); break;
|
||||
case MACHINETYPE_UI: /* draw_MachineType(); */ break;
|
||||
case STROKE_UI: /* draw_Stroke(); */ break;
|
||||
case HOME_DIR_UI: /* draw_HomeDir(); */ break;
|
||||
case ENDSTOP_TYPE_UI: /* draw_EndstopType(); */ break;
|
||||
case FILAMENT_SETTINGS_UI: lv_draw_filament_settings(); break;
|
||||
case LEVELING_SETTIGNS_UI: /* draw_LevelingSettings(); */ break;
|
||||
case LEVELING_PARA_UI: lv_draw_level_settings(); break;
|
||||
case DELTA_LEVELING_PARA_UI: /* draw_DeltaLevelPara(); */ break;
|
||||
case MANUAL_LEVELING_POSIGION_UI: lv_draw_manual_level_pos_settings(); break;
|
||||
case MAXFEEDRATE_UI: lv_draw_max_feedrate_settings(); break;
|
||||
case STEPS_UI: lv_draw_step_settings(); break;
|
||||
case ACCELERATION_UI: lv_draw_acceleration_settings(); break;
|
||||
#if HAS_CLASSIC_JERK
|
||||
case JERK_UI: lv_draw_jerk_settings(); break;
|
||||
#endif
|
||||
case MOTORDIR_UI: /* draw_MotorDir(); */ break;
|
||||
case HOMESPEED_UI: /* draw_HomeSpeed(); */ break;
|
||||
case NOZZLE_CONFIG_UI: /* draw_NozzleConfig(); */ break;
|
||||
case HOTBED_CONFIG_UI: /* draw_HotbedConfig(); */ break;
|
||||
case ADVANCED_UI: lv_draw_advance_settings(); break;
|
||||
case DOUBLE_Z_UI: /* draw_DoubleZ(); */ break;
|
||||
case ENABLE_INVERT_UI: /* draw_EnableInvert(); */ break;
|
||||
case NUMBER_KEY_UI: lv_draw_number_key(); break;
|
||||
case DIALOG_UI: /* draw_dialog(uiCfg.dialogType); */ break;
|
||||
case BABY_STEP_UI: lv_draw_baby_stepping(); break;
|
||||
case PAUSE_POS_UI: lv_draw_pause_position(); break;
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
case TMC_CURRENT_UI: lv_draw_tmc_current_settings(); break;
|
||||
#endif
|
||||
case EEPROM_SETTINGS_UI: lv_draw_eeprom_settings(); break;
|
||||
#if HAS_STEALTHCHOP
|
||||
case TMC_MODE_UI:
|
||||
lv_draw_tmc_step_mode_settings();
|
||||
break;
|
||||
case TMC_MODE_UI: lv_draw_tmc_step_mode_settings(); break;
|
||||
#endif
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
case WIFI_SETTINGS_UI:
|
||||
lv_draw_wifi_settings();
|
||||
break;
|
||||
case WIFI_SETTINGS_UI: lv_draw_wifi_settings(); break;
|
||||
#endif
|
||||
#if USE_SENSORLESS
|
||||
case HOMING_SENSITIVITY_UI:
|
||||
lv_draw_homing_sensitivity_settings();
|
||||
break;
|
||||
case HOMING_SENSITIVITY_UI: lv_draw_homing_sensitivity_settings(); break;
|
||||
#endif
|
||||
#if HAS_ROTARY_ENCODER
|
||||
case ENCODER_SETTINGS_UI:
|
||||
lv_draw_encoder_settings();
|
||||
break;
|
||||
case ENCODER_SETTINGS_UI: lv_draw_encoder_settings(); break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
@ -1879,15 +1621,11 @@ void LV_TASK_HANDLER() {
|
||||
lv_task_handler();
|
||||
if (mks_test_flag == 0x1E) mks_hardware_test();
|
||||
|
||||
#if HAS_GCODE_PREVIEW
|
||||
disp_pre_gcode(2, 36);
|
||||
#endif
|
||||
TERN_(HAS_GCODE_PREVIEW, disp_pre_gcode(2, 36));
|
||||
|
||||
GUI_RefreshPage();
|
||||
|
||||
#if ENABLED(USE_WIFI_FUNCTION)
|
||||
get_wifi_commands();
|
||||
#endif
|
||||
TERN_(USE_WIFI_FUNCTION, get_wifi_commands());
|
||||
|
||||
//sd_detection();
|
||||
|
||||
|
@ -313,7 +313,8 @@ typedef enum {
|
||||
EEPROM_SETTINGS_UI,
|
||||
WIFI_SETTINGS_UI,
|
||||
HOMING_SENSITIVITY_UI,
|
||||
ENCODER_SETTINGS_UI
|
||||
ENCODER_SETTINGS_UI,
|
||||
TOUCH_CALIBRATION_UI
|
||||
} DISP_STATE;
|
||||
|
||||
typedef struct {
|
||||
|
@ -51,6 +51,11 @@ XPT2046 touch;
|
||||
#include "../../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../../../tft_io/touch_calibration.h"
|
||||
#include "draw_touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#ifndef TFT_WIDTH
|
||||
@ -211,7 +216,14 @@ void tft_lvgl_init() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ready) lv_draw_ready_print();
|
||||
if (ready) {
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
if (touch_calibration.need_calibration()) lv_draw_touch_calibration_screen();
|
||||
else lv_draw_ready_print();
|
||||
#else
|
||||
lv_draw_ready_print();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mks_test_flag == 0x1E)
|
||||
mks_gpio_test();
|
||||
@ -240,17 +252,22 @@ unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
|
||||
static bool get_point(int16_t *x, int16_t *y) {
|
||||
bool is_touched = touch.getRawPoint(x, y);
|
||||
|
||||
if (is_touched) {
|
||||
*x = int16_t((int32_t(*x) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET;
|
||||
*y = int16_t((int32_t(*y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
|
||||
}
|
||||
if (!is_touched) return false;
|
||||
|
||||
#if (TFT_ROTATION & TFT_ROTATE_180)
|
||||
*x = int16_t((TFT_WIDTH) - (int)(*x));
|
||||
*y = int16_t((TFT_HEIGHT) - (int)(*y));
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
const calibrationState state = touch_calibration.get_calibration_state();
|
||||
if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) {
|
||||
if (touch_calibration.handleTouch(*x, *y)) lv_update_touch_calibration_screen();
|
||||
return false;
|
||||
}
|
||||
*x = int16_t((int32_t(*x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
|
||||
*y = int16_t((int32_t(*y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
|
||||
#else
|
||||
*x = int16_t((int32_t(*x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
|
||||
*y = int16_t((int32_t(*y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
|
||||
#endif
|
||||
|
||||
return is_touched;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
|
||||
|
@ -671,6 +671,15 @@ namespace Language_en {
|
||||
PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard");
|
||||
|
||||
PROGMEM Language_Str MSG_SOUND = _UxGT("Sound");
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Top Left");
|
||||
PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Bottom Left");
|
||||
PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Top Right");
|
||||
PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Bottom Right");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibration Completed");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibration Failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FAN_COUNT == 1
|
||||
|
@ -570,4 +570,13 @@ namespace Language_fr {
|
||||
PROGMEM Language_Str MSG_SERVICE_IN = _UxGT(" dans:");
|
||||
PROGMEM Language_Str MSG_BACKLASH_CORRECTION = _UxGT("Correction");
|
||||
PROGMEM Language_Str MSG_BACKLASH_SMOOTHING = _UxGT("Lissage");
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Haut à Gauche");
|
||||
PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Bas à Gauche");
|
||||
PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Haut à Droite");
|
||||
PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Bas à Droite");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibration Terminée");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Échec de l'étalonnage");
|
||||
#endif
|
||||
}
|
||||
|
@ -160,4 +160,13 @@ namespace Language_pt {
|
||||
PROGMEM Language_Str MSG_LCD_ENDSTOPS = _UxGT("Fim de curso");
|
||||
|
||||
PROGMEM Language_Str MSG_KILL_EXPECTED_PRINTER = _UxGT("Impressora Incorreta");
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Superior Esquerdo");
|
||||
PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Inferior Esquerdo");
|
||||
PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Superior Direto");
|
||||
PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Inferior Direto");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibração Completa");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibração Falhou");
|
||||
#endif
|
||||
}
|
||||
|
@ -478,4 +478,13 @@ namespace Language_pt_br {
|
||||
PROGMEM Language_Str MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_1_LINE("Clique p. finalizar"));
|
||||
PROGMEM Language_Str MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("Continuando..."));
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
PROGMEM Language_Str MSG_TOP_LEFT = _UxGT("Superior Esquerdo");
|
||||
PROGMEM Language_Str MSG_BOTTOM_LEFT = _UxGT("Inferior Esquerdo");
|
||||
PROGMEM Language_Str MSG_TOP_RIGHT = _UxGT("Superior Direto");
|
||||
PROGMEM Language_Str MSG_BOTTOM_RIGHT = _UxGT("Inferior Direto");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_COMPLETED = _UxGT("Calibração Completa");
|
||||
PROGMEM Language_Str MSG_CALIBRATION_FAILED = _UxGT("Calibração Falhou");
|
||||
#endif
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
#if HAS_SLOW_BUTTONS
|
||||
volatile uint8_t MarlinUI::slow_buttons;
|
||||
#endif
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
#include "touch/touch_buttons.h"
|
||||
bool MarlinUI::on_edit_screen = false;
|
||||
#endif
|
||||
@ -241,7 +241,7 @@ millis_t MarlinUI::next_button_update_ms; // = 0
|
||||
int8_t MarlinUI::encoderDirection = ENCODERBASE;
|
||||
#endif
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
uint8_t MarlinUI::touch_buttons;
|
||||
uint8_t MarlinUI::repeat_delay;
|
||||
#endif
|
||||
@ -862,7 +862,7 @@ void MarlinUI::update() {
|
||||
quick_feedback(); // - Always make a click sound
|
||||
};
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
if (touch_buttons) {
|
||||
RESET_STATUS_TIMEOUT();
|
||||
if (touch_buttons & (EN_A | EN_B)) { // Menu arrows, in priority
|
||||
@ -883,7 +883,7 @@ void MarlinUI::update() {
|
||||
}
|
||||
else // keep wait_for_unclick value
|
||||
|
||||
#endif // HAS_TOUCH_XPT2046
|
||||
#endif // HAS_TOUCH_BUTTONS
|
||||
|
||||
{
|
||||
// Integrated LCD click handling via button_pressed
|
||||
@ -905,7 +905,7 @@ void MarlinUI::update() {
|
||||
|
||||
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
||||
if (on_status_screen()) next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2;
|
||||
|
||||
@ -1250,7 +1250,7 @@ void MarlinUI::update() {
|
||||
#if HAS_SLOW_BUTTONS
|
||||
| slow_buttons
|
||||
#endif
|
||||
#if BOTH(HAS_TOUCH_XPT2046, HAS_ENCODER_ACTION)
|
||||
#if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION)
|
||||
| (touch_buttons & TERN(HAS_ENCODER_WHEEL, ~(EN_A | EN_B), 0xFF))
|
||||
#endif
|
||||
);
|
||||
@ -1561,7 +1561,7 @@ void MarlinUI::update() {
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
||||
//
|
||||
// Screen Click
|
||||
|
@ -31,6 +31,10 @@
|
||||
#include "../sd/cardreader.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "tft_io/touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
|
||||
#define HAS_ENCODER_ACTION 1
|
||||
#endif
|
||||
@ -74,7 +78,7 @@
|
||||
uint8_t get_ADC_keyValue();
|
||||
#endif
|
||||
|
||||
#define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_XPT2046, 50, 100)
|
||||
#define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_BUTTONS, 50, 100)
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
@ -146,7 +150,7 @@
|
||||
|
||||
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
|
||||
|
||||
#if BUTTON_EXISTS(ENC) || HAS_TOUCH_XPT2046
|
||||
#if BUTTON_EXISTS(ENC) || HAS_TOUCH_BUTTONS
|
||||
#define BLEN_C 2
|
||||
#define EN_C _BV(BLEN_C)
|
||||
#endif
|
||||
@ -212,7 +216,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_XPT2046, IS_TFTGLCD_PANEL)
|
||||
#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_BUTTONS, IS_TFTGLCD_PANEL)
|
||||
#define BLEN_D 3
|
||||
#define EN_D _BV(BLEN_D)
|
||||
#define LCD_BACK_CLICKED() (buttons & EN_D)
|
||||
@ -311,6 +315,12 @@ public:
|
||||
// LCD implementations
|
||||
static void clear_lcd();
|
||||
|
||||
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION)
|
||||
static void check_touch_calibration() {
|
||||
if (touch_calibration.need_calibration()) currentScreen = touch_calibration_screen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
static void media_changed(const uint8_t old_stat, const uint8_t stat);
|
||||
#endif
|
||||
@ -452,7 +462,7 @@ public:
|
||||
static void draw_hotend_status(const uint8_t row, const uint8_t extruder);
|
||||
#endif
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
static bool on_edit_screen;
|
||||
static void screen_click(const uint8_t row, const uint8_t col, const uint8_t x, const uint8_t y);
|
||||
#endif
|
||||
@ -512,7 +522,7 @@ public:
|
||||
static millis_t return_to_status_ms;
|
||||
#endif
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
static uint8_t touch_buttons;
|
||||
static uint8_t repeat_delay;
|
||||
#endif
|
||||
@ -682,7 +692,7 @@ public:
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
static void touch_calibration();
|
||||
static void touch_calibration_screen();
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_TFT
|
||||
|
@ -82,7 +82,7 @@ void MarlinUI::save_previous_screen() {
|
||||
|
||||
void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
|
||||
IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false);
|
||||
TERN_(HAS_TOUCH_XPT2046, on_edit_screen = false);
|
||||
TERN_(HAS_TOUCH_BUTTONS, on_edit_screen = false);
|
||||
if (screen_history_depth > 0) {
|
||||
menuPosition &sh = screen_history[--screen_history_depth];
|
||||
goto_screen(sh.menu_function,
|
||||
@ -123,7 +123,7 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b
|
||||
* MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999)
|
||||
*/
|
||||
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
|
||||
TERN_(HAS_TOUCH_XPT2046, ui.repeat_delay = BUTTON_DELAY_EDIT);
|
||||
TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT);
|
||||
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
||||
if (ui.should_draw())
|
||||
@ -145,7 +145,7 @@ void MenuEditItemBase::goto_edit_screen(
|
||||
const screenFunc_t cb, // Callback after edit
|
||||
const bool le // Flag to call cb() during editing
|
||||
) {
|
||||
TERN_(HAS_TOUCH_XPT2046, ui.on_edit_screen = true);
|
||||
TERN_(HAS_TOUCH_BUTTONS, ui.on_edit_screen = true);
|
||||
ui.screen_changed = true;
|
||||
ui.save_previous_screen();
|
||||
ui.refresh();
|
||||
@ -175,7 +175,7 @@ bool printer_busy() {
|
||||
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
|
||||
if (currentScreen != screen) {
|
||||
|
||||
TERN_(HAS_TOUCH_XPT2046, repeat_delay = BUTTON_DELAY_MENU);
|
||||
TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU);
|
||||
|
||||
TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset());
|
||||
|
||||
|
@ -37,8 +37,10 @@
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_TFT
|
||||
#include "../tft/touch.h"
|
||||
#include "../tft/tft.h"
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
#include "../tft/touch.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
void touch_screen_calibration() {
|
||||
|
||||
ui.touch_calibration();
|
||||
ui.touch_calibration_screen();
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,17 +48,12 @@ millis_t Touch::last_touch_ms = 0,
|
||||
Touch::repeat_delay,
|
||||
Touch::touch_time;
|
||||
TouchControlType Touch::touch_control_type = NONE;
|
||||
touch_calibration_t Touch::calibration;
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
calibrationState Touch::calibration_state = CALIBRATION_NONE;
|
||||
touch_calibration_point_t Touch::calibration_points[4];
|
||||
#endif
|
||||
#if HAS_RESUME_CONTINUE
|
||||
extern bool wait_for_user;
|
||||
#endif
|
||||
|
||||
void Touch::init() {
|
||||
calibration_reset();
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
|
||||
reset();
|
||||
io.Init();
|
||||
enable();
|
||||
@ -155,52 +150,7 @@ void Touch::touch(touch_control_t *control) {
|
||||
switch (control->type) {
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
case CALIBRATE:
|
||||
ui.refresh();
|
||||
|
||||
if (calibration_state < CALIBRATION_SUCCESS) {
|
||||
calibration_points[calibration_state].x = int16_t(control->data >> 16);
|
||||
calibration_points[calibration_state].y = int16_t(control->data & 0xFFFF);
|
||||
calibration_points[calibration_state].raw_x = x;
|
||||
calibration_points[calibration_state].raw_y = y;
|
||||
}
|
||||
|
||||
switch (calibration_state) {
|
||||
case CALIBRATION_POINT_1: calibration_state = CALIBRATION_POINT_2; break;
|
||||
case CALIBRATION_POINT_2: calibration_state = CALIBRATION_POINT_3; break;
|
||||
case CALIBRATION_POINT_3: calibration_state = CALIBRATION_POINT_4; break;
|
||||
case CALIBRATION_POINT_4:
|
||||
if (validate_precision_x(0, 1) && validate_precision_x(2, 3) && validate_precision_y(0, 2) && validate_precision_y(1, 3)) {
|
||||
calibration_state = CALIBRATION_SUCCESS;
|
||||
calibration.x = ((calibration_points[2].x - calibration_points[0].x) << 17) / (calibration_points[3].raw_x + calibration_points[2].raw_x - calibration_points[1].raw_x - calibration_points[0].raw_x);
|
||||
calibration.y = ((calibration_points[1].y - calibration_points[0].y) << 17) / (calibration_points[3].raw_y - calibration_points[2].raw_y + calibration_points[1].raw_y - calibration_points[0].raw_y);
|
||||
calibration.offset_x = calibration_points[0].x - int16_t(((calibration_points[0].raw_x + calibration_points[1].raw_x) * calibration.x) >> 17);
|
||||
calibration.offset_y = calibration_points[0].y - int16_t(((calibration_points[0].raw_y + calibration_points[2].raw_y) * calibration.y) >> 17);
|
||||
calibration.orientation = TOUCH_LANDSCAPE;
|
||||
}
|
||||
else if (validate_precision_y(0, 1) && validate_precision_y(2, 3) && validate_precision_x(0, 2) && validate_precision_x(1, 3)) {
|
||||
calibration_state = CALIBRATION_SUCCESS;
|
||||
calibration.x = ((calibration_points[2].x - calibration_points[0].x) << 17) / (calibration_points[3].raw_y + calibration_points[2].raw_y - calibration_points[1].raw_y - calibration_points[0].raw_y);
|
||||
calibration.y = ((calibration_points[1].y - calibration_points[0].y) << 17) / (calibration_points[3].raw_x - calibration_points[2].raw_x + calibration_points[1].raw_x - calibration_points[0].raw_x);
|
||||
calibration.offset_x = calibration_points[0].x - int16_t(((calibration_points[0].raw_y + calibration_points[1].raw_y) * calibration.x) >> 17);
|
||||
calibration.offset_y = calibration_points[0].y - int16_t(((calibration_points[0].raw_x + calibration_points[2].raw_x) * calibration.y) >> 17);
|
||||
calibration.orientation = TOUCH_PORTRAIT;
|
||||
}
|
||||
else {
|
||||
calibration_state = CALIBRATION_FAIL;
|
||||
calibration_reset();
|
||||
}
|
||||
|
||||
if (calibration_state == CALIBRATION_SUCCESS) {
|
||||
SERIAL_ECHOLNPGM("Touch screen calibration completed");
|
||||
SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_X ", calibration.x);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_Y ", calibration.y);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y);
|
||||
SERIAL_ECHOPGM("TOUCH_ORIENTATION "); if (calibration.orientation == TOUCH_LANDSCAPE) SERIAL_ECHOLNPGM("TOUCH_LANDSCAPE"); else SERIAL_ECHOLNPGM("TOUCH_PORTRAIT");
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (touch_calibration.handleTouch(x, y)) ui.refresh();
|
||||
break;
|
||||
#endif // TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
@ -298,12 +248,18 @@ void Touch::hold(touch_control_t *control, millis_t delay) {
|
||||
}
|
||||
|
||||
bool Touch::get_point(int16_t *x, int16_t *y) {
|
||||
bool is_touched = (calibration.orientation == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
bool is_touched = (touch_calibration.calibration.orientation == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
|
||||
|
||||
if (is_touched && calibration.orientation != TOUCH_ORIENTATION_NONE) {
|
||||
*x = int16_t((int32_t(*x) * calibration.x) >> 16) + calibration.offset_x;
|
||||
*y = int16_t((int32_t(*y) * calibration.y) >> 16) + calibration.offset_y;
|
||||
}
|
||||
if (is_touched && touch_calibration.calibration.orientation != TOUCH_ORIENTATION_NONE) {
|
||||
*x = int16_t((int32_t(*x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
|
||||
*y = int16_t((int32_t(*y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
|
||||
}
|
||||
#else
|
||||
bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
|
||||
*x = uint16_t((uint32_t(*x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
|
||||
*y = uint16_t((uint32_t(*y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
|
||||
#endif
|
||||
return is_touched;
|
||||
}
|
||||
Touch touch;
|
||||
|
@ -23,42 +23,16 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
|
||||
#include "tft_color.h"
|
||||
#include "tft_image.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../tft_io/touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#include HAL_PATH(../../HAL, tft/xpt2046.h)
|
||||
#define TOUCH_DRIVER XPT2046
|
||||
|
||||
#ifndef TOUCH_SCREEN_CALIBRATION_PRECISION
|
||||
#define TOUCH_SCREEN_CALIBRATION_PRECISION 80
|
||||
#endif
|
||||
|
||||
#ifndef TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS
|
||||
#define TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS 2500
|
||||
#endif
|
||||
|
||||
#define TOUCH_ORIENTATION_NONE 0
|
||||
#define TOUCH_LANDSCAPE 1
|
||||
#define TOUCH_PORTRAIT 2
|
||||
|
||||
#if !(defined(TOUCH_CALIBRATION_X) || defined(TOUCH_CALIBRATION_Y) || defined(TOUCH_OFFSET_X) || defined(TOUCH_OFFSET_Y) || defined(TOUCH_ORIENTATION))
|
||||
#if defined(XPT2046_X_CALIBRATION) && defined(XPT2046_Y_CALIBRATION) && defined(XPT2046_X_OFFSET) && defined(XPT2046_Y_OFFSET)
|
||||
#define TOUCH_CALIBRATION_X XPT2046_X_CALIBRATION
|
||||
#define TOUCH_CALIBRATION_Y XPT2046_Y_CALIBRATION
|
||||
#define TOUCH_OFFSET_X XPT2046_X_OFFSET
|
||||
#define TOUCH_OFFSET_Y XPT2046_Y_OFFSET
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#else
|
||||
#define TOUCH_CALIBRATION_X 0
|
||||
#define TOUCH_CALIBRATION_Y 0
|
||||
#define TOUCH_OFFSET_X 0
|
||||
#define TOUCH_OFFSET_Y 0
|
||||
#define TOUCH_ORIENTATION TOUCH_ORIENTATION_NONE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Menu Navigation
|
||||
extern int8_t encoderTopLine, encoderLine, screen_items;
|
||||
|
||||
@ -101,31 +75,6 @@ typedef struct __attribute__((__packed__)) {
|
||||
intptr_t data;
|
||||
} touch_control_t;
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int16_t offset_x;
|
||||
int16_t offset_y;
|
||||
uint8_t orientation;
|
||||
} touch_calibration_t;
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
int16_t raw_x;
|
||||
int16_t raw_y;
|
||||
} touch_calibration_point_t;
|
||||
|
||||
enum calibrationState : uint8_t {
|
||||
CALIBRATION_POINT_1 = 0x00,
|
||||
CALIBRATION_POINT_2,
|
||||
CALIBRATION_POINT_3,
|
||||
CALIBRATION_POINT_4,
|
||||
CALIBRATION_SUCCESS,
|
||||
CALIBRATION_FAIL,
|
||||
CALIBRATION_NONE,
|
||||
};
|
||||
|
||||
#define MAX_CONTROLS 16
|
||||
#define MINIMUM_HOLD_TIME 15
|
||||
#define TOUCH_REPEAT_DELAY 75
|
||||
@ -150,15 +99,6 @@ class Touch {
|
||||
static void touch(touch_control_t *control);
|
||||
static void hold(touch_control_t *control, millis_t delay = 0);
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
static calibrationState calibration_state;
|
||||
static touch_calibration_point_t calibration_points[4];
|
||||
|
||||
static bool validate_precision(int32_t a, int32_t b) { return (a > b ? (100 * b) / a : (100 * a) / b) > TOUCH_SCREEN_CALIBRATION_PRECISION; }
|
||||
static bool validate_precision_x(uint8_t a, uint8_t b) { return validate_precision(calibration_points[a].raw_x, calibration_points[b].raw_x); }
|
||||
static bool validate_precision_y(uint8_t a, uint8_t b) { return validate_precision(calibration_points[a].raw_y, calibration_points[b].raw_y); }
|
||||
#endif // TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
public:
|
||||
static void init();
|
||||
static void reset() { controls_count = 0; touch_time = 0; current_control = NULL; }
|
||||
@ -175,17 +115,6 @@ class Touch {
|
||||
static void enable() { enabled = true; }
|
||||
|
||||
static void add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, intptr_t data = 0);
|
||||
|
||||
static touch_calibration_t calibration;
|
||||
static void calibration_reset() { calibration = {TOUCH_CALIBRATION_X, TOUCH_CALIBRATION_Y, TOUCH_OFFSET_X, TOUCH_OFFSET_Y, TOUCH_ORIENTATION}; }
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
static calibrationState calibration_start() { calibration = {0, 0, 0, 0, TOUCH_ORIENTATION_NONE}; return calibration_state = CALIBRATION_POINT_1; }
|
||||
static void calibration_end() { calibration_state = CALIBRATION_NONE; }
|
||||
static calibrationState get_calibration_state() { return calibration_state; }
|
||||
#endif // TOUCH_SCREEN_CALIBRATION
|
||||
};
|
||||
|
||||
extern Touch touch;
|
||||
|
||||
#endif // TOUCH_SCREEN
|
||||
|
@ -584,33 +584,37 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
void MarlinUI::touch_calibration() {
|
||||
static uint16_t x, y;
|
||||
void MarlinUI::touch_calibration_screen() {
|
||||
uint16_t x, y;
|
||||
|
||||
calibrationState calibration_stage = touch.get_calibration_state();
|
||||
calibrationState calibration_stage = touch_calibration.get_calibration_state();
|
||||
|
||||
if (calibration_stage == CALIBRATION_NONE) {
|
||||
defer_status_screen(true);
|
||||
clear_lcd();
|
||||
calibration_stage = touch.calibration_start();
|
||||
calibration_stage = touch_calibration.calibration_start();
|
||||
}
|
||||
else {
|
||||
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
tft.canvas(x - 15, y - 15, 31, 31);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
x = 20; y = 20;
|
||||
touch.clear();
|
||||
|
||||
if (calibration_stage < CALIBRATION_SUCCESS) {
|
||||
switch (calibration_stage) {
|
||||
case CALIBRATION_POINT_1: tft_string.set("Top Left"); break;
|
||||
case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
|
||||
case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
|
||||
case CALIBRATION_POINT_4: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); break;
|
||||
case CALIBRATION_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_LEFT)); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break;
|
||||
case CALIBRATION_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: tft_string.set(GET_TEXT(MSG_BOTTOM_RIGHT)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
x = touch_calibration.calibration_points[calibration_stage].x;
|
||||
y = touch_calibration.calibration_points[calibration_stage].y;
|
||||
|
||||
tft.canvas(x - 15, y - 15, 31, 31);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);
|
||||
@ -619,9 +623,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y));
|
||||
}
|
||||
else {
|
||||
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? "Calibration Completed" : "Calibration Failed");
|
||||
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED));
|
||||
defer_status_screen(false);
|
||||
touch.calibration_end();
|
||||
touch_calibration.calibration_end();
|
||||
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
}
|
||||
|
||||
|
@ -589,33 +589,37 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
void MarlinUI::touch_calibration() {
|
||||
static uint16_t x, y;
|
||||
void MarlinUI::touch_calibration_screen() {
|
||||
uint16_t x, y;
|
||||
|
||||
calibrationState calibration_stage = touch.get_calibration_state();
|
||||
calibrationState calibration_stage = touch_calibration.get_calibration_state();
|
||||
|
||||
if (calibration_stage == CALIBRATION_NONE) {
|
||||
defer_status_screen(true);
|
||||
clear_lcd();
|
||||
calibration_stage = touch.calibration_start();
|
||||
calibration_stage = touch_calibration.calibration_start();
|
||||
}
|
||||
else {
|
||||
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
tft.canvas(x - 15, y - 15, 31, 31);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
x = 20; y = 20;
|
||||
touch.clear();
|
||||
|
||||
if (calibration_stage < CALIBRATION_SUCCESS) {
|
||||
switch (calibration_stage) {
|
||||
case CALIBRATION_POINT_1: tft_string.set("Top Left"); break;
|
||||
case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
|
||||
case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
|
||||
case CALIBRATION_POINT_4: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); break;
|
||||
case CALIBRATION_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_LEFT)); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break;
|
||||
case CALIBRATION_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: tft_string.set(GET_TEXT(MSG_BOTTOM_RIGHT)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
x = touch_calibration.calibration_points[calibration_stage].x;
|
||||
y = touch_calibration.calibration_points[calibration_stage].y;
|
||||
|
||||
tft.canvas(x - 15, y - 15, 31, 31);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);
|
||||
@ -624,9 +628,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y));
|
||||
}
|
||||
else {
|
||||
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? "Calibration Completed" : "Calibration Failed");
|
||||
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED));
|
||||
defer_status_screen(false);
|
||||
touch.calibration_end();
|
||||
touch_calibration.calibration_end();
|
||||
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
}
|
||||
|
||||
|
81
Marlin/src/lcd/tft_io/touch_calibration.cpp
Normal file
81
Marlin/src/lcd/tft_io/touch_calibration.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
#include "touch_calibration.h"
|
||||
|
||||
TouchCalibration touch_calibration;
|
||||
|
||||
touch_calibration_t TouchCalibration::calibration;
|
||||
calibrationState TouchCalibration::calibration_state = CALIBRATION_NONE;
|
||||
touch_calibration_point_t TouchCalibration::calibration_points[4];
|
||||
|
||||
void TouchCalibration::validate_calibration() {
|
||||
const bool landscape = validate_precision_x(0, 1) && validate_precision_x(2, 3) && validate_precision_y(0, 2) && validate_precision_y(1, 3);
|
||||
const bool portrait = validate_precision_y(0, 1) && validate_precision_y(2, 3) && validate_precision_x(0, 2) && validate_precision_x(1, 3);
|
||||
|
||||
if (landscape || portrait) {
|
||||
calibration_state = CALIBRATION_SUCCESS;
|
||||
calibration.x = ((calibration_points[2].x - calibration_points[0].x) << 17) / (calibration_points[3].raw_x + calibration_points[2].raw_x - calibration_points[1].raw_x - calibration_points[0].raw_x);
|
||||
calibration.y = ((calibration_points[1].y - calibration_points[0].y) << 17) / (calibration_points[3].raw_y - calibration_points[2].raw_y + calibration_points[1].raw_y - calibration_points[0].raw_y);
|
||||
calibration.offset_x = calibration_points[0].x - int16_t(((calibration_points[0].raw_x + calibration_points[1].raw_x) * calibration.x) >> 17);
|
||||
calibration.offset_y = calibration_points[0].y - int16_t(((calibration_points[0].raw_y + calibration_points[2].raw_y) * calibration.y) >> 17);
|
||||
calibration.orientation = landscape ? TOUCH_LANDSCAPE : TOUCH_PORTRAIT;
|
||||
}
|
||||
else {
|
||||
calibration_state = CALIBRATION_FAIL;
|
||||
calibration_reset();
|
||||
}
|
||||
|
||||
if (calibration_state == CALIBRATION_SUCCESS) {
|
||||
SERIAL_ECHOLNPGM("Touch screen calibration completed");
|
||||
SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_X ", calibration.x);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_Y ", calibration.y);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x);
|
||||
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y);
|
||||
SERIAL_ECHOPGM("TOUCH_ORIENTATION "); if (calibration.orientation == TOUCH_LANDSCAPE) SERIAL_ECHOLNPGM("TOUCH_LANDSCAPE"); else SERIAL_ECHOLNPGM("TOUCH_PORTRAIT");
|
||||
}
|
||||
}
|
||||
|
||||
bool TouchCalibration::handleTouch(uint16_t x, uint16_t y) {
|
||||
static millis_t next_button_update_ms = 0;
|
||||
const millis_t now = millis();
|
||||
if (PENDING(now, next_button_update_ms)) return false;
|
||||
next_button_update_ms = now + BUTTON_DELAY_MENU;
|
||||
|
||||
if (calibration_state < CALIBRATION_SUCCESS) {
|
||||
calibration_points[calibration_state].raw_x = x;
|
||||
calibration_points[calibration_state].raw_y = y;
|
||||
}
|
||||
|
||||
switch (calibration_state) {
|
||||
case CALIBRATION_TOP_LEFT: calibration_state = CALIBRATION_BOTTOM_LEFT; break;
|
||||
case CALIBRATION_BOTTOM_LEFT: calibration_state = CALIBRATION_TOP_RIGHT; break;
|
||||
case CALIBRATION_TOP_RIGHT: calibration_state = CALIBRATION_BOTTOM_RIGHT; break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: validate_calibration(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // TOUCH_SCREEN_CALIBRATION
|
93
Marlin/src/lcd/tft_io/touch_calibration.h
Normal file
93
Marlin/src/lcd/tft_io/touch_calibration.h
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#ifndef TOUCH_SCREEN_CALIBRATION_PRECISION
|
||||
#define TOUCH_SCREEN_CALIBRATION_PRECISION 80
|
||||
#endif
|
||||
|
||||
#ifndef TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS
|
||||
#define TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS 2500
|
||||
#endif
|
||||
|
||||
#define TOUCH_ORIENTATION_NONE 0
|
||||
#define TOUCH_LANDSCAPE 1
|
||||
#define TOUCH_PORTRAIT 2
|
||||
|
||||
#ifndef TOUCH_ORIENTATION
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#endif
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
int32_t x, y;
|
||||
int16_t offset_x, offset_y;
|
||||
uint8_t orientation;
|
||||
} touch_calibration_t;
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
uint16_t x, y;
|
||||
int16_t raw_x, raw_y;
|
||||
} touch_calibration_point_t;
|
||||
|
||||
enum calibrationState : uint8_t {
|
||||
CALIBRATION_TOP_LEFT = 0x00,
|
||||
CALIBRATION_BOTTOM_LEFT,
|
||||
CALIBRATION_TOP_RIGHT,
|
||||
CALIBRATION_BOTTOM_RIGHT,
|
||||
CALIBRATION_SUCCESS,
|
||||
CALIBRATION_FAIL,
|
||||
CALIBRATION_NONE,
|
||||
};
|
||||
|
||||
class TouchCalibration {
|
||||
public:
|
||||
static calibrationState calibration_state;
|
||||
static touch_calibration_point_t calibration_points[4];
|
||||
|
||||
static bool validate_precision(int32_t a, int32_t b) { return (a > b ? (100 * b) / a : (100 * a) / b) > TOUCH_SCREEN_CALIBRATION_PRECISION; }
|
||||
static bool validate_precision_x(uint8_t a, uint8_t b) { return validate_precision(calibration_points[a].raw_x, calibration_points[b].raw_x); }
|
||||
static bool validate_precision_y(uint8_t a, uint8_t b) { return validate_precision(calibration_points[a].raw_y, calibration_points[b].raw_y); }
|
||||
static void validate_calibration();
|
||||
|
||||
static touch_calibration_t calibration;
|
||||
static void calibration_reset() { calibration = { TOUCH_CALIBRATION_X, TOUCH_CALIBRATION_Y, TOUCH_OFFSET_X, TOUCH_OFFSET_Y, TOUCH_ORIENTATION }; }
|
||||
static bool need_calibration() { return !calibration.offset_x && !calibration.offset_y && !calibration.x && !calibration.y; }
|
||||
|
||||
static calibrationState calibration_start() {
|
||||
calibration = { 0, 0, 0, 0, TOUCH_ORIENTATION_NONE };
|
||||
calibration_state = CALIBRATION_TOP_LEFT;
|
||||
calibration_points[CALIBRATION_TOP_LEFT].x = 30;
|
||||
calibration_points[CALIBRATION_TOP_LEFT].y = 30;
|
||||
calibration_points[CALIBRATION_BOTTOM_LEFT].x = 30;
|
||||
calibration_points[CALIBRATION_BOTTOM_LEFT].y = TFT_HEIGHT - 31;
|
||||
calibration_points[CALIBRATION_TOP_RIGHT].x = TFT_WIDTH - 31;
|
||||
calibration_points[CALIBRATION_TOP_RIGHT].y = 30;
|
||||
calibration_points[CALIBRATION_BOTTOM_RIGHT].x = TFT_WIDTH - 31;
|
||||
calibration_points[CALIBRATION_BOTTOM_RIGHT].y = TFT_HEIGHT - 31;
|
||||
return calibration_state;
|
||||
}
|
||||
static void calibration_end() { calibration_state = CALIBRATION_NONE; }
|
||||
static calibrationState get_calibration_state() { return calibration_state; }
|
||||
|
||||
static bool handleTouch(uint16_t x, uint16_t y);
|
||||
};
|
||||
|
||||
extern TouchCalibration touch_calibration;
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TOUCH_XPT2046
|
||||
#if HAS_TOUCH_BUTTONS
|
||||
|
||||
#include "touch_buttons.h"
|
||||
#include "../scaled_tft.h"
|
||||
@ -27,7 +27,11 @@
|
||||
#include HAL_PATH(../../HAL, tft/xpt2046.h)
|
||||
XPT2046 touchIO;
|
||||
|
||||
#include "../../lcd/marlinui.h" // For EN_C bit mask
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../tft_io/touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#include "../marlinui.h" // For EN_C bit mask
|
||||
|
||||
#define DOGM_AREA_LEFT TFT_PIXEL_OFFSET_X
|
||||
#define DOGM_AREA_TOP TFT_PIXEL_OFFSET_Y
|
||||
@ -47,14 +51,20 @@ uint8_t TouchButtons::read_buttons() {
|
||||
|
||||
if (!touchIO.getRawPoint(&x, &y)) return 0;
|
||||
|
||||
x = uint16_t((uint32_t(x) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET;
|
||||
y = uint16_t((uint32_t(y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
|
||||
|
||||
#if (TFT_ROTATION & TFT_ROTATE_180)
|
||||
x = TFT_WIDTH - x;
|
||||
y = TFT_HEIGHT - y;
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
const calibrationState state = touch_calibration.get_calibration_state();
|
||||
if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) {
|
||||
if (touch_calibration.handleTouch(x, y)) ui.refresh();
|
||||
return 0;
|
||||
}
|
||||
x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
|
||||
y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
|
||||
#else
|
||||
x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
|
||||
y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
|
||||
#endif
|
||||
|
||||
|
||||
// Touch within the button area simulates an encoder button
|
||||
if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
|
||||
return WITHIN(x, BUTTOND_X_LO, BUTTOND_X_HI) ? EN_D
|
||||
@ -77,4 +87,4 @@ uint8_t TouchButtons::read_buttons() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // HAS_TOUCH_XPT2046
|
||||
#endif // HAS_TOUCH_BUTTONS
|
||||
|
@ -146,7 +146,7 @@
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../lcd/tft/touch.h"
|
||||
#include "../lcd/tft_io/touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#if HAS_ETHERNET
|
||||
@ -443,7 +443,7 @@ typedef struct SettingsDataStruct {
|
||||
// TOUCH_SCREEN_CALIBRATION
|
||||
//
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
touch_calibration_t touch_calibration;
|
||||
touch_calibration_t touch_calibration_data;
|
||||
#endif
|
||||
|
||||
// Ethernet settings
|
||||
@ -1410,7 +1410,7 @@ void MarlinSettings::postprocess() {
|
||||
// TOUCH_SCREEN_CALIBRATION
|
||||
//
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
EEPROM_WRITE(touch.calibration);
|
||||
EEPROM_WRITE(touch_calibration.calibration);
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -2293,8 +2293,8 @@ void MarlinSettings::postprocess() {
|
||||
// TOUCH_SCREEN_CALIBRATION
|
||||
//
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
_FIELD_TEST(touch.calibration);
|
||||
EEPROM_READ(touch.calibration);
|
||||
_FIELD_TEST(touch_calibration_data);
|
||||
EEPROM_READ(touch_calibration.calibration);
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -2626,7 +2626,7 @@ void MarlinSettings::reset() {
|
||||
//
|
||||
// TOUCH_SCREEN_CALIBRATION
|
||||
//
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch.calibration_reset());
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
|
||||
|
||||
//
|
||||
// Buzzer enable/disable
|
||||
|
@ -353,36 +353,7 @@
|
||||
#define LCD_PINS_ENABLE -1
|
||||
#define LCD_PINS_RS -1
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ENABLED(TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -11245
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 8629
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 685
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -285
|
||||
#endif
|
||||
#elif ENABLED(TFT_480x320_SPI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17232
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11196
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 1047
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -358
|
||||
#endif
|
||||
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
#endif
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
|
||||
#elif IS_TFTGLCD_PANEL
|
||||
|
||||
|
@ -268,36 +268,7 @@
|
||||
#define LCD_PINS_ENABLE -1
|
||||
#define LCD_PINS_RS -1
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ENABLED(TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -11386
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 8684
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 689
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -273
|
||||
#endif
|
||||
#elif ENABLED(TFT_COLOR_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -16741
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11258
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 1024
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -367
|
||||
#endif
|
||||
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
#endif
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
|
||||
#define BTN_EN1 P3_25
|
||||
#define BTN_EN2 P3_26
|
||||
|
@ -318,36 +318,7 @@
|
||||
#define LCD_PINS_ENABLE -1
|
||||
#define LCD_PINS_RS -1
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ENABLED(TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -11386
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 8684
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 689
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -273
|
||||
#endif
|
||||
#elif ENABLED(TFT_COLOR_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17089
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11424
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 1044
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -365
|
||||
#endif
|
||||
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
#endif
|
||||
#define TFT_BUFFER_SIZE 2400
|
||||
|
||||
#else // !MKS_12864OLED_SSD1306
|
||||
|
||||
|
@ -158,17 +158,17 @@
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ANY(TFT_LVGL_UI, TFT_COLOR_UI, TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17181
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#define TOUCH_CALIBRATION_X -17181
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11434
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#define TOUCH_CALIBRATION_Y 11434
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 501
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#define TOUCH_OFFSET_X 501
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -9
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#define TOUCH_OFFSET_Y -9
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -173,17 +173,17 @@
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ANY(TFT_LVGL_UI, TFT_COLOR_UI, TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17181
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#define TOUCH_CALIBRATION_X -17181
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11434
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#define TOUCH_CALIBRATION_Y 11434
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 501
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#define TOUCH_OFFSET_X 501
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -9
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#define TOUCH_OFFSET_Y -9
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -286,22 +286,22 @@
|
||||
|
||||
// MKS Robin TFT v2.0 with ILI9341
|
||||
// Read display identification information (0xD3 on ILI9341)
|
||||
//#define XPT2046_X_CALIBRATION 12013
|
||||
//#define XPT2046_Y_CALIBRATION -8711
|
||||
//#define XPT2046_X_OFFSET -32
|
||||
//#define XPT2046_Y_OFFSET 256
|
||||
//#define TOUCH_CALIBRATION_X 12013
|
||||
//#define TOUCH_CALIBRATION_Y -8711
|
||||
//#define TOUCH_OFFSET_X -32
|
||||
//#define TOUCH_OFFSET_Y 256
|
||||
|
||||
// MKS Robin TFT v1.1 with ILI9328
|
||||
//#define XPT2046_X_CALIBRATION -11792
|
||||
//#define XPT2046_Y_CALIBRATION 8947
|
||||
//#define XPT2046_X_OFFSET 342
|
||||
//#define XPT2046_Y_OFFSET -19
|
||||
//#define TOUCH_CALIBRATION_X -11792
|
||||
//#define TOUCH_CALIBRATION_Y 8947
|
||||
//#define TOUCH_OFFSET_X 342
|
||||
//#define TOUCH_OFFSET_Y -19
|
||||
|
||||
// MKS Robin TFT v1.1 with R61505
|
||||
//#define XPT2046_X_CALIBRATION 12489
|
||||
//#define XPT2046_Y_CALIBRATION 9210
|
||||
//#define XPT2046_X_OFFSET -52
|
||||
//#define XPT2046_Y_OFFSET -17
|
||||
//#define TOUCH_CALIBRATION_X 12489
|
||||
//#define TOUCH_CALIBRATION_Y 9210
|
||||
//#define TOUCH_OFFSET_X -52
|
||||
//#define TOUCH_OFFSET_Y -17
|
||||
|
||||
// QQS-Pro uses MKS Robin TFT v2.0
|
||||
|
||||
@ -324,42 +324,6 @@
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 2
|
||||
#endif
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if EITHER(TFT_LVGL_UI_FSMC, TFT_COLOR_UI)
|
||||
#define TFT_BUFFER_SIZE 14400
|
||||
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION 12218
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION -8814
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET -35
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET 256
|
||||
#endif
|
||||
|
||||
#elif ENABLED(TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION 12149
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION -8746
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET -35
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET 256
|
||||
#endif
|
||||
|
||||
#define TFT_MARLINUI_COLOR 0xFFFF // White
|
||||
#define TFT_BTARROWS_COLOR 0xDEE6 // 11011 110111 00110 Yellow
|
||||
#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
|
||||
#endif
|
||||
|
||||
#if NEED_TOUCH_PINS
|
||||
#define TOUCH_CS_PIN PC2 // SPI2_NSS
|
||||
#define TOUCH_SCK_PIN PB13 // SPI2_SCK
|
||||
|
@ -282,35 +282,6 @@
|
||||
#define TFT_BUFFER_SIZE 14400
|
||||
#endif
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if EITHER(HAS_TFT_LVGL_UI, TFT_480x320_SPI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17253
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11579
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 514
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -24
|
||||
#endif
|
||||
#elif HAS_SPI_GRAPHICAL_TFT
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -11386
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 8684
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 339
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -18
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_WIRED_LCD && !HAS_SPI_TFT
|
||||
|
||||
// NON TFT Displays
|
||||
|
@ -171,17 +171,17 @@
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION 12033
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#define TOUCH_CALIBRATION_X 12033
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION -9047
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#define TOUCH_CALIBRATION_Y -9047
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET -30
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#define TOUCH_OFFSET_X -30
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET 254
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#define TOUCH_OFFSET_Y 254
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -202,35 +202,6 @@
|
||||
#define TFT_BUFFER_SIZE 14400
|
||||
#endif
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ANY(HAS_TFT_LVGL_UI_FSMC, TFT_COLOR_UI, TFT_CLASSIC_UI) && ENABLED(TFT_RES_480x320)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION 17880
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION -12234
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET -45
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET 349
|
||||
#endif
|
||||
#elif EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) && ENABLED(TFT_RES_320x240)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -12246
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 9453
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 360
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -22
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define HAS_SPI_FLASH 1
|
||||
#if HAS_SPI_FLASH
|
||||
#define SPI_FLASH_SIZE 0x1000000 // 16MB
|
||||
|
@ -285,22 +285,6 @@
|
||||
#define TFT_BUFFER_SIZE 14400
|
||||
#endif
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ANY(TFT_LVGL_UI, TFT_COLOR_UI, TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17253
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11579
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 514
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -24
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_WIRED_LCD && !HAS_SPI_TFT
|
||||
|
||||
// NON TFT Displays
|
||||
|
@ -141,17 +141,17 @@
|
||||
|
||||
// XPT2046 Touch Screen calibration
|
||||
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI)
|
||||
#ifndef XPT2046_X_CALIBRATION
|
||||
#define XPT2046_X_CALIBRATION -17181
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#define TOUCH_CALIBRATION_X -17181
|
||||
#endif
|
||||
#ifndef XPT2046_Y_CALIBRATION
|
||||
#define XPT2046_Y_CALIBRATION 11434
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#define TOUCH_CALIBRATION_Y 11434
|
||||
#endif
|
||||
#ifndef XPT2046_X_OFFSET
|
||||
#define XPT2046_X_OFFSET 501
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#define TOUCH_OFFSET_X 501
|
||||
#endif
|
||||
#ifndef XPT2046_Y_OFFSET
|
||||
#define XPT2046_Y_OFFSET -9
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#define TOUCH_OFFSET_Y -9
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -236,7 +236,7 @@ HAS_SPI_TFT = src_filter=+<src/HAL/STM32/tft/tft_spi.cpp> +<src/HAL/
|
||||
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
|
||||
DWIN_CREALITY_LCD = src_filter=+<src/lcd/dwin>
|
||||
IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD>
|
||||
HAS_TOUCH_XPT2046 = src_filter=+<src/lcd/touch/touch_buttons.cpp>
|
||||
HAS_TOUCH_BUTTONS = src_filter=+<src/lcd/touch/touch_buttons.cpp>
|
||||
HAS_LCD_MENU = src_filter=+<src/lcd/menu>
|
||||
HAS_GAMES = src_filter=+<src/lcd/menu/game/game.cpp>
|
||||
MARLIN_BRICKOUT = src_filter=+<src/lcd/menu/game/brickout.cpp>
|
||||
|
Loading…
Reference in New Issue
Block a user