Pārlūkot izejas kodu

Merge pull request #4665 from thinkyhead/rc_lcd_not_ultipanel

Clean up ultralcd code, dependencies on ULTIPANEL
Scott Lahteine 8 gadus atpakaļ
vecāks
revīzija
a1f6cf1e5d
6 mainītis faili ar 521 papildinājumiem un 539 dzēšanām
  1. 7
    252
      Marlin/ultralcd.cpp
  2. 0
    17
      Marlin/ultralcd.h
  3. 149
    140
      Marlin/ultralcd_impl_DOGM.h
  4. 135
    129
      Marlin/ultralcd_impl_HD44780.h
  5. 183
    0
      Marlin/utility.cpp
  6. 47
    1
      Marlin/utility.h

+ 7
- 252
Marlin/ultralcd.cpp Parādīt failu

@@ -28,6 +28,7 @@
28 28
 #include "temperature.h"
29 29
 #include "stepper.h"
30 30
 #include "configuration_store.h"
31
+#include "utility.h"
31 32
 
32 33
 #if ENABLED(PRINTCOUNTER)
33 34
   #include "printcounter.h"
@@ -1878,6 +1879,7 @@ void kill_screen(const char* lcd_msg) {
1878 1879
    *
1879 1880
    */
1880 1881
   #if ENABLED(FWRETRACT)
1882
+
1881 1883
     static void lcd_control_retract_menu() {
1882 1884
       START_MENU();
1883 1885
       MENU_ITEM(back, MSG_CONTROL);
@@ -1895,6 +1897,7 @@ void kill_screen(const char* lcd_msg) {
1895 1897
       MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate_mm_s, 1, 999);
1896 1898
       END_MENU();
1897 1899
     }
1900
+
1898 1901
   #endif // FWRETRACT
1899 1902
 
1900 1903
   #if ENABLED(SDSUPPORT)
@@ -2582,12 +2585,12 @@ void lcd_update() {
2582 2585
       lcd_implementation_update_indicators();
2583 2586
     #endif
2584 2587
 
2585
-    #if ENABLED(LCD_HAS_SLOW_BUTTONS)
2586
-      slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
2587
-    #endif
2588
-
2589 2588
     #if ENABLED(ULTIPANEL)
2590 2589
 
2590
+      #if ENABLED(LCD_HAS_SLOW_BUTTONS)
2591
+        slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
2592
+      #endif
2593
+
2591 2594
       #if ENABLED(REPRAPWORLD_KEYPAD)
2592 2595
 
2593 2596
         static uint8_t keypad_debounce = 0;
@@ -2936,252 +2939,4 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2936 2939
 
2937 2940
 #endif // ULTIPANEL
2938 2941
 
2939
-/*********************************/
2940
-/** Number to string conversion **/
2941
-/*********************************/
2942
-
2943
-#define DIGIT(n) ('0' + (n))
2944
-#define DIGIMOD(n) DIGIT((n) % 10)
2945
-
2946
-char conv[8];
2947
-
2948
-// Convert float to rj string with 123 or -12 format
2949
-char *ftostr3(const float& x) { return itostr3((int)x); }
2950
-
2951
-// Convert float to rj string with _123, -123, _-12, or __-1 format
2952
-char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
2953
-
2954
-// Convert unsigned int to string with 12 format
2955
-char* itostr2(const uint8_t& x) {
2956
-  int xx = x;
2957
-  conv[0] = DIGIMOD(xx / 10);
2958
-  conv[1] = DIGIMOD(xx);
2959
-  conv[2] = '\0';
2960
-  return conv;
2961
-}
2962
-
2963
-// Convert float to string with +123.4 / -123.4 format
2964
-char* ftostr41sign(const float& x) {
2965
-  int xx = int(abs(x * 10)) % 10000;
2966
-  conv[0] = x >= 0 ? '+' : '-';
2967
-  conv[1] = DIGIMOD(xx / 1000);
2968
-  conv[2] = DIGIMOD(xx / 100);
2969
-  conv[3] = DIGIMOD(xx / 10);
2970
-  conv[4] = '.';
2971
-  conv[5] = DIGIMOD(xx);
2972
-  conv[6] = '\0';
2973
-  return conv;
2974
-}
2975
-
2976
-// Convert signed float to string with 023.45 / -23.45 format
2977
-char *ftostr32(const float& x) {
2978
-  long xx = abs(x * 100);
2979
-  conv[0] = x >= 0 ? DIGIMOD(xx / 10000) : '-';
2980
-  conv[1] = DIGIMOD(xx / 1000);
2981
-  conv[2] = DIGIMOD(xx / 100);
2982
-  conv[3] = '.';
2983
-  conv[4] = DIGIMOD(xx / 10);
2984
-  conv[5] = DIGIMOD(xx);
2985
-  conv[6] = '\0';
2986
-  return conv;
2987
-}
2988
-
2989
-// Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
2990
-char* ftostr43sign(const float& x, char plus/*=' '*/) {
2991
-  long xx = x * 1000;
2992
-  if (xx == 0)
2993
-    conv[0] = ' ';
2994
-  else if (xx > 0)
2995
-    conv[0] = plus;
2996
-  else {
2997
-    xx = -xx;
2998
-    conv[0] = '-';
2999
-  }
3000
-  conv[1] = DIGIMOD(xx / 1000);
3001
-  conv[2] = '.';
3002
-  conv[3] = DIGIMOD(xx / 100);
3003
-  conv[4] = DIGIMOD(xx / 10);
3004
-  conv[5] = DIGIMOD(xx);
3005
-  conv[6] = '\0';
3006
-  return conv;
3007
-}
3008
-
3009
-// Convert unsigned float to string with 1.23 format
3010
-char* ftostr12ns(const float& x) {
3011
-  long xx = x * 100;
3012
-  xx = abs(xx);
3013
-  conv[0] = DIGIMOD(xx / 100);
3014
-  conv[1] = '.';
3015
-  conv[2] = DIGIMOD(xx / 10);
3016
-  conv[3] = DIGIMOD(xx);
3017
-  conv[4] = '\0';
3018
-  return conv;
3019
-}
3020
-
3021
-// Convert signed int to lj string with +012 / -012 format
3022
-char* itostr3sign(const int& x) {
3023
-  int xx;
3024
-  if (x >= 0) {
3025
-    conv[0] = '+';
3026
-    xx = x;
3027
-  }
3028
-  else {
3029
-    conv[0] = '-';
3030
-    xx = -x;
3031
-  }
3032
-  conv[1] = DIGIMOD(xx / 100);
3033
-  conv[2] = DIGIMOD(xx / 10);
3034
-  conv[3] = DIGIMOD(xx);
3035
-  conv[4] = '.';
3036
-  conv[5] = '0';
3037
-  conv[6] = '\0';
3038
-  return conv;
3039
-}
3040
-
3041
-// Convert signed int to rj string with 123 or -12 format
3042
-char* itostr3(const int& x) {
3043
-  int xx = x;
3044
-  if (xx < 0) {
3045
-    conv[0] = '-';
3046
-    xx = -xx;
3047
-  }
3048
-  else
3049
-    conv[0] = xx >= 100 ? DIGIMOD(xx / 100) : ' ';
3050
-
3051
-  conv[1] = xx >= 10 ? DIGIMOD(xx / 10) : ' ';
3052
-  conv[2] = DIGIMOD(xx);
3053
-  conv[3] = '\0';
3054
-  return conv;
3055
-}
3056
-
3057
-// Convert unsigned int to lj string with 123 format
3058
-char* itostr3left(const int& xx) {
3059
-  if (xx >= 100) {
3060
-    conv[0] = DIGIMOD(xx / 100);
3061
-    conv[1] = DIGIMOD(xx / 10);
3062
-    conv[2] = DIGIMOD(xx);
3063
-    conv[3] = '\0';
3064
-  }
3065
-  else if (xx >= 10) {
3066
-    conv[0] = DIGIMOD(xx / 10);
3067
-    conv[1] = DIGIMOD(xx);
3068
-    conv[2] = '\0';
3069
-  }
3070
-  else {
3071
-    conv[0] = DIGIMOD(xx);
3072
-    conv[1] = '\0';
3073
-  }
3074
-  return conv;
3075
-}
3076
-
3077
-// Convert signed int to rj string with _123, -123, _-12, or __-1 format
3078
-char *itostr4sign(const int& x) {
3079
-  int xx = abs(x);
3080
-  int sign = 0;
3081
-  if (xx >= 100) {
3082
-    conv[1] = DIGIMOD(xx / 100);
3083
-    conv[2] = DIGIMOD(xx / 10);
3084
-  }
3085
-  else if (xx >= 10) {
3086
-    conv[0] = ' ';
3087
-    sign = 1;
3088
-    conv[2] = DIGIMOD(xx / 10);
3089
-  }
3090
-  else {
3091
-    conv[0] = ' ';
3092
-    conv[1] = ' ';
3093
-    sign = 2;
3094
-  }
3095
-  conv[sign] = x < 0 ? '-' : ' ';
3096
-  conv[3] = DIGIMOD(xx);
3097
-  conv[4] = '\0';
3098
-  return conv;
3099
-}
3100
-
3101
-// Convert unsigned float to rj string with 12345 format
3102
-char* ftostr5rj(const float& x) {
3103
-  long xx = abs(x);
3104
-  conv[0] = xx >= 10000 ? DIGIMOD(xx / 10000) : ' ';
3105
-  conv[1] = xx >= 1000 ? DIGIMOD(xx / 1000) : ' ';
3106
-  conv[2] = xx >= 100 ? DIGIMOD(xx / 100) : ' ';
3107
-  conv[3] = xx >= 10 ? DIGIMOD(xx / 10) : ' ';
3108
-  conv[4] = DIGIMOD(xx);
3109
-  conv[5] = '\0';
3110
-  return conv;
3111
-}
3112
-
3113
-// Convert signed float to string with +1234.5 format
3114
-char* ftostr51sign(const float& x) {
3115
-  long xx = abs(x * 10);
3116
-  conv[0] = (x >= 0) ? '+' : '-';
3117
-  conv[1] = DIGIMOD(xx / 10000);
3118
-  conv[2] = DIGIMOD(xx / 1000);
3119
-  conv[3] = DIGIMOD(xx / 100);
3120
-  conv[4] = DIGIMOD(xx / 10);
3121
-  conv[5] = '.';
3122
-  conv[6] = DIGIMOD(xx);
3123
-  conv[7] = '\0';
3124
-  return conv;
3125
-}
3126
-
3127
-// Convert signed float to string with +123.45 format
3128
-char* ftostr52sign(const float& x) {
3129
-  long xx = abs(x * 100);
3130
-  conv[0] = (x >= 0) ? '+' : '-';
3131
-  conv[1] = DIGIMOD(xx / 10000);
3132
-  conv[2] = DIGIMOD(xx / 1000);
3133
-  conv[3] = DIGIMOD(xx / 100);
3134
-  conv[4] = '.';
3135
-  conv[5] = DIGIMOD(xx / 10);
3136
-  conv[6] = DIGIMOD(xx);
3137
-  conv[7] = '\0';
3138
-  return conv;
3139
-}
3140
-
3141
-// Convert signed float to space-padded string with -_23.4_ format
3142
-char* ftostr52sp(const float& x) {
3143
-  long xx = x * 100;
3144
-  uint8_t dig;
3145
-  if (xx < 0) { // negative val = -_0
3146
-    xx = -xx;
3147
-    conv[0] = '-';
3148
-    dig = (xx / 1000) % 10;
3149
-    conv[1] = dig ? DIGIT(dig) : ' ';
3150
-  }
3151
-  else { // positive val = __0
3152
-    dig = (xx / 10000) % 10;
3153
-    if (dig) {
3154
-      conv[0] = DIGIT(dig);
3155
-      conv[1] = DIGIMOD(xx / 1000);
3156
-    }
3157
-    else {
3158
-      conv[0] = ' ';
3159
-      dig = (xx / 1000) % 10;
3160
-      conv[1] = dig ? DIGIT(dig) : ' ';
3161
-    }
3162
-  }
3163
-
3164
-  conv[2] = DIGIMOD(xx / 100); // lsd always
3165
-
3166
-  dig = xx % 10;
3167
-  if (dig) { // 2 decimal places
3168
-    conv[5] = DIGIT(dig);
3169
-    conv[4] = DIGIMOD(xx / 10);
3170
-    conv[3] = '.';
3171
-  }
3172
-  else { // 1 or 0 decimal place
3173
-    dig = (xx / 10) % 10;
3174
-    if (dig) {
3175
-      conv[4] = DIGIT(dig);
3176
-      conv[3] = '.';
3177
-    }
3178
-    else {
3179
-      conv[3] = conv[4] = ' ';
3180
-    }
3181
-    conv[5] = ' ';
3182
-  }
3183
-  conv[6] = '\0';
3184
-  return conv;
3185
-}
3186
-
3187 2942
 #endif // ULTRA_LCD

+ 0
- 17
Marlin/ultralcd.h Parādīt failu

@@ -167,21 +167,4 @@
167 167
 
168 168
 #endif //ULTRA_LCD
169 169
 
170
-char* itostr2(const uint8_t& x);
171
-char* itostr3sign(const int& x);
172
-char* itostr3(const int& x);
173
-char* itostr3left(const int& x);
174
-char* itostr4sign(const int& x);
175
-
176
-char* ftostr3(const float& x);
177
-char* ftostr4sign(const float& x);
178
-char* ftostr41sign(const float& x);
179
-char* ftostr32(const float& x);
180
-char* ftostr43sign(const float& x, char plus=' ');
181
-char* ftostr12ns(const float& x);
182
-char* ftostr5rj(const float& x);
183
-char* ftostr51sign(const float& x);
184
-char* ftostr52sign(const float& x);
185
-char* ftostr52sp(const float& x); // remove zero-padding from ftostr32
186
-
187 170
 #endif //ULTRALCD_H

+ 149
- 140
Marlin/ultralcd_impl_DOGM.h Parādīt failu

@@ -45,6 +45,7 @@
45 45
 #include "ultralcd.h"
46 46
 #include "ultralcd_st7920_u8glib_rrd.h"
47 47
 #include "dogm_bitmaps.h"
48
+#include "utility.h"
48 49
 #include "duration_t.h"
49 50
 
50 51
 #include <U8glib.h>
@@ -200,26 +201,20 @@ char lcd_print(char c) {
200 201
 }
201 202
 
202 203
 char lcd_print(const char* str) {
203
-  char c;
204 204
   int i = 0;
205
-  char n = 0;
206
-  while ((c = str[i++])) {
207
-    n += lcd_print(c);
208
-  }
205
+  char c, n = 0;
206
+  while ((c = str[i++])) n += lcd_print(c);
209 207
   return n;
210 208
 }
211 209
 
212
-/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
210
+// Needed for Arduino < 1.0.0
213 211
 char lcd_printPGM(const char* str) {
214
-  char c;
215
-  char n = 0;
216
-  while ((c = pgm_read_byte(str++))) {
217
-    n += lcd_print(c);
218
-  }
212
+  char c, n = 0;
213
+  while ((c = pgm_read_byte(str++))) n += lcd_print(c);
219 214
   return n;
220 215
 }
221 216
 
222
-/* Warning: This function is called from interrupt context */
217
+// Initialize or re-initializw the LCD
223 218
 static void lcd_implementation_init() {
224 219
 
225 220
   #if defined(LCD_PIN_BL) && LCD_PIN_BL > -1 // Enable LCD backlight
@@ -290,6 +285,7 @@ static void lcd_implementation_init() {
290 285
   #endif // SHOW_BOOTSCREEN
291 286
 }
292 287
 
288
+// The kill screen is displayed for unrecoverable conditions
293 289
 void lcd_kill_screen() {
294 290
   lcd_setFont(FONT_MENU);
295 291
   u8g.setPrintPos(0, u8g.getHeight()/4*1);
@@ -302,6 +298,10 @@ void lcd_kill_screen() {
302 298
 
303 299
 static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
304 300
 
301
+//
302
+// Status Screen
303
+//
304
+
305 305
 FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) {
306 306
   int degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width
307 307
   u8g.setPrintPos(x - (18 - degsize) / 2, y); // move left if shorter
@@ -472,164 +472,173 @@ static void lcd_implementation_status_screen() {
472 472
   #endif
473 473
 }
474 474
 
475
-static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
476
-  if (isSelected) {
477
-    u8g.setColorIndex(1);  // black on white
478
-    u8g.drawBox(0, row * (DOG_CHAR_HEIGHT) + 3 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
479
-    u8g.setColorIndex(0);  // following text must be white on black
480
-  }
481
-  else {
482
-    u8g.setColorIndex(1); // unmarked text is black on white
475
+#if ENABLED(ULTIPANEL)
476
+
477
+  // Set the colors for a menu item based on whether it is selected
478
+  static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
479
+    if (isSelected) {
480
+      u8g.setColorIndex(1);  // black on white
481
+      u8g.drawBox(0, row * (DOG_CHAR_HEIGHT) + 3 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
482
+      u8g.setColorIndex(0);  // following text must be white on black
483
+    }
484
+    else {
485
+      u8g.setColorIndex(1); // unmarked text is black on white
486
+    }
487
+    u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
483 488
   }
484
-  u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
485
-}
486 489
 
487
-#if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
490
+  #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
488 491
 
489
-  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char* valstr=NULL) {
492
+    // Draw a static line of text in the same idiom as a menu item
493
+    static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char* valstr=NULL) {
490 494
 
491
-    lcd_implementation_mark_as_selected(row, invert);
495
+      lcd_implementation_mark_as_selected(row, invert);
492 496
 
493
-    char c;
494
-    int8_t n = LCD_WIDTH - (START_COL);
497
+      char c;
498
+      int8_t n = LCD_WIDTH - (START_COL);
495 499
 
496
-    if (center && !valstr) {
497
-      int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
498
-      while (--pad >= 0) { lcd_print(' '); n--; }
499
-    }
500
-    while (n > 0 && (c = pgm_read_byte(pstr))) {
501
-      n -= lcd_print(c);
502
-      pstr++;
503
-    }
504
-    if (valstr) while (n > 0 && (c = *valstr)) {
505
-      n -= lcd_print(c);
506
-      valstr++;
500
+      if (center && !valstr) {
501
+        int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
502
+        while (--pad >= 0) { lcd_print(' '); n--; }
503
+      }
504
+      while (n > 0 && (c = pgm_read_byte(pstr))) {
505
+        n -= lcd_print(c);
506
+        pstr++;
507
+      }
508
+      if (valstr) while (n > 0 && (c = *valstr)) {
509
+        n -= lcd_print(c);
510
+        valstr++;
511
+      }
512
+      while (n-- > 0) lcd_print(' ');
507 513
     }
508
-    while (n-- > 0) lcd_print(' ');
509
-  }
510 514
 
511
-#endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
515
+  #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
512 516
 
513
-static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
514
-  UNUSED(pre_char);
517
+  // Draw a generic menu item
518
+  static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
519
+    UNUSED(pre_char);
515 520
 
516
-  char c;
517
-  uint8_t n = LCD_WIDTH - (START_COL) - 2;
521
+    char c;
522
+    uint8_t n = LCD_WIDTH - (START_COL) - 2;
518 523
 
519
-  lcd_implementation_mark_as_selected(row, isSelected);
524
+    lcd_implementation_mark_as_selected(row, isSelected);
520 525
 
521
-  while (c = pgm_read_byte(pstr)) {
522
-    n -= lcd_print(c);
523
-    pstr++;
526
+    while (c = pgm_read_byte(pstr)) {
527
+      n -= lcd_print(c);
528
+      pstr++;
529
+    }
530
+    while (n--) lcd_print(' ');
531
+    u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
532
+    lcd_print(post_char);
533
+    lcd_print(' ');
524 534
   }
525
-  while (n--) lcd_print(' ');
526
-  u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
527
-  lcd_print(post_char);
528
-  lcd_print(' ');
529
-}
530 535
 
531
-static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
532
-  char c;
533
-  uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
534
-  uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
536
+  // Macros for specific types of menu items
537
+  #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
538
+  #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
539
+  #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
540
+  #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
535 541
 
536
-  lcd_implementation_mark_as_selected(row, isSelected);
542
+  // Draw a menu item with an editable value
543
+  static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
544
+    char c;
545
+    uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
546
+    uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
537 547
 
538
-  while (c = pgm_read_byte(pstr)) {
539
-    n -= lcd_print(c);
540
-    pstr++;
541
-  }
542
-  lcd_print(':');
543
-  while (n--) lcd_print(' ');
544
-  u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, (row + 1) * (DOG_CHAR_HEIGHT));
545
-  if (pgm)  lcd_printPGM(data);  else  lcd_print((char*)data);
546
-}
548
+    lcd_implementation_mark_as_selected(row, isSelected);
547 549
 
548
-#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
549
-#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
550
-
551
-#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
552
-#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
553
-#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
554
-#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
555
-#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
556
-#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
557
-#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
558
-#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
559
-#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
560
-
561
-//Add version for callback functions
562
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
563
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
564
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
565
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
566
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
567
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
568
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
569
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
570
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
571
-
572
-void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
573
-  uint8_t rows = 1;
574
-  uint8_t lcd_width = LCD_WIDTH - (START_COL), char_width = DOG_CHAR_WIDTH;
575
-  uint8_t vallen = lcd_strlen(value);
576
-
577
-  #if ENABLED(USE_BIG_EDIT_FONT)
578
-    if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
579
-      lcd_setFont(FONT_MENU_EDIT);
580
-      lcd_width = LCD_WIDTH_EDIT + 1;
581
-      char_width = DOG_CHAR_WIDTH_EDIT;
582
-      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
583
-    }
584
-    else {
585
-      lcd_setFont(FONT_MENU);
550
+    while (c = pgm_read_byte(pstr)) {
551
+      n -= lcd_print(c);
552
+      pstr++;
586 553
     }
587
-  #endif
554
+    lcd_print(':');
555
+    while (n--) lcd_print(' ');
556
+    u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, (row + 1) * (DOG_CHAR_HEIGHT));
557
+    if (pgm)  lcd_printPGM(data);  else  lcd_print((char*)data);
558
+  }
559
+
560
+  // Macros for edit items
561
+  #define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
562
+  #define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
563
+
564
+  #define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
565
+  #define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
566
+  #define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
567
+  #define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
568
+  #define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
569
+  #define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
570
+  #define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
571
+  #define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
572
+  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
573
+
574
+  #define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
575
+  #define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
576
+  #define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
577
+  #define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
578
+  #define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
579
+  #define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
580
+  #define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
581
+  #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
582
+  #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
583
+
584
+  void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
585
+    uint8_t rows = 1;
586
+    uint8_t lcd_width = LCD_WIDTH - (START_COL), char_width = DOG_CHAR_WIDTH;
587
+    uint8_t vallen = lcd_strlen(value);
588
+
589
+    #if ENABLED(USE_BIG_EDIT_FONT)
590
+      if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
591
+        lcd_setFont(FONT_MENU_EDIT);
592
+        lcd_width = LCD_WIDTH_EDIT + 1;
593
+        char_width = DOG_CHAR_WIDTH_EDIT;
594
+        if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
595
+      }
596
+      else {
597
+        lcd_setFont(FONT_MENU);
598
+      }
599
+    #endif
588 600
 
589
-  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
601
+    if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
590 602
 
591
-  const float kHalfChar = (DOG_CHAR_HEIGHT_EDIT) / 2;
592
-  float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
603
+    const float kHalfChar = (DOG_CHAR_HEIGHT_EDIT) / 2;
604
+    float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
593 605
 
594
-  u8g.setPrintPos(0, rowHeight + kHalfChar);
595
-  lcd_printPGM(pstr);
596
-  if (value != NULL) {
597
-    lcd_print(':');
598
-    u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
599
-    lcd_print(value);
606
+    u8g.setPrintPos(0, rowHeight + kHalfChar);
607
+    lcd_printPGM(pstr);
608
+    if (value != NULL) {
609
+      lcd_print(':');
610
+      u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
611
+      lcd_print(value);
612
+    }
600 613
   }
601
-}
602 614
 
603
-#if ENABLED(SDSUPPORT)
615
+  #if ENABLED(SDSUPPORT)
604 616
 
605
-  static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
606
-    UNUSED(pstr);
607
-    char c;
608
-    uint8_t n = LCD_WIDTH - (START_COL) - 1;
617
+    static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
618
+      UNUSED(pstr);
619
+      char c;
620
+      uint8_t n = LCD_WIDTH - (START_COL) - 1;
609 621
 
610
-    if (longFilename[0]) {
611
-      filename = longFilename;
612
-      longFilename[n] = '\0';
613
-    }
622
+      if (longFilename[0]) {
623
+        filename = longFilename;
624
+        longFilename[n] = '\0';
625
+      }
614 626
 
615
-    lcd_implementation_mark_as_selected(row, isSelected);
627
+      lcd_implementation_mark_as_selected(row, isSelected);
616 628
 
617
-    if (isDir) lcd_print(LCD_STR_FOLDER[0]);
618
-    while ((c = *filename)) {
619
-      n -= lcd_print(c);
620
-      filename++;
629
+      if (isDir) lcd_print(LCD_STR_FOLDER[0]);
630
+      while ((c = *filename)) {
631
+        n -= lcd_print(c);
632
+        filename++;
633
+      }
634
+      while (n--) lcd_print(' ');
621 635
     }
622
-    while (n--) lcd_print(' ');
623
-  }
624 636
 
625
-  #define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
626
-  #define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
637
+    #define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
638
+    #define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
627 639
 
628
-#endif //SDSUPPORT
640
+  #endif // SDSUPPORT
629 641
 
630
-#define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
631
-#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
632
-#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
633
-#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
642
+#endif // ULTIPANEL
634 643
 
635 644
 #endif //__ULTRALCD_IMPL_DOGM_H

+ 135
- 129
Marlin/ultralcd_impl_HD44780.h Parādīt failu

@@ -24,9 +24,11 @@
24 24
 #define ULTRALCD_IMPL_HD44780_H
25 25
 
26 26
 /**
27
-* Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
28
-**/
27
+ * Implementation of the LCD display routines for a Hitachi HD44780 display.
28
+ * These are the most common LCD character displays.
29
+ */
29 30
 
31
+#include "utility.h"
30 32
 #include "duration_t.h"
31 33
 
32 34
 extern volatile uint8_t buttons;  //an extended version of the last checked buttons in a bit array.
@@ -787,135 +789,158 @@ static void lcd_implementation_status_screen() {
787 789
   lcd_print(lcd_status_message);
788 790
 }
789 791
 
790
-#if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
792
+#if ENABLED(ULTIPANEL)
793
+
794
+  #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
795
+
796
+    static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char *valstr=NULL) {
797
+      UNUSED(invert);
798
+      char c;
799
+      int8_t n = LCD_WIDTH;
800
+      lcd.setCursor(0, row);
801
+      if (center && !valstr) {
802
+        int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
803
+        while (--pad >= 0) { lcd.print(' '); n--; }
804
+      }
805
+      while (n > 0 && (c = pgm_read_byte(pstr))) {
806
+        n -= lcd_print(c);
807
+        pstr++;
808
+      }
809
+      if (valstr) while (n > 0 && (c = *valstr)) {
810
+        n -= lcd_print(c);
811
+        valstr++;
812
+      }
813
+      while (n-- > 0) lcd.print(' ');
814
+    }
791 815
 
792
-  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char *valstr=NULL) {
793
-    UNUSED(invert);
816
+  #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
817
+
818
+  static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
794 819
     char c;
795
-    int8_t n = LCD_WIDTH;
820
+    uint8_t n = LCD_WIDTH - 2;
796 821
     lcd.setCursor(0, row);
797
-    if (center && !valstr) {
798
-      int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
799
-      while (--pad >= 0) { lcd.print(' '); n--; }
800
-    }
801
-    while (n > 0 && (c = pgm_read_byte(pstr))) {
822
+    lcd.print(sel ? pre_char : ' ');
823
+    while ((c = pgm_read_byte(pstr)) && n > 0) {
802 824
       n -= lcd_print(c);
803 825
       pstr++;
804 826
     }
805
-    if (valstr) while (n > 0 && (c = *valstr)) {
806
-      n -= lcd_print(c);
807
-      valstr++;
808
-    }
809
-    while (n-- > 0) lcd.print(' ');
810
-  }
811
-
812
-#endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
813
-
814
-static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
815
-  char c;
816
-  uint8_t n = LCD_WIDTH - 2;
817
-  lcd.setCursor(0, row);
818
-  lcd.print(sel ? pre_char : ' ');
819
-  while ((c = pgm_read_byte(pstr)) && n > 0) {
820
-    n -= lcd_print(c);
821
-    pstr++;
822
-  }
823
-  while (n--) lcd.print(' ');
824
-  lcd.print(post_char);
825
-}
826
-
827
-static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
828
-  char c;
829
-  uint8_t n = LCD_WIDTH - 2 - lcd_strlen(data);
830
-  lcd.setCursor(0, row);
831
-  lcd.print(sel ? pre_char : ' ');
832
-  while ((c = pgm_read_byte(pstr)) && n > 0) {
833
-    n -= lcd_print(c);
834
-    pstr++;
835
-  }
836
-  lcd.print(':');
837
-  while (n--) lcd.print(' ');
838
-  lcd_print(data);
839
-}
840
-static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
841
-  char c;
842
-  uint8_t n = LCD_WIDTH - 2 - lcd_strlen_P(data);
843
-  lcd.setCursor(0, row);
844
-  lcd.print(sel ? pre_char : ' ');
845
-  while ((c = pgm_read_byte(pstr)) && n > 0) {
846
-    n -= lcd_print(c);
847
-    pstr++;
827
+    while (n--) lcd.print(' ');
828
+    lcd.print(post_char);
848 829
   }
849
-  lcd.print(':');
850
-  while (n--) lcd.print(' ');
851
-  lcd_printPGM(data);
852
-}
853 830
 
854
-#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
855
-#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
856
-#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
857
-#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
858
-#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
859
-#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
860
-#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
861
-#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
862
-#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
863
-
864
-//Add version for callback functions
865
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
866
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
867
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
868
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
869
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
870
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
871
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
872
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
873
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
874
-
875
-void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
876
-  lcd.setCursor(1, 1);
877
-  lcd_printPGM(pstr);
878
-  if (value != NULL) {
831
+  static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
832
+    char c;
833
+    uint8_t n = LCD_WIDTH - 2 - lcd_strlen(data);
834
+    lcd.setCursor(0, row);
835
+    lcd.print(sel ? pre_char : ' ');
836
+    while ((c = pgm_read_byte(pstr)) && n > 0) {
837
+      n -= lcd_print(c);
838
+      pstr++;
839
+    }
879 840
     lcd.print(':');
880
-    lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1);
881
-    lcd_print(value);
841
+    while (n--) lcd.print(' ');
842
+    lcd_print(data);
882 843
   }
883
-}
884
-
885
-#if ENABLED(SDSUPPORT)
886
-
887
-  static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat, char post_char) {
888
-    UNUSED(pstr);
844
+  static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
889 845
     char c;
890
-    uint8_t n = LCD_WIDTH - concat;
846
+    uint8_t n = LCD_WIDTH - 2 - lcd_strlen_P(data);
891 847
     lcd.setCursor(0, row);
892
-    lcd.print(sel ? '>' : ' ');
893
-    if (longFilename[0]) {
894
-      filename = longFilename;
895
-      longFilename[n] = '\0';
896
-    }
897
-    while ((c = *filename) && n > 0) {
848
+    lcd.print(sel ? pre_char : ' ');
849
+    while ((c = pgm_read_byte(pstr)) && n > 0) {
898 850
       n -= lcd_print(c);
899
-      filename++;
851
+      pstr++;
900 852
     }
853
+    lcd.print(':');
901 854
     while (n--) lcd.print(' ');
902
-    lcd.print(post_char);
855
+    lcd_printPGM(data);
903 856
   }
904 857
 
905
-  static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
906
-    lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, ' ');
858
+  #define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
859
+  #define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
860
+  #define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
861
+  #define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
862
+  #define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
863
+  #define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
864
+  #define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
865
+  #define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
866
+  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
867
+
868
+  //Add version for callback functions
869
+  #define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
870
+  #define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
871
+  #define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
872
+  #define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
873
+  #define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
874
+  #define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
875
+  #define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
876
+  #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
877
+  #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
878
+
879
+  void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
880
+    lcd.setCursor(1, 1);
881
+    lcd_printPGM(pstr);
882
+    if (value != NULL) {
883
+      lcd.print(':');
884
+      lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1);
885
+      lcd_print(value);
886
+    }
907 887
   }
908 888
 
909
-  static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
910
-    lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, LCD_STR_FOLDER[0]);
911
-  }
889
+  #if ENABLED(SDSUPPORT)
890
+
891
+    static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat, char post_char) {
892
+      UNUSED(pstr);
893
+      char c;
894
+      uint8_t n = LCD_WIDTH - concat;
895
+      lcd.setCursor(0, row);
896
+      lcd.print(sel ? '>' : ' ');
897
+      if (longFilename[0]) {
898
+        filename = longFilename;
899
+        longFilename[n] = '\0';
900
+      }
901
+      while ((c = *filename) && n > 0) {
902
+        n -= lcd_print(c);
903
+        filename++;
904
+      }
905
+      while (n--) lcd.print(' ');
906
+      lcd.print(post_char);
907
+    }
908
+
909
+    static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
910
+      lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, ' ');
911
+    }
912
+
913
+    static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
914
+      lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, LCD_STR_FOLDER[0]);
915
+    }
916
+
917
+  #endif // SDSUPPORT
918
+
919
+  #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
920
+  #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
921
+  #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
922
+  #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
912 923
 
913
-#endif //SDSUPPORT
924
+  #if ENABLED(LCD_HAS_SLOW_BUTTONS)
914 925
 
915
-#define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
916
-#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
917
-#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
918
-#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
926
+    extern millis_t next_button_update_ms;
927
+
928
+    static uint8_t lcd_implementation_read_slow_buttons() {
929
+      #if ENABLED(LCD_I2C_TYPE_MCP23017)
930
+        // Reading these buttons this is likely to be too slow to call inside interrupt context
931
+        // so they are called during normal lcd_update
932
+        uint8_t slow_bits = lcd.readButtons() << B_I2C_BTN_OFFSET;
933
+        #if ENABLED(LCD_I2C_VIKI)
934
+          if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
935
+            slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
936
+        #endif // LCD_I2C_VIKI
937
+        return slow_bits;
938
+      #endif // LCD_I2C_TYPE_MCP23017
939
+    }
940
+
941
+  #endif // LCD_HAS_SLOW_BUTTONS
942
+
943
+#endif // ULTIPANEL
919 944
 
920 945
 #if ENABLED(LCD_HAS_STATUS_INDICATORS)
921 946
 
@@ -955,23 +980,4 @@ void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
955 980
 
956 981
 #endif // LCD_HAS_STATUS_INDICATORS
957 982
 
958
-#if ENABLED(LCD_HAS_SLOW_BUTTONS)
959
-
960
-  extern millis_t next_button_update_ms;
961
-
962
-  static uint8_t lcd_implementation_read_slow_buttons() {
963
-    #if ENABLED(LCD_I2C_TYPE_MCP23017)
964
-      // Reading these buttons this is likely to be too slow to call inside interrupt context
965
-      // so they are called during normal lcd_update
966
-      uint8_t slow_bits = lcd.readButtons() << B_I2C_BTN_OFFSET;
967
-      #if ENABLED(LCD_I2C_VIKI)
968
-        if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
969
-          slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
970
-      #endif // LCD_I2C_VIKI
971
-      return slow_bits;
972
-    #endif // LCD_I2C_TYPE_MCP23017
973
-  }
974
-
975
-#endif // LCD_HAS_SLOW_BUTTONS
976
-
977 983
 #endif // ULTRALCD_IMPL_HD44780_H

+ 183
- 0
Marlin/utility.cpp Parādīt failu

@@ -32,3 +32,186 @@ void safe_delay(millis_t ms) {
32 32
   }
33 33
   delay(ms);
34 34
 }
35
+
36
+#if ENABLED(ULTRA_LCD)
37
+
38
+  char conv[8];
39
+
40
+  #define DIGIT(n) ('0' + (n))
41
+  #define DIGIMOD(n, f) DIGIT((n)/(f) % 10)
42
+  #define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
43
+  #define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
44
+
45
+  // Convert unsigned int to string with 12 format
46
+  char* itostr2(const uint8_t& x) {
47
+    int xx = x;
48
+    conv[0] = DIGIMOD(xx, 10);
49
+    conv[1] = DIGIMOD(xx, 1);
50
+    conv[2] = '\0';
51
+    return conv;
52
+  }
53
+
54
+  // Convert signed int to rj string with 123 or -12 format
55
+  char* itostr3(const int& x) {
56
+    int xx = x;
57
+    conv[0] = MINUSOR(xx, RJDIGIT(xx, 100));
58
+    conv[1] = RJDIGIT(xx, 10);
59
+    conv[2] = DIGIMOD(xx, 1);
60
+    conv[3] = '\0';
61
+    return conv;
62
+  }
63
+
64
+  // Convert unsigned int to lj string with 123 format
65
+  char* itostr3left(const int& xx) {
66
+    char *str = &conv[3];
67
+    *str = '\0';
68
+    *(--str) = DIGIMOD(xx, 1);
69
+    if (xx >= 10) {
70
+      *(--str) = DIGIMOD(xx, 10);
71
+      if (xx >= 100)
72
+        *(--str) = DIGIMOD(xx, 100);
73
+    }
74
+    return str;
75
+  }
76
+
77
+  // Convert signed int to rj string with _123, -123, _-12, or __-1 format
78
+  char *itostr4sign(const int& x) {
79
+    int xx = abs(x), sign = 0;
80
+    if (xx >= 100) {
81
+      conv[1] = DIGIMOD(xx, 100);
82
+      conv[2] = DIGIMOD(xx, 10);
83
+    }
84
+    else {
85
+      conv[0] = ' ';
86
+      if (xx >= 10) {
87
+        sign = 1;
88
+        conv[2] = DIGIMOD(xx, 10);
89
+      }
90
+      else {
91
+        conv[1] = ' ';
92
+        sign = 2;
93
+      }
94
+    }
95
+    conv[sign] = x < 0 ? '-' : ' ';
96
+    conv[3] = DIGIMOD(xx, 1);
97
+    conv[4] = '\0';
98
+    return conv;
99
+  }
100
+
101
+  // Convert unsigned float to string with 1.23 format
102
+  char* ftostr12ns(const float& x) {
103
+    long xx = abs(x * 100);
104
+    conv[0] = DIGIMOD(xx, 100);
105
+    conv[1] = '.';
106
+    conv[2] = DIGIMOD(xx, 10);
107
+    conv[3] = DIGIMOD(xx, 1);
108
+    conv[4] = '\0';
109
+    return conv;
110
+  }
111
+
112
+  // Convert signed float to fixed-length string with 023.45 / -23.45 format
113
+  char *ftostr32(const float& x) {
114
+    long xx = x * 100;
115
+    conv[0] = MINUSOR(xx, DIGIMOD(xx, 10000));
116
+    conv[1] = DIGIMOD(xx, 1000);
117
+    conv[2] = DIGIMOD(xx, 100);
118
+    conv[3] = '.';
119
+    conv[4] = DIGIMOD(xx, 10);
120
+    conv[5] = DIGIMOD(xx, 1);
121
+    conv[6] = '\0';
122
+    return conv;
123
+  }
124
+
125
+  // Convert float to fixed-length string with +123.4 / -123.4 format
126
+  char* ftostr41sign(const float& x) {
127
+    int xx = x * 10;
128
+    conv[0] = MINUSOR(xx, '+');
129
+    conv[1] = DIGIMOD(xx, 1000);
130
+    conv[2] = DIGIMOD(xx, 100);
131
+    conv[3] = DIGIMOD(xx, 10);
132
+    conv[4] = '.';
133
+    conv[5] = DIGIMOD(xx, 1);
134
+    conv[6] = '\0';
135
+    return conv;
136
+  }
137
+
138
+  // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
139
+  char* ftostr43sign(const float& x, char plus/*=' '*/) {
140
+    long xx = x * 1000;
141
+    conv[0] = xx ? MINUSOR(xx, plus) : ' ';
142
+    conv[1] = DIGIMOD(xx, 1000);
143
+    conv[2] = '.';
144
+    conv[3] = DIGIMOD(xx, 100);
145
+    conv[4] = DIGIMOD(xx, 10);
146
+    conv[5] = DIGIMOD(xx, 1);
147
+    conv[6] = '\0';
148
+    return conv;
149
+  }
150
+
151
+  // Convert unsigned float to rj string with 12345 format
152
+  char* ftostr5rj(const float& x) {
153
+    long xx = abs(x);
154
+    conv[0] = RJDIGIT(xx, 10000);
155
+    conv[1] = RJDIGIT(xx, 1000);
156
+    conv[2] = RJDIGIT(xx, 100);
157
+    conv[3] = RJDIGIT(xx, 10);
158
+    conv[4] = DIGIMOD(xx, 1);
159
+    conv[5] = '\0';
160
+    return conv;
161
+  }
162
+
163
+  // Convert signed float to string with +1234.5 format
164
+  char* ftostr51sign(const float& x) {
165
+    long xx = x * 10;
166
+    conv[0] = MINUSOR(xx, '+');
167
+    conv[1] = DIGIMOD(xx, 10000);
168
+    conv[2] = DIGIMOD(xx, 1000);
169
+    conv[3] = DIGIMOD(xx, 100);
170
+    conv[4] = DIGIMOD(xx, 10);
171
+    conv[5] = '.';
172
+    conv[6] = DIGIMOD(xx, 1);
173
+    conv[7] = '\0';
174
+    return conv;
175
+  }
176
+
177
+  // Convert signed float to string with +123.45 format
178
+  char* ftostr52sign(const float& x) {
179
+    long xx = x * 100;
180
+    conv[0] = MINUSOR(xx, '+');
181
+    conv[1] = DIGIMOD(xx, 10000);
182
+    conv[2] = DIGIMOD(xx, 1000);
183
+    conv[3] = DIGIMOD(xx, 100);
184
+    conv[4] = '.';
185
+    conv[5] = DIGIMOD(xx, 10);
186
+    conv[6] = DIGIMOD(xx, 1);
187
+    conv[7] = '\0';
188
+    return conv;
189
+  }
190
+
191
+  // Convert signed float to space-padded string with -_23.4_ format
192
+  char* ftostr52sp(const float& x) {
193
+    long xx = x * 100;
194
+    uint8_t dig;
195
+    conv[0] = MINUSOR(xx, RJDIGIT(xx, 10000));
196
+    conv[1] = RJDIGIT(xx, 1000);
197
+    conv[2] = DIGIMOD(xx, 100);
198
+
199
+    if ((dig = xx % 10)) {          // second digit after decimal point?
200
+      conv[3] = '.';
201
+      conv[4] = DIGIMOD(xx, 10);
202
+      conv[5] = DIGIT(dig);
203
+    }
204
+    else {
205
+      if ((dig = (xx / 10) % 10)) { // first digit after decimal point?
206
+        conv[3] = '.';
207
+        conv[4] = DIGIT(dig);
208
+      }
209
+      else                          // nothing after decimal point
210
+        conv[3] = conv[4] = ' ';
211
+      conv[5] = ' ';
212
+    }
213
+    conv[6] = '\0';
214
+    return conv;
215
+  }
216
+
217
+#endif // ULTRA_LCD

+ 47
- 1
Marlin/utility.h Parādīt failu

@@ -25,4 +25,50 @@
25 25
 
26 26
 void safe_delay(millis_t ms);
27 27
 
28
-#endif
28
+#if ENABLED(ULTRA_LCD)
29
+
30
+  // Convert unsigned int to string with 12 format
31
+  char* itostr2(const uint8_t& x);
32
+
33
+  // Convert signed int to rj string with 123 or -12 format
34
+  char* itostr3(const int& x);
35
+
36
+  // Convert unsigned int to lj string with 123 format
37
+  char* itostr3left(const int& xx);
38
+
39
+  // Convert signed int to rj string with _123, -123, _-12, or __-1 format
40
+  char *itostr4sign(const int& x);
41
+
42
+  // Convert unsigned float to string with 1.23 format
43
+  char* ftostr12ns(const float& x);
44
+
45
+  // Convert signed float to fixed-length string with 023.45 / -23.45 format
46
+  char *ftostr32(const float& x);
47
+
48
+  // Convert float to fixed-length string with +123.4 / -123.4 format
49
+  char* ftostr41sign(const float& x);
50
+
51
+  // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
52
+  char* ftostr43sign(const float& x, char plus=' ');
53
+
54
+  // Convert unsigned float to rj string with 12345 format
55
+  char* ftostr5rj(const float& x);
56
+
57
+  // Convert signed float to string with +1234.5 format
58
+  char* ftostr51sign(const float& x);
59
+
60
+  // Convert signed float to space-padded string with -_23.4_ format
61
+  char* ftostr52sp(const float& x);
62
+
63
+  // Convert signed float to string with +123.45 format
64
+  char* ftostr52sign(const float& x);
65
+
66
+  // Convert float to rj string with 123 or -12 format
67
+  FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); }
68
+
69
+  // Convert float to rj string with _123, -123, _-12, or __-1 format
70
+  FORCE_INLINE char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
71
+
72
+#endif // ULTRA_LCD
73
+
74
+#endif // __UTILITY_H__

Notiek ielāde…
Atcelt
Saglabāt