Browse Source

G20/21 and M149 support, and code_value() refactor

This is an update of MarlinDev PR #196.

G20/21: support for switching input units between millimeters and
inches.
M149: support for changing input temperature units.

In support of these changes, code_value() and code_value_short() are
replaced with an array of functions which handle converting to the
proper types and/or units.
Reid Rankin 8 years ago
parent
commit
16212432c9

+ 10
- 0
Marlin/Configuration.h View File

@@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
749 749
 //
750 750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
751 751
 
752
+//
753
+// G20/G21 Inch mode support
754
+//
755
+//#define INCH_MODE_SUPPORT
756
+
757
+//
758
+// M149 Set temperature units support
759
+//
760
+//#define TEMPERATURE_UNITS_SUPPORT
761
+
752 762
 // @section temperature
753 763
 
754 764
 // Preheat Constants

+ 2
- 3
Marlin/M100_Free_Mem_Chk.cpp View File

@@ -51,8 +51,7 @@ extern size_t  __heap_start, __heap_end, __flp;
51 51
 // Declare all the functions we need from Marlin_Main.cpp to do the work!
52 52
 //
53 53
 
54
-float code_value();
55
-long code_value_long();
54
+int code_value_int();
56 55
 bool code_seen(char);
57 56
 void serial_echopair_P(const char*, float);
58 57
 void serial_echopair_P(const char*, double);
@@ -177,7 +176,7 @@ void gcode_M100() {
177 176
 #if ENABLED(M100_FREE_MEMORY_CORRUPTOR)
178 177
   if (code_seen('C')) {
179 178
     int x;      // x gets the # of locations to corrupt within the memory pool
180
-    x = code_value();
179
+    x = code_value_int();
181 180
     SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
182 181
     ptr = (unsigned char*) __brkval;
183 182
     SERIAL_ECHOPAIR("\n__brkval : ", ptr);

+ 16
- 2
Marlin/Marlin.h View File

@@ -217,6 +217,9 @@ enum AxisEnum {NO_AXIS = -1, X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, B_AXIS = 1, Z_A
217 217
 
218 218
 #define _AXIS(AXIS) AXIS ##_AXIS
219 219
 
220
+typedef enum { LINEARUNIT_MM = 0, LINEARUNIT_INCH = 1 } LinearUnit;
221
+typedef enum { TEMPUNIT_C = 0, TEMPUNIT_K = 1, TEMPUNIT_F = 2 } TempUnit;
222
+
220 223
 void enable_all_steppers();
221 224
 void disable_all_steppers();
222 225
 
@@ -288,9 +291,20 @@ extern bool axis_homed[3]; // axis[n].is_homed
288 291
 
289 292
 // GCode support for external objects
290 293
 bool code_seen(char);
291
-float code_value();
294
+float code_value_float();
295
+unsigned long code_value_ulong();
292 296
 long code_value_long();
293
-int16_t code_value_short();
297
+int code_value_int();
298
+uint16_t code_value_ushort();
299
+uint8_t code_value_byte();
300
+bool code_value_bool();
301
+float code_value_linear_units();
302
+float code_value_per_axis_unit(int axis);
303
+float code_value_axis_units(int axis);
304
+float code_value_temp_abs();
305
+float code_value_temp_diff();
306
+millis_t code_value_millis();
307
+millis_t code_value_millis_from_seconds();
294 308
 
295 309
 #if ENABLED(DELTA)
296 310
   extern float delta[3];

+ 320
- 173
Marlin/Marlin_main.cpp
File diff suppressed because it is too large
View File


+ 10
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -732,6 +732,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
732 732
 //
733 733
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
734 734
 
735
+//
736
+// G20/G21 Inch mode support
737
+//
738
+//#define INCH_MODE_SUPPORT
739
+
740
+//
741
+// M149 Set temperature units support
742
+//
743
+//#define TEMPERATURE_UNITS_SUPPORT
744
+
735 745
 // @section temperature
736 746
 
737 747
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -730,6 +730,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
730 730
 //
731 731
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
732 732
 
733
+//
734
+// G20/G21 Inch mode support
735
+//
736
+//#define INCH_MODE_SUPPORT
737
+
738
+//
739
+// M149 Set temperature units support
740
+//
741
+//#define TEMPERATURE_UNITS_SUPPORT
742
+
733 743
 // @section temperature
734 744
 
735 745
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -741,6 +741,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
741 741
 //
742 742
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
743 743
 
744
+//
745
+// G20/G21 Inch mode support
746
+//
747
+//#define INCH_MODE_SUPPORT
748
+
749
+//
750
+// M149 Set temperature units support
751
+//
752
+//#define TEMPERATURE_UNITS_SUPPORT
753
+
744 754
 // @section temperature
745 755
 
746 756
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -743,6 +743,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
743 743
 //
744 744
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
745 745
 
746
+//
747
+// G20/G21 Inch mode support
748
+//
749
+//#define INCH_MODE_SUPPORT
750
+
751
+//
752
+// M149 Set temperature units support
753
+//
754
+//#define TEMPERATURE_UNITS_SUPPORT
755
+
746 756
 // @section temperature
747 757
 
748 758
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -766,6 +766,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
766 766
 //
767 767
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
768 768
 
769
+//
770
+// G20/G21 Inch mode support
771
+//
772
+//#define INCH_MODE_SUPPORT
773
+
774
+//
775
+// M149 Set temperature units support
776
+//
777
+//#define TEMPERATURE_UNITS_SUPPORT
778
+
769 779
 // @section temperature
770 780
 
771 781
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
749 749
 //
750 750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
751 751
 
752
+//
753
+// G20/G21 Inch mode support
754
+//
755
+//#define INCH_MODE_SUPPORT
756
+
757
+//
758
+// M149 Set temperature units support
759
+//
760
+//#define TEMPERATURE_UNITS_SUPPORT
761
+
752 762
 // @section temperature
753 763
 
754 764
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -744,6 +744,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
744 744
 //
745 745
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
746 746
 
747
+//
748
+// G20/G21 Inch mode support
749
+//
750
+//#define INCH_MODE_SUPPORT
751
+
752
+//
753
+// M149 Set temperature units support
754
+//
755
+//#define TEMPERATURE_UNITS_SUPPORT
756
+
747 757
 // @section temperature
748 758
 
749 759
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -757,6 +757,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
757 757
 //
758 758
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
759 759
 
760
+//
761
+// G20/G21 Inch mode support
762
+//
763
+//#define INCH_MODE_SUPPORT
764
+
765
+//
766
+// M149 Set temperature units support
767
+//
768
+//#define TEMPERATURE_UNITS_SUPPORT
769
+
760 770
 // @section temperature
761 771
 
762 772
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -770,6 +770,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
770 770
 //
771 771
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
772 772
 
773
+//
774
+// G20/G21 Inch mode support
775
+//
776
+//#define INCH_MODE_SUPPORT
777
+
778
+//
779
+// M149 Set temperature units support
780
+//
781
+//#define TEMPERATURE_UNITS_SUPPORT
782
+
773 783
 // @section temperature
774 784
 
775 785
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -741,6 +741,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
741 741
 //
742 742
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
743 743
 
744
+//
745
+// G20/G21 Inch mode support
746
+//
747
+//#define INCH_MODE_SUPPORT
748
+
749
+//
750
+// M149 Set temperature units support
751
+//
752
+//#define TEMPERATURE_UNITS_SUPPORT
753
+
744 754
 // @section temperature
745 755
 
746 756
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
749 749
 //
750 750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
751 751
 
752
+//
753
+// G20/G21 Inch mode support
754
+//
755
+//#define INCH_MODE_SUPPORT
756
+
757
+//
758
+// M149 Set temperature units support
759
+//
760
+//#define TEMPERATURE_UNITS_SUPPORT
761
+
752 762
 // @section temperature
753 763
 
754 764
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -838,6 +838,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
838 838
 //
839 839
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
840 840
 
841
+//
842
+// G20/G21 Inch mode support
843
+//
844
+//#define INCH_MODE_SUPPORT
845
+
846
+//
847
+// M149 Set temperature units support
848
+//
849
+//#define TEMPERATURE_UNITS_SUPPORT
850
+
841 851
 // @section temperature
842 852
 
843 853
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -832,6 +832,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
832 832
 //
833 833
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
834 834
 
835
+//
836
+// G20/G21 Inch mode support
837
+//
838
+//#define INCH_MODE_SUPPORT
839
+
840
+//
841
+// M149 Set temperature units support
842
+//
843
+//#define TEMPERATURE_UNITS_SUPPORT
844
+
835 845
 // @section temperature
836 846
 
837 847
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -835,6 +835,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
835 835
 //
836 836
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
837 837
 
838
+//
839
+// G20/G21 Inch mode support
840
+//
841
+//#define INCH_MODE_SUPPORT
842
+
843
+//
844
+// M149 Set temperature units support
845
+//
846
+//#define TEMPERATURE_UNITS_SUPPORT
847
+
838 848
 // @section temperature
839 849
 
840 850
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -835,6 +835,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
835 835
 //
836 836
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
837 837
 
838
+//
839
+// G20/G21 Inch mode support
840
+//
841
+//#define INCH_MODE_SUPPORT
842
+
843
+//
844
+// M149 Set temperature units support
845
+//
846
+//#define TEMPERATURE_UNITS_SUPPORT
847
+
838 848
 // @section temperature
839 849
 
840 850
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -837,6 +837,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
837 837
 //
838 838
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
839 839
 
840
+//
841
+// G20/G21 Inch mode support
842
+//
843
+//#define INCH_MODE_SUPPORT
844
+
845
+//
846
+// M149 Set temperature units support
847
+//
848
+//#define TEMPERATURE_UNITS_SUPPORT
849
+
840 850
 // @section temperature
841 851
 
842 852
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -752,6 +752,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
752 752
 //
753 753
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
754 754
 
755
+//
756
+// G20/G21 Inch mode support
757
+//
758
+//#define INCH_MODE_SUPPORT
759
+
760
+//
761
+// M149 Set temperature units support
762
+//
763
+//#define TEMPERATURE_UNITS_SUPPORT
764
+
755 765
 // @section temperature
756 766
 
757 767
 // Preheat Constants

+ 10
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -743,6 +743,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
743 743
 //
744 744
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
745 745
 
746
+//
747
+// G20/G21 Inch mode support
748
+//
749
+//#define INCH_MODE_SUPPORT
750
+
751
+//
752
+// M149 Set temperature units support
753
+//
754
+//#define TEMPERATURE_UNITS_SUPPORT
755
+
746 756
 // @section temperature
747 757
 
748 758
 // Preheat Constants

+ 3
- 3
Marlin/planner.cpp View File

@@ -1155,9 +1155,9 @@ void Planner::reset_acceleration_rates() {
1155 1155
 
1156 1156
   void Planner::autotemp_M109() {
1157 1157
     autotemp_enabled = code_seen('F');
1158
-    if (autotemp_enabled) autotemp_factor = code_value();
1159
-    if (code_seen('S')) autotemp_min = code_value();
1160
-    if (code_seen('B')) autotemp_max = code_value();
1158
+    if (autotemp_enabled) autotemp_factor = code_value_temp_diff();
1159
+    if (code_seen('S')) autotemp_min = code_value_temp_abs();
1160
+    if (code_seen('B')) autotemp_max = code_value_temp_abs();
1161 1161
   }
1162 1162
 
1163 1163
 #endif

Loading…
Cancel
Save