Add TFT_LVGL_UI support (#18438)
This commit is contained in:
@@ -21,11 +21,10 @@
|
||||
*/
|
||||
#include "../../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(TFT_LITTLE_VGL_UI)
|
||||
#if ENABLED(TFT_LVGL_UI)
|
||||
|
||||
#include "W25Qxx.h"
|
||||
#include "tft_lvgl_configuration.h"
|
||||
#include "pic_manager.h"
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
@@ -38,6 +37,8 @@
|
||||
#include "../../../../module/motion.h"
|
||||
#include "../../../../module/planner.h"
|
||||
|
||||
#include "pic_manager.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../../feature/powerloss.h"
|
||||
#endif
|
||||
@@ -73,7 +74,33 @@ extern void LCD_IO_WriteData(uint16_t RegValue);
|
||||
|
||||
void gCfgItems_init() {
|
||||
gCfgItems.multiple_language = MULTI_LANGUAGE_ENABLE;
|
||||
gCfgItems.language = LANG_ENGLISH;
|
||||
#if 1 //LCD_LANGUAGE == en
|
||||
gCfgItems.language = LANG_ENGLISH;
|
||||
#elif LCD_LANGUAGE == zh_CN
|
||||
gCfgItems.language = LANG_SIMPLE_CHINESE;
|
||||
#elif LCD_LANGUAGE == zh_TW
|
||||
gCfgItems.language = LANG_COMPLEX_CHINESE;
|
||||
#elif LCD_LANGUAGE == jp_kana
|
||||
gCfgItems.language = LANG_JAPAN;
|
||||
#elif LCD_LANGUAGE == de
|
||||
gCfgItems.language = LANG_GERMAN;
|
||||
#elif LCD_LANGUAGE == fr
|
||||
gCfgItems.language = LANG_FRENCH;
|
||||
#elif LCD_LANGUAGE == ru
|
||||
gCfgItems.language = LANG_RUSSIAN;
|
||||
#elif LCD_LANGUAGE == ko_KR
|
||||
gCfgItems.language = LANG_KOREAN;
|
||||
#elif LCD_LANGUAGE == tr
|
||||
gCfgItems.language = LANG_TURKISH;
|
||||
#elif LCD_LANGUAGE == es
|
||||
gCfgItems.language = LANG_SPANISH;
|
||||
#elif LCD_LANGUAGE == el
|
||||
gCfgItems.language = LANG_GREEK;
|
||||
#elif LCD_LANGUAGE == it
|
||||
gCfgItems.language = LANG_ITALY;
|
||||
#elif LCD_LANGUAGE == pt
|
||||
gCfgItems.language = LANG_PORTUGUESE;
|
||||
#endif
|
||||
gCfgItems.leveling_mode = 0;
|
||||
gCfgItems.from_flash_pic = 0;
|
||||
gCfgItems.curFilesize = 0;
|
||||
@@ -139,8 +166,13 @@ void tft_style_init() {
|
||||
tft_style_lable_rel.body.grad_color = LV_COLOR_BACKGROUND;
|
||||
tft_style_lable_rel.text.color = LV_COLOR_TEXT;
|
||||
tft_style_lable_rel.text.sel_color = LV_COLOR_TEXT;
|
||||
tft_style_lable_pre.text.font = &gb2312_puhui32;
|
||||
tft_style_lable_rel.text.font = &gb2312_puhui32;
|
||||
#if HAS_SPI_FLASH_FONT
|
||||
tft_style_lable_pre.text.font = &gb2312_puhui32;
|
||||
tft_style_lable_rel.text.font = &gb2312_puhui32;
|
||||
#else
|
||||
tft_style_lable_pre.text.font = LV_FONT_DEFAULT;
|
||||
tft_style_lable_rel.text.font = LV_FONT_DEFAULT;
|
||||
#endif
|
||||
tft_style_lable_pre.line.width = 0;
|
||||
tft_style_lable_rel.line.width = 0;
|
||||
tft_style_lable_pre.text.letter_space = 0;
|
||||
@@ -325,6 +357,9 @@ char *creat_title_text() {
|
||||
return public_buf_m;
|
||||
}
|
||||
|
||||
#if HAS_GCODE_PREVIEW
|
||||
uint32_t gPicturePreviewStart = 0;
|
||||
|
||||
void preview_gcode_prehandle(char *path) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
//uint8_t re;
|
||||
@@ -333,6 +368,7 @@ void preview_gcode_prehandle(char *path) {
|
||||
uint32_t *p1;
|
||||
char *cur_name;
|
||||
|
||||
gPicturePreviewStart = 0;
|
||||
cur_name = strrchr(path, '/');
|
||||
card.openFileRead(cur_name);
|
||||
card.read(public_buf, 512);
|
||||
@@ -369,7 +405,24 @@ void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
|
||||
cur_name = strrchr(path, '/');
|
||||
card.openFileRead(cur_name);
|
||||
|
||||
card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
|
||||
if (gPicturePreviewStart <= 0) {
|
||||
while (1) {
|
||||
uint32_t br = card.read(public_buf, 400);
|
||||
uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
|
||||
if (p1) {
|
||||
gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
gPicturePreviewStart += br;
|
||||
}
|
||||
if (br < 400) break;
|
||||
}
|
||||
}
|
||||
|
||||
// SERIAL_ECHOLNPAIR("gPicturePreviewStart: ", gPicturePreviewStart, " PREVIEW_LITTLE_PIC_SIZE: ", PREVIEW_LITTLE_PIC_SIZE);
|
||||
|
||||
card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
|
||||
#if ENABLED(SPI_GRAPHICAL_TFT)
|
||||
SPI_TFT.spi_init(SPI_FULL_SPEED);
|
||||
//SPI_TFT.SetCursor(0,0);
|
||||
@@ -417,14 +470,16 @@ void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
|
||||
#else
|
||||
for (i = 0; i < 400;) {
|
||||
p_index = (uint16_t *)(&bmp_public_buf[i]);
|
||||
//if (*p_index == 0x0000)*p_index=gCfgItems.preview_bk_color;
|
||||
if (*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
|
||||
LCD_IO_WriteData(*p_index);
|
||||
i += 2;
|
||||
}
|
||||
#endif
|
||||
W25QXX.init(SPI_QUARTER_SPEED);
|
||||
if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
|
||||
W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
|
||||
#if HAS_BAK_VIEW_IN_FLASH
|
||||
W25QXX.init(SPI_QUARTER_SPEED);
|
||||
if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
|
||||
W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
|
||||
#endif
|
||||
row++;
|
||||
if (row >= 200) {
|
||||
size = 809;
|
||||
@@ -489,15 +544,19 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
|
||||
int x_off = 0, y_off = 0;
|
||||
int _y;
|
||||
uint16_t *p_index;
|
||||
int i, j;
|
||||
uint16_t temp_p, Color;
|
||||
int i;
|
||||
uint16_t temp_p;
|
||||
|
||||
for (index = 0; index < 10; index++) { // 200*200
|
||||
if (sel == 1) flash_view_Read(bmp_public_buf, 8000); //20k
|
||||
//memset(bmp_public_buf,0x1f,8000);
|
||||
else
|
||||
#if HAS_BAK_VIEW_IN_FLASH
|
||||
if (sel == 1) flash_view_Read(bmp_public_buf, 8000); //20k
|
||||
//memset(bmp_public_buf,0x1f,8000);
|
||||
default_view_Read(bmp_public_buf, 8000); //20k
|
||||
else
|
||||
//memset(bmp_public_buf,0x1f,8000);
|
||||
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); //20k
|
||||
#else
|
||||
default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); //20k
|
||||
#endif
|
||||
|
||||
i = 0;
|
||||
#if ENABLED(SPI_GRAPHICAL_TFT)
|
||||
@@ -534,6 +593,7 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
|
||||
else {
|
||||
p_index = (uint16_t *)(&bmp_public_buf[i]);
|
||||
}
|
||||
if (*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
|
||||
LCD_IO_WriteData(*p_index);
|
||||
i += 2;
|
||||
}
|
||||
@@ -547,15 +607,20 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
|
||||
|
||||
void disp_pre_gcode(int xpos_pixel, int ypos_pixel) {
|
||||
if (gcode_preview_over == 1) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel);
|
||||
if (flash_preview_begin == 1) {
|
||||
flash_preview_begin = 0;
|
||||
Draw_default_preview(xpos_pixel, ypos_pixel, 1);
|
||||
}
|
||||
if (default_preview_flg == 1) {
|
||||
Draw_default_preview(xpos_pixel, ypos_pixel, 0);
|
||||
default_preview_flg = 0;
|
||||
}
|
||||
#if HAS_BAK_VIEW_IN_FLASH
|
||||
if (flash_preview_begin == 1) {
|
||||
flash_preview_begin = 0;
|
||||
Draw_default_preview(xpos_pixel, ypos_pixel, 1);
|
||||
}
|
||||
#endif
|
||||
#if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
|
||||
if (default_preview_flg == 1) {
|
||||
Draw_default_preview(xpos_pixel, ypos_pixel, 0);
|
||||
default_preview_flg = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void print_time_run() {
|
||||
static uint8_t lastSec = 0;
|
||||
@@ -1175,9 +1240,11 @@ void LV_TASK_HANDLER() {
|
||||
//lv_tick_inc(1);
|
||||
lv_task_handler();
|
||||
TERN_(MKS_TEST, mks_test());
|
||||
disp_pre_gcode(2, 36);
|
||||
#if HAS_GCODE_PREVIEW
|
||||
disp_pre_gcode(2, 36);
|
||||
#endif
|
||||
GUI_RefreshPage();
|
||||
//sd_detection();
|
||||
}
|
||||
|
||||
#endif // TFT_LITTLE_VGL_UI
|
||||
#endif // TFT_LVGL_UI
|
||||
|
||||
Reference in New Issue
Block a user