Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFT_LITTLE_VGL_UI for everyone #18438

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d1ad4fe
Fixes PR #18071 TFT_LITTLE_VGL_UI broken compilation
rhapsodyv Jun 24, 2020
50f7943
Update draw_error_message.h
thinkyhead Jun 24, 2020
4f1edb3
fix a lot of issues with TFT_LITTLE_VGL_UI. Now its fully working in …
rhapsodyv Jun 27, 2020
17f658e
chitu boards with TFT Little VGL UI
rhapsodyv Jun 27, 2020
f574195
keep defaults as it was in the mks code
rhapsodyv Jun 27, 2020
26ea9ae
correct name
rhapsodyv Jun 27, 2020
d7fc9e2
correct platform
rhapsodyv Jun 27, 2020
beb3873
now compliling fine
rhapsodyv Jun 27, 2020
c19205a
Update MarlinCore.cpp
thinkyhead Jun 27, 2020
bd211bf
Fix setting of board name
thinkyhead Jun 27, 2020
827c9a9
Update draw_ui.h
thinkyhead Jun 27, 2020
53d9cf1
Update draw_ui.h
thinkyhead Jun 27, 2020
42eb75b
Update draw_ui.cpp
thinkyhead Jun 27, 2020
5f19675
Update draw_ui.cpp
thinkyhead Jun 27, 2020
151d34d
General cleanup
thinkyhead Jun 27, 2020
09973af
Strip pic_manager dead code
thinkyhead Jun 27, 2020
249c73d
FSMC define
thinkyhead Jun 27, 2020
e339ca1
Strip tft_lvgl_configuration
thinkyhead Jun 27, 2020
24a6a42
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/18438
thinkyhead Jun 27, 2020
fcdf092
NO_LCD_REINIT not needed
thinkyhead Jun 27, 2020
4d110c2
Apply pins formatting js
thinkyhead Jun 27, 2020
d73290e
tweaks
thinkyhead Jun 27, 2020
506b177
Update env and SoftwareSerialM
thinkyhead Jun 27, 2020
269726b
need to remove two extra pixel that dont exists
rhapsodyv Jun 27, 2020
c761f3f
just call init if enabled
rhapsodyv Jun 27, 2020
a9e9df3
reverting touch calibration to original values, and configuring it in…
rhapsodyv Jun 27, 2020
d83e247
changed include order to fix redefinition warning
rhapsodyv Jun 27, 2020
99d419f
the selected lang now is the same the user selected in the configurat…
rhapsodyv Jun 27, 2020
e75b98a
using a icon that I could find
rhapsodyv Jun 27, 2020
d2b11a8
Optimized asset load. Now the code just load the necessary assets acc…
rhapsodyv Jun 27, 2020
1caae1d
index issue
rhapsodyv Jun 27, 2020
a5aa649
align
rhapsodyv Jun 27, 2020
8d81e70
icons for screen that only shows while printing
rhapsodyv Jun 27, 2020
3a60ab4
fixes file image preview in the file selection screen
rhapsodyv Jun 28, 2020
224d307
now it works with the 50x50 and 100x100 icons!
rhapsodyv Jun 28, 2020
c0da960
gcode preview fully working
rhapsodyv Jun 28, 2020
f95c35a
some files dont have the LONG_FILE_NAME flag, but are valid and needs…
rhapsodyv Jun 29, 2020
b3111e2
fixed icon namming to match with MKS icons release
rhapsodyv Jun 29, 2020
309a915
fixes sizes and options for chitu board, to fit the current assets
rhapsodyv Jun 29, 2020
08581ac
missing include to HAS_LANG_SELECT_SCREEN work
rhapsodyv Jun 29, 2020
99ea2ba
disable lang selection screen, because the lvgl current default font …
rhapsodyv Jun 29, 2020
1ac925d
keep only english, until we have a font that support more characters
rhapsodyv Jun 29, 2020
de11ca4
Update name to LVGL
thinkyhead Jul 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2131,9 +2131,12 @@
//#define FSMC_GRAPHICAL_TFT

//
// TFT Little VGL UI
// TFT LVGL UI
//
//#define TFT_LITTLE_VGL_UI
// Default MKS icons and fonts: https://git.io/JJvzK
// Copy mks_pic and mks_font folders to the root of your SD
//
//#define TFT_LVGL_UI

//=============================================================================
//============================ Other Controllers ============================
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
return uint32_t(data);
}

#if ENABLED(LCD_USE_DMA_FSMC)
#ifdef LCD_USE_DMA_FSMC

void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
while (count > 0) {
Expand Down
9 changes: 5 additions & 4 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "gcode/parser.h"
#include "gcode/queue.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)
#include "lvgl.h"
#include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
#include "lcd/extui/lib/mks_ui/draw_ui.h"
Expand Down Expand Up @@ -743,7 +743,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
// Direct Stepping
TERN_(DIRECT_STEPPING, page_manager.write_responses());

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)
LV_TASK_HANDLER();
#endif
}
Expand Down Expand Up @@ -1180,7 +1180,8 @@ void setup() {
SETUP_RUN(page_manager.init());
#endif

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
SETUP_RUN(tft_lvgl_init());
#endif

Expand Down Expand Up @@ -1216,7 +1217,7 @@ void loop() {

endstops.event_handler();

TERN_(TFT_LITTLE_VGL_UI, printer_state_polling());
TERN_(TFT_LVGL_UI, printer_state_polling());

} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
}
56 changes: 29 additions & 27 deletions Marlin/src/feature/touch/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,41 @@ void XPT2046::init() {
#include "../../lcd/ultralcd.h" // For EN_C bit mask

uint8_t XPT2046::read_buttons() {
int16_t tsoffsets[4] = { 0 };

if (tsoffsets[0] + tsoffsets[1] == 0) {
// Not yet set, so use defines as fallback...
tsoffsets[0] = XPT2046_X_CALIBRATION;
tsoffsets[1] = XPT2046_X_OFFSET;
tsoffsets[2] = XPT2046_Y_CALIBRATION;
tsoffsets[3] = XPT2046_Y_OFFSET;
}
#ifdef HAS_SPI_LCD
int16_t tsoffsets[4] = { 0 };

if (tsoffsets[0] + tsoffsets[1] == 0) {
// Not yet set, so use defines as fallback...
tsoffsets[0] = XPT2046_X_CALIBRATION;
tsoffsets[1] = XPT2046_X_OFFSET;
tsoffsets[2] = XPT2046_Y_CALIBRATION;
tsoffsets[3] = XPT2046_Y_OFFSET;
}

// We rely on XPT2046 compatible mode to ADS7843, hence no Z1 and Z2 measurements possible.
// We rely on XPT2046 compatible mode to ADS7843, hence no Z1 and Z2 measurements possible.

if (!isTouched()) return 0;
const uint16_t x = uint16_t(((uint32_t(getInTouch(XPT2046_X))) * tsoffsets[0]) >> 16) + tsoffsets[1],
y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
if (!isTouched()) return 0;
const uint16_t x = uint16_t(((uint32_t(getInTouch(XPT2046_X))) * tsoffsets[0]) >> 16) + tsoffsets[1],
y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.

// Touch within the button area simulates an encoder button
if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
return WITHIN(x, 14, 77) ? EN_D
: WITHIN(x, 90, 153) ? EN_A
: WITHIN(x, 166, 229) ? EN_B
: WITHIN(x, 242, 305) ? EN_C
: 0;
// Touch within the button area simulates an encoder button
if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
return WITHIN(x, 14, 77) ? EN_D
: WITHIN(x, 90, 153) ? EN_A
: WITHIN(x, 166, 229) ? EN_B
: WITHIN(x, 242, 305) ? EN_C
: 0;

if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;

// Column and row above BUTTON_AREA_TOP
int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
// Column and row above BUTTON_AREA_TOP
int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);

// Send the touch to the UI (which will simulate the encoder wheel)
MarlinUI::screen_click(row, col, x, y);
// Send the touch to the UI (which will simulate the encoder wheel)
MarlinUI::screen_click(row, col, x, y);
#endif
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

#include <string.h>

#if ENABLED(LCD_USE_DMA_FSMC)
#ifdef LCD_USE_DMA_FSMC
extern void LCD_IO_WriteReg(uint16_t Reg);
extern void LCD_IO_WriteData(uint16_t RegValue);
extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "../../../../inc/MarlinConfigPre.h"

#if 1 // ENABLED(SPI_FLASH)
#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include <SPI.h>
#include "../../../../inc/MarlinConfig.h"
Expand Down Expand Up @@ -391,5 +391,5 @@ void ext_FLASH::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16

void ext_FLASH::lv_pic_read(uint8_t *P_Rbuff, uint32_t addr, uint32_t size) {SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, addr, size);}

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
#endif // 1 ... SPI_FLASH
27 changes: 13 additions & 14 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "lv_conf.h"
#include "draw_ui.h"
Expand Down Expand Up @@ -99,29 +99,28 @@ void lv_draw_about(void) {

fw_version = lv_label_create(scr, NULL);
lv_obj_set_style(fw_version, &tft_style_lable_rel);
lv_label_set_text(fw_version, "Version: V_2.0.5.3");
lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);

fw_type = lv_label_create(scr, NULL);
lv_obj_set_style(fw_type, &tft_style_lable_rel);
#if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO)
lv_label_set_text(fw_type, "Firmware: Robin_Pro35");
#elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO)
lv_label_set_text(fw_type, "Firmware: Robin_Nano35");
#endif
lv_label_set_text(fw_type,
#if MB(MKS_ROBIN_PRO)
"Firmware: Robin_Pro35"
#elif MB(MKS_ROBIN_NANO)
"Firmware: Robin_Nano35"
#else
CUSTOM_MACHINE_NAME
#endif
);
lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20);

board = lv_label_create(scr, NULL);
lv_obj_set_style(board, &tft_style_lable_rel);
#if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO)
lv_label_set_text(board, "Board: MKS Robin pro");
#elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO)
lv_label_set_text(board, "Board: MKS Robin nano");
#endif

lv_label_set_text(board, "Board: " BOARD_INFO_NAME);
lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20);
}

void lv_clear_about() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
12 changes: 6 additions & 6 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "lv_conf.h"
#include "draw_ui.h"
Expand Down Expand Up @@ -310,13 +310,13 @@ void disp_print_speed() {
void disp_speed_type() {
switch (speedType) {
case 1:
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed_sel.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed.bin", 0);
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_extruct_sel.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_changespeed.bin", 0);
break;

default:
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed_sel.bin", 0);
lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct.bin", 0);
lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_sel.bin", 0);
break;
}
lv_obj_refresh_ext_draw_pad(buttonExt);
Expand All @@ -333,4 +333,4 @@ void disp_speed_type() {

void lv_clear_change_speed() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
12 changes: 7 additions & 5 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "lv_conf.h"
#include "draw_ui.h"
Expand Down Expand Up @@ -61,7 +61,9 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
}
else if (event == LV_EVENT_RELEASED) {
if (DialogType == DIALOG_TYPE_PRINT_FILE) {
preview_gcode_prehandle(list_file.file_name[sel_id]);
#if HAS_GCODE_PREVIEW
preview_gcode_prehandle(list_file.file_name[sel_id]);
#endif
reset_print_time();
start_print_time();

Expand Down Expand Up @@ -202,7 +204,7 @@ void lv_draw_dialog(uint8_t type) {
style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
style_btn_rel.text.color = lv_color_hex3(0xDEF);
style_btn_rel.text.font = &gb2312_puhui32;
style_btn_rel.text.font = &lv_font_roboto_22;

static lv_style_t style_btn_pr; // A variable to store the pressed style
lv_style_copy(&style_btn_pr, &style_btn_rel); // Initialize from the released style
Expand All @@ -211,7 +213,7 @@ void lv_draw_dialog(uint8_t type) {
style_btn_pr.body.grad_color = lv_color_hex3(0x24A);
style_btn_pr.body.shadow.width = 2;
style_btn_pr.text.color = lv_color_hex3(0xBCD);
style_btn_pr.text.font = &gb2312_puhui32;
style_btn_pr.text.font = &lv_font_roboto_22;

lv_obj_t * labelDialog = lv_label_create(scr, NULL);
lv_obj_set_style(labelDialog, &tft_style_lable_rel);
Expand Down Expand Up @@ -340,4 +342,4 @@ void lv_draw_dialog(uint8_t type) {

void lv_clear_dialog() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "lv_conf.h"
#include "draw_ui.h"
Expand Down Expand Up @@ -81,4 +81,4 @@ void lv_draw_error_message(PGM_P const msg) {

void lv_clear_error_message() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "lv_conf.h"
#include "draw_ui.h"
Expand Down Expand Up @@ -375,4 +375,4 @@ void disp_ext_step() {

void lv_clear_extrusion() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "../../../../MarlinCore.h"
#include "lv_conf.h"
Expand Down Expand Up @@ -244,4 +244,4 @@ void disp_fan_value() {

void lv_clear_fan() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
8 changes: 4 additions & 4 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
#include "../../../../inc/MarlinConfigPre.h"

#if ENABLED(TFT_LITTLE_VGL_UI)
#if ENABLED(TFT_LVGL_UI)

#include "../../../../MarlinCore.h"
#include "draw_ready_print.h"
Expand Down Expand Up @@ -190,13 +190,13 @@ void lv_draw_home(void) {
lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_lable_rel);

lv_obj_set_event_cb_mks(buttonOffAll, event_handler, ID_H_OFF_ALL, "bmp_Motor_off.bin", 0);
lv_obj_set_event_cb_mks(buttonOffAll, event_handler, ID_H_OFF_ALL, "bmp_manual_off.bin", 0);
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_lable_pre);
lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_lable_rel);

lv_obj_set_event_cb_mks(buttonOffXY, event_handler, ID_H_OFF_XY, "bmp_Motor_off.bin", 0);
lv_obj_set_event_cb_mks(buttonOffXY, event_handler, ID_H_OFF_XY, "bmp_manual_off.bin", 0);
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic);
lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic);
lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_lable_pre);
Expand Down Expand Up @@ -280,4 +280,4 @@ void lv_draw_home(void) {

void lv_clear_home() { lv_obj_del(scr); }

#endif // TFT_LITTLE_VGL_UI
#endif // TFT_LVGL_UI
Loading