Przeglądaj źródła

Add "Bed" / "Chamber" substitutions (#18255)

Scott Lahteine 4 lat temu
rodzic
commit
67305f7976
No account linked to committer's email address

+ 11
- 9
Marlin/src/lcd/lcdprint.cpp Wyświetl plik

@@ -35,7 +35,7 @@
35 35
  * lcd_put_u8str_ind_P
36 36
  * Print a string with an index substituted within it
37 37
  */
38
-lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const uint8_t ind, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
38
+lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, const lcd_uint_t maxlen/*=LCD_WIDTH*/) {
39 39
   uint8_t *p = (uint8_t*)pstr;
40 40
   lcd_uint_t n = maxlen;
41 41
   for (; n; n--) {
@@ -43,15 +43,17 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const uint8_t ind, const lcd_ui
43 43
     p = get_utf8_value_cb(p, read_byte_rom, &ch);
44 44
     if (!ch) break;
45 45
     if (ch == '=' || ch == '~' || ch == '*') {
46
-      if (ch == '*') { lcd_put_wchar('E'); n--; }
47 46
       // lcd_put_int(ind); n--; if (ind >= 10) n--;
48
-      // if (ind >= 0)
49
-        {
50
-          lcd_put_wchar(ind + ((ch == '=') ? '0' : LCD_FIRST_TOOL));
51
-          n--;
52
-        }
53
-      // else if (ind == -1) { PGM_P const b = GET_TEXT(MSG_BED); lcd_put_u8str_P(b); n -= utf8_strlen_P(b); }
54
-      // else if (ind == -2) { PGM_P const c = GET_TEXT(MSG_CHAMBER); lcd_put_u8str_P(c); n -= utf8_strlen_P(c); }
47
+      if (ind >= 0) {
48
+        if (ch == '*') { lcd_put_wchar('E'); n--; }
49
+        lcd_put_wchar(ind + ((ch == '=') ? '0' : LCD_FIRST_TOOL));
50
+        n--;
51
+      }
52
+      else {
53
+        PGM_P const b = ind == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED);
54
+        lcd_put_u8str_P(b);
55
+        n -= utf8_strlen_P(b);
56
+      }
55 57
       if (n) n -= lcd_put_u8str_max_P((PGM_P)p, n);
56 58
       break;
57 59
     }

+ 2
- 2
Marlin/src/lcd/lcdprint.h Wyświetl plik

@@ -71,8 +71,8 @@ inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P con
71 71
   return lcd_put_u8str_P(pstr);
72 72
 }
73 73
 
74
-lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const uint8_t ind, const lcd_uint_t maxlen=LCD_WIDTH);
75
-inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr, const uint8_t ind, const lcd_uint_t maxlen=LCD_WIDTH) {
74
+lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, const lcd_uint_t maxlen=LCD_WIDTH);
75
+inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr, const int8_t ind, const lcd_uint_t maxlen=LCD_WIDTH) {
76 76
   lcd_moveto(col, row);
77 77
   return lcd_put_u8str_ind_P(pstr, ind, maxlen);
78 78
 }

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp Wyświetl plik

@@ -61,7 +61,7 @@ typedef struct {
61 61
 menuPosition screen_history[6];
62 62
 uint8_t screen_history_depth = 0;
63 63
 
64
-uint8_t MenuItemBase::itemIndex;  // Index number for draw and action
64
+int8_t MenuItemBase::itemIndex;   // Index number for draw and action
65 65
 chimera_t editable;               // Value Editing
66 66
 
67 67
 // Menu Edit Items

+ 2
- 2
Marlin/src/lcd/menu/menu.h Wyświetl plik

@@ -65,10 +65,10 @@ class MenuItemBase {
65 65
   public:
66 66
     // An index to interject in the item label and for
67 67
     // use by the action
68
-    static uint8_t itemIndex;
68
+    static int8_t itemIndex;
69 69
 
70 70
     // Store the index of the item ahead of use by indexed items
71
-    FORCE_INLINE static void init(const uint8_t ind) { itemIndex = ind; }
71
+    FORCE_INLINE static void init(const int8_t ind) { itemIndex = ind; }
72 72
 
73 73
     // Draw an item either selected (pre_char) or not (space) with post_char
74 74
     static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);

Ładowanie…
Anuluj
Zapisz