浏览代码

Merge pull request #4553 from thinkyhead/rc_lcd_chars_save_ram

Save bytes for custom chars (Hitachi LCD)
Scott Lahteine 8 年前
父节点
当前提交
cffe77c537
共有 2 个文件被更改,包括 113 次插入112 次删除
  1. 22
    20
      Marlin/ultralcd.cpp
  2. 91
    92
      Marlin/ultralcd_impl_HD44780.h

+ 22
- 20
Marlin/ultralcd.cpp 查看文件

367
 
367
 
368
   /**
368
   /**
369
    * General function to go directly to a menu
369
    * General function to go directly to a menu
370
-   * Remembers the previous position
371
    */
370
    */
372
   static void lcd_goto_screen(screenFunc_t screen, const bool feedback = false, const uint32_t encoder = 0) {
371
   static void lcd_goto_screen(screenFunc_t screen, const bool feedback = false, const uint32_t encoder = 0) {
373
     if (currentScreen != screen) {
372
     if (currentScreen != screen) {
374
       currentScreen = screen;
373
       currentScreen = screen;
375
-      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
376
       encoderPosition = encoder;
374
       encoderPosition = encoder;
377
-      if (feedback) lcd_quick_feedback();
378
       if (screen == lcd_status_screen) {
375
       if (screen == lcd_status_screen) {
379
         defer_return_to_status = false;
376
         defer_return_to_status = false;
380
         screen_history_depth = 0;
377
         screen_history_depth = 0;
381
       }
378
       }
379
+      if (feedback) lcd_quick_feedback();
380
+      lcd_implementation_clear();
382
       #if ENABLED(LCD_PROGRESS_BAR)
381
       #if ENABLED(LCD_PROGRESS_BAR)
383
         // For LCD_PROGRESS_BAR re-initialize custom characters
382
         // For LCD_PROGRESS_BAR re-initialize custom characters
384
         lcd_set_custom_characters(screen == lcd_status_screen);
383
         lcd_set_custom_characters(screen == lcd_status_screen);
385
       #endif
384
       #endif
385
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
386
     }
386
     }
387
   }
387
   }
388
 
388
 
484
     }
484
     }
485
 
485
 
486
     if (current_click) {
486
     if (current_click) {
487
-      lcd_goto_screen(lcd_main_menu, true);
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
491
-        #endif
492
-      );
493
       #if ENABLED(FILAMENT_LCD_DISPLAY)
487
       #if ENABLED(FILAMENT_LCD_DISPLAY)
494
         previous_lcd_status_ms = millis();  // get status message to show up for a while
488
         previous_lcd_status_ms = millis();  // get status message to show up for a while
495
       #endif
489
       #endif
490
+      lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
491
+        #if ENABLED(LCD_PROGRESS_BAR)
492
+          false
493
+        #endif
494
+      );
495
+      lcd_goto_screen(lcd_main_menu, true);
496
     }
496
     }
497
 
497
 
498
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
498
     #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
2091
 
2091
 
2092
     static void lcd_filament_change_resume_print() {
2092
     static void lcd_filament_change_resume_print() {
2093
       filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_RESUME_PRINT;
2093
       filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_RESUME_PRINT;
2094
-      lcdDrawUpdate = 2;
2095
       lcd_goto_screen(lcd_status_screen);
2094
       lcd_goto_screen(lcd_status_screen);
2096
     }
2095
     }
2097
 
2096
 
2377
     (*callback)();
2376
     (*callback)();
2378
   }
2377
   }
2379
 
2378
 
2380
-#endif //ULTIPANEL
2379
+#endif // ULTIPANEL
2381
 
2380
 
2382
-/** LCD API **/
2383
 void lcd_init() {
2381
 void lcd_init() {
2384
 
2382
 
2385
-  lcd_implementation_init();
2383
+  lcd_implementation_init(
2384
+    #if ENABLED(LCD_PROGRESS_BAR)
2385
+      true
2386
+    #endif
2387
+  );
2386
 
2388
 
2387
   #if ENABLED(NEWPANEL)
2389
   #if ENABLED(NEWPANEL)
2388
     #if BUTTON_EXISTS(EN1)
2390
     #if BUTTON_EXISTS(EN1)
2537
 
2539
 
2538
     bool sd_status = IS_SD_INSERTED;
2540
     bool sd_status = IS_SD_INSERTED;
2539
     if (sd_status != lcd_sd_status && lcd_detected()) {
2541
     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
-      );
2542
+      lcd_sd_status = sd_status;
2546
 
2543
 
2547
       if (sd_status) {
2544
       if (sd_status) {
2548
         card.initsd();
2545
         card.initsd();
2553
         if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
2550
         if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
2554
       }
2551
       }
2555
 
2552
 
2556
-      lcd_sd_status = sd_status;
2553
+      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2554
+      lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
2555
+        #if ENABLED(LCD_PROGRESS_BAR)
2556
+          currentScreen == lcd_status_screen
2557
+        #endif
2558
+      );
2557
     }
2559
     }
2558
 
2560
 
2559
   #endif //SDSUPPORT && SD_DETECT_PIN
2561
   #endif //SDSUPPORT && SD_DETECT_PIN

+ 91
- 92
Marlin/ultralcd_impl_HD44780.h 查看文件

189
 
189
 
190
 static void lcd_set_custom_characters(
190
 static void lcd_set_custom_characters(
191
   #if ENABLED(LCD_PROGRESS_BAR)
191
   #if ENABLED(LCD_PROGRESS_BAR)
192
-    bool progress_bar_set = true
192
+    bool info_screen_charset = true
193
   #endif
193
   #endif
194
 ) {
194
 ) {
195
-  byte bedTemp[8] = {
195
+  static byte bedTemp[8] = {
196
     B00000,
196
     B00000,
197
     B11111,
197
     B11111,
198
     B10101,
198
     B10101,
202
     B00000,
202
     B00000,
203
     B00000
203
     B00000
204
   }; //thanks Sonny Mounicou
204
   }; //thanks Sonny Mounicou
205
-  byte degree[8] = {
205
+  static byte degree[8] = {
206
     B01100,
206
     B01100,
207
     B10010,
207
     B10010,
208
     B10010,
208
     B10010,
212
     B00000,
212
     B00000,
213
     B00000
213
     B00000
214
   };
214
   };
215
-  byte thermometer[8] = {
215
+  static byte thermometer[8] = {
216
     B00100,
216
     B00100,
217
     B01010,
217
     B01010,
218
     B01010,
218
     B01010,
222
     B10001,
222
     B10001,
223
     B01110
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
     B11100,
226
     B11100,
257
     B10000,
227
     B10000,
258
     B11000,
228
     B11000,
262
     B00101,
232
     B00101,
263
     B00000
233
     B00000
264
   }; //thanks Sonny Mounicou
234
   }; //thanks Sonny Mounicou
265
-  byte clock[8] = {
235
+  static byte clock[8] = {
266
     B00000,
236
     B00000,
267
     B01110,
237
     B01110,
268
     B10011,
238
     B10011,
273
     B00000
243
     B00000
274
   }; //thanks Sonny Mounicou
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
       B00000,
259
       B00000,
280
-      B10000,
281
-      B10000,
282
-      B10000,
283
-      B10000,
284
-      B10000,
285
-      B10000,
286
-      B00000
287
-    }, {
288
       B00000,
260
       B00000,
289
-      B10100,
290
-      B10100,
291
-      B10100,
292
-      B10100,
293
-      B10100,
294
-      B10100,
295
       B00000
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
       B00000,
280
       B00000,
298
-      B10101,
299
-      B10101,
300
-      B10101,
301
-      B10101,
302
-      B10101,
303
-      B10101,
304
       B00000
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
   #endif
331
   #endif
334
 }
332
 }
335
 
333
 
336
 static void lcd_implementation_init(
334
 static void lcd_implementation_init(
337
   #if ENABLED(LCD_PROGRESS_BAR)
335
   #if ENABLED(LCD_PROGRESS_BAR)
338
-    bool progress_bar_set = true
336
+    bool info_screen_charset = true
339
   #endif
337
   #endif
340
 ) {
338
 ) {
341
 
339
 
365
 
363
 
366
   lcd_set_custom_characters(
364
   lcd_set_custom_characters(
367
     #if ENABLED(LCD_PROGRESS_BAR)
365
     #if ENABLED(LCD_PROGRESS_BAR)
368
-      progress_bar_set
366
+      info_screen_charset
369
     #endif
367
     #endif
370
   );
368
   );
371
 
369
 
528
       logo_lines(PSTR(""));
526
       logo_lines(PSTR(""));
529
       safe_delay(2000);
527
       safe_delay(2000);
530
     #endif
528
     #endif
529
+
531
     lcd_set_custom_characters(
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
 

正在加载...
取消
保存