mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 13:25:54 +00:00
🚸 ColorUI Touch Calibrate in CW order
This commit is contained in:
parent
6bc42300a1
commit
a0e3dea8b8
@ -396,9 +396,9 @@
|
||||
FORCE_INLINE constexpr T operator|(T x, T y) { return static_cast<T>(static_cast<int>(x) | static_cast<int>(y)); } \
|
||||
FORCE_INLINE constexpr T operator^(T x, T y) { return static_cast<T>(static_cast<int>(x) ^ static_cast<int>(y)); } \
|
||||
FORCE_INLINE constexpr T operator~(T x) { return static_cast<T>(~static_cast<int>(x)); } \
|
||||
FORCE_INLINE T & operator&=(T &x, T y) { return x &= y; } \
|
||||
FORCE_INLINE T & operator|=(T &x, T y) { return x |= y; } \
|
||||
FORCE_INLINE T & operator^=(T &x, T y) { return x ^= y; }
|
||||
FORCE_INLINE T & operator&=(T &x, T y) { x = x & y; return x; } \
|
||||
FORCE_INLINE T & operator|=(T &x, T y) { x = x | y; return x; } \
|
||||
FORCE_INLINE T & operator^=(T &x, T y) { x = x ^ y; return x; }
|
||||
|
||||
// C++11 solution that is standard compliant. <type_traits> is not available on all platform
|
||||
namespace Private {
|
||||
|
@ -1782,20 +1782,22 @@
|
||||
#define HAS_UI_1024x600 1
|
||||
#endif
|
||||
|
||||
// Number of text lines the screen can display (may depend on font used)
|
||||
// Touch screens leave space for extra buttons at the bottom
|
||||
#if ANY(HAS_UI_320x240, HAS_UI_480x272)
|
||||
#if ENABLED(TFT_COLOR_UI_PORTRAIT)
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 8, 9) // Fewer lines with touch buttons onscreen
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 8, 9)
|
||||
#else
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
|
||||
#endif
|
||||
#elif HAS_UI_480x320
|
||||
#if ENABLED(TFT_COLOR_UI_PORTRAIT)
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 9, 10) // Fewer lines with touch buttons onscreen
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 9, 10)
|
||||
#else
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
|
||||
#endif
|
||||
#elif HAS_UI_1024x600
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13) // Fewer lines with touch buttons onscreen
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13)
|
||||
#endif
|
||||
|
||||
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
|
@ -784,6 +784,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
}
|
||||
|
||||
#if HAS_PRINT_PROGRESS
|
||||
|
||||
#define TPOFFSET (LCD_WIDTH - 1)
|
||||
static uint8_t timepos = TPOFFSET - 6;
|
||||
static char buffer[8];
|
||||
@ -837,6 +838,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HAS_PRINT_PROGRESS
|
||||
|
||||
/**
|
||||
|
@ -596,8 +596,8 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
|
||||
#endif // HAS_CUTTER
|
||||
|
||||
|
||||
#if HAS_PRINT_PROGRESS // UNTESTED!!!
|
||||
|
||||
#define TPOFFSET (LCD_WIDTH - 1)
|
||||
static uint8_t timepos = TPOFFSET - 6;
|
||||
|
||||
@ -648,6 +648,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HAS_PRINT_PROGRESS
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
|
@ -773,7 +773,7 @@ void MarlinUI::draw_status_screen() {
|
||||
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
|
||||
|
||||
// Progress strings
|
||||
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)){
|
||||
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
|
||||
ui.rotate_progress();
|
||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc);
|
||||
}
|
||||
|
@ -510,8 +510,8 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
|
||||
}
|
||||
else {
|
||||
// clear last cross
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].y;
|
||||
drawCross(x, y, TFT_MARLINBG_COLOR);
|
||||
}
|
||||
|
||||
@ -519,10 +519,10 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
|
||||
if (stage < CALIBRATION_SUCCESS) {
|
||||
// handle current state
|
||||
switch (stage) {
|
||||
case CALIBRATION_TOP_LEFT: str = GET_TEXT_F(MSG_TOP_LEFT); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT_F(MSG_BOTTOM_LEFT); break;
|
||||
case CALIBRATION_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break;
|
||||
case CALIBRATION_TOP_LEFT: str = GET_TEXT_F(MSG_TOP_LEFT); break;
|
||||
case CALIBRATION_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT_F(MSG_BOTTOM_RIGHT); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT_F(MSG_BOTTOM_LEFT); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
||||
|
||||
case MLEVEL_BL:
|
||||
if (draw)
|
||||
drawMenuItem(row, ICON_AxisBL, F("Bottom Left"));
|
||||
drawMenuItem(row, ICON_AxisBL, GET_TEXT_F(MSG_BOTTOM_LEFT));
|
||||
else {
|
||||
popupHandler(Popup_MoveWait);
|
||||
if (use_probe) {
|
||||
@ -1443,7 +1443,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
||||
break;
|
||||
case MLEVEL_TL:
|
||||
if (draw)
|
||||
drawMenuItem(row, ICON_AxisTL, F("Top Left"));
|
||||
drawMenuItem(row, ICON_AxisTL, GET_TEXT_F(MSG_TOP_LEFT));
|
||||
else {
|
||||
popupHandler(Popup_MoveWait);
|
||||
if (use_probe) {
|
||||
@ -1466,7 +1466,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
||||
break;
|
||||
case MLEVEL_TR:
|
||||
if (draw)
|
||||
drawMenuItem(row, ICON_AxisTR, F("Top Right"));
|
||||
drawMenuItem(row, ICON_AxisTR, GET_TEXT_F(MSG_TOP_RIGHT));
|
||||
else {
|
||||
popupHandler(Popup_MoveWait);
|
||||
if (use_probe) {
|
||||
@ -1489,7 +1489,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra
|
||||
break;
|
||||
case MLEVEL_BR:
|
||||
if (draw)
|
||||
drawMenuItem(row, ICON_AxisBR, F("Bottom Right"));
|
||||
drawMenuItem(row, ICON_AxisBR, GET_TEXT_F(MSG_BOTTOM_RIGHT));
|
||||
else {
|
||||
popupHandler(Popup_MoveWait);
|
||||
if (use_probe) {
|
||||
|
@ -60,10 +60,10 @@ namespace ExtUI {
|
||||
void onPrintTimerStopped() { dgus.timerEvent(AC_timer_stopped); }
|
||||
void onPrintDone() {}
|
||||
|
||||
void onFilamentRunout(const extruder_t) { dgus.filamentRunout(); }
|
||||
void onFilamentRunout(const extruder_t) { dgus.filamentRunout(); }
|
||||
|
||||
void onUserConfirmRequired(const char * const msg) { dgus.confirmationRequest(msg); }
|
||||
void onStatusChanged(const char * const msg) { dgus.statusChange(msg); }
|
||||
void onUserConfirmRequired(const char * const msg) { dgus.confirmationRequest(msg); }
|
||||
void onStatusChanged(const char * const msg) { dgus.statusChange(msg); }
|
||||
|
||||
void onHomingStart() { dgus.homingStart(); }
|
||||
void onHomingDone() { dgus.homingComplete(); }
|
||||
|
@ -62,8 +62,8 @@ void lv_update_touch_calibration_screen() {
|
||||
}
|
||||
else {
|
||||
// clear last cross
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].y;
|
||||
drawCross(x, y, LV_COLOR_BACKGROUND.full);
|
||||
}
|
||||
|
||||
@ -72,9 +72,9 @@ void lv_update_touch_calibration_screen() {
|
||||
// handle current state
|
||||
switch (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;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ static bool get_point(int16_t *x, int16_t *y) {
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
const calibrationState state = touch_calibration.get_calibration_state();
|
||||
if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) {
|
||||
if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_LEFT)) {
|
||||
if (touch_calibration.handleTouch(*x, *y)) lv_update_touch_calibration_screen();
|
||||
return false;
|
||||
}
|
||||
|
@ -173,7 +173,10 @@ class TFT_String {
|
||||
static uint16_t *string() { return data; }
|
||||
static uint16_t width() { return span; }
|
||||
static uint16_t center(const uint16_t width) { return span > width ? 0 : (width - span) / 2; }
|
||||
static uint16_t vcenter(const uint16_t height) { return (height + font_header->capitalAHeight + 1) / 2 > font_header->fontAscent ? (height + font_header->capitalAHeight + 1) / 2 - font_header->fontAscent : 0 ; }
|
||||
static uint16_t vcenter(const uint16_t height) {
|
||||
const uint16_t mid = (height + font_header->capitalAHeight + 1) / 2;
|
||||
return mid > font_header->fontAscent ? mid - font_header->fontAscent : 0;
|
||||
}
|
||||
};
|
||||
|
||||
extern TFT_String tft_string;
|
||||
|
@ -440,8 +440,8 @@ void MarlinUI::clear_lcd() {
|
||||
stage = touch_calibration.calibration_start();
|
||||
}
|
||||
else {
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_LEFT)].y;
|
||||
tft.canvas(x - 15, y - 15, 31, 31);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
}
|
||||
@ -450,10 +450,10 @@ void MarlinUI::clear_lcd() {
|
||||
|
||||
if (stage < CALIBRATION_SUCCESS) {
|
||||
switch (stage) {
|
||||
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_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_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;
|
||||
case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ void disable_steppers();
|
||||
bool lcd_sleep_task();
|
||||
#endif
|
||||
|
||||
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater);
|
||||
void draw_heater_status(uint16_t x, uint16_t y, const int8_t heater);
|
||||
void draw_fan_status(uint16_t x, uint16_t y, const bool blink);
|
||||
|
||||
void text_line(const uint16_t y, uint16_t color=COLOR_BACKGROUND);
|
||||
|
@ -103,10 +103,10 @@ bool TouchCalibration::handleTouch(const uint16_t x, const uint16_t 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_LEFT: calibration_state = CALIBRATION_TOP_RIGHT; break;
|
||||
case CALIBRATION_TOP_RIGHT: calibration_state = CALIBRATION_BOTTOM_RIGHT; break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: validate_calibration(); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: calibration_state = CALIBRATION_BOTTOM_LEFT; break;
|
||||
case CALIBRATION_BOTTOM_LEFT: validate_calibration(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ typedef struct __attribute__((__packed__)) {
|
||||
|
||||
enum calibrationState : uint8_t {
|
||||
CALIBRATION_TOP_LEFT = 0x00,
|
||||
CALIBRATION_BOTTOM_LEFT,
|
||||
CALIBRATION_TOP_RIGHT,
|
||||
CALIBRATION_BOTTOM_RIGHT,
|
||||
CALIBRATION_BOTTOM_LEFT,
|
||||
CALIBRATION_SUCCESS,
|
||||
CALIBRATION_FAIL,
|
||||
CALIBRATION_NONE,
|
||||
@ -73,12 +73,12 @@ public:
|
||||
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;
|
||||
calibration_points[CALIBRATION_BOTTOM_LEFT].x = 30;
|
||||
calibration_points[CALIBRATION_BOTTOM_LEFT].y = TFT_HEIGHT - 31;
|
||||
failed_count = 0;
|
||||
return calibration_state;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ uint8_t TouchButtons::read_buttons() {
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
const calibrationState state = touch_calibration.get_calibration_state();
|
||||
if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) {
|
||||
if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_LEFT)) {
|
||||
if (touch_calibration.handleTouch(x, y)) ui.refresh();
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,10 +48,12 @@ void W25QXXFlash::init(uint8_t spiRate) {
|
||||
* STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1
|
||||
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
|
||||
*/
|
||||
#if SPI_DEVICE == 1
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
|
||||
#else
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
|
||||
#ifndef SPI_CLOCK_MAX
|
||||
#if SPI_DEVICE == 1
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
|
||||
#else
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
|
||||
#endif
|
||||
#endif
|
||||
uint8_t clock;
|
||||
switch (spiRate) {
|
||||
|
Loading…
Reference in New Issue
Block a user