Browse Source

Save bytes for custom chars (Hitachi LCD)

Scott Lahteine 8 years ago
parent
commit
e47c8b9829
2 changed files with 106 additions and 104 deletions
  1. 15
    12
      Marlin/ultralcd.cpp
  2. 91
    92
      Marlin/ultralcd_impl_HD44780.h

+ 15
- 12
Marlin/ultralcd.cpp View File

@@ -486,8 +486,8 @@ static void lcd_status_screen() {
486 486
     if (current_click) {
487 487
       lcd_goto_screen(lcd_main_menu, true);
488 488
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
489
-        #if ENABLED(LCD_PROGRESS_BAR) && ENABLED(ULTIPANEL)
490
-          currentScreen == lcd_status_screen
489
+        #if ENABLED(LCD_PROGRESS_BAR)
490
+          false
491 491
         #endif
492 492
       );
493 493
       #if ENABLED(FILAMENT_LCD_DISPLAY)
@@ -2377,12 +2377,15 @@ void kill_screen(const char* lcd_msg) {
2377 2377
     (*callback)();
2378 2378
   }
2379 2379
 
2380
-#endif //ULTIPANEL
2380
+#endif // ULTIPANEL
2381 2381
 
2382
-/** LCD API **/
2383 2382
 void lcd_init() {
2384 2383
 
2385
-  lcd_implementation_init();
2384
+  lcd_implementation_init(
2385
+    #if ENABLED(LCD_PROGRESS_BAR)
2386
+      true
2387
+    #endif
2388
+  );
2386 2389
 
2387 2390
   #if ENABLED(NEWPANEL)
2388 2391
     #if BUTTON_EXISTS(EN1)
@@ -2537,12 +2540,7 @@ void lcd_update() {
2537 2540
 
2538 2541
     bool sd_status = IS_SD_INSERTED;
2539 2542
     if (sd_status != lcd_sd_status && lcd_detected()) {
2540
-      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2541
-      lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
2542
-        #if ENABLED(LCD_PROGRESS_BAR) && ENABLED(ULTIPANEL)
2543
-          currentScreen == lcd_status_screen
2544
-        #endif
2545
-      );
2543
+      lcd_sd_status = sd_status;
2546 2544
 
2547 2545
       if (sd_status) {
2548 2546
         card.initsd();
@@ -2553,7 +2551,12 @@ void lcd_update() {
2553 2551
         if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
2554 2552
       }
2555 2553
 
2556
-      lcd_sd_status = sd_status;
2554
+      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2555
+      lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
2556
+        #if ENABLED(LCD_PROGRESS_BAR)
2557
+          currentScreen == lcd_status_screen
2558
+        #endif
2559
+      );
2557 2560
     }
2558 2561
 
2559 2562
   #endif //SDSUPPORT && SD_DETECT_PIN

+ 91
- 92
Marlin/ultralcd_impl_HD44780.h View File

@@ -189,10 +189,10 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
189 189
 
190 190
 static void lcd_set_custom_characters(
191 191
   #if ENABLED(LCD_PROGRESS_BAR)
192
-    bool progress_bar_set = true
192
+    bool info_screen_charset = true
193 193
   #endif
194 194
 ) {
195
-  byte bedTemp[8] = {
195
+  static byte bedTemp[8] = {
196 196
     B00000,
197 197
     B11111,
198 198
     B10101,
@@ -202,7 +202,7 @@ static void lcd_set_custom_characters(
202 202
     B00000,
203 203
     B00000
204 204
   }; //thanks Sonny Mounicou
205
-  byte degree[8] = {
205
+  static byte degree[8] = {
206 206
     B01100,
207 207
     B10010,
208 208
     B10010,
@@ -212,7 +212,7 @@ static void lcd_set_custom_characters(
212 212
     B00000,
213 213
     B00000
214 214
   };
215
-  byte thermometer[8] = {
215
+  static byte thermometer[8] = {
216 216
     B00100,
217 217
     B01010,
218 218
     B01010,
@@ -222,37 +222,7 @@ static void lcd_set_custom_characters(
222 222
     B10001,
223 223
     B01110
224 224
   };
225
-  byte uplevel[8] = {
226
-    B00100,
227
-    B01110,
228
-    B11111,
229
-    B00100,
230
-    B11100,
231
-    B00000,
232
-    B00000,
233
-    B00000
234
-  }; //thanks joris
235
-  byte refresh[8] = {
236
-    B00000,
237
-    B00110,
238
-    B11001,
239
-    B11000,
240
-    B00011,
241
-    B10011,
242
-    B01100,
243
-    B00000,
244
-  }; //thanks joris
245
-  byte folder[8] = {
246
-    B00000,
247
-    B11100,
248
-    B11111,
249
-    B10001,
250
-    B10001,
251
-    B11111,
252
-    B00000,
253
-    B00000
254
-  }; //thanks joris
255
-  byte feedrate[8] = {
225
+  static byte feedrate[8] = {
256 226
     B11100,
257 227
     B10000,
258 228
     B11000,
@@ -262,7 +232,7 @@ static void lcd_set_custom_characters(
262 232
     B00101,
263 233
     B00000
264 234
   }; //thanks Sonny Mounicou
265
-  byte clock[8] = {
235
+  static byte clock[8] = {
266 236
     B00000,
267 237
     B01110,
268 238
     B10011,
@@ -273,69 +243,97 @@ static void lcd_set_custom_characters(
273 243
     B00000
274 244
   }; //thanks Sonny Mounicou
275 245
 
276
-  #if ENABLED(LCD_PROGRESS_BAR)
277
-    static bool char_mode = false;
278
-    byte progress[3][8] = { {
246
+  lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
247
+  lcd.createChar(LCD_STR_DEGREE[0], degree);
248
+  lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
249
+  lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
250
+  lcd.createChar(LCD_STR_CLOCK[0], clock);
251
+
252
+  #if ENABLED(SDSUPPORT)
253
+    static byte uplevel[8] = {
254
+      B00100,
255
+      B01110,
256
+      B11111,
257
+      B00100,
258
+      B11100,
279 259
       B00000,
280
-      B10000,
281
-      B10000,
282
-      B10000,
283
-      B10000,
284
-      B10000,
285
-      B10000,
286
-      B00000
287
-    }, {
288 260
       B00000,
289
-      B10100,
290
-      B10100,
291
-      B10100,
292
-      B10100,
293
-      B10100,
294
-      B10100,
295 261
       B00000
296
-    }, {
262
+    }; //thanks joris
263
+    static byte refresh[8] = {
264
+      B00000,
265
+      B00110,
266
+      B11001,
267
+      B11000,
268
+      B00011,
269
+      B10011,
270
+      B01100,
271
+      B00000,
272
+    }; //thanks joris
273
+    static byte folder[8] = {
274
+      B00000,
275
+      B11100,
276
+      B11111,
277
+      B10001,
278
+      B10001,
279
+      B11111,
297 280
       B00000,
298
-      B10101,
299
-      B10101,
300
-      B10101,
301
-      B10101,
302
-      B10101,
303
-      B10101,
304 281
       B00000
305
-    } };
306
-    if (progress_bar_set != char_mode) {
307
-      char_mode = progress_bar_set;
308
-      lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
309
-      lcd.createChar(LCD_STR_DEGREE[0], degree);
310
-      lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
311
-      lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
312
-      lcd.createChar(LCD_STR_CLOCK[0], clock);
313
-      if (progress_bar_set) {
314
-        // Progress bar characters for info screen
315
-        for (int i = 3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
316
-      }
317
-      else {
318
-        // Custom characters for submenus
319
-        lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
320
-        lcd.createChar(LCD_STR_REFRESH[0], refresh);
321
-        lcd.createChar(LCD_STR_FOLDER[0], folder);
282
+    }; //thanks joris
283
+
284
+    #if ENABLED(LCD_PROGRESS_BAR)
285
+      static byte progress[3][8] = { {
286
+        B00000,
287
+        B10000,
288
+        B10000,
289
+        B10000,
290
+        B10000,
291
+        B10000,
292
+        B10000,
293
+        B00000
294
+      }, {
295
+        B00000,
296
+        B10100,
297
+        B10100,
298
+        B10100,
299
+        B10100,
300
+        B10100,
301
+        B10100,
302
+        B00000
303
+      }, {
304
+        B00000,
305
+        B10101,
306
+        B10101,
307
+        B10101,
308
+        B10101,
309
+        B10101,
310
+        B10101,
311
+        B00000
312
+      } };
313
+      static bool char_mode = false;
314
+      if (info_screen_charset != char_mode) {
315
+        char_mode = info_screen_charset;
316
+        if (info_screen_charset) { // Progress bar characters for info screen
317
+          for (int i = 3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
318
+        }
319
+        else { // Custom characters for submenus
320
+          lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
321
+          lcd.createChar(LCD_STR_REFRESH[0], refresh);
322
+          lcd.createChar(LCD_STR_FOLDER[0], folder);
323
+        }
322 324
       }
323
-    }
324
-  #else
325
-    lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
326
-    lcd.createChar(LCD_STR_DEGREE[0], degree);
327
-    lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
328
-    lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
329
-    lcd.createChar(LCD_STR_REFRESH[0], refresh);
330
-    lcd.createChar(LCD_STR_FOLDER[0], folder);
331
-    lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
332
-    lcd.createChar(LCD_STR_CLOCK[0], clock);
325
+    #else
326
+      lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
327
+      lcd.createChar(LCD_STR_REFRESH[0], refresh);
328
+      lcd.createChar(LCD_STR_FOLDER[0], folder);
329
+    #endif
330
+
333 331
   #endif
334 332
 }
335 333
 
336 334
 static void lcd_implementation_init(
337 335
   #if ENABLED(LCD_PROGRESS_BAR)
338
-    bool progress_bar_set = true
336
+    bool info_screen_charset = true
339 337
   #endif
340 338
 ) {
341 339
 
@@ -365,7 +363,7 @@ static void lcd_implementation_init(
365 363
 
366 364
   lcd_set_custom_characters(
367 365
     #if ENABLED(LCD_PROGRESS_BAR)
368
-      progress_bar_set
366
+      info_screen_charset
369 367
     #endif
370 368
   );
371 369
 
@@ -528,10 +526,11 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
528 526
       logo_lines(PSTR(""));
529 527
       safe_delay(2000);
530 528
     #endif
529
+
531 530
     lcd_set_custom_characters(
532
-    #if ENABLED(LCD_PROGRESS_BAR)
533
-      false
534
-    #endif
531
+      #if ENABLED(LCD_PROGRESS_BAR)
532
+        false
533
+      #endif
535 534
     );
536 535
   }
537 536
 

Loading…
Cancel
Save