Skip to content

Commit bc040d5

Browse files
authored
Simplify touchscreen calibration for SimUI (#23124)
1 parent 8ee368b commit bc040d5

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

Marlin/src/inc/SanityCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,8 +3652,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
36523652
/**
36533653
* Touch Screen Calibration
36543654
*/
3655-
#if ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \
3656-
&& (!defined(TOUCH_CALIBRATION_X) || !defined(TOUCH_CALIBRATION_Y) || !defined(TOUCH_OFFSET_X) || !defined(TOUCH_OFFSET_Y))
3655+
#if !MB(LINUX_RAMPS) && ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \
3656+
&& !(defined(TOUCH_CALIBRATION_X) && defined(TOUCH_CALIBRATION_Y) && defined(TOUCH_OFFSET_X) && defined(TOUCH_OFFSET_Y))
36573657
#error "TOUCH_CALIBRATION_[XY] and TOUCH_OFFSET_[XY] are required for resistive touch screens with TOUCH_SCREEN_CALIBRATION disabled."
36583658
#endif
36593659

Marlin/src/pins/linux/pins_RAMPS_LINUX.h

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@
391391
#define BEEPER_PIN 42
392392

393393
#define TOUCH_CS_PIN 33
394+
394395
#define SD_DETECT_PIN 41
395396

396397
#define HAS_SPI_FLASH 1
@@ -407,17 +408,47 @@
407408
#ifndef TFT_DRIVER
408409
#define TFT_DRIVER ST7796
409410
#endif
410-
#ifndef XPT2046_X_CALIBRATION
411-
#define XPT2046_X_CALIBRATION 63934
412-
#endif
413-
#ifndef XPT2046_Y_CALIBRATION
414-
#define XPT2046_Y_CALIBRATION 63598
415-
#endif
416-
#ifndef XPT2046_X_OFFSET
417-
#define XPT2046_X_OFFSET -1
418-
#endif
419-
#ifndef XPT2046_Y_OFFSET
420-
#define XPT2046_Y_OFFSET -20
411+
#ifndef TOUCH_SCREEN_CALIBRATION
412+
#if ENABLED(TFT_RES_320x240)
413+
#ifndef TOUCH_CALIBRATION_X
414+
#define TOUCH_CALIBRATION_X 20525
415+
#endif
416+
#ifndef TOUCH_CALIBRATION_Y
417+
#define TOUCH_CALIBRATION_Y 15335
418+
#endif
419+
#ifndef TOUCH_OFFSET_X
420+
#define TOUCH_OFFSET_X -1
421+
#endif
422+
#ifndef TOUCH_OFFSET_Y
423+
#define TOUCH_OFFSET_Y 0
424+
#endif
425+
#elif ENABLED(TFT_RES_480x272)
426+
#ifndef TOUCH_CALIBRATION_X
427+
#define TOUCH_CALIBRATION_X 30715
428+
#endif
429+
#ifndef TOUCH_CALIBRATION_Y
430+
#define TOUCH_CALIBRATION_Y 17415
431+
#endif
432+
#ifndef TOUCH_OFFSET_X
433+
#define TOUCH_OFFSET_X 0
434+
#endif
435+
#ifndef TOUCH_OFFSET_Y
436+
#define TOUCH_OFFSET_Y -1
437+
#endif
438+
#elif ENABLED(TFT_RES_480x320)
439+
#ifndef TOUCH_CALIBRATION_X
440+
#define TOUCH_CALIBRATION_X 30595
441+
#endif
442+
#ifndef TOUCH_CALIBRATION_Y
443+
#define TOUCH_CALIBRATION_Y 20415
444+
#endif
445+
#ifndef TOUCH_OFFSET_X
446+
#define TOUCH_OFFSET_X 2
447+
#endif
448+
#ifndef TOUCH_OFFSET_Y
449+
#define TOUCH_OFFSET_Y 1
450+
#endif
451+
#endif
421452
#endif
422453

423454
#define BTN_BACK 70

0 commit comments

Comments
 (0)