🎨 Axis name string interpolation, with examples (#22879)
This commit is contained in:
@ -89,11 +89,13 @@ uint8_t read_byte(uint8_t *byte) { return *byte; }
|
||||
/**
|
||||
* Add a string, applying substitutions for the following characters:
|
||||
*
|
||||
* $ displays an inserted C-string given by the itemString parameter
|
||||
* = displays '0'....'10' for indexes 0 - 10
|
||||
* ~ displays '1'....'11' for indexes 0 - 10
|
||||
* * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL)
|
||||
* @ displays an axis name such as XYZUVW, or E for an extruder
|
||||
*/
|
||||
void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) {
|
||||
void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString/*=nullptr*/) {
|
||||
wchar_t wchar;
|
||||
|
||||
while (*string) {
|
||||
@ -108,17 +110,15 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString) {
|
||||
if (inum >= 10) { add_character('0' + (inum / 10)); inum %= 10; }
|
||||
add_character('0' + inum);
|
||||
}
|
||||
else {
|
||||
else
|
||||
add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (ch == '$' && itemString) {
|
||||
else if (ch == '$' && itemString)
|
||||
add(itemString);
|
||||
continue;
|
||||
}
|
||||
|
||||
add_character(ch);
|
||||
else if (ch == '@')
|
||||
add_character(axis_codes[index]);
|
||||
else
|
||||
add_character(ch);
|
||||
}
|
||||
eol();
|
||||
}
|
||||
@ -150,9 +150,8 @@ void TFT_String::rtrim(uint8_t character) {
|
||||
span -= glyph(data[length])->DWidth;
|
||||
eol();
|
||||
}
|
||||
else {
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user