Bladeren bron

Use const parameters instead of static casting

Alternative fix to #3149
Scott Lahteine 8 jaren geleden
bovenliggende
commit
c97c2dcaf7
4 gewijzigde bestanden met toevoegingen van 8 en 8 verwijderingen
  1. 2
    2
      Marlin/dogm_lcd_implementation.h
  2. 3
    3
      Marlin/ultralcd.cpp
  3. 1
    1
      Marlin/ultralcd.h
  4. 2
    2
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 2
- 2
Marlin/dogm_lcd_implementation.h Bestand weergeven

@@ -169,7 +169,7 @@ char lcd_print(char c) {
169 169
   }
170 170
 }
171 171
 
172
-char lcd_print(char* str) {
172
+char lcd_print(const char* str) {
173 173
   char c;
174 174
   int i = 0;
175 175
   char n = 0;
@@ -508,7 +508,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
508 508
 #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, ftostr5(*(data)))
509 509
 #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))
510 510
 
511
-void lcd_implementation_drawedit(const char* pstr, char* value) {
511
+void lcd_implementation_drawedit(const char* pstr, const char* value) {
512 512
   uint8_t rows = 1;
513 513
   uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
514 514
   uint8_t vallen = lcd_strlen(value);

+ 3
- 3
Marlin/ultralcd.cpp Bestand weergeven

@@ -516,7 +516,7 @@ void lcd_set_home_offsets() {
516 516
         babystepsTodo[axis] += distance;
517 517
       #endif
518 518
     }
519
-    if (lcdDrawUpdate) lcd_implementation_drawedit(msg, (char*)"");
519
+    if (lcdDrawUpdate) lcd_implementation_drawedit(msg, PSTR(""));
520 520
     if (LCD_CLICKED) lcd_goto_previous_menu();
521 521
   }
522 522
 
@@ -1715,7 +1715,7 @@ void lcd_init() {
1715 1715
   #endif
1716 1716
 }
1717 1717
 
1718
-int lcd_strlen(char* s) {
1718
+int lcd_strlen(const char* s) {
1719 1719
   int i = 0, j = 0;
1720 1720
   while (s[i]) {
1721 1721
     if ((s[i] & 0xc0) != 0x80) j++;
@@ -2397,7 +2397,7 @@ char* ftostr52(const float& x) {
2397 2397
    * MBL Move to mesh starting point
2398 2398
    */
2399 2399
   static void _lcd_level_bed_homing() {
2400
-    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), (char*)"Homing");
2400
+    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), PSTR("Homing"));
2401 2401
     if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) {
2402 2402
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2403 2403
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);

+ 1
- 1
Marlin/ultralcd.h Bestand weergeven

@@ -5,7 +5,7 @@
5 5
 #if ENABLED(ULTRA_LCD)
6 6
   #include "buzzer.h"
7 7
 
8
-  int lcd_strlen(char* s);
8
+  int lcd_strlen(const char* s);
9 9
   int lcd_strlen_P(const char* s);
10 10
   void lcd_update();
11 11
   void lcd_init();

+ 2
- 2
Marlin/ultralcd_implementation_hitachi_HD44780.h Bestand weergeven

@@ -407,7 +407,7 @@ char lcd_printPGM(const char* str) {
407 407
   return n;
408 408
 }
409 409
 
410
-char lcd_print(char* str) {
410
+char lcd_print(const char* str) {
411 411
   char c, n = 0;
412 412
   unsigned char i = 0;
413 413
   while ((c = str[i++])) n += charset_mapper(c);
@@ -825,7 +825,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t
825 825
 #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, '>', ftostr5(*(data)))
826 826
 #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))
827 827
 
828
-void lcd_implementation_drawedit(const char* pstr, char* value) {
828
+void lcd_implementation_drawedit(const char* pstr, const char* value) {
829 829
   lcd.setCursor(1, 1);
830 830
   lcd_printPGM(pstr);
831 831
   lcd.print(':');

Laden…
Annuleren
Opslaan