Browse Source

Move scaled TFT / touch defines (#18915)

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
7dd7d6dda6
  1. 4
      Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp
  2. 29
      Marlin/src/MarlinCore.cpp
  3. 113
      Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp
  4. 21
      Marlin/src/lcd/dogm/ultralcd_DOGM.h
  5. 3
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  6. 32
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  7. 22
      Marlin/src/lcd/lcdprint.h
  8. 50
      Marlin/src/lcd/scaled_tft.h
  9. 35
      Marlin/src/lcd/touch/xpt2046.cpp
  10. 0
      Marlin/src/lcd/touch/xpt2046.h
  11. 2
      Marlin/src/lcd/ultralcd.cpp
  12. 19
      Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h
  13. 19
      Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h
  14. 11
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h

4
Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_hwspi.cpp

@ -20,7 +20,7 @@
#include "../../../inc/MarlinConfig.h" #include "../../../inc/MarlinConfig.h"
#if BOTH(HAS_GRAPHICAL_LCD, SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI) #if ENABLED(SPI_GRAPHICAL_TFT) && DISABLED(FORCE_SOFT_SPI)
#include "../HAL.h" #include "../HAL.h"
#include <U8glib.h> #include <U8glib.h>
@ -232,5 +232,5 @@ uint8_t u8g_com_stm32duino_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1; return 1;
} }
#endif // HAS_GRAPHICAL_LCD #endif // SPI_GRAPHICAL_TFT && !FORCE_SOFT_SPI
#endif // STM32F1 #endif // STM32F1

29
Marlin/src/MarlinCore.cpp

@ -39,26 +39,27 @@
#include <math.h> #include <math.h>
#include "core/utility.h" #include "core/utility.h"
#include "lcd/ultralcd.h"
#include "module/motion.h" #include "module/motion.h"
#include "module/planner.h" #include "module/planner.h"
#include "module/stepper.h"
#include "module/endstops.h" #include "module/endstops.h"
#include "module/probe.h"
#include "module/temperature.h" #include "module/temperature.h"
#include "sd/cardreader.h"
#include "module/configuration_store.h" #include "module/configuration_store.h"
#include "module/printcounter.h" // PrintCounter or Stopwatch #include "module/printcounter.h" // PrintCounter or Stopwatch
#include "feature/closedloop.h"
#include "module/stepper.h"
#include "module/stepper/indirection.h" #include "module/stepper/indirection.h"
#include "libs/nozzle.h"
#include "gcode/gcode.h" #include "gcode/gcode.h"
#include "gcode/parser.h" #include "gcode/parser.h"
#include "gcode/queue.h" #include "gcode/queue.h"
#include "sd/cardreader.h"
#include "lcd/ultralcd.h"
#if HAS_TOUCH_XPT2046
#include "lcd/touch/xpt2046.h"
#endif
#if HAS_TFT_LVGL_UI #if HAS_TFT_LVGL_UI
#include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h" #include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
#include "lcd/extui/lib/mks_ui/draw_ui.h" #include "lcd/extui/lib/mks_ui/draw_ui.h"
@ -80,10 +81,6 @@
#include "feature/direct_stepping.h" #include "feature/direct_stepping.h"
#endif #endif
#if HAS_TOUCH_XPT2046
#include "feature/touch/xpt2046.h"
#endif
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
#include "feature/host_actions.h" #include "feature/host_actions.h"
#endif #endif
@ -92,6 +89,10 @@
#include "libs/buzzer.h" #include "libs/buzzer.h"
#endif #endif
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
#include "feature/closedloop.h"
#endif
#if HAS_I2C_DIGIPOT #if HAS_I2C_DIGIPOT
#include "feature/digipot/digipot.h" #include "feature/digipot/digipot.h"
#endif #endif
@ -176,6 +177,10 @@
#include "feature/runout.h" #include "feature/runout.h"
#endif #endif
#if HAS_Z_SERVO_PROBE
#include "module/probe.h"
#endif
#if ENABLED(HOTEND_IDLE_TIMEOUT) #if ENABLED(HOTEND_IDLE_TIMEOUT)
#include "feature/hotend_idle.h" #include "feature/hotend_idle.h"
#endif #endif
@ -1194,7 +1199,9 @@ void setup() {
#endif #endif
#if HAS_TFT_LVGL_UI #if HAS_TFT_LVGL_UI
#if ENABLED(SDSUPPORT)
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
#endif
SETUP_RUN(tft_lvgl_init()); SETUP_RUN(tft_lvgl_init());
#endif #endif

113
Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp

@ -20,39 +20,38 @@
* *
*/ */
/* /**
* u8g_dev_tft_320x240_upscale_from_128x64.cpp
u8g_dev_tft_320x240_upscale_from_128x64.cpp *
* Universal 8bit Graphics Library
Universal 8bit Graphics Library *
* Copyright (c) 2011, olikraus@gmail.com
Copyright (c) 2011, olikraus@gmail.com * All rights reserved.
All rights reserved. *
* Redistribution and use in source and binary forms, with or without modification,
Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met:
are permitted provided that the following conditions are met: *
* Redistributions of source code must retain the above copyright notice, this list * Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. * of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this * Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other * list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution. * materials provided with the distribution.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/ */
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
@ -84,10 +83,12 @@
#define HEIGHT LCD_PIXEL_HEIGHT #define HEIGHT LCD_PIXEL_HEIGHT
#define PAGE_HEIGHT 8 #define PAGE_HEIGHT 8
#define X_LO LCD_PIXEL_OFFSET_X #include "../scaled_tft.h"
#define Y_LO LCD_PIXEL_OFFSET_Y
#define X_HI (X_LO + (FSMC_UPSCALE) * WIDTH - 1) #define UPSCALE0(M) ((M) * (FSMC_UPSCALE))
#define Y_HI (Y_LO + (FSMC_UPSCALE) * HEIGHT - 1) #define UPSCALE(A,M) (UPSCALE0(M) + (A))
#define X_HI (UPSCALE(LCD_PIXEL_OFFSET_X, WIDTH) - 1)
#define Y_HI (UPSCALE(LCD_PIXEL_OFFSET_Y, HEIGHT) - 1)
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html // see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
@ -153,7 +154,6 @@ static uint32_t lcd_id = 0;
#define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */ #define ILI9328_VASTART 0x52 /* Vertical address start position (0-511) */
#define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */ #define ILI9328_VAEND 0x53 /* Vertical address end position (0-511) */
static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { static void setWindow_ili9328(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {
#if HAS_LCD_IO #if HAS_LCD_IO
#define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0) #define IO_REG_DATA(R,D) do { LCD_IO_WriteReg(R); LCD_IO_WriteData(D); }while(0)
@ -216,7 +216,6 @@ static void setWindow_st7789v(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_
static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {} static void setWindow_none(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) {}
void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none; void (*setWindow)(u8g_t *u8g, u8g_dev_t *dev, uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) = setWindow_none;
#define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x #define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
#define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF) #define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
#define ESC_END 0xFFFF, 0x7FFF #define ESC_END 0xFFFF, 0x7FFF
@ -552,20 +551,20 @@ static const uint16_t st9677_init[] = {
#define BUTTON_SIZE_Y 20 #define BUTTON_SIZE_Y 20
// 14, 90, 166, 242, 185 are the original values upscaled 2x. // 14, 90, 166, 242, 185 are the original values upscaled 2x.
#define BUTTOND_X_LO (14 / 2) * (FSMC_UPSCALE) #define BUTTOND_X_LO UPSCALE0(14 / 2)
#define BUTTOND_X_HI (BUTTOND_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) #define BUTTOND_X_HI (UPSCALE(BUTTOND_X_LO, BUTTON_SIZE_X) - 1)
#define BUTTONA_X_LO (90 / 2) * (FSMC_UPSCALE) #define BUTTONA_X_LO UPSCALE0(90 / 2)
#define BUTTONA_X_HI (BUTTONA_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) #define BUTTONA_X_HI (UPSCALE(BUTTONA_X_LO, BUTTON_SIZE_X) - 1)
#define BUTTONB_X_LO (166 / 2) * (FSMC_UPSCALE) #define BUTTONB_X_LO UPSCALE0(166 / 2)
#define BUTTONB_X_HI (BUTTONB_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) #define BUTTONB_X_HI (UPSCALE(BUTTONB_X_LO, BUTTON_SIZE_X) - 1)
#define BUTTONC_X_LO (242 / 2) * (FSMC_UPSCALE) #define BUTTONC_X_LO UPSCALE0(242 / 2)
#define BUTTONC_X_HI (BUTTONC_X_LO + (FSMC_UPSCALE) * BUTTON_SIZE_X - 1) #define BUTTONC_X_HI (UPSCALE(BUTTONC_X_LO, BUTTON_SIZE_X) - 1)
#define BUTTON_Y_LO (140 / 2) * (FSMC_UPSCALE) + 44 //184 2x, 254 3x #define BUTTON_Y_LO UPSCALE0(140 / 2) + 44 // 184 2x, 254 3x
#define BUTTON_Y_HI (BUTTON_Y_LO + (FSMC_UPSCALE) * BUTTON_SIZE_Y - 1) #define BUTTON_Y_HI (UPSCALE(BUTTON_Y_LO, 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)];
@ -584,8 +583,8 @@ static const uint16_t st9677_init[] = {
} }
#if HAS_LCD_IO #if HAS_LCD_IO
LOOP_S_L_N(n, 1, FSMC_UPSCALE) LOOP_S_L_N(n, 1, FSMC_UPSCALE)
for (uint16_t l = 0; l < length * (FSMC_UPSCALE); l++) for (uint16_t l = 0; l < UPSCALE0(length); l++)
buffer[l + (length * (FSMC_UPSCALE) * n)] = buffer[l]; buffer[l + n * UPSCALE0(length)] = buffer[l];
LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE)); LCD_IO_WriteSequence(buffer, length * sq(FSMC_UPSCALE));
#else #else
@ -660,13 +659,13 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
} }
// Clear Screen // Clear Screen
setWindow(u8g, dev, 0, 0, LCD_FULL_PIXEL_WIDTH - 1, LCD_FULL_PIXEL_HEIGHT - 1); setWindow(u8g, dev, 0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1);
#if HAS_LCD_IO #if HAS_LCD_IO
LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT); LCD_IO_WriteMultiple(TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
#else #else
memset2(buffer, TFT_MARLINBG_COLOR, 160); memset2(buffer, TFT_MARLINBG_COLOR, (LCD_FULL_PIXEL_WIDTH) / 2);
for (uint16_t i = 0; i < 960; i++) for (uint16_t i = 0; i < (LCD_FULL_PIXEL_WIDTH) * 3; i++)
u8g_WriteSequence(u8g, dev, 160, (uint8_t *)buffer); u8g_WriteSequence(u8g, dev, (LCD_FULL_PIXEL_WIDTH) / 2, (uint8_t *)buffer);
#endif #endif
// Bottom buttons // Bottom buttons
@ -690,7 +689,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
case U8G_DEV_MSG_PAGE_FIRST: case U8G_DEV_MSG_PAGE_FIRST:
page = 0; page = 0;
setWindow(u8g, dev, X_LO, Y_LO, X_HI, Y_HI); setWindow(u8g, dev, LCD_PIXEL_OFFSET_X, LCD_PIXEL_OFFSET_Y, X_HI, Y_HI);
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT:
@ -708,8 +707,8 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
} }
#if HAS_LCD_IO #if HAS_LCD_IO
LOOP_S_L_N(n, 1, FSMC_UPSCALE) LOOP_S_L_N(n, 1, FSMC_UPSCALE)
for (uint16_t l = 0; l < WIDTH * (FSMC_UPSCALE); l++) for (uint16_t l = 0; l < UPSCALE0(WIDTH); l++)
buffer[l + WIDTH * (FSMC_UPSCALE) * n] = buffer[l]; buffer[l + n * UPSCALE0(WIDTH)] = buffer[l];
if (allow_async) { if (allow_async) {
if (y > 0 || page > 1) LCD_IO_WaitSequence_Async(); if (y > 0 || page > 1) LCD_IO_WaitSequence_Async();

21
Marlin/src/lcd/dogm/ultralcd_DOGM.h

@ -212,30 +212,9 @@
#endif #endif
#endif #endif
// LCD_FULL_PIXEL_WIDTH =
// LCD_PIXEL_OFFSET_X + (LCD_PIXEL_WIDTH * 2) + LCD_PIXEL_OFFSET_X
#if TFT_SCALED_DOGLCD
#ifndef LCD_FULL_PIXEL_WIDTH
#define LCD_FULL_PIXEL_WIDTH 320
#endif
#ifndef LCD_PIXEL_OFFSET_X
#define LCD_PIXEL_OFFSET_X 32
#endif
#ifndef LCD_FULL_PIXEL_HEIGHT
#define LCD_FULL_PIXEL_HEIGHT 240
#endif
#ifndef LCD_PIXEL_OFFSET_Y
#define LCD_PIXEL_OFFSET_Y 32
#endif
#endif
// For selective rendering within a Y range // For selective rendering within a Y range
#define PAGE_OVER(ya) ((ya) <= u8g.getU8g()->current_page.y1) // Does the current page follow a region top? #define PAGE_OVER(ya) ((ya) <= u8g.getU8g()->current_page.y1) // Does the current page follow a region top?
#define PAGE_UNDER(yb) ((yb) >= u8g.getU8g()->current_page.y0) // Does the current page precede a region bottom? #define PAGE_UNDER(yb) ((yb) >= u8g.getU8g()->current_page.y0) // Does the current page precede a region bottom?
#define PAGE_CONTAINS(ya, yb) ((yb) >= u8g.getU8g()->current_page.y0 && (ya) <= u8g.getU8g()->current_page.y1) // Do two vertical regions overlap? #define PAGE_CONTAINS(ya, yb) ((yb) >= u8g.getU8g()->current_page.y0 && (ya) <= u8g.getU8g()->current_page.y1) // Do two vertical regions overlap?
#ifndef FSMC_UPSCALE
#define FSMC_UPSCALE 2
#endif
extern U8G_CLASS u8g; extern U8G_CLASS u8g;

3
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp

@ -35,9 +35,10 @@
#include "pic_manager.h" #include "pic_manager.h"
#include <lvgl.h> #include <lvgl.h>
#include "../../../touch/xpt2046.h"
#include "../../../../MarlinCore.h" #include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h" #include "../../../../module/temperature.h"
#include "../../../../feature/touch/xpt2046.h"
#include "../../../../sd/cardreader.h" #include "../../../../sd/cardreader.h"
uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta; uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;

32
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp

@ -41,8 +41,11 @@
#include "draw_ui.h" #include "draw_ui.h"
#include <lvgl.h> #include <lvgl.h>
#include "../../../../MarlinCore.h" #include "../../../../inc/MarlinConfig.h"
#include "../../../../feature/touch/xpt2046.h"
#if HAS_TOUCH_XPT2046
#include "../../../touch/xpt2046.h"
#endif
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h" #include "../../../../feature/powerloss.h"
@ -50,6 +53,13 @@
#include <SPI.h> #include <SPI.h>
#ifndef LCD_FULL_PIXEL_WIDTH
#define LCD_FULL_PIXEL_WIDTH 480
#endif
#ifndef LCD_FULL_PIXEL_HEIGHT
#define LCD_FULL_PIXEL_HEIGHT 320
#endif
#if HAS_SPI_FLASH_FONT #if HAS_SPI_FLASH_FONT
extern void init_gb2312_font(); extern void init_gb2312_font();
#endif #endif
@ -127,9 +137,8 @@ void LCD_WriteRAM_Prepare(void) {
void tft_set_point(uint16_t x, uint16_t y, uint16_t point) { void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
//if (DeviceCode == 0x9488) { //if (DeviceCode == 0x9488) {
if ((x > 480) || (y > 320)) return; if (x > (LCD_FULL_PIXEL_WIDTH) || y > (LCD_FULL_PIXEL_HEIGHT)) return;
//} //}
//**if ( (x>320)||(y>240) ) return;
tft_set_cursor(x, y); tft_set_cursor(x, y);
LCD_WriteRAM_Prepare(); LCD_WriteRAM_Prepare();
@ -224,16 +233,16 @@ void LCD_Clear(uint16_t Color) {
if (DeviceCode == 0x9488) { if (DeviceCode == 0x9488) {
tft_set_cursor(0, 0); tft_set_cursor(0, 0);
ili9320_SetWindows(0, 0, 480, 320); ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
LCD_WriteRAM_Prepare(); LCD_WriteRAM_Prepare();
#ifdef LCD_USE_DMA_FSMC #ifdef LCD_USE_DMA_FSMC
LCD_IO_WriteMultiple(Color, LCD_FULL_PIXEL_WIDTH * LCD_FULL_PIXEL_HEIGHT); LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
#else #else
//index = (160*480); //index = (LCD_FULL_PIXEL_HEIGHT) / 2 * (LCD_FULL_PIXEL_WIDTH);
for (index = 0; index < 320 * 480; index++) for (index = 0; index < (LCD_FULL_PIXEL_HEIGHT) * (LCD_FULL_PIXEL_WIDTH); index++)
LCD_IO_WriteData(Color); LCD_IO_WriteData(Color);
#endif #endif
//LCD_IO_WriteMultiple(Color, (480*320)); //LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
//while(index --) LCD_IO_WriteData(Color); //while(index --) LCD_IO_WriteData(Color);
} }
else if (DeviceCode == 0x5761) { else if (DeviceCode == 0x5761) {
@ -262,7 +271,6 @@ void LCD_Clear(uint16_t Color) {
extern uint16_t ILI9488_ReadRAM(); extern uint16_t ILI9488_ReadRAM();
void init_tft() { void init_tft() {
uint16_t i; uint16_t i;
//************* Start Initial Sequence **********// //************* Start Initial Sequence **********//
@ -393,7 +401,7 @@ void init_tft() {
for (i = 0; i < 65535; i++); for (i = 0; i < 65535; i++);
LCD_IO_WriteReg(0x0029); LCD_IO_WriteReg(0x0029);
ili9320_SetWindows(0, 0, 480, 320); ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
LCD_Clear(0x0000); LCD_Clear(0x0000);
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
@ -486,7 +494,7 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co
#if ENABLED(TFT_LVGL_UI_SPI) #if ENABLED(TFT_LVGL_UI_SPI)
uint16_t i, width, height; uint16_t i, width, height;
uint16_t clr_temp; uint16_t clr_temp;
uint8_t tbuf[480 * 2]; uint8_t tbuf[(LCD_FULL_PIXEL_WIDTH) * 2];
SPI_TFT.spi_init(SPI_FULL_SPEED); SPI_TFT.spi_init(SPI_FULL_SPEED);

22
Marlin/src/lcd/lcdprint.h

@ -1,3 +1,25 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/** /**
* @file lcdprint.h * @file lcdprint.h
* @brief LCD print api * @brief LCD print api

50
Marlin/src/lcd/scaled_tft.h

@ -0,0 +1,50 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../inc/MarlinConfig.h"
#ifndef FSMC_UPSCALE
#define FSMC_UPSCALE 2
#endif
#ifndef LCD_FULL_PIXEL_WIDTH
#if FSMC_UPSCALE == 3
#define LCD_FULL_PIXEL_WIDTH 480
#else
#define LCD_FULL_PIXEL_WIDTH 320
#endif
#endif
#ifndef LCD_FULL_PIXEL_HEIGHT
#if FSMC_UPSCALE == 3
#define LCD_FULL_PIXEL_HEIGHT 320
#else
#define LCD_FULL_PIXEL_HEIGHT 240
#endif
#endif
#ifndef LCD_PIXEL_OFFSET_X
#define LCD_PIXEL_OFFSET_X 48
#endif
#ifndef LCD_PIXEL_OFFSET_Y
#define LCD_PIXEL_OFFSET_Y 48
#endif

35
Marlin/src/feature/touch/xpt2046.cpp → Marlin/src/lcd/touch/xpt2046.cpp

@ -21,11 +21,8 @@
#if HAS_TOUCH_XPT2046 #if HAS_TOUCH_XPT2046
#if TFT_SCALED_DOGLCD
#include "../../lcd/dogm/ultralcd_DOGM.h" // for LCD_FULL_PIXEL_WIDTH, etc.
#endif
#include "xpt2046.h" #include "xpt2046.h"
#include "../scaled_tft.h"
#ifndef XPT2046_Z1_THRESHOLD #ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10 #define XPT2046_Z1_THRESHOLD 10
@ -35,12 +32,12 @@
* Draw and Touch processing * Draw and Touch processing
* *
* LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution. * LCD_PIXEL_WIDTH/HEIGHT (128x64) is the (emulated DOGM) Pixel Drawing resolution.
* TOUCH_SCREEN_WIDTH/HEIGHT (320x240) is the Touch Area resolution. * TOUCH_SENSOR_WIDTH/HEIGHT (320x240) is the Touch Area resolution.
* LCD_FULL_PIXEL_WIDTH/HEIGHT (320x240 or 480x320) is the Actual (FSMC) Display 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) * - All native (u8g) drawing is done in LCD_PIXEL_* (128x64)
* - The DOGM pixels are is upscaled 2-3x (as needed) for display. * - The DOGM pixels are is upscaled 2-3x (as needed) for display.
* - Touch coordinates use TOUCH_SCREEN_* resolution and are converted to * - Touch coordinates use TOUCH_SENSOR_* resolution and are converted to
* click and scroll-wheel events (emulating of a common DOGM display). * 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 * TOUCH_SCREEN resolution exists to fit our calibration values. The original touch code was made
@ -54,21 +51,25 @@
* The Marlin screen touchable area starts at LCD_PIXEL_OFFSET_X/Y (translated to SCREEN_START_LEFT/TOP) * 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). * 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
// Coordinates in terms of touch area // 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) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) // Touch sensor resolution independent of display resolution
#define SCREEN_START_LEFT ((LCD_PIXEL_OFFSET_X) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH)) #define TOUCH_SENSOR_WIDTH 320
#define SCREEN_HEIGHT ((LCD_PIXEL_HEIGHT * FSMC_UPSCALE) * (TOUCH_SCREEN_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT)) #define TOUCH_SENSOR_HEIGHT 240
#define SCREEN_WIDTH ((LCD_PIXEL_WIDTH * FSMC_UPSCALE) * (TOUCH_SCREEN_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
#define SCREEN_WIDTH_PCT(X) ((X) * (TOUCH_SENSOR_WIDTH) / (LCD_FULL_PIXEL_WIDTH))
#define SCREEN_HEIGHT_PCT(Y) ((Y) * (TOUCH_SENSOR_HEIGHT) / (LCD_FULL_PIXEL_HEIGHT))
#define SCREEN_START_LEFT SCREEN_WIDTH_PCT(LCD_PIXEL_OFFSET_X)
#define SCREEN_START_TOP SCREEN_HEIGHT_PCT(LCD_PIXEL_OFFSET_Y)
#define SCREEN_WIDTH SCREEN_WIDTH_PCT((LCD_PIXEL_WIDTH) * (FSMC_UPSCALE))
#define SCREEN_HEIGHT SCREEN_HEIGHT_PCT((LCD_PIXEL_HEIGHT) * (FSMC_UPSCALE))
#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT
#define TOUCHABLE_X_WIDTH SCREEN_WIDTH #define TOUCHABLE_X_WIDTH SCREEN_WIDTH
#define TOUCHABLE_Y_HEIGHT SCREEN_HEIGHT
#ifndef TOUCH_INT_PIN #ifndef TOUCH_INT_PIN
#define TOUCH_INT_PIN -1 #define TOUCH_INT_PIN -1
@ -125,8 +126,8 @@ uint8_t XPT2046::read_buttons() {
if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read. if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
#if ENABLED(GRAPHICAL_TFT_ROTATE_180) #if ENABLED(GRAPHICAL_TFT_ROTATE_180)
x = TOUCH_SCREEN_WIDTH - x; x = TOUCH_SENSOR_WIDTH - x;
y = TOUCH_SCREEN_HEIGHT - y; y = TOUCH_SENSOR_HEIGHT - y;
#endif #endif
// Touch within the button area simulates an encoder button // Touch within the button area simulates an encoder button
@ -137,7 +138,7 @@ uint8_t XPT2046::read_buttons() {
: WITHIN(x, 242, 305) ? EN_C : WITHIN(x, 242, 305) ? EN_C
: 0; : 0;
if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0; if (x > TOUCH_SENSOR_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
// Column and row above BUTTON_AREA_TOP // Column and row above BUTTON_AREA_TOP
int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH), int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),

0
Marlin/src/feature/touch/xpt2046.h → Marlin/src/lcd/touch/xpt2046.h

2
Marlin/src/lcd/ultralcd.cpp

@ -150,7 +150,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
volatile uint8_t MarlinUI::slow_buttons; volatile uint8_t MarlinUI::slow_buttons;
#endif #endif
#if HAS_TOUCH_XPT2046 #if HAS_TOUCH_XPT2046
#include "../feature/touch/xpt2046.h" #include "touch/xpt2046.h"
bool MarlinUI::on_edit_screen = false; bool MarlinUI::on_edit_screen = false;
#endif #endif
#endif #endif

19
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h

@ -112,10 +112,6 @@
#if ENABLED(FSMC_GRAPHICAL_TFT) #if ENABLED(FSMC_GRAPHICAL_TFT)
#define FSMC_UPSCALE 3 #define FSMC_UPSCALE 3
#define LCD_FULL_PIXEL_WIDTH 480
#define LCD_PIXEL_OFFSET_X 48
#define LCD_FULL_PIXEL_HEIGHT 320
#define LCD_PIXEL_OFFSET_Y 48
#define LCD_RESET_PIN PF11 #define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13 #define LCD_BACKLIGHT_PIN PD13
@ -173,30 +169,31 @@
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
//#define TOUCH_INT_PIN PB6 //#define TOUCH_INT_PIN PB6
#if ENABLED(TFT_LVGL_UI_SPI)
#define SPI_TFT_CS_PIN TOUCH_CS_PIN #define SPI_TFT_CS_PIN TOUCH_CS_PIN
#define SPI_TFT_SCK_PIN TOUCH_SCK_PIN #define SPI_TFT_SCK_PIN TOUCH_SCK_PIN
#define SPI_TFT_MISO_PIN TOUCH_MISO_PIN #define SPI_TFT_MISO_PIN TOUCH_MISO_PIN
#define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN #define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN
#define SPI_TFT_DC_PIN PB6 #define SPI_TFT_DC_PIN PB6
#define SPI_TFT_RST_PIN PF11 #define SPI_TFT_RST_PIN PF11
#endif
#define LCD_RESET_PIN PF11 #define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13 #define LCD_BACKLIGHT_PIN PD13
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11
#define FSMC_DMA_DEV DMA2 #define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5 #define FSMC_DMA_CHANNEL DMA_CH5
#define LCD_FULL_PIXEL_WIDTH 480 #define LCD_PIXEL_WIDTH 480
#define LCD_PIXEL_HEIGHT 320
#define LCD_FULL_PIXEL_WIDTH LCD_PIXEL_WIDTH
#define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT
#define LCD_PIXEL_OFFSET_X 48 #define LCD_PIXEL_OFFSET_X 48
#define LCD_FULL_PIXEL_HEIGHT 320
#define LCD_PIXEL_OFFSET_Y 48 #define LCD_PIXEL_OFFSET_Y 48
#define LCD_PIXEL_HEIGHT 320
#define LCD_PIXEL_WIDTH 480
#define XPT2046_X_CALIBRATION -12316 #define XPT2046_X_CALIBRATION -12316
#define XPT2046_Y_CALIBRATION 8981 #define XPT2046_Y_CALIBRATION 8981
#define XPT2046_X_OFFSET 340 #define XPT2046_X_OFFSET 340

19
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h

@ -118,10 +118,6 @@
// //
#if ENABLED(FSMC_GRAPHICAL_TFT) #if ENABLED(FSMC_GRAPHICAL_TFT)
#define FSMC_UPSCALE 3 #define FSMC_UPSCALE 3
#define LCD_FULL_PIXEL_WIDTH 480
#define LCD_PIXEL_OFFSET_X 48
#define LCD_FULL_PIXEL_HEIGHT 320
#define LCD_PIXEL_OFFSET_Y 48
#define LCD_RESET_PIN PF11 #define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13 #define LCD_BACKLIGHT_PIN PD13
@ -178,30 +174,31 @@
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
//#define TOUCH_INT_PIN PB6 //#define TOUCH_INT_PIN PB6
#if ENABLED(TFT_LVGL_UI_SPI)
#define SPI_TFT_CS_PIN TOUCH_CS_PIN #define SPI_TFT_CS_PIN TOUCH_CS_PIN
#define SPI_TFT_SCK_PIN TOUCH_SCK_PIN #define SPI_TFT_SCK_PIN TOUCH_SCK_PIN
#define SPI_TFT_MISO_PIN TOUCH_MISO_PIN #define SPI_TFT_MISO_PIN TOUCH_MISO_PIN
#define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN #define SPI_TFT_MOSI_PIN TOUCH_MOSI_PIN
#define SPI_TFT_DC_PIN PB6 #define SPI_TFT_DC_PIN PB6
#define SPI_TFT_RST_PIN PF11 #define SPI_TFT_RST_PIN PF11
#endif
#define LCD_RESET_PIN PF11 #define LCD_RESET_PIN PF11
#define LCD_BACKLIGHT_PIN PD13 #define LCD_BACKLIGHT_PIN PD13
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PD11
#define FSMC_DMA_DEV DMA2 #define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5 #define FSMC_DMA_CHANNEL DMA_CH5
#define LCD_FULL_PIXEL_WIDTH 480 #define LCD_PIXEL_WIDTH 480
#define LCD_PIXEL_HEIGHT 320
#define LCD_FULL_PIXEL_WIDTH LCD_PIXEL_WIDTH
#define LCD_FULL_PIXEL_HEIGHT LCD_PIXEL_HEIGHT
#define LCD_PIXEL_OFFSET_X 48 #define LCD_PIXEL_OFFSET_X 48
#define LCD_FULL_PIXEL_HEIGHT 320
#define LCD_PIXEL_OFFSET_Y 48 #define LCD_PIXEL_OFFSET_Y 48
#define LCD_PIXEL_HEIGHT 320
#define LCD_PIXEL_WIDTH 480
#define XPT2046_X_CALIBRATION -12316 #define XPT2046_X_CALIBRATION -12316
#define XPT2046_Y_CALIBRATION 8981 #define XPT2046_Y_CALIBRATION 8981
#define XPT2046_X_OFFSET 340 #define XPT2046_X_OFFSET 340

11
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h

@ -294,7 +294,7 @@
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1 #define TOUCH_BUTTONS_HW_SPI_DEVICE 1
//#define TOUCH_SCREEN //#define TOUCH_SCREEN
#if NEED_TOUCH_PINS #if EITHER(TOUCH_SCREEN, NEED_TOUCH_PINS)
#define TOUCH_CS_PIN PE14 // SPI1_NSS #define TOUCH_CS_PIN PE14 // SPI1_NSS
#define TOUCH_SCK_PIN PA5 // SPI1_SCK #define TOUCH_SCK_PIN PA5 // SPI1_SCK
#define TOUCH_MISO_PIN PA6 // SPI1_MISO #define TOUCH_MISO_PIN PA6 // SPI1_MISO
@ -317,15 +317,6 @@
#ifndef FSMC_UPSCALE #ifndef FSMC_UPSCALE
#define FSMC_UPSCALE 3 #define FSMC_UPSCALE 3
#endif #endif
#ifndef LCD_FULL_PIXEL_WIDTH
#define LCD_FULL_PIXEL_WIDTH 480
#endif
#ifndef LCD_PIXEL_OFFSET_X
#define LCD_PIXEL_OFFSET_X 48
#endif
#ifndef LCD_FULL_PIXEL_HEIGHT
#define LCD_FULL_PIXEL_HEIGHT 320
#endif
#ifndef LCD_PIXEL_OFFSET_Y #ifndef LCD_PIXEL_OFFSET_Y
#define LCD_PIXEL_OFFSET_Y 32 #define LCD_PIXEL_OFFSET_Y 32
#endif #endif

Loading…
Cancel
Save