Quellcode durchsuchen

Improve editing, fix some small value editing

Scott Lahteine vor 5 Jahren
Ursprung
Commit
44caf70917

+ 12
- 0
Marlin/src/core/utility.cpp Datei anzeigen

@@ -161,6 +161,18 @@ void safe_delay(millis_t ms) {
161 161
     return &conv[3];
162 162
   }
163 163
 
164
+  // Convert signed float to fixed-length string with 12.34 / -2.34 format or 123.45 / -23.45 format
165
+  char* ftostr42_52(const float &f) {
166
+    if (f <= -10 || f >= 100) return ftostr52(f); // need more digits
167
+    long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;
168
+    conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000));
169
+    conv[3] = DIGIMOD(i, 100);
170
+    conv[4] = '.';
171
+    conv[5] = DIGIMOD(i, 10);
172
+    conv[6] = DIGIMOD(i, 1);
173
+    return &conv[2];
174
+  }
175
+
164 176
   // Convert signed float to fixed-length string with 023.45 / -23.45 format
165 177
   char* ftostr52(const float &f) {
166 178
     long i = (f * 1000 + (f < 0 ? -5: 5)) / 10;

+ 3
- 0
Marlin/src/core/utility.h Datei anzeigen

@@ -82,6 +82,9 @@ inline void serial_delay(const millis_t ms) {
82 82
   // Convert unsigned float to string with 1.23 format
83 83
   char* ftostr12ns(const float &x);
84 84
 
85
+  // Convert signed float to fixed-length string with 12.34 / -2.34 or 023.45 / -23.45 format
86
+  char* ftostr42_52(const float &x);
87
+
85 88
   // Convert signed float to fixed-length string with 023.45 / -23.45 format
86 89
   char* ftostr52(const float &x);
87 90
 

+ 1
- 1
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp Datei anzeigen

@@ -418,7 +418,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
418 418
         onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline);
419 419
       }
420 420
       if (onpage) {
421
-        lcd_moveto(((lcd_chr_fit - 1) - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
421
+        lcd_moveto((lcd_chr_fit - (vallen + 1)) * one_chr_width, baseline); // Right-justified, leaving padded by spaces
422 422
         lcd_put_wchar(' '); // overwrite char if value gets shorter
423 423
         lcd_put_u8str(value);
424 424
       }

+ 2
- 2
Marlin/src/lcd/menu/menu.h Datei anzeigen

@@ -53,7 +53,7 @@ DECLARE_MENU_EDIT_TYPE(uint8_t,  uint8,       ui8tostr3,       1     );   // 123
53 53
 DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_3,    ui16tostr3,      1     );   // 123, -12   right-justified
54 54
 DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_4,    ui16tostr4,      0.1   );   // 1234, -123 right-justified
55 55
 DECLARE_MENU_EDIT_TYPE(float,    float3,      ftostr3,         1     );   // 123        right-justified
56
-DECLARE_MENU_EDIT_TYPE(float,    float52,     ftostr52,      100     );   // 123.45, -23.45
56
+DECLARE_MENU_EDIT_TYPE(float,    float52,     ftostr42_52,   100     );   // _2.34, 12.34, -2.34 or 123.45, -23.45
57 57
 DECLARE_MENU_EDIT_TYPE(float,    float43,     ftostr43sign, 1000     );   // 1.234
58 58
 DECLARE_MENU_EDIT_TYPE(float,    float5,      ftostr5rj,       0.01f );   // 12345      right-justified
59 59
 DECLARE_MENU_EDIT_TYPE(float,    float5_25,   ftostr5rj,       0.04f );   // 12345      right-justified (25 increment)
@@ -123,7 +123,7 @@ DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint8);            // 123        right-justif
123 123
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_3);         // 123, -12   right-justified
124 124
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_4);         // 1234, -123 right-justified
125 125
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3);           // 123        right-justified
126
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52);          // 123.45, -23.45
126
+DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52);          // _2.34, 12.34, -2.34 or 123.45, -23.45
127 127
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43);          // 1.234
128 128
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5);           // 12345      right-justified
129 129
 DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5_25);        // 12345      right-justified (25 increment)

Laden…
Abbrechen
Speichern