|
|
@ -108,7 +108,7 @@ void MarlinUI::set_font(const MarlinFont font_nr) { |
|
|
|
// Draws a slice of a particular frame of the custom bootscreen, without the u8g loop
|
|
|
|
void MarlinUI::draw_custom_bootscreen(const uint8_t frame/*=0*/) { |
|
|
|
constexpr u8g_uint_t left = u8g_uint_t((LCD_PIXEL_WIDTH - (CUSTOM_BOOTSCREEN_BMPWIDTH)) / 2), |
|
|
|
top = u8g_uint_t((LCD_PIXEL_HEIGHT - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) / 2); |
|
|
|
top = u8g_uint_t((LCD_PIXEL_HEIGHT - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) / 2); |
|
|
|
#if ENABLED(CUSTOM_BOOTSCREEN_INVERTED) |
|
|
|
constexpr u8g_uint_t right = left + CUSTOM_BOOTSCREEN_BMPWIDTH, |
|
|
|
bottom = top + CUSTOM_BOOTSCREEN_BMPHEIGHT; |
|
|
@ -160,23 +160,23 @@ void MarlinUI::set_font(const MarlinFont font_nr) { |
|
|
|
// Draws a slice of the Marlin bootscreen, without the u8g loop
|
|
|
|
void MarlinUI::draw_marlin_bootscreen() { |
|
|
|
// Screen dimensions.
|
|
|
|
//const uint8_t width = u8g.getWidth(), height = u8g.getHeight();
|
|
|
|
constexpr uint8_t width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT; |
|
|
|
//const u8g_uint_t width = u8g.getWidth(), height = u8g.getHeight();
|
|
|
|
constexpr u8g_uint_t width = LCD_PIXEL_WIDTH, height = LCD_PIXEL_HEIGHT; |
|
|
|
|
|
|
|
// Determine text space needed
|
|
|
|
#ifndef STRING_SPLASH_LINE2 |
|
|
|
constexpr uint8_t text_total_height = MENU_FONT_HEIGHT, |
|
|
|
text_width_1 = uint8_t(sizeof(STRING_SPLASH_LINE1) - 1) * uint8_t(MENU_FONT_WIDTH), |
|
|
|
text_width_2 = 0; |
|
|
|
constexpr u8g_uint_t text_total_height = MENU_FONT_HEIGHT, |
|
|
|
text_width_1 = u8g_uint_t(sizeof(STRING_SPLASH_LINE1) - 1) * u8g_uint_t(MENU_FONT_WIDTH), |
|
|
|
text_width_2 = 0; |
|
|
|
#else |
|
|
|
constexpr uint8_t text_total_height = uint8_t(MENU_FONT_HEIGHT) * 2, |
|
|
|
text_width_1 = uint8_t(sizeof(STRING_SPLASH_LINE1) - 1) * uint8_t(MENU_FONT_WIDTH), |
|
|
|
text_width_2 = uint8_t(sizeof(STRING_SPLASH_LINE2) - 1) * uint8_t(MENU_FONT_WIDTH); |
|
|
|
constexpr u8g_uint_t text_total_height = u8g_uint_t(MENU_FONT_HEIGHT) * 2, |
|
|
|
text_width_1 = u8g_uint_t(sizeof(STRING_SPLASH_LINE1) - 1) * u8g_uint_t(MENU_FONT_WIDTH), |
|
|
|
text_width_2 = u8g_uint_t(sizeof(STRING_SPLASH_LINE2) - 1) * u8g_uint_t(MENU_FONT_WIDTH); |
|
|
|
#endif |
|
|
|
constexpr uint8_t text_max_width = _MAX(text_width_1, text_width_2), |
|
|
|
rspace = width - (START_BMPWIDTH); |
|
|
|
constexpr u8g_uint_t text_max_width = _MAX(text_width_1, text_width_2), |
|
|
|
rspace = width - (START_BMPWIDTH); |
|
|
|
|
|
|
|
int8_t offx, offy, txt_base, txt_offx_1, txt_offx_2; |
|
|
|
u8g_int_t offx, offy, txt_base, txt_offx_1, txt_offx_2; |
|
|
|
|
|
|
|
// Can the text fit to the right of the bitmap?
|
|
|
|
if (text_max_width < rspace) { |
|
|
@ -299,7 +299,7 @@ void MarlinUI::draw_kill_screen() { |
|
|
|
#if ENABLED(LIGHTWEIGHT_UI) |
|
|
|
ST7920_Lite_Status_Screen::clear_text_buffer(); |
|
|
|
#endif |
|
|
|
const uint8_t h4 = u8g.getHeight() / 4; |
|
|
|
const u8g_uint_t h4 = u8g.getHeight() / 4; |
|
|
|
u8g.firstPage(); |
|
|
|
do { |
|
|
|
set_font(FONT_MENU); |
|
|
@ -316,7 +316,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
|
|
|
|
#if HAS_LCD_MENU |
|
|
|
|
|
|
|
uint8_t row_y1, row_y2; |
|
|
|
u8g_uint_t row_y1, row_y2; |
|
|
|
|
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE) |
|
|
|
|
|
|
@ -373,7 +373,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
|
|
|
|
if (mark_as_selected(row, invert)) { |
|
|
|
|
|
|
|
uint8_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
|
|
|
|
u8g_uint_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed
|
|
|
|
|
|
|
|
if (center && !valstr) { |
|
|
|
int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; |
|
|
@ -390,7 +390,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
UNUSED(pre_char); |
|
|
|
|
|
|
|
if (mark_as_selected(row, sel)) { |
|
|
|
uint8_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH); |
|
|
|
u8g_uint_t n = (LCD_WIDTH - 2) * (MENU_FONT_WIDTH); |
|
|
|
n -= lcd_put_u8str_max_P(pstr, n); |
|
|
|
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); |
|
|
|
lcd_moveto(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2); |
|
|
@ -403,7 +403,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { |
|
|
|
if (mark_as_selected(row, sel)) { |
|
|
|
const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)); |
|
|
|
uint8_t n = (LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH); |
|
|
|
u8g_uint_t n = (LCD_WIDTH - 2 - vallen) * (MENU_FONT_WIDTH); |
|
|
|
n -= lcd_put_u8str_max_P(pstr, n); |
|
|
|
lcd_put_wchar(':'); |
|
|
|
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); |
|
|
@ -415,13 +415,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
void draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { |
|
|
|
ui.encoder_direction_normal(); |
|
|
|
|
|
|
|
const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); |
|
|
|
const u8g_uint_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); |
|
|
|
bool extra_row = labellen > LCD_WIDTH - 2 - vallen; |
|
|
|
|
|
|
|
#if ENABLED(USE_BIG_EDIT_FONT) |
|
|
|
// Use the menu font if the label won't fit on a single line
|
|
|
|
constexpr uint8_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH); |
|
|
|
uint8_t lcd_chr_fit, one_chr_width; |
|
|
|
constexpr u8g_uint_t lcd_edit_width = (LCD_PIXEL_WIDTH) / (EDIT_FONT_WIDTH); |
|
|
|
u8g_uint_t lcd_chr_fit, one_chr_width; |
|
|
|
if (labellen <= lcd_edit_width - 1) { |
|
|
|
if (labellen + vallen + 1 > lcd_edit_width) extra_row = true; |
|
|
|
lcd_chr_fit = lcd_edit_width + 1; |
|
|
@ -434,13 +434,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
ui.set_font(FONT_MENU); |
|
|
|
} |
|
|
|
#else |
|
|
|
constexpr uint8_t lcd_chr_fit = LCD_WIDTH, |
|
|
|
one_chr_width = MENU_FONT_WIDTH; |
|
|
|
constexpr u8g_uint_t lcd_chr_fit = LCD_WIDTH, |
|
|
|
one_chr_width = MENU_FONT_WIDTH; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Center the label and value lines on the middle line
|
|
|
|
uint8_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2 - 1 |
|
|
|
: (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2; |
|
|
|
u8g_uint_t baseline = extra_row ? (LCD_PIXEL_HEIGHT) / 2 - 1 |
|
|
|
: (LCD_PIXEL_HEIGHT + EDIT_FONT_ASCENT) / 2; |
|
|
|
|
|
|
|
// Assume the label is alpha-numeric (with a descender)
|
|
|
|
bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT); |
|
|
@ -465,9 +465,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
inline void draw_boxed_string(const uint8_t x, const uint8_t y, PGM_P const pstr, const bool inv) { |
|
|
|
const uint8_t len = utf8_strlen_P(pstr), bw = len * (MENU_FONT_WIDTH), |
|
|
|
bx = x * (MENU_FONT_WIDTH), by = (y + 1) * (MENU_FONT_HEIGHT); |
|
|
|
inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) { |
|
|
|
const u8g_uint_t len = utf8_strlen_P(pstr), bw = len * (MENU_FONT_WIDTH), |
|
|
|
bx = x * (MENU_FONT_WIDTH), by = (y + 1) * (MENU_FONT_HEIGHT); |
|
|
|
if (inv) { |
|
|
|
u8g.setColorIndex(1); |
|
|
|
u8g.drawBox(bx - 1, by - (MENU_FONT_ASCENT) + 1, bw + 2, MENU_FONT_HEIGHT - 1); |
|
|
@ -492,8 +492,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
if (mark_as_selected(row, sel)) { |
|
|
|
if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]); |
|
|
|
constexpr uint8_t maxlen = LCD_WIDTH - 1; |
|
|
|
const uint8_t pixw = maxlen * (MENU_FONT_WIDTH); |
|
|
|
uint8_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); |
|
|
|
const u8g_uint_t pixw = maxlen * (MENU_FONT_WIDTH); |
|
|
|
u8g_uint_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); |
|
|
|
while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); |
|
|
|
} |
|
|
|
} |
|
|
@ -512,8 +512,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
|
|
|
|
void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { |
|
|
|
// Scale the box pixels appropriately
|
|
|
|
uint8_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X), |
|
|
|
y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y), |
|
|
|
u8g_uint_t x_map_pixels = ((MAP_MAX_PIXELS_X - 4) / (GRID_MAX_POINTS_X)) * (GRID_MAX_POINTS_X), |
|
|
|
y_map_pixels = ((MAP_MAX_PIXELS_Y - 4) / (GRID_MAX_POINTS_Y)) * (GRID_MAX_POINTS_Y), |
|
|
|
|
|
|
|
pixels_per_x_mesh_pnt = x_map_pixels / (GRID_MAX_POINTS_X), |
|
|
|
pixels_per_y_mesh_pnt = y_map_pixels / (GRID_MAX_POINTS_Y), |
|
|
@ -535,8 +535,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
// Display Mesh Point Locations
|
|
|
|
|
|
|
|
u8g.setColorIndex(1); |
|
|
|
const uint8_t sx = x_offset + pixels_per_x_mesh_pnt / 2; |
|
|
|
uint8_t y = y_offset + pixels_per_y_mesh_pnt / 2; |
|
|
|
const u8g_uint_t sx = x_offset + pixels_per_x_mesh_pnt / 2; |
|
|
|
u8g_uint_t y = y_offset + pixels_per_y_mesh_pnt / 2; |
|
|
|
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt) |
|
|
|
if (PAGE_CONTAINS(y, y)) |
|
|
|
for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt) |
|
|
@ -544,10 +544,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop |
|
|
|
|
|
|
|
// Fill in the Specified Mesh Point
|
|
|
|
|
|
|
|
uint8_t inverted_y = GRID_MAX_POINTS_Y - y_plot - 1; // The origin is typically in the lower right corner. We need to
|
|
|
|
// invert the Y to get it to plot in the right location.
|
|
|
|
const uint8_t y_plot_inv = (GRID_MAX_POINTS_Y - 1) - y_plot; // The origin is typically in the lower right corner. We need to
|
|
|
|
// invert the Y to get it to plot in the right location.
|
|
|
|
|
|
|
|
const uint8_t by = y_offset + inverted_y * pixels_per_y_mesh_pnt; |
|
|
|
const u8g_uint_t by = y_offset + y_plot_inv * pixels_per_y_mesh_pnt; |
|
|
|
if (PAGE_CONTAINS(by, by + pixels_per_y_mesh_pnt)) |
|
|
|
u8g.drawBox( |
|
|
|
x_offset + x_plot * pixels_per_x_mesh_pnt, by, |
|
|
|