Emulated DOGM via HAL TFT, XPT IO (#19017)
This commit is contained in:
@ -33,25 +33,6 @@
|
||||
|
||||
TFT SPI_TFT;
|
||||
|
||||
#ifndef SPI_TFT_MISO_PIN
|
||||
#define SPI_TFT_MISO_PIN PA6
|
||||
#endif
|
||||
#ifndef SPI_TFT_MOSI_PIN
|
||||
#define SPI_TFT_MOSI_PIN PA7
|
||||
#endif
|
||||
#ifndef SPI_TFT_SCK_PIN
|
||||
#define SPI_TFT_SCK_PIN PA5
|
||||
#endif
|
||||
#ifndef SPI_TFT_CS_PIN
|
||||
#define SPI_TFT_CS_PIN PD11
|
||||
#endif
|
||||
#ifndef SPI_TFT_DC_PIN
|
||||
#define SPI_TFT_DC_PIN PD10
|
||||
#endif
|
||||
#ifndef SPI_TFT_RST_PIN
|
||||
#define SPI_TFT_RST_PIN PC6
|
||||
#endif
|
||||
|
||||
// use SPI1 for the spi tft.
|
||||
void TFT::spi_init(uint8_t spiRate) {
|
||||
tftio.Init();
|
||||
@ -93,11 +74,11 @@ void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
|
||||
}
|
||||
|
||||
void TFT::LCD_init() {
|
||||
SPI_TFT_RST_H;
|
||||
TFT_RST_H;
|
||||
delay(150);
|
||||
SPI_TFT_RST_L;
|
||||
TFT_RST_L;
|
||||
delay(150);
|
||||
SPI_TFT_RST_H;
|
||||
TFT_RST_H;
|
||||
|
||||
tftio.DataTransferBegin(DATASIZE_8BIT);
|
||||
|
||||
@ -176,22 +157,22 @@ void TFT::LCD_init() {
|
||||
|
||||
LCD_clear(0x0000); //
|
||||
LCD_Draw_Logo();
|
||||
SPI_TFT_BLK_H;
|
||||
TFT_BLK_H;
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void TFT::LCD_clear(uint16_t color) {
|
||||
SetWindows(0, 0, (LCD_FULL_PIXEL_WIDTH) - 1, (LCD_FULL_PIXEL_HEIGHT) - 1);
|
||||
tftio.WriteMultiple(color, (uint32_t)(LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
|
||||
SetWindows(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
|
||||
tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
|
||||
}
|
||||
|
||||
extern unsigned char bmp_public_buf[17 * 1024];
|
||||
|
||||
void TFT::LCD_Draw_Logo() {
|
||||
SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
|
||||
for (uint16_t i = 0; i < (LCD_FULL_PIXEL_HEIGHT); i ++) {
|
||||
Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (LCD_FULL_PIXEL_WIDTH) * 2);
|
||||
tftio.WriteSequence((uint16_t *)bmp_public_buf, LCD_FULL_PIXEL_WIDTH);
|
||||
SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
|
||||
Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
|
||||
tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@
|
||||
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
|
||||
#endif
|
||||
|
||||
#define SPI_TFT_RST_H OUT_WRITE(SPI_TFT_RST_PIN, HIGH)
|
||||
#define SPI_TFT_RST_L OUT_WRITE(SPI_TFT_RST_PIN, LOW)
|
||||
#define TFT_RST_H OUT_WRITE(TFT_RESET_PIN, HIGH)
|
||||
#define TFT_RST_L OUT_WRITE(TFT_RESET_PIN, LOW)
|
||||
|
||||
#define SPI_TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH)
|
||||
#define SPI_TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW)
|
||||
#define TFT_BLK_H OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH)
|
||||
#define TFT_BLK_L OUT_WRITE(LCD_BACKLIGHT_PIN, LOW)
|
||||
|
||||
class TFT {
|
||||
public:
|
||||
|
@ -653,10 +653,10 @@ char *creat_title_text() {
|
||||
i += 2;
|
||||
if (*p_index == 0x0000) *p_index = 0xC318;
|
||||
}
|
||||
SPI_TFT_CS_L;
|
||||
SPI_TFT_DC_H;
|
||||
TFT_CS_L;
|
||||
TFT_DC_H;
|
||||
SPI.dmaSend(bmp_public_buf, 400, true);
|
||||
SPI_TFT_CS_H;
|
||||
TFT_CS_H;
|
||||
|
||||
#else
|
||||
for (i = 0; i < 400;) {
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "pic_manager.h"
|
||||
#include <lvgl.h>
|
||||
|
||||
#include "../../../touch/xpt2046.h"
|
||||
|
||||
#include "../../../../MarlinCore.h"
|
||||
#include "../../../../module/temperature.h"
|
||||
#include "../../../../sd/cardreader.h"
|
||||
|
@ -51,11 +51,11 @@ XPT2046 touch;
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#ifndef LCD_FULL_PIXEL_WIDTH
|
||||
#define LCD_FULL_PIXEL_WIDTH 480
|
||||
#ifndef TFT_WIDTH
|
||||
#define TFT_WIDTH 480
|
||||
#endif
|
||||
#ifndef LCD_FULL_PIXEL_HEIGHT
|
||||
#define LCD_FULL_PIXEL_HEIGHT 320
|
||||
#ifndef TFT_HEIGHT
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#if HAS_SPI_FLASH_FONT
|
||||
@ -135,7 +135,7 @@ void LCD_WriteRAM_Prepare(void) {
|
||||
|
||||
void tft_set_point(uint16_t x, uint16_t y, uint16_t point) {
|
||||
//if (DeviceCode == 0x9488) {
|
||||
if (x > (LCD_FULL_PIXEL_WIDTH) || y > (LCD_FULL_PIXEL_HEIGHT)) return;
|
||||
if (x > (TFT_WIDTH) || y > (TFT_HEIGHT)) return;
|
||||
//}
|
||||
tft_set_cursor(x, y);
|
||||
|
||||
@ -196,8 +196,8 @@ void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16
|
||||
LCD_WriteReg(0x0053, yEnd);*/
|
||||
LCD_WriteReg(0x0050, StartY); // Specify the start/end positions of the window address in the horizontal direction by an address unit
|
||||
LCD_WriteReg(0x0051, yEnd); // Specify the start positions of the window address in the vertical direction by an address unit
|
||||
LCD_WriteReg(0x0052, (LCD_FULL_PIXEL_HEIGHT) - xEnd);
|
||||
LCD_WriteReg(0x0053, (LCD_FULL_PIXEL_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit
|
||||
LCD_WriteReg(0x0052, (TFT_HEIGHT) - xEnd);
|
||||
LCD_WriteReg(0x0053, (TFT_HEIGHT) - StartX - 1); // Specify the end positions of the window address in the vertical direction by an address unit
|
||||
|
||||
}
|
||||
else {
|
||||
@ -231,16 +231,16 @@ void LCD_Clear(uint16_t Color) {
|
||||
|
||||
if (DeviceCode == 0x9488) {
|
||||
tft_set_cursor(0, 0);
|
||||
ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
|
||||
ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
LCD_WriteRAM_Prepare();
|
||||
#ifdef LCD_USE_DMA_FSMC
|
||||
LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
|
||||
LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
|
||||
#else
|
||||
//index = (LCD_FULL_PIXEL_HEIGHT) / 2 * (LCD_FULL_PIXEL_WIDTH);
|
||||
for (index = 0; index < (LCD_FULL_PIXEL_HEIGHT) * (LCD_FULL_PIXEL_WIDTH); index++)
|
||||
//index = (TFT_HEIGHT) / 2 * (TFT_WIDTH);
|
||||
for (index = 0; index < (TFT_HEIGHT) * (TFT_WIDTH); index++)
|
||||
LCD_IO_WriteData(Color);
|
||||
#endif
|
||||
//LCD_IO_WriteMultiple(Color, (LCD_FULL_PIXEL_WIDTH) * (LCD_FULL_PIXEL_HEIGHT));
|
||||
//LCD_IO_WriteMultiple(Color, (TFT_WIDTH) * (TFT_HEIGHT));
|
||||
//while(index --) LCD_IO_WriteData(Color);
|
||||
}
|
||||
else if (DeviceCode == 0x5761) {
|
||||
@ -378,7 +378,7 @@ void init_tft() {
|
||||
for (i = 0; i < 65535; i++);
|
||||
LCD_IO_WriteReg(0x0029);
|
||||
|
||||
ili9320_SetWindows(0, 0, LCD_FULL_PIXEL_WIDTH, LCD_FULL_PIXEL_HEIGHT);
|
||||
ili9320_SetWindows(0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
LCD_Clear(0x0000);
|
||||
|
||||
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
|
||||
@ -522,8 +522,8 @@ static bool get_point(int16_t *x, int16_t *y) {
|
||||
}
|
||||
|
||||
#if ENABLED(GRAPHICAL_TFT_ROTATE_180)
|
||||
x = (LCD_FULL_PIXEL_WIDTH) - x;
|
||||
y = (LCD_FULL_PIXEL_HEIGHT) - y;
|
||||
x = (TFT_WIDTH) - x;
|
||||
y = (TFT_HEIGHT) - y;
|
||||
#endif
|
||||
|
||||
return is_touched;
|
||||
|
Reference in New Issue
Block a user