2020-06-16 10:05:33 +08:00
|
|
|
/**
|
|
|
|
* 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
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-06-16 10:05:33 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-06 04:17:59 -05:00
|
|
|
#include "../../../inc/MarlinConfigPre.h"
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-10-12 18:38:07 -03:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-07-25 13:52:07 +08:00
|
|
|
#include "SPI_TFT.h"
|
|
|
|
#include "pic_manager.h"
|
2020-09-21 09:55:02 +08:00
|
|
|
#include "tft_lvgl_configuration.h"
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2021-05-06 04:17:59 -05:00
|
|
|
#include "../../../inc/MarlinConfig.h"
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-07-25 13:52:07 +08:00
|
|
|
#include <SPI.h>
|
|
|
|
|
2020-10-12 18:38:07 -03:00
|
|
|
#include "draw_ui.h"
|
|
|
|
|
2020-07-25 13:52:07 +08:00
|
|
|
TFT SPI_TFT;
|
|
|
|
|
2020-06-16 10:05:33 +08:00
|
|
|
// use SPI1 for the spi tft.
|
2020-07-25 13:52:07 +08:00
|
|
|
void TFT::spi_init(uint8_t spiRate) {
|
2020-08-13 20:31:59 -03:00
|
|
|
tftio.Init();
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-07-25 13:52:07 +08:00
|
|
|
void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) {
|
|
|
|
if ((x > 480) || (y > 320)) return;
|
|
|
|
|
2020-10-12 18:38:07 -03:00
|
|
|
setWindow(x, y, 1, 1);
|
2020-08-13 20:31:59 -03:00
|
|
|
tftio.WriteMultiple(point, (uint16_t)1);
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
|
|
|
|
2020-10-12 18:38:07 -03:00
|
|
|
void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
|
|
|
|
tftio.set_window(x, y, (x + with - 1), (y + height - 1));
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TFT::LCD_init() {
|
2020-10-12 18:38:07 -03:00
|
|
|
tftio.InitTFT();
|
|
|
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
|
|
|
OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
|
|
|
|
#endif
|
|
|
|
delay(100);
|
|
|
|
LCD_clear(0x0000);
|
2020-07-25 13:52:07 +08:00
|
|
|
LCD_Draw_Logo();
|
2020-10-12 18:38:07 -03:00
|
|
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
|
|
|
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
|
|
|
#endif
|
|
|
|
#if HAS_LOGO_IN_FLASH
|
|
|
|
delay(2000);
|
|
|
|
#endif
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TFT::LCD_clear(uint16_t color) {
|
2020-10-12 18:38:07 -03:00
|
|
|
setWindow(0, 0, (TFT_WIDTH), (TFT_HEIGHT));
|
2020-08-21 20:54:21 -03:00
|
|
|
tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-07-25 13:52:07 +08:00
|
|
|
void TFT::LCD_Draw_Logo() {
|
2020-10-12 18:38:07 -03:00
|
|
|
#if HAS_LOGO_IN_FLASH
|
|
|
|
setWindow(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);
|
|
|
|
}
|
|
|
|
#endif
|
2020-07-25 13:52:07 +08:00
|
|
|
}
|
2020-06-16 10:05:33 +08:00
|
|
|
|
2020-10-12 18:38:07 -03:00
|
|
|
#endif // HAS_TFT_LVGL_UI
|