🚸 MarlinUI Endstop Test Screen, and more (#25667)

This commit is contained in:
Scott Lahteine
2023-04-22 01:56:10 -05:00
committed by GitHub
parent 98277f2c1c
commit 4233e4864f
22 changed files with 952 additions and 791 deletions

View File

@@ -1137,17 +1137,38 @@ void MarlinUI::draw_status_screen() {
#endif // ADVANCED_PAUSE_FEATURE
// Draw a static item with no left-right margin required. Centered by default.
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) {
int8_t n = LCD_WIDTH;
void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char *vstr/*=nullptr*/) {
lcd_moveto(0, row);
int8_t n = LCD_WIDTH;
const bool center = bool(style & SS_CENTER), full = bool(style & SS_FULL);
const int8_t plen = fstr ? utf8_strlen(fstr) : 0,
vlen = vstr ? utf8_strlen(vstr) : 0;
if (style & SS_CENTER) {
int8_t pad = (LCD_WIDTH - plen - vlen) / 2;
while (--pad >= 0) { lcd_put_u8str(F(" ")); n--; }
int8_t pad = (center || full) ? n - plen - vlen : 0;
// SS_CENTER: Pad with half of the unused space first
if (center) for (int8_t lpad = pad / 2; lpad > 0; --lpad) { lcd_put_u8str(F(" ")); n--; }
// Draw as much of the label as fits
if (plen) {
const int8_t expl = n;
n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n);
pad -= (expl - n - plen); // Reduce the padding
}
if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n);
if (vlen) n -= lcd_put_u8str_max(vstr, n);
if (vlen && n > 0) {
// SS_FULL: Pad with enough space to justify the value
if (full && !center) {
// Move the leading colon from the value to the label
if (*vstr == ':') { n -= lcd_put_u8str(F(":")); vstr++; }
// Move spaces to the padding
while (*vstr == ' ') { vstr++; pad++; }
// Pad in-between
for (; pad > 0; --pad) { lcd_put_u8str(F(" ")); n--; }
}
n -= lcd_put_u8str_max(vstr, n);
}
for (; n > 0; --n) lcd_put_u8str(F(" "));
}