Browse Source

Save up to 94 bytes of RAM on 20x4 LCD Display machines (#6964)

* Save up to 94 bytes of RAM on 20x4 LCD Display machines

Moved the custom screen characters out of RAM into Program Memory.  With
SD-Card support and the Progress Bar enabled, this saves 94 bytes of RAM
memory.

This was tested using the example_configurations/FolgerTech-i3-2020
files.  So a couple small changes to those files snuck into this Pull
Request.

Probably...  We can find similar savings in the Graphics LCD code it we
comb through it.   And if so...  That is the place we really need to
save RAM memory!

* Tidy up white space and indentation
Roxy-3D 8 years ago
parent
commit
0dd0033b33

+ 7
- 7
Marlin/Conditionals_LCD.h View File

241
     #define LCD_STR_FILAM_MUL   "\xa4"
241
     #define LCD_STR_FILAM_MUL   "\xa4"
242
   #else
242
   #else
243
     /* Custom characters defined in the first 8 characters of the LCD */
243
     /* Custom characters defined in the first 8 characters of the LCD */
244
-    #define LCD_STR_BEDTEMP     "\x00"  // Print only as a char. This will have 'unexpected' results when used in a string!
245
-    #define LCD_STR_DEGREE      "\x01"
246
-    #define LCD_STR_THERMOMETER "\x02"
247
-    #define LCD_STR_UPLEVEL     "\x03"
248
-    #define LCD_STR_REFRESH     "\x04"
244
+    #define LCD_BEDTEMP_CHAR     0x00  // Print only as a char. This will have 'unexpected' results when used in a string!
245
+    #define LCD_DEGREE_CHAR      0x01
246
+    #define LCD_STR_THERMOMETER "\x02" // Too many places use preprocessor string concatination to change this to a char right now.
247
+    #define LCD_UPLEVEL_CHAR     0x03
248
+    #define LCD_REFRESH_CHAR     0x04
249
     #define LCD_STR_FOLDER      "\x05"
249
     #define LCD_STR_FOLDER      "\x05"
250
-    #define LCD_STR_FEEDRATE    "\x06"
251
-    #define LCD_STR_CLOCK       "\x07"
250
+    #define LCD_FEEDRATE_CHAR    0x06
251
+    #define LCD_CLOCK_CHAR       0x07
252
     #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
252
     #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
253
   #endif
253
   #endif
254
 
254
 

+ 1
- 1
Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h View File

649
  */
649
  */
650
 #define X_PROBE_OFFSET_FROM_EXTRUDER 38     // X offset: -left  +right  [of the nozzle]
650
 #define X_PROBE_OFFSET_FROM_EXTRUDER 38     // X offset: -left  +right  [of the nozzle]
651
 #define Y_PROBE_OFFSET_FROM_EXTRUDER -7     // Y offset: -front +behind [the nozzle]
651
 #define Y_PROBE_OFFSET_FROM_EXTRUDER -7     // Y offset: -front +behind [the nozzle]
652
-#define Z_PROBE_OFFSET_FROM_EXTRUDER -10.1  // Z offset: -below +above  [the nozzle]
652
+#define Z_PROBE_OFFSET_FROM_EXTRUDER -10.4  // Z offset: -below +above  [the nozzle]
653
 
653
 
654
 // X and Y axis travel speed (mm/m) between probes
654
 // X and Y axis travel speed (mm/m) between probes
655
 #define XY_PROBE_SPEED 7500
655
 #define XY_PROBE_SPEED 7500

+ 2
- 2
Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h View File

509
   #endif
509
   #endif
510
 
510
 
511
   // Show a progress bar on HD44780 LCDs for SD printing
511
   // Show a progress bar on HD44780 LCDs for SD printing
512
-  //#define LCD_PROGRESS_BAR
512
+  #define LCD_PROGRESS_BAR
513
 
513
 
514
   #if ENABLED(LCD_PROGRESS_BAR)
514
   #if ENABLED(LCD_PROGRESS_BAR)
515
     // Amount of time (ms) to show the bar
515
     // Amount of time (ms) to show the bar
1228
  *  - M206 and M428 are disabled.
1228
  *  - M206 and M428 are disabled.
1229
  *  - G92 will revert to its behavior from Marlin 1.0.
1229
  *  - G92 will revert to its behavior from Marlin 1.0.
1230
  */
1230
  */
1231
-//#define NO_WORKSPACE_OFFSETS
1231
+#define NO_WORKSPACE_OFFSETS
1232
 
1232
 
1233
 /**
1233
 /**
1234
  * Set the number of proportional font spaces required to fill up a typical character space.
1234
  * Set the number of proportional font spaces required to fill up a typical character space.

+ 67
- 44
Marlin/ultralcd_impl_HD44780.h View File

193
   static void lcd_implementation_update_indicators();
193
   static void lcd_implementation_update_indicators();
194
 #endif
194
 #endif
195
 
195
 
196
-static void lcd_set_custom_characters(
197
-  #if ENABLED(LCD_PROGRESS_BAR)
198
-    const bool info_screen_charset = true
199
-  #endif
200
-) {
201
-  static byte bedTemp[8] = {
196
+
197
+static void createChar_P(char c, PROGMEM byte *ptr) {
198
+  byte temp[8];
199
+  int8_t i;
200
+
201
+  for(i=0; i<8; i++)  {
202
+    temp[i] = pgm_read_byte(&ptr[i]);
203
+  }
204
+  lcd.createChar(c, temp);
205
+}
206
+
207
+const static PROGMEM byte bedTemp[8] = {
202
     B00000,
208
     B00000,
203
     B11111,
209
     B11111,
204
     B10101,
210
     B10101,
207
     B11111,
213
     B11111,
208
     B00000,
214
     B00000,
209
     B00000
215
     B00000
210
-  }; //thanks Sonny Mounicou
211
-  static byte degree[8] = {
216
+};
217
+
218
+const static PROGMEM byte degree[8] = {
212
     B01100,
219
     B01100,
213
     B10010,
220
     B10010,
214
     B10010,
221
     B10010,
218
     B00000,
225
     B00000,
219
     B00000
226
     B00000
220
   };
227
   };
221
-  static byte thermometer[8] = {
228
+
229
+const static PROGMEM byte thermometer[8] = {
222
     B00100,
230
     B00100,
223
     B01010,
231
     B01010,
224
     B01010,
232
     B01010,
228
     B10001,
236
     B10001,
229
     B01110
237
     B01110
230
   };
238
   };
231
-  static byte uplevel[8] = {
239
+
240
+const static PROGMEM byte uplevel[8] = {
232
     B00100,
241
     B00100,
233
     B01110,
242
     B01110,
234
     B11111,
243
     B11111,
237
     B00000,
246
     B00000,
238
     B00000,
247
     B00000,
239
     B00000
248
     B00000
240
-  }; //thanks joris
241
-  static byte feedrate[8] = {
249
+};
250
+
251
+const static PROGMEM byte feedrate[8] = {
242
     B11100,
252
     B11100,
243
     B10000,
253
     B10000,
244
     B11000,
254
     B11000,
247
     B00110,
257
     B00110,
248
     B00101,
258
     B00101,
249
     B00000
259
     B00000
250
-  }; //thanks Sonny Mounicou
251
-  static byte clock[8] = {
260
+};
261
+
262
+const static PROGMEM byte clock[8] = {
252
     B00000,
263
     B00000,
253
     B01110,
264
     B01110,
254
     B10011,
265
     B10011,
257
     B01110,
268
     B01110,
258
     B00000,
269
     B00000,
259
     B00000
270
     B00000
260
-  }; //thanks Sonny Mounicou
271
+};
261
 
272
 
262
-  lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
263
-  lcd.createChar(LCD_STR_DEGREE[0], degree);
264
-  lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
265
-  lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
266
-  lcd.createChar(LCD_STR_CLOCK[0], clock);
267
-
268
-  #if ENABLED(SDSUPPORT)
269
-    static byte refresh[8] = {
273
+#if ENABLED(SDSUPPORT)
274
+  const static PROGMEM byte refresh[8] = {
270
       B00000,
275
       B00000,
271
       B00110,
276
       B00110,
272
       B11001,
277
       B11001,
275
       B10011,
280
       B10011,
276
       B01100,
281
       B01100,
277
       B00000,
282
       B00000,
278
-    }; //thanks joris
279
-    static byte folder[8] = {
283
+  };
284
+  const static PROGMEM byte folder[8] = {
280
       B00000,
285
       B00000,
281
       B11100,
286
       B11100,
282
       B11111,
287
       B11111,
285
       B11111,
290
       B11111,
286
       B00000,
291
       B00000,
287
       B00000
292
       B00000
288
-    }; //thanks joris
293
+  };
289
 
294
 
290
-    #if ENABLED(LCD_PROGRESS_BAR)
291
-      static byte progress[3][8] = { {
295
+  #if ENABLED(LCD_PROGRESS_BAR)
296
+    const static PROGMEM byte progress[3][8] = { {
292
         B00000,
297
         B00000,
293
         B10000,
298
         B10000,
294
         B10000,
299
         B10000,
316
         B10101,
321
         B10101,
317
         B00000
322
         B00000
318
       } };
323
       } };
324
+  #endif
325
+#endif
326
+
327
+static void lcd_set_custom_characters(
328
+  #if ENABLED(LCD_PROGRESS_BAR)
329
+    const bool info_screen_charset = true
330
+  #endif
331
+) {
332
+
333
+  createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
334
+  createChar_P(LCD_DEGREE_CHAR, degree);
335
+  createChar_P(LCD_STR_THERMOMETER[0], thermometer);
336
+  createChar_P(LCD_FEEDRATE_CHAR, feedrate);
337
+  createChar_P(LCD_CLOCK_CHAR, clock);
338
+
339
+  #if ENABLED(SDSUPPORT)
340
+    #if ENABLED(LCD_PROGRESS_BAR)
319
       static bool char_mode = false;
341
       static bool char_mode = false;
320
       if (info_screen_charset != char_mode) {
342
       if (info_screen_charset != char_mode) {
321
         char_mode = info_screen_charset;
343
         char_mode = info_screen_charset;
322
         if (info_screen_charset) { // Progress bar characters for info screen
344
         if (info_screen_charset) { // Progress bar characters for info screen
323
-          for (int i = 3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
345
+          for (int i = 3; i--;) createChar_P(LCD_STR_PROGRESS[i], progress[i]);
324
         }
346
         }
325
         else { // Custom characters for submenus
347
         else { // Custom characters for submenus
326
-          lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
327
-          lcd.createChar(LCD_STR_REFRESH[0], refresh);
328
-          lcd.createChar(LCD_STR_FOLDER[0], folder);
348
+          createChar_P(LCD_UPLEVEL_CHAR, uplevel);
349
+          createChar_P(LCD_REFRESH_CHAR, refresh);
350
+          createChar_P(LCD_STR_FOLDER[0], folder);
329
         }
351
         }
330
       }
352
       }
331
     #else
353
     #else
332
-      lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
333
-      lcd.createChar(LCD_STR_REFRESH[0], refresh);
334
-      lcd.createChar(LCD_STR_FOLDER[0], folder);
354
+      createChar_P(LCD_UPLEVEL_CHAR, uplevel);
355
+      createChar_P(LCD_REFRESH_CHAR, refresh);
356
+      createChar_P(LCD_STR_FOLDER[0], folder);
335
     #endif
357
     #endif
336
 
358
 
337
   #else
359
   #else
338
-    lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
360
+    createChar_P(LCD_UPLEVEL_CHAR, uplevel);
339
   #endif
361
   #endif
340
 }
362
 }
341
 
363
 
607
       lcd.print(itostr3left(t2 + 0.5));
629
       lcd.print(itostr3left(t2 + 0.5));
608
 
630
 
609
   if (prefix >= 0) {
631
   if (prefix >= 0) {
610
-    lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
632
+    lcd.print((char)LCD_DEGREE_CHAR);
633
+    lcd.print(' ');
611
     if (t2 < 10) lcd.print(' ');
634
     if (t2 < 10) lcd.print(' ');
612
   }
635
   }
613
 }
636
 }
677
 
700
 
678
       lcd.setCursor(8, 0);
701
       lcd.setCursor(8, 0);
679
       #if HOTENDS > 1
702
       #if HOTENDS > 1
680
-        lcd.print(LCD_STR_THERMOMETER[0]);
703
+        lcd.print((CHAR)LCD_STR_THERMOMETER[0]);
681
         _draw_heater_status(1, -1, blink);
704
         _draw_heater_status(1, -1, blink);
682
       #else
705
       #else
683
-        lcd.print(LCD_STR_BEDTEMP[0]);
706
+        lcd.print((CHAR)LCD_BEDTEMP_CHAR);
684
         _draw_heater_status(-1, -1, blink);
707
         _draw_heater_status(-1, -1, blink);
685
       #endif
708
       #endif
686
 
709
 
701
       #if HOTENDS > 1
724
       #if HOTENDS > 1
702
         _draw_heater_status(1, LCD_STR_THERMOMETER[0], blink);
725
         _draw_heater_status(1, LCD_STR_THERMOMETER[0], blink);
703
       #else
726
       #else
704
-        _draw_heater_status(-1, LCD_STR_BEDTEMP[0], blink);
727
+        _draw_heater_status(-1, LCD_BEDTEMP_CHAR, blink);
705
       #endif
728
       #endif
706
 
729
 
707
     #endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
730
     #endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
735
         // If we both have a 2nd extruder and a heated bed,
758
         // If we both have a 2nd extruder and a heated bed,
736
         // show the heated bed temp on the left,
759
         // show the heated bed temp on the left,
737
         // since the first line is filled with extruder temps
760
         // since the first line is filled with extruder temps
738
-      _draw_heater_status(-1, LCD_STR_BEDTEMP[0], blink);
761
+      _draw_heater_status(-1, LCD_BEDTEMP_CHAR, blink);
739
 
762
 
740
       #else
763
       #else
741
         // Before homing the axis letters are blinking 'X' <-> '?'.
764
         // Before homing the axis letters are blinking 'X' <-> '?'.
767
   #if LCD_HEIGHT > 3
790
   #if LCD_HEIGHT > 3
768
 
791
 
769
     lcd.setCursor(0, 2);
792
     lcd.setCursor(0, 2);
770
-    lcd.print(LCD_STR_FEEDRATE[0]);
793
+    lcd.print((char)LCD_FEEDRATE_CHAR);
771
     lcd.print(itostr3(feedrate_percentage));
794
     lcd.print(itostr3(feedrate_percentage));
772
     lcd.print('%');
795
     lcd.print('%');
773
 
796
 
788
     uint8_t len = elapsed.toDigital(buffer);
811
     uint8_t len = elapsed.toDigital(buffer);
789
 
812
 
790
     lcd.setCursor(LCD_WIDTH - len - 1, 2);
813
     lcd.setCursor(LCD_WIDTH - len - 1, 2);
791
-    lcd.print(LCD_STR_CLOCK[0]);
814
+    lcd.print((char)LCD_CLOCK_CHAR);
792
     lcd_print(buffer);
815
     lcd_print(buffer);
793
 
816
 
794
   #endif // LCD_HEIGHT > 3
817
   #endif // LCD_HEIGHT > 3
980
 
1003
 
981
   #endif // SDSUPPORT
1004
   #endif // SDSUPPORT
982
 
1005
 
983
-  #define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
1006
+  #define lcd_implementation_drawmenu_back(sel, row, pstr, dummy) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_UPLEVEL_CHAR,LCD_UPLEVEL_CHAR)
984
   #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
1007
   #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
985
   #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
1008
   #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
986
   #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
1009
   #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')

Loading…
Cancel
Save