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

Graphical TFT fixes, cleanup #20861

Merged
merged 32 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2f02baa
color_ui: do not ignore maxlen params
tpruvot Jan 23, 2021
aafa846
colorui: fix output of level corners / probe
tpruvot Jan 23, 2021
a57664b
colorui: implement missing lcd_put_int
tpruvot Jan 25, 2021
d61ea12
Update tft_string.h
thinkyhead Jan 25, 2021
9e745bf
cursor tweaks
thinkyhead Jan 25, 2021
751aec9
ibid.
thinkyhead Jan 25, 2021
6d7d006
simplify
thinkyhead Jan 25, 2021
d06f421
avoid possible out of range crash
tpruvot Jan 25, 2021
3cd10e4
typo
tpruvot Jan 25, 2021
28e2724
Update tft_string.h
thinkyhead Jan 25, 2021
e2dc1d6
short strings
thinkyhead Jan 25, 2021
a8f45ca
ibid.
thinkyhead Jan 25, 2021
8c5d92d
Simplify lcd_moveto
thinkyhead Jan 25, 2021
59badf3
Add ui_common.h
thinkyhead Jan 25, 2021
e3fd8cd
ensure enough bits for integer multiply
thinkyhead Jan 25, 2021
66b08df
BABYSTEP_DISPLAY_TOTAL is okay
thinkyhead Jan 25, 2021
0b6e131
restore right 320x240 line height
tpruvot Jan 25, 2021
b1fb45f
update x cursor for _P variant
tpruvot Jan 25, 2021
76c1621
Tweak conditionals
thinkyhead Jan 25, 2021
1fce35c
Add ui_common.cpp
thinkyhead Jan 25, 2021
98d4198
Merge branch 'color_ui_maxlen' of https://github.com/tpruvot/Marlin i…
thinkyhead Jan 25, 2021
cc84dc0
merge followup patch
thinkyhead Jan 25, 2021
791d689
More common methods
thinkyhead Jan 25, 2021
4dacbe1
Try HAS_GRAPHICAL_TFT
thinkyhead Jan 25, 2021
78b2a14
move 'cursor'
thinkyhead Jan 25, 2021
c9fb1d4
conditional compatibility
thinkyhead Jan 25, 2021
7b1f5f5
Custom babystep total drawing
thinkyhead Jan 25, 2021
a2b864c
use common.h
thinkyhead Jan 25, 2021
0b4711d
Move draw_menu_navigation
thinkyhead Jan 25, 2021
b56514e
fix up dependencies
thinkyhead Jan 25, 2021
83efe8f
menu_pause_option
tpruvot Jan 25, 2021
824549e
lcd_put_u8str_P
tpruvot Jan 25, 2021
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
43 changes: 22 additions & 21 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,36 +1155,37 @@
#endif
#endif

#if ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 240
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_320x240_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_320x240
#endif
#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 320
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_480x320_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x320
#endif
#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 272
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_480x272_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x272
#if ENABLED(TFT_COLOR_UI)
#if TFT_HEIGHT == 240
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_320x240_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_320x240
#endif
#elif TFT_HEIGHT == 320
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_480x320_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x320
#endif
#elif TFT_HEIGHT == 272
#if ENABLED(TFT_INTERFACE_SPI)
#define TFT_480x272_SPI
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x272
#endif
#endif
#endif

// Fewer lines with touch buttons on-screen
#if EITHER(TFT_320x240, TFT_320x240_SPI)
#define HAS_UI_320x240 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#elif EITHER(TFT_480x320, TFT_480x320_SPI)
#define HAS_UI_480x320 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#elif EITHER(TFT_480x272, TFT_480x272_SPI)
#define HAS_UI_480x272 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#endif
#if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272)
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen
#endif

// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if ENABLED(BABYSTEP_XY)
static_assert(BABYSTEP_MULTIPLICATOR_XY <= 0.25f, "BABYSTEP_MULTIPLICATOR_XY must be less than or equal to 0.25mm.");
#endif
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL) && ANY(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)
#error "New Color UI (TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI) does not support BABYSTEP_DISPLAY_TOTAL yet."
#endif
#endif

Expand Down
8 changes: 5 additions & 3 deletions Marlin/src/lcd/menu/menu_bed_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,13 @@ static inline void _lcd_level_bed_corners_get_next_position() {

MenuItem_static::draw(0, GET_TEXT(MSG_PROBING_MESH), SS_INVERT); // "Probing Mesh" heading

uint8_t cy = LCD_HEIGHT - 1, y = LCD_ROW_Y(cy);
uint8_t cy = TERN(TFT_COLOR_UI, 3, LCD_HEIGHT - 1), y = LCD_ROW_Y(cy);

// Display # of good points found vs total needed
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(0, cy);
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy);
lcd_put_u8str_P(GET_TEXT(MSG_LEVEL_CORNERS_GOOD_POINTS));
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy));
lcd_put_u8str(GOOD_POINTS_TO_STR(good_points));
lcd_put_wchar('/');
lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points));
Expand All @@ -190,8 +191,9 @@ static inline void _lcd_level_bed_corners_get_next_position() {

// Display the Last Z value
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(0, cy);
SETCURSOR(TERN(TFT_COLOR_UI, 2, 0), cy);
lcd_put_u8str_P(GET_TEXT(MSG_LEVEL_CORNERS_LAST_Z));
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 2));
lcd_put_u8str(LAST_Z_TO_STR(last_z));
}
}
Expand Down
13 changes: 10 additions & 3 deletions Marlin/src/lcd/menu/menu_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@
const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
if (in_view) {
TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU));
lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1));
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
#if ENABLED(TFT_COLOR_UI)
lcd_moveto(4, 3);
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
lcd_moveto(10, 3);
#else
lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1));
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':');
#endif
lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
}
#endif
Expand Down
41 changes: 39 additions & 2 deletions Marlin/src/lcd/tft/tft_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
*
*/

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

#if HAS_GRAPHICAL_TFT

#include "tft_image.h"
#include <stddef.h>

const tImage NoLogo = { nullptr, 0, 0, NOCOLORS };

Expand Down Expand Up @@ -70,4 +73,38 @@ const tImage Leveling_32x32x4 = { (void *)leveling_32x32x4, 32, 32, GREYSC

const tImage Slider8x16x4 = { (void *)slider_8x16x4, 8, 16, GREYSCALE4 };

extern const tImage Images[imgCount];
const tImage Images[imgCount] = {
TERN(SHOW_BOOTSCREEN, TERN(BOOT_MARLIN_LOGO_SMALL, MarlinLogo195x59x16, MARLIN_LOGO_FULL_SIZE), NoLogo),
HotEnd_64x64x4,
Bed_64x64x4,
Bed_Heated_64x64x4,
Chamber_64x64x4,
Chamber_Heated_64x64x4,
Fan0_64x64x4,
Fan_Slow0_64x64x4,
Fan_Slow1_64x64x4,
Fan_Fast0_64x64x4,
Fan_Fast1_64x64x4,
Feedrate_32x32x4,
Flowrate_32x32x4,
SD_64x64x4,
Menu_64x64x4,
Settings_64x64x4,
Directory_32x32x4,
Confirm_64x64x4,
Cancel_64x64x4,
Increase_64x64x4,
Decrease_64x64x4,
Back_32x32x4,
Up_32x32x4,
Down_32x32x4,
Left_32x32x4,
Right_32x32x4,
Refresh_32x32x4,
Leveling_32x32x4,
Slider8x16x4,
Home_64x64x4,
BtnRounded_64x52x4,
};

#endif // HAS_GRAPHICAL_TFT
3 changes: 2 additions & 1 deletion Marlin/src/lcd/tft/tft_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
*/
#pragma once

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

#include <stdint.h>

extern const uint8_t marlin_logo_112x38x1[];
extern const uint8_t marlin_logo_228x255x2[];
extern const uint8_t marlin_logo_228x255x4[];
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/lcd/tft/tft_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ font_t *TFT_String::font_header;

uint8_t TFT_String::data[];
uint16_t TFT_String::span;
uint16_t TFT_String::length;
uint8_t TFT_String::length;

void TFT_String::set_font(const uint8_t *font) {
font_header = (font_t *)font;
Expand Down Expand Up @@ -122,13 +122,14 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) {
eol();
}

void TFT_String::add(uint8_t *string) {
void TFT_String::add(uint8_t *string, uint8_t max_len) {
wchar_t wchar;
while (*string) {
while (*string && max_len) {
string = get_utf8_value_cb(string, read_byte, &wchar);
if (wchar > 255) wchar |= 0x0080;
uint8_t ch = uint8_t(wchar & 0x00FF);
add_character(ch);
max_len--;
}
eol();
}
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/lcd/tft/tft_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TFT_String {

static uint8_t data[MAX_STRING_LENGTH + 1];
static uint16_t span; // in pixels
static uint16_t length; // in characters
static uint8_t length; // in characters

static void add_character(uint8_t character);
static void eol() { data[length] = 0x00; }
Expand All @@ -85,7 +85,7 @@ class TFT_String {

static void set();
static void add(uint8_t character) { add_character(character); eol(); }
static void add(uint8_t *string);
static void add(uint8_t *string, uint8_t max_len=MAX_STRING_LENGTH);
static void add(uint8_t *string, int8_t index, uint8_t *itemString=nullptr);
static void set(uint8_t *string) { set(); add(string); };
static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); };
Expand All @@ -96,6 +96,9 @@ class TFT_String {
static void trim(uint8_t character=0x20);
static void rtrim(uint8_t character=0x20);
static void ltrim(uint8_t character=0x20);

static void truncate(uint8_t maxlen) { if (length > maxlen) { length = maxlen; eol(); } }

static uint16_t width() { return span; }
static uint8_t *string() { return data; }
static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; }
Expand Down
Loading