|
@@ -25,6 +25,29 @@
|
25
|
25
|
#include "../../inc/MarlinConfig.h"
|
26
|
26
|
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
|
27
|
27
|
|
|
28
|
+/*
|
|
29
|
+ * Draw and Touch processing
|
|
30
|
+ *
|
|
31
|
+ * LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution.
|
|
32
|
+ * TOUCH_SCREEN_WIDTH/HEIGHT (320x240) is the Touch Area resolution.
|
|
33
|
+ * LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution.
|
|
34
|
+ *
|
|
35
|
+ * - All native (u8g) drawing is done in LCD_PIXEL_* (128x64)
|
|
36
|
+ * - The DOGM pixels are is upscaled 2-3x (as needed) for display.
|
|
37
|
+ * - Touch coordinates use TOUCH_SCREEN_* resolution and are converted to
|
|
38
|
+ * click and scroll-wheel events (emulating of a common DOGM display).
|
|
39
|
+ *
|
|
40
|
+ * TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made
|
|
41
|
+ * and originally calibrated for 320x240. If you decide to change the resolution of the touch code,
|
|
42
|
+ * new calibration values will be needed.
|
|
43
|
+ *
|
|
44
|
+ * The Marlin menus are drawn scaled in the upper region of the screen. The bottom region (in a
|
|
45
|
+ * fixed location in TOUCH_SCREEN* coordinate space) is used for 4 general-purpose buttons to
|
|
46
|
+ * navigate and select menu items. Both regions are touchable.
|
|
47
|
+ *
|
|
48
|
+ * The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP)
|
|
49
|
+ * and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT).
|
|
50
|
+ */
|
28
|
51
|
// Touch screen resolution independent of display resolution
|
29
|
52
|
#define TOUCH_SCREEN_HEIGHT 240
|
30
|
53
|
#define TOUCH_SCREEN_WIDTH 320
|
|
@@ -33,8 +56,13 @@
|
33
|
56
|
#define BUTTON_AREA_TOP 175
|
34
|
57
|
#define BUTTON_AREA_BOT 234
|
35
|
58
|
|
36
|
|
-#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
|
37
|
|
-#define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP))
|
|
59
|
+#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
|
|
60
|
+#define SCREEN_START_LEFT ((LCD_PIXEL_OFFSET_X) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
|
|
61
|
+#define SCREEN_HEIGHT ((LCD_PIXEL_HEIGHT * FSMC_UPSCALE) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
|
|
62
|
+#define SCREEN_WIDTH ((LCD_PIXEL_WIDTH * FSMC_UPSCALE) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
|
|
63
|
+
|
|
64
|
+#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT
|
|
65
|
+#define TOUCHABLE_X_WIDTH SCREEN_WIDTH
|
38
|
66
|
|
39
|
67
|
#ifndef TOUCH_INT_PIN
|
40
|
68
|
#define TOUCH_INT_PIN -1
|
|
@@ -98,10 +126,10 @@ uint8_t XPT2046::read_buttons() {
|
98
|
126
|
: WITHIN(x, 242, 305) ? EN_C
|
99
|
127
|
: 0;
|
100
|
128
|
|
101
|
|
- if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0;
|
|
129
|
+ if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
|
102
|
130
|
|
103
|
131
|
// Column and row above BUTTON_AREA_TOP
|
104
|
|
- int8_t col = x * (LCD_WIDTH) / (TOUCH_SCREEN_WIDTH),
|
|
132
|
+ int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
|
105
|
133
|
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
|
106
|
134
|
|
107
|
135
|
// Send the touch to the UI (which will simulate the encoder wheel)
|