|
|
@ -25,6 +25,29 @@ |
|
|
|
#include "../../inc/MarlinConfig.h" |
|
|
|
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc. |
|
|
|
|
|
|
|
/*
|
|
|
|
* Draw and Touch processing |
|
|
|
* |
|
|
|
* LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution. |
|
|
|
* TOUCH_SCREEN_WIDTH/HEIGHT (320x240) is the Touch Area resolution. |
|
|
|
* LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display resolution. |
|
|
|
* |
|
|
|
* - All native (u8g) drawing is done in LCD_PIXEL_* (128x64) |
|
|
|
* - The DOGM pixels are is upscaled 2-3x (as needed) for display. |
|
|
|
* - Touch coordinates use TOUCH_SCREEN_* resolution and are converted to |
|
|
|
* click and scroll-wheel events (emulating of a common DOGM display). |
|
|
|
* |
|
|
|
* TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made |
|
|
|
* and originally calibrated for 320x240. If you decide to change the resolution of the touch code, |
|
|
|
* new calibration values will be needed. |
|
|
|
* |
|
|
|
* The Marlin menus are drawn scaled in the upper region of the screen. The bottom region (in a |
|
|
|
* fixed location in TOUCH_SCREEN* coordinate space) is used for 4 general-purpose buttons to |
|
|
|
* navigate and select menu items. Both regions are touchable. |
|
|
|
* |
|
|
|
* The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP) |
|
|
|
* and spans LCD_PIXEL_WIDTH/HEIGHT (scaled to SCREEN_WIDTH/HEIGHT). |
|
|
|
*/ |
|
|
|
// Touch screen resolution independent of display resolution
|
|
|
|
#define TOUCH_SCREEN_HEIGHT 240 |
|
|
|
#define TOUCH_SCREEN_WIDTH 320 |
|
|
@ -34,7 +57,12 @@ |
|
|
|
#define BUTTON_AREA_BOT 234 |
|
|
|
|
|
|
|
#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) |
|
|
|
#define TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP)) |
|
|
|
#define SCREEN_START_LEFT ((LCD_PIXEL_OFFSET_X) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) |
|
|
|
#define SCREEN_HEIGHT ((LCD_PIXEL_HEIGHT * FSMC_UPSCALE) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) |
|
|
|
#define SCREEN_WIDTH ((LCD_PIXEL_WIDTH * FSMC_UPSCALE) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) |
|
|
|
|
|
|
|
#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT |
|
|
|
#define TOUCHABLE_X_WIDTH SCREEN_WIDTH |
|
|
|
|
|
|
|
#ifndef TOUCH_INT_PIN |
|
|
|
#define TOUCH_INT_PIN -1 |
|
|
@ -98,10 +126,10 @@ uint8_t XPT2046::read_buttons() { |
|
|
|
: WITHIN(x, 242, 305) ? EN_C |
|
|
|
: 0; |
|
|
|
|
|
|
|
if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0; |
|
|
|
if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0; |
|
|
|
|
|
|
|
// Column and row above BUTTON_AREA_TOP
|
|
|
|
int8_t col = x * (LCD_WIDTH) / (TOUCH_SCREEN_WIDTH), |
|
|
|
int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH), |
|
|
|
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT); |
|
|
|
|
|
|
|
// Send the touch to the UI (which will simulate the encoder wheel)
|
|
|
|