瀏覽代碼

Save PROGMEM with string changes

Unlike RAM-based strings, PROGMEM strings aren’t consolidated by the
compiler.
Scott Lahteine 7 年之前
父節點
當前提交
fccc97de6d
共有 2 個文件被更改,包括 25 次插入38 次删除
  1. 22
    27
      Marlin/Marlin_main.cpp
  2. 3
    11
      Marlin/pinsDebug.h

+ 22
- 27
Marlin/Marlin_main.cpp 查看文件

@@ -3551,6 +3551,9 @@ inline void gcode_G28() {
3551 3551
     stepper.synchronize();
3552 3552
   }
3553 3553
 
3554
+  // Save 130 bytes with non-duplication of PSTR
3555
+  void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3556
+
3554 3557
   /**
3555 3558
    * G29: Mesh-based Z probe, probes a grid and produces a
3556 3559
    *      mesh to compensate for variable bed height
@@ -3663,7 +3666,7 @@ inline void gcode_G28() {
3663 3666
           }
3664 3667
         }
3665 3668
         else {
3666
-          SERIAL_CHAR('X'); SERIAL_PROTOCOLLNPGM(" not entered.");
3669
+          SERIAL_CHAR('X'); say_not_entered();
3667 3670
           return;
3668 3671
         }
3669 3672
 
@@ -3675,7 +3678,7 @@ inline void gcode_G28() {
3675 3678
           }
3676 3679
         }
3677 3680
         else {
3678
-          SERIAL_CHAR('Y'); SERIAL_PROTOCOLLNPGM(" not entered.");
3681
+          SERIAL_CHAR('Y'); say_not_entered();
3679 3682
           return;
3680 3683
         }
3681 3684
 
@@ -3683,7 +3686,7 @@ inline void gcode_G28() {
3683 3686
           mbl.z_values[py][px] = code_value_axis_units(Z_AXIS);
3684 3687
         }
3685 3688
         else {
3686
-          SERIAL_CHAR('Z'); SERIAL_PROTOCOLLNPGM(" not entered.");
3689
+          SERIAL_CHAR('Z'); say_not_entered();
3687 3690
           return;
3688 3691
         }
3689 3692
         break;
@@ -3693,7 +3696,7 @@ inline void gcode_G28() {
3693 3696
           mbl.z_offset = code_value_axis_units(Z_AXIS);
3694 3697
         }
3695 3698
         else {
3696
-          SERIAL_CHAR('Z'); SERIAL_PROTOCOLLNPGM(" not entered.");
3699
+          SERIAL_CHAR('Z'); say_not_entered();
3697 3700
           return;
3698 3701
         }
3699 3702
         break;
@@ -5822,63 +5825,55 @@ inline void gcode_M115() {
5822 5825
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
5823 5826
 
5824 5827
     // EEPROM (M500, M501)
5825
-    SERIAL_PROTOCOLPGM("Cap:");
5826 5828
     #if ENABLED(EEPROM_SETTINGS)
5827
-      SERIAL_PROTOCOLLNPGM("EEPROM:1");
5829
+      SERIAL_PROTOCOLLNPGM("Cap:EEPROM:1");
5828 5830
     #else
5829
-      SERIAL_PROTOCOLLNPGM("EEPROM:0");
5831
+      SERIAL_PROTOCOLLNPGM("Cap:EEPROM:0");
5830 5832
     #endif
5831 5833
 
5832 5834
     // AUTOREPORT_TEMP (M155)
5833
-    SERIAL_PROTOCOLPGM("Cap:");
5834 5835
     #if ENABLED(AUTO_REPORT_TEMPERATURES)
5835
-      SERIAL_PROTOCOLLNPGM("AUTOREPORT_TEMP:1");
5836
+      SERIAL_PROTOCOLLNPGM("Cap:AUTOREPORT_TEMP:1");
5836 5837
     #else
5837
-      SERIAL_PROTOCOLLNPGM("AUTOREPORT_TEMP:0");
5838
+      SERIAL_PROTOCOLLNPGM("Cap:AUTOREPORT_TEMP:0");
5838 5839
     #endif
5839 5840
 
5840 5841
     // PROGRESS (M530 S L, M531 <file>, M532 X L)
5841
-    SERIAL_PROTOCOLPGM("Cap:");
5842
-    SERIAL_PROTOCOLLNPGM("PROGRESS:0");
5842
+    SERIAL_PROTOCOLLNPGM("Cap:PROGRESS:0");
5843 5843
 
5844 5844
     // AUTOLEVEL (G29)
5845
-    SERIAL_PROTOCOLPGM("Cap:");
5846 5845
     #if HAS_ABL
5847
-      SERIAL_PROTOCOLLNPGM("AUTOLEVEL:1");
5846
+      SERIAL_PROTOCOLLNPGM("Cap:AUTOLEVEL:1");
5848 5847
     #else
5849
-      SERIAL_PROTOCOLLNPGM("AUTOLEVEL:0");
5848
+      SERIAL_PROTOCOLLNPGM("Cap:AUTOLEVEL:0");
5850 5849
     #endif
5851 5850
 
5852 5851
     // Z_PROBE (G30)
5853
-    SERIAL_PROTOCOLPGM("Cap:");
5854 5852
     #if HAS_BED_PROBE
5855
-      SERIAL_PROTOCOLLNPGM("Z_PROBE:1");
5853
+      SERIAL_PROTOCOLLNPGM("Cap:Z_PROBE:1");
5856 5854
     #else
5857
-      SERIAL_PROTOCOLLNPGM("Z_PROBE:0");
5855
+      SERIAL_PROTOCOLLNPGM("Cap:Z_PROBE:0");
5858 5856
     #endif
5859 5857
 
5860 5858
     // SOFTWARE_POWER (G30)
5861
-    SERIAL_PROTOCOLPGM("Cap:");
5862 5859
     #if HAS_POWER_SWITCH
5863
-      SERIAL_PROTOCOLLNPGM("SOFTWARE_POWER:1");
5860
+      SERIAL_PROTOCOLLNPGM("Cap:SOFTWARE_POWER:1");
5864 5861
     #else
5865
-      SERIAL_PROTOCOLLNPGM("SOFTWARE_POWER:0");
5862
+      SERIAL_PROTOCOLLNPGM("Cap:SOFTWARE_POWER:0");
5866 5863
     #endif
5867 5864
 
5868 5865
     // TOGGLE_LIGHTS (M355)
5869
-    SERIAL_PROTOCOLPGM("Cap:");
5870 5866
     #if HAS_CASE_LIGHT
5871
-      SERIAL_PROTOCOLLNPGM("TOGGLE_LIGHTS:1");
5867
+      SERIAL_PROTOCOLLNPGM("Cap:TOGGLE_LIGHTS:1");
5872 5868
     #else
5873
-      SERIAL_PROTOCOLLNPGM("TOGGLE_LIGHTS:0");
5869
+      SERIAL_PROTOCOLLNPGM("Cap:TOGGLE_LIGHTS:0");
5874 5870
     #endif
5875 5871
 
5876 5872
     // EMERGENCY_PARSER (M108, M112, M410)
5877
-    SERIAL_PROTOCOLPGM("Cap:");
5878 5873
     #if ENABLED(EMERGENCY_PARSER)
5879
-      SERIAL_PROTOCOLLNPGM("EMERGENCY_PARSER:1");
5874
+      SERIAL_PROTOCOLLNPGM("Cap:EMERGENCY_PARSER:1");
5880 5875
     #else
5881
-      SERIAL_PROTOCOLLNPGM("EMERGENCY_PARSER:0");
5876
+      SERIAL_PROTOCOLLNPGM("Cap:EMERGENCY_PARSER:0");
5882 5877
     #endif
5883 5878
 
5884 5879
   #endif // EXTENDED_CAPABILITIES_REPORT

+ 3
- 11
Marlin/pinsDebug.h 查看文件

@@ -730,21 +730,13 @@ static bool pwm_status(uint8_t pin) {
730 730
 #define WGM_TEST2 (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13)
731 731
 
732 732
 static void err_is_counter() {
733
-  SERIAL_PROTOCOLPGM("   Can't ");
734
-  SERIAL_PROTOCOLPGM("be used as a PWM because ");
735
-  SERIAL_PROTOCOLPGM("of counter mode");
733
+  SERIAL_PROTOCOLPGM("   Can't be used as a PWM because of counter mode");
736 734
 }
737 735
 static void err_is_interrupt() {
738
-  SERIAL_PROTOCOLPGM("   Can't ");
739
-  SERIAL_PROTOCOLPGM("be used as a PWM because ");
740
-  SERIAL_PROTOCOLPGM("it's ");
741
-  SERIAL_PROTOCOLPGM("being used as an interrupt");
736
+  SERIAL_PROTOCOLPGM("   Can't be used as a PWM because it's being used as an interrupt");
742 737
 }
743 738
 static void err_prob_interrupt() {
744
-  SERIAL_PROTOCOLPGM("   Probably can't ");
745
-  SERIAL_PROTOCOLPGM("be used as a PWM because ");
746
-  SERIAL_PROTOCOLPGM("counter/timer is ");
747
-  SERIAL_PROTOCOLPGM("being used as an interrupt");
739
+  SERIAL_PROTOCOLPGM("   Probably can't be used as a PWM because counter/timer is being used as an interrupt");
748 740
 }
749 741
 static void can_be_used() { SERIAL_PROTOCOLPGM("   can be used as PWM   "); }
750 742
 

Loading…
取消
儲存