Browse Source

Add _draw_axis_label function to reduce source

Scott Lahteine 8 years ago
parent
commit
90c97c8185
2 changed files with 43 additions and 82 deletions
  1. 22
    42
      Marlin/dogm_lcd_implementation.h
  2. 21
    40
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 22
- 42
Marlin/dogm_lcd_implementation.h View File

309
   }
309
   }
310
 }
310
 }
311
 
311
 
312
+FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
313
+  if (blink)
314
+    lcd_printPGM(pstr);
315
+  else {
316
+    if (!axis_homed[axis])
317
+      lcd_printPGM(PSTR("?"));
318
+    else {
319
+      #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
320
+        if (!axis_known_position[axis])
321
+          lcd_printPGM(PSTR(" "));
322
+        else
323
+      #endif
324
+      lcd_printPGM(pstr);
325
+    }
326
+  }
327
+}
328
+
312
 static void lcd_implementation_status_screen() {
329
 static void lcd_implementation_status_screen() {
313
   u8g.setColorIndex(1); // black on white
330
   u8g.setColorIndex(1); // black on white
314
 
331
 
382
     u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9);
399
     u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9);
383
   #endif
400
   #endif
384
   u8g.setColorIndex(0); // white on black
401
   u8g.setColorIndex(0); // white on black
402
+
385
   u8g.setPrintPos(2, XYZ_BASELINE);
403
   u8g.setPrintPos(2, XYZ_BASELINE);
386
-  if (blink)
387
-    lcd_printPGM(PSTR(MSG_X));
388
-  else {
389
-    if (!axis_homed[X_AXIS])
390
-      lcd_printPGM(PSTR("?"));
391
-    else {
392
-      #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
393
-        if (!axis_known_position[X_AXIS])
394
-          lcd_printPGM(PSTR(" "));
395
-        else
396
-      #endif
397
-      lcd_printPGM(PSTR(MSG_X));
398
-    }
399
-  }
404
+  _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
400
   u8g.setPrintPos(10, XYZ_BASELINE);
405
   u8g.setPrintPos(10, XYZ_BASELINE);
401
   lcd_print(ftostr4sign(current_position[X_AXIS]));
406
   lcd_print(ftostr4sign(current_position[X_AXIS]));
402
 
407
 
403
   u8g.setPrintPos(43, XYZ_BASELINE);
408
   u8g.setPrintPos(43, XYZ_BASELINE);
404
-  if (blink)
405
-    lcd_printPGM(PSTR(MSG_Y));
406
-  else {
407
-    if (!axis_homed[Y_AXIS])
408
-      lcd_printPGM(PSTR("?"));
409
-    else {
410
-      #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
411
-        if (!axis_known_position[Y_AXIS])
412
-          lcd_printPGM(PSTR(" "));
413
-        else
414
-      #endif
415
-      lcd_printPGM(PSTR(MSG_Y));
416
-    }
417
-  }
409
+  _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
418
   u8g.setPrintPos(51, XYZ_BASELINE);
410
   u8g.setPrintPos(51, XYZ_BASELINE);
419
   lcd_print(ftostr4sign(current_position[Y_AXIS]));
411
   lcd_print(ftostr4sign(current_position[Y_AXIS]));
420
 
412
 
421
   u8g.setPrintPos(83, XYZ_BASELINE);
413
   u8g.setPrintPos(83, XYZ_BASELINE);
422
-  if (blink)
423
-    lcd_printPGM(PSTR(MSG_Z));
424
-  else {
425
-    if (!axis_homed[Z_AXIS])
426
-      lcd_printPGM(PSTR("?"));
427
-    else {
428
-      #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
429
-        if (!axis_known_position[Z_AXIS])
430
-          lcd_printPGM(PSTR(" "));
431
-        else
432
-      #endif
433
-      lcd_printPGM(PSTR(MSG_Z));
434
-    }
435
-  }
414
+  _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
436
   u8g.setPrintPos(91, XYZ_BASELINE);
415
   u8g.setPrintPos(91, XYZ_BASELINE);
437
   lcd_print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
416
   lcd_print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
417
+
438
   u8g.setColorIndex(1); // black on white
418
   u8g.setColorIndex(1); // black on white
439
 
419
 
440
   // Feedrate
420
   // Feedrate

+ 21
- 40
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

569
 
569
 
570
 #endif // SHOW_BOOTSCREEN
570
 #endif // SHOW_BOOTSCREEN
571
 
571
 
572
+FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
573
+  if (blink)
574
+    lcd_printPGM(pstr);
575
+  else {
576
+    if (!axis_homed[axis])
577
+      lcd_printPGM(PSTR("?"));
578
+    else {
579
+      #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
580
+        if (!axis_known_position[axis])
581
+          lcd_printPGM(PSTR(" "));
582
+        else
583
+      #endif
584
+      lcd_printPGM(pstr);
585
+    }
586
+  }
587
+}
588
+
572
 /**
589
 /**
573
 Possible status screens:
590
 Possible status screens:
574
 16x2   |000/000 B000/000|
591
 16x2   |000/000 B000/000|
692
         // When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
709
         // When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
693
         // When everything is ok you see a constant 'X'.
710
         // When everything is ok you see a constant 'X'.
694
 
711
 
695
-        if (blink)
696
-          lcd_printPGM(PSTR(MSG_X));
697
-        else {
698
-          if (!axis_homed[X_AXIS])
699
-            lcd_printPGM(PSTR("?"));
700
-          else
701
-            #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
702
-              if (!axis_known_position[X_AXIS])
703
-                lcd_printPGM(PSTR(" "));
704
-              else
705
-            #endif
706
-            lcd_printPGM(PSTR(MSG_X));
707
-        }
708
-
712
+        _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
709
         lcd.print(ftostr4sign(current_position[X_AXIS]));
713
         lcd.print(ftostr4sign(current_position[X_AXIS]));
710
 
714
 
711
         lcd_printPGM(PSTR(" "));
715
         lcd_printPGM(PSTR(" "));
712
-        if (blink)
713
-          lcd_printPGM(PSTR(MSG_Y));
714
-        else {
715
-          if (!axis_homed[Y_AXIS])
716
-            lcd_printPGM(PSTR("?"));
717
-          else
718
-            #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
719
-              if (!axis_known_position[Y_AXIS])
720
-                lcd_printPGM(PSTR(" "));
721
-              else
722
-            #endif
723
-            lcd_printPGM(PSTR(MSG_Y));
724
-        }
716
+
717
+        _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
725
         lcd.print(ftostr4sign(current_position[Y_AXIS]));
718
         lcd.print(ftostr4sign(current_position[Y_AXIS]));
726
 
719
 
727
       #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
720
       #endif // EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
729
     #endif // LCD_WIDTH >= 20
722
     #endif // LCD_WIDTH >= 20
730
 
723
 
731
     lcd.setCursor(LCD_WIDTH - 8, 1);
724
     lcd.setCursor(LCD_WIDTH - 8, 1);
732
-    if (blink)
733
-      lcd_printPGM(PSTR(MSG_Z));
734
-    else {
735
-      if (!axis_homed[Z_AXIS])
736
-        lcd_printPGM(PSTR("?"));
737
-      else
738
-        #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
739
-          if (!axis_known_position[Z_AXIS])
740
-            lcd_printPGM(PSTR(" "));
741
-          else
742
-        #endif
743
-        lcd_printPGM(PSTR(MSG_Z));
744
-    }
725
+    _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
745
     lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
726
     lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
746
 
727
 
747
   #endif // LCD_HEIGHT > 2
728
   #endif // LCD_HEIGHT > 2

Loading…
Cancel
Save