🎨 Axis name string interpolation, with examples (#22879)

x301
Scott Lahteine 3 years ago
parent 854ce63358
commit 1de265ea5d

@ -43,9 +43,11 @@ uint8_t read_byte(uint8_t *byte) { return *byte; }
/**
* Add a string, applying substitutions for the following characters:
*
* $ displays the clipped C-string given by the itemString argument
* = 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 DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/*=nullptr*/) {
wchar_t wchar;
@ -62,17 +64,15 @@ void DWIN_String::add(uint8_t *string, const 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();
}

@ -129,9 +129,8 @@ namespace Language_cz {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikace");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Zrcadlení");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Plná kontrola");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. tryska X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. tryska Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. tryska Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. tryska @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Provádím G29");
LSTR MSG_UBL_TOOLS = _UxGT("UBL nástroje");

@ -121,9 +121,8 @@ namespace Language_de {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplizieren");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Spiegelkopie");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("vollstä. Kontrolle");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. Düse X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. Düse Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. Düse Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. Düse @");
LSTR MSG_UBL_DOING_G29 = _UxGT("G29 ausführen");
LSTR MSG_UBL_TOOLS = _UxGT("UBL-Werkzeuge");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling");

@ -30,9 +30,11 @@
* Substitutions are applied for the following characters when used
* in menu items that call lcd_put_u8str_ind_P with an index:
*
* $ displays an inserted C-string
* = 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
*/
#define en 1234
@ -72,12 +74,7 @@ namespace Language_en {
LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Progress Bar Test");
LSTR MSG_HOMING = _UxGT("Homing");
LSTR MSG_AUTO_HOME = _UxGT("Auto Home");
LSTR MSG_AUTO_HOME_X = _UxGT("Home X");
LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y");
LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z");
LSTR MSG_AUTO_HOME_I = _UxGT("Home ") LCD_STR_I;
LSTR MSG_AUTO_HOME_J = _UxGT("Home ") LCD_STR_J;
LSTR MSG_AUTO_HOME_K = _UxGT("Home ") LCD_STR_K;
LSTR MSG_AUTO_HOME_A = _UxGT("Home @");
LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings");
LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management");
LSTR MSG_LEVBED_FL = _UxGT("Front Left");
@ -175,9 +172,8 @@ namespace Language_en {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplicate X-Gap");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Doing G29");
LSTR MSG_UBL_TOOLS = _UxGT("UBL Tools");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling");
@ -279,7 +275,7 @@ namespace Language_en {
LSTR MSG_MOVING = _UxGT("Moving...");
LSTR MSG_FREE_XY = _UxGT("Free XY");
LSTR MSG_MOVE_X = _UxGT("Move X");
LSTR MSG_MOVE_X = _UxGT("Move X"); // Used by draw_edit_screen
LSTR MSG_MOVE_Y = _UxGT("Move Y");
LSTR MSG_MOVE_Z = _UxGT("Move Z");
LSTR MSG_MOVE_I = _UxGT("Move ") LCD_STR_I;
@ -303,6 +299,7 @@ namespace Language_en {
LSTR MSG_MAXSPEED_Y = _UxGT("Max ") LCD_STR_B _UxGT(" Speed");
LSTR MSG_MAXSPEED_Z = _UxGT("Max ") LCD_STR_C _UxGT(" Speed");
LSTR MSG_MAXSPEED_E = _UxGT("Max ") LCD_STR_E _UxGT(" Speed");
LSTR MSG_MAXSPEED_A = _UxGT("Max @ Speed");
LSTR MSG_BED_Z = _UxGT("Bed Z");
LSTR MSG_NOZZLE = _UxGT("Nozzle");
LSTR MSG_NOZZLE_N = _UxGT("Nozzle ~");

@ -124,9 +124,8 @@ namespace Language_es {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicar");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia Reflejada");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Control Total");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2ª Fusor X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2ª Fusor Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2ª Fusor Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2ª Fusor @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Hacer G29");
LSTR MSG_UBL_TOOLS = _UxGT("Herramientas UBL");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Nivelado UBL");

@ -134,9 +134,8 @@ namespace Language_fr {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copie miroir");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Contrôle complet");
LSTR MSG_OFFSETS_MENU = _UxGT("Offsets Outil");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("Buse 2 X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("Buse 2 Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("Buse 2 Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("Buse 2 @");
LSTR MSG_G26_HEATING_BED = _UxGT("G26: Chauffage du lit");
LSTR MSG_G26_HEATING_NOZZLE = _UxGT("Buse en chauffe...");
LSTR MSG_G26_MANUAL_PRIME = _UxGT("Amorce manuelle...");

@ -121,9 +121,8 @@ namespace Language_gl {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicación");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia Espello");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Control Total");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2º Bico X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2º Bico Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2º Bico Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2º Bico @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Executando G29");
LSTR MSG_UBL_TOOLS = _UxGT("Ferramentas UBL");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling");

@ -156,9 +156,8 @@ namespace Language_hu {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Tükrözött másolás");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Teljes felügyelet");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-hézag másolása");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. fej X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. fej Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. fej Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. fej @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Szintezz! G29");
LSTR MSG_UBL_TOOLS = _UxGT("UBL eszköz");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Egységes ágy szint");

@ -30,9 +30,11 @@
* Substitutions are applied for the following characters when used
* in menu items that call lcd_put_u8str_ind_P with an index:
*
* $ displays an inserted C-string
* = 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
*/
#define DISPLAY_CHARSET_ISO10646_1
@ -160,9 +162,8 @@ namespace Language_it {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Copia speculare");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Pieno controllo");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-Gap-X duplicato");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2° ugello X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2° ugello Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2° ugello Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2° ugello @");
LSTR MSG_UBL_DOING_G29 = _UxGT("G29 in corso");
LSTR MSG_UBL_TOOLS = _UxGT("Strumenti UBL");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Livel.letto unificato");

@ -30,9 +30,11 @@
* Substitutions are applied for the following characters when used
* in menu items that call lcd_put_u8str_ind_P with an index:
*
* $ displays an inserted C-string
* = 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
*/
#define DISPLAY_CHARSET_ISO10646_PL
@ -133,9 +135,8 @@ namespace Language_pl {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplikowanie");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Kopia lustrzana");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Pełne sterowanie");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2ga dysza X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2ga dysza Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2ga dysza Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2ga dysza @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Wykonywanie G29");
LSTR MSG_UBL_TOOLS = _UxGT("Narzędzia UBL");
LSTR MSG_LCD_TILTING_MESH = _UxGT("Punkt pochylenia");

@ -111,9 +111,8 @@ namespace Language_pt_br {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplicação");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Cópia espelhada");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Controle Total");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2o bico X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2o bico Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2o bico Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2o bico @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Executando G29");
LSTR MSG_UBL_TOOLS = _UxGT("Ferramentas UBL");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Nivel. Mesa Unif.");

@ -120,9 +120,8 @@ namespace Language_ro {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplication");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Doing G29");
LSTR MSG_UBL_TOOLS = _UxGT("UBL Tools");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling");

@ -197,9 +197,8 @@ namespace Language_ru {
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Полный контроль");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("Дублировать X-зазор");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2-е сопло X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2-е сопло Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2-е сопло Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2-е сопло @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Выполняем G29");
LSTR MSG_UBL_TOOLS = _UxGT("Инструменты UBL");

@ -34,9 +34,11 @@
* Substitutions are applied for the following characters when used
* in menu items that call lcd_put_u8str_ind_P with an index:
*
* $ displays an inserted C-string
* = 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
*/
#define DISPLAY_CHARSET_ISO10646_SK
@ -172,9 +174,8 @@ namespace Language_sk {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Zrkadlená kópia");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Plná kontrola");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplik. medz.-X");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. tryska X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. tryska Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. tryska Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. tryska @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Vykonávam G29");
LSTR MSG_UBL_TOOLS = _UxGT("Nástroje UBL");
LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL rovnanie");
@ -300,6 +301,7 @@ namespace Language_sk {
LSTR MSG_MAXSPEED_Y = _UxGT("Max rýchl. ") LCD_STR_B;
LSTR MSG_MAXSPEED_Z = _UxGT("Max rýchl. ") LCD_STR_C;
LSTR MSG_MAXSPEED_E = _UxGT("Max rýchl. ") LCD_STR_E;
LSTR MSG_MAXSPEED_A = _UxGT("Max rýchl. @");
LSTR MSG_BED_Z = _UxGT("Výška podl.");
LSTR MSG_NOZZLE = _UxGT("Tryska");
LSTR MSG_NOZZLE_N = _UxGT("Tryska ~");

@ -145,9 +145,8 @@ namespace Language_sv {
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Speglad Kopia");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Kontroll");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("Duplicera X-Avstånd");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2:a Munstycke X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2:a Munstycke Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2:a Munstycke Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2:a Munstycke @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Utför G29");
LSTR MSG_UBL_TOOLS = _UxGT("UBL Verktyg");
LSTR MSG_UBL_LEVEL_BED = _UxGT("Enad Bädd Nivellering (UBL)");

@ -123,9 +123,8 @@ namespace Language_tr {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Kopyala");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Yansıtılmış kopya");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Tam Kontrol");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2. nozul X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2. nozul Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. nozul Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. nozul @");
LSTR MSG_UBL_DOING_G29 = _UxGT("G29 Çalışıyor");
LSTR MSG_UBL_TOOLS = _UxGT("UBL Araçları");
LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL Yatak Hizalama");

@ -198,9 +198,8 @@ namespace Language_uk {
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Повний контроль");
LSTR MSG_IDEX_DUPE_GAP = _UxGT("Дублюв. X-проміжок");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("Друге сопло X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("Друге сопло Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("Друге сопло Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("Друге сопло @");
LSTR MSG_UBL_DOING_G29 = _UxGT("Виконується G29");
LSTR MSG_UBL_TOOLS = _UxGT("Інструменти UBL");

@ -119,9 +119,8 @@ namespace Language_zh_CN {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("复制");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("镜像复制");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("完全控制");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("第二喷头是X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("第二喷头是Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("第二喷头是Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("第二喷头是@");
LSTR MSG_UBL_DOING_G29 = _UxGT("执行G29"); // "Doing G29"
LSTR MSG_UBL_TOOLS = _UxGT("UBL工具"); // "UBL Tools"
LSTR MSG_UBL_LEVEL_BED = _UxGT("统一热床调平(UBL)"); // "Unified Bed Leveling"

@ -116,9 +116,8 @@ namespace Language_zh_TW {
LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplication");
LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Mirrored Copy");
LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Full Control");
LSTR MSG_HOTEND_OFFSET_X = _UxGT("2nd Nozzle X");
LSTR MSG_HOTEND_OFFSET_Y = _UxGT("2nd Nozzle Y");
LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2nd Nozzle Z");
LSTR MSG_HOTEND_OFFSET_A = _UxGT("2nd Nozzle @");
LSTR MSG_UBL_DOING_G29 = _UxGT("執行G29"); // "Doing G29"
LSTR MSG_UBL_TOOLS = _UxGT("UBL工具"); // "UBL Tools"
LSTR MSG_UBL_LEVEL_BED = _UxGT("統一熱床調平(UBL)"); // "Unified Bed Leveling"

@ -36,9 +36,11 @@
*
* Print a string with an index substituted within it:
*
* $ displays the clipped C-string given by the inStr argument
* = 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
*/
lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
const uint8_t prop = USE_WIDE_GLYPH ? 2 : 1;
@ -72,6 +74,10 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i
else if (ch == '$' && inStr) {
n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
}
else if (ch == '@') {
lcd_put_wchar(axis_codes[ind]);
n--;
}
else {
lcd_put_wchar(ch);
n -= ch > 255 ? prop : 1;

@ -103,42 +103,28 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b
/////////// Menu Editing Actions ///////////
////////////////////////////////////////////
/**
* Functions for editing single values
*
* The "DEFINE_MENU_EDIT_ITEM" macro generates the classes needed to edit a numerical value.
*
* The prerequisite is that in the header the type was already declared:
*
* DEFINE_MENU_EDIT_ITEM_TYPE(int3, int16_t, i16tostr3rj, 1)
*
* For example, DEFINE_MENU_EDIT_ITEM(int3) expands into:
*
* template class TMenuEditItem<MenuEditItemInfo_int3>
*
* You can then use one of the menu macros to present the edit interface:
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
*
* This expands into a more primitive menu item:
* _MENU_ITEM_P(int3, false, GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999)
*
* ...which calls:
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
* MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999)
*/
// All Edit Screens run the same way, but `draw_edit_screen` is implementation-specific
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
// Reset repeat_delay for Touch Buttons
TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT);
// Constrain ui.encoderPosition to 0 ... maxEditValue (calculated in encoder steps)
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
// If drawing is flagged then redraw the (whole) edit screen
if (ui.should_draw())
draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));
// If there was a click or "live editing" and encoder moved...
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
// Pass the editValue pointer to the loadfunc along with the encoder plus min
if (editValue) loadfunc(editValue, ui.encoderPosition + minEditValue);
// If a callbackFunc was set, call it for click or always for "live editing"
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
// Use up the click to finish editing and go to the previous screen
if (ui.use_click()) ui.goto_previous_screen();
}
}
// Going to an edit screen sets up some persistent values first
void MenuEditItemBase::goto_edit_screen(
PGM_P const el, // Edit label
void * const ev, // Edit value pointer

@ -60,7 +60,9 @@ class MenuItemBase {
// Store the index of the item ahead of use by indexed items
FORCE_INLINE static void init(const int8_t ind=0, PGM_P const pstr=nullptr) { itemIndex = ind; itemString = pstr; }
// Implementation-specific:
// Draw an item either selected (pre_char) or not (space) with post_char
// Menus may set up itemIndex, itemString and pass them to string-building or string-emitting functions
static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
// Draw an item either selected ('>') or not (space) with post_char
@ -167,11 +169,11 @@ class MenuEditItemBase : public MenuItemBase {
);
static void edit_screen(strfunc_t, loadfunc_t); // Edit value handler
public:
// Implemented for HD44780 and DOGM
// Implementation-specific:
// Draw the current item at specified row with edit data
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm=false);
// Implemented for HD44780 and DOGM
// Implementation-specific:
// This low-level method is good to draw from anywhere
static void draw_edit_screen(PGM_P const pstr, const char * const value);

@ -174,12 +174,12 @@ void menu_advanced_settings();
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
#if ENABLED(DUAL_X_CARRIAGE)
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
#else
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
#endif
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
EDIT_ITEM_FAST_N(float42_52, Z_AXIS, MSG_HOTEND_OFFSET_A, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
#if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
#endif

@ -106,9 +106,23 @@ class TMenuEditItem : MenuEditItemBase {
}
};
// Provide a set of Edit Item Types which encompass a primitive
// type, a string function, and a scale factor for edit and display.
// These items call the Edit Item draw method passing the prepared string.
/**
* DEFINE_MENU_EDIT_ITEM_TYPE(int3, int16_t, i16tostr3rj, 1)
*
* Define struct types for use by EDIT_ITEM(...) macros, which encompass
* a primitive storage type, a string function, and a scale factor for edit / display.
* The EDIT_ITEM macros take care of calling action and draw methods as needed.
*
* For example, DEFINE_MENU_EDIT_ITEM_TYPE(percent, uint8_t, ui8tostr4pctrj, 100.f/255.f, +0.5f) expands into:
*
* struct MenuEditItemInfo_percent {
* typedef uint8_t type_t;
* static inline float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; }
* static inline float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; }
* static inline const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); }
* };
* typedef TMenuEditItem<MenuEditItemInfo_percent> MenuItem_percent
*/
#define __DOFIXfloat PROBE()
#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \

@ -329,21 +329,21 @@ void menu_move() {
BACK_ITEM(MSG_MOTION);
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X"));
#if HAS_Y_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, PSTR("G28Y"));
#endif
#if HAS_Z_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z"));
#endif
#if LINEAR_AXES >= 4
GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR));
GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR));
#endif
#if LINEAR_AXES >= 5
GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR));
GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR));
#endif
#if LINEAR_AXES >= 6
GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR));
GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR));
#endif
END_MENU();
@ -382,21 +382,21 @@ void menu_motion() {
#else
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
#if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X"));
#if HAS_Y_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, PSTR("G28Y"));
#endif
#if HAS_Z_AXIS
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, PSTR("G28Z"));
#endif
#if LINEAR_AXES >= 4
GCODES_ITEM(MSG_AUTO_HOME_I, PSTR("G28" AXIS4_STR));
GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR));
#endif
#if LINEAR_AXES >= 5
GCODES_ITEM(MSG_AUTO_HOME_J, PSTR("G28" AXIS5_STR));
GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR));
#endif
#if LINEAR_AXES >= 6
GCODES_ITEM(MSG_AUTO_HOME_K, PSTR("G28" AXIS6_STR));
GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR));
#endif
#endif
#endif

@ -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;
}
}
}

Loading…
Cancel
Save