TFT 3x upscale followup (#18256)
This commit is contained in:
parent
1d504e596d
commit
0a49ad1ccf
|
@ -25,9 +25,15 @@
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
|
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
|
||||||
|
|
||||||
|
// Touch screen resolution independent of display resolution
|
||||||
|
#define TOUCH_SCREEN_HEIGHT 240
|
||||||
|
#define TOUCH_SCREEN_WIDTH 320
|
||||||
|
|
||||||
|
// Coordinates in terms of touch area
|
||||||
#define BUTTON_AREA_TOP 175
|
#define BUTTON_AREA_TOP 175
|
||||||
#define BUTTON_AREA_BOT 234
|
#define BUTTON_AREA_BOT 234
|
||||||
#define SCREEN_START_TOP ((LCD_PIXEL_OFFSET_Y) * 240 / (LCD_FULL_PIXEL_HEIGHT))
|
|
||||||
|
#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 TOUCHABLE_Y_HEIGHT (BUTTON_AREA_TOP - (SCREEN_START_TOP))
|
||||||
|
|
||||||
#ifndef TOUCH_INT_PIN
|
#ifndef TOUCH_INT_PIN
|
||||||
|
@ -92,10 +98,10 @@ uint8_t XPT2046::read_buttons() {
|
||||||
: WITHIN(x, 242, 305) ? EN_C
|
: WITHIN(x, 242, 305) ? EN_C
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
if (x > LCD_FULL_PIXEL_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0;
|
if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, BUTTON_AREA_TOP)) return 0;
|
||||||
|
|
||||||
// Column and row above BUTTON_AREA_TOP
|
// Column and row above BUTTON_AREA_TOP
|
||||||
int8_t col = x * (LCD_WIDTH) / (LCD_FULL_PIXEL_WIDTH),
|
int8_t col = x * (LCD_WIDTH) / (TOUCH_SCREEN_WIDTH),
|
||||||
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
|
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
|
||||||
|
|
||||||
// Send the touch to the UI (which will simulate the encoder wheel)
|
// Send the touch to the UI (which will simulate the encoder wheel)
|
||||||
|
|
|
@ -546,12 +546,15 @@ static const uint16_t ili9341_init[] = {
|
||||||
#define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
|
#define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE)
|
||||||
#define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
|
#define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1)
|
||||||
|
|
||||||
#define BUTTON_Y_LO (184 / 2) * (FSMC_UPSCALE)
|
#define BUTTON_Y_LO (140 / 2) * (FSMC_UPSCALE) + 44 //184 2x, 254 3x
|
||||||
#define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
|
#define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1)
|
||||||
|
|
||||||
void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
|
void drawImage(const uint8_t *data, u8g_t *u8g, u8g_dev_t *dev, uint16_t length, uint16_t height, uint16_t color) {
|
||||||
uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
|
uint16_t buffer[BUTTON_SIZE_X * sq(FSMC_UPSCALE)];
|
||||||
|
|
||||||
|
//NOTE: the buffer are sized for max 32 lenght! If you need draw bigger things with this function, we need increase the buffer
|
||||||
|
if (length > BUTTON_SIZE_X) return;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < height; i++) {
|
for (uint16_t i = 0; i < height; i++) {
|
||||||
uint16_t k = 0;
|
uint16_t k = 0;
|
||||||
for (uint16_t j = 0; j < length; j++) {
|
for (uint16_t j = 0; j < length; j++) {
|
||||||
|
@ -567,7 +570,7 @@ static const uint16_t ili9341_init[] = {
|
||||||
for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
|
for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++)
|
||||||
buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l];
|
buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l];
|
||||||
|
|
||||||
LCD_IO_WriteSequence(buffer, COUNT(buffer));
|
LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE));
|
||||||
#else
|
#else
|
||||||
u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
|
u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
|
||||||
u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
|
u8g_WriteSequence(u8g, dev, k << 1, (uint8_t*)buffer);
|
||||||
|
@ -657,9 +660,9 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
||||||
// bottom line and buttons
|
// bottom line and buttons
|
||||||
#if ENABLED(TOUCH_BUTTONS)
|
#if ENABLED(TOUCH_BUTTONS)
|
||||||
|
|
||||||
setWindow(u8g, dev, 10, 170, 309, 171);
|
setWindow(u8g, dev, BUTTOND_X_LO - 4, BUTTON_Y_LO - 5, BUTTONC_X_HI + BUFSIZE + 4, BUTTON_Y_LO - 4);
|
||||||
#ifdef LCD_USE_DMA_FSMC
|
#ifdef LCD_USE_DMA_FSMC
|
||||||
LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 600);
|
LCD_IO_WriteMultiple(TFT_DISABLED_COLOR, 600 / 2 * FSMC_UPSCALE);
|
||||||
#else
|
#else
|
||||||
memset2(buffer, TFT_DISABLED_COLOR, 150);
|
memset2(buffer, TFT_DISABLED_COLOR, 150);
|
||||||
for (uint8_t i = 8; i--;)
|
for (uint8_t i = 8; i--;)
|
||||||
|
|
|
@ -115,6 +115,7 @@
|
||||||
#define LCD_FULL_PIXEL_WIDTH 480
|
#define LCD_FULL_PIXEL_WIDTH 480
|
||||||
#define LCD_PIXEL_OFFSET_X 48
|
#define LCD_PIXEL_OFFSET_X 48
|
||||||
#define LCD_FULL_PIXEL_HEIGHT 320
|
#define LCD_FULL_PIXEL_HEIGHT 320
|
||||||
|
#define LCD_PIXEL_OFFSET_Y 48
|
||||||
|
|
||||||
#define LCD_RESET_PIN PF11
|
#define LCD_RESET_PIN PF11
|
||||||
#define NO_LCD_REINIT
|
#define NO_LCD_REINIT
|
||||||
|
|
|
@ -120,6 +120,7 @@
|
||||||
#define LCD_FULL_PIXEL_WIDTH 480
|
#define LCD_FULL_PIXEL_WIDTH 480
|
||||||
#define LCD_PIXEL_OFFSET_X 48
|
#define LCD_PIXEL_OFFSET_X 48
|
||||||
#define LCD_FULL_PIXEL_HEIGHT 320
|
#define LCD_FULL_PIXEL_HEIGHT 320
|
||||||
|
#define LCD_PIXEL_OFFSET_Y 48
|
||||||
|
|
||||||
#define LCD_RESET_PIN PF11
|
#define LCD_RESET_PIN PF11
|
||||||
#define NO_LCD_REINIT
|
#define NO_LCD_REINIT
|
||||||
|
|
Loading…
Reference in a new issue