Skip to content

Commit

Permalink
colorui: fix output of level corners / probe
Browse files Browse the repository at this point in the history
MENU_ITEM_HEIGHT & adjust right column
  • Loading branch information
tpruvot committed Jan 25, 2021
1 parent 2f02baa commit aafa846
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Marlin/src/lcd/menu/menu_bed_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ static inline void _lcd_level_bed_corners_get_next_position() {
// Display # of good points found vs total needed
if (PAGE_CONTAINS(y - (MENU_FONT_HEIGHT), y)) {
SETCURSOR(0, cy);
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(2, 3));
lcd_put_u8str_P(GET_TEXT(MSG_LEVEL_CORNERS_GOOD_POINTS));
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, 3));
lcd_put_u8str(GOOD_POINTS_TO_STR(good_points));
lcd_put_wchar('/');
lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points));
Expand All @@ -191,7 +193,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);
IF_ENABLED(TFT_COLOR_UI, lcd_moveto(2, 2));
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
26 changes: 22 additions & 4 deletions Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

static bool draw_menu_navigation = false;

static xy_uint_t cursor;

void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
if (draw_menu_navigation) {
Expand Down Expand Up @@ -85,6 +87,7 @@ void MarlinUI::clear_lcd() {

tft.queue.reset();
tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_BACKGROUND);
cursor.x = cursor.y = 0;
}

#if ENABLED(SHOW_BOOTSCREEN)
Expand Down Expand Up @@ -641,7 +644,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#endif // TOUCH_SCREEN_CALIBRATION

void menu_line(const uint8_t row, uint16_t color) {
tft.canvas(0, 2 + 34 * row, TFT_WIDTH, 32);
cursor.x = 0;
cursor.y = row;
tft.canvas(cursor.x, 2 + (MENU_ITEM_HEIGHT * cursor.y), TFT_WIDTH, 32);
tft.set_background(color);
}

Expand All @@ -658,13 +663,23 @@ void menu_item(const uint8_t row, bool sel ) {
menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
#if ENABLED(TOUCH_SCREEN)
const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? MENU_CLICK : MENU_ITEM;
touch.add_control(tct, 0, 2 + 34 * row, TFT_WIDTH, 32, encoderTopLine + row);
touch.add_control(tct, 0, 2 + (MENU_ITEM_HEIGHT * row), TFT_WIDTH, 32, encoderTopLine + row);
#endif
}

void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) {
#define TFT_COL_WIDTH ((TFT_WIDTH) / (LCD_WIDTH))
tft.canvas(col * TFT_COL_WIDTH, 4 + 45 * row, TFT_WIDTH - (col * TFT_COL_WIDTH), 43);
cursor.x = col;
cursor.y = row;
tft.canvas(col * TFT_COL_WIDTH, 2 + (MENU_ITEM_HEIGHT * row), TFT_WIDTH - (col * TFT_COL_WIDTH), 32);
tft.set_background(COLOR_BACKGROUND);
}

void lcd_gotopixel(uint16_t x, const lcd_uint_t y) {
if (x > TFT_WIDTH) x = TFT_WIDTH;
cursor.x = (x / TFT_COL_WIDTH);
cursor.y = (y / MENU_ITEM_HEIGHT);
tft.canvas(x, 2 + y, TFT_WIDTH - x, 32);
tft.set_background(COLOR_BACKGROUND);
}

Expand All @@ -673,6 +688,7 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
tft_string.set();
tft_string.add(c);
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
lcd_gotopixel((cursor.x + 1) * TFT_COL_WIDTH + tft_string.width(), cursor.y * MENU_ITEM_HEIGHT);
return tft_string.width();
}

Expand All @@ -686,7 +702,9 @@ int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
}

int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return lcd_put_u8str_max_P(utf8_str, max_length);
int span = lcd_put_u8str_max_P(utf8_str, max_length);
lcd_gotopixel((cursor.x + 1) * TFT_COL_WIDTH + span, cursor.y * MENU_ITEM_HEIGHT);
return span;
}

void MarlinUI::move_axis_screen() {
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/tft/ui_320x240.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater);
void draw_fan_status(uint16_t x, uint16_t y, const bool blink);

#define MENU_ITEM_HEIGHT 34
#define MENU_TEXT_X_OFFSET 10
#define MENU_TEXT_Y_OFFSET 7
void menu_line(const uint8_t row, uint16_t color = COLOR_BACKGROUND);
Expand Down
24 changes: 21 additions & 3 deletions Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
static bool draw_menu_navigation = false;
#endif

static xy_uint_t cursor;

void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
if (draw_menu_navigation) {
Expand Down Expand Up @@ -87,6 +89,7 @@ void MarlinUI::clear_lcd() {

tft.queue.reset();
tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_BACKGROUND);
cursor.x = cursor.y = 0;
}

#if ENABLED(SHOW_BOOTSCREEN)
Expand Down Expand Up @@ -649,7 +652,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#endif // TOUCH_SCREEN_CALIBRATION

void menu_line(const uint8_t row, uint16_t color) {
tft.canvas(0, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH, MENU_ITEM_HEIGHT);
cursor.x = 0;
cursor.y = row;
tft.canvas(0, 4 + (MENU_ITEM_HEIGHT + 2) * cursor.y, TFT_WIDTH, MENU_ITEM_HEIGHT);
tft.set_background(color);
}

Expand All @@ -672,7 +677,17 @@ void menu_item(const uint8_t row, bool sel ) {

void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) {
#define TFT_COL_WIDTH ((TFT_WIDTH) / (LCD_WIDTH))
tft.canvas(col * TFT_COL_WIDTH, 4 + 45 * row, TFT_WIDTH - (col * TFT_COL_WIDTH), 43);
cursor.x = col;
cursor.y = row;
tft.canvas(col * TFT_COL_WIDTH, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH - (col * TFT_COL_WIDTH), MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
}

void lcd_gotopixel(uint16_t x, const uint16_t y) {
if (x > TFT_WIDTH) x = TFT_WIDTH;
cursor.x = (x / TFT_COL_WIDTH);
cursor.y = (y / (MENU_ITEM_HEIGHT + 2));
tft.canvas(x, 4 + y, TFT_WIDTH - x, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
}

Expand All @@ -681,6 +696,7 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
tft_string.set();
tft_string.add(c);
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
lcd_gotopixel((cursor.x + 1) * TFT_COL_WIDTH + tft_string.width(), cursor.y * (MENU_ITEM_HEIGHT + 2));
return tft_string.width();
}

Expand All @@ -694,7 +710,9 @@ int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
}

int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return lcd_put_u8str_max_P(utf8_str, max_length);
int span = lcd_put_u8str_max_P(utf8_str, max_length);
lcd_gotopixel((cursor.x + 1) * TFT_COL_WIDTH + span, cursor.y * (MENU_ITEM_HEIGHT + 2));
return span;
}

#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
Expand Down

0 comments on commit aafa846

Please sign in to comment.