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
 //
749
 //
750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
762
 // @section temperature
753
 
763
 
754
 // Preheat Constants
764
 // Preheat Constants

+ 2
- 3
Marlin/M100_Free_Mem_Chk.cpp View File

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

+ 16
- 2
Marlin/Marlin.h View File

217
 
217
 
218
 #define _AXIS(AXIS) AXIS ##_AXIS
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
 void enable_all_steppers();
223
 void enable_all_steppers();
221
 void disable_all_steppers();
224
 void disable_all_steppers();
222
 
225
 
288
 
291
 
289
 // GCode support for external objects
292
 // GCode support for external objects
290
 bool code_seen(char);
293
 bool code_seen(char);
291
-float code_value();
294
+float code_value_float();
295
+unsigned long code_value_ulong();
292
 long code_value_long();
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
 #if ENABLED(DELTA)
309
 #if ENABLED(DELTA)
296
   extern float delta[3];
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
 //
732
 //
733
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
745
 // @section temperature
736
 
746
 
737
 // Preheat Constants
747
 // Preheat Constants

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

730
 //
730
 //
731
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
743
 // @section temperature
734
 
744
 
735
 // Preheat Constants
745
 // Preheat Constants

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

741
 //
741
 //
742
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
754
 // @section temperature
745
 
755
 
746
 // Preheat Constants
756
 // Preheat Constants

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

743
 //
743
 //
744
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
756
 // @section temperature
747
 
757
 
748
 // Preheat Constants
758
 // Preheat Constants

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

766
 //
766
 //
767
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
779
 // @section temperature
770
 
780
 
771
 // Preheat Constants
781
 // Preheat Constants

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

749
 //
749
 //
750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
762
 // @section temperature
753
 
763
 
754
 // Preheat Constants
764
 // Preheat Constants

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

744
 //
744
 //
745
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
757
 // @section temperature
748
 
758
 
749
 // Preheat Constants
759
 // Preheat Constants

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

757
 //
757
 //
758
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
770
 // @section temperature
761
 
771
 
762
 // Preheat Constants
772
 // Preheat Constants

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

770
 //
770
 //
771
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
783
 // @section temperature
774
 
784
 
775
 // Preheat Constants
785
 // Preheat Constants

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

741
 //
741
 //
742
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
754
 // @section temperature
745
 
755
 
746
 // Preheat Constants
756
 // Preheat Constants

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

749
 //
749
 //
750
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
762
 // @section temperature
753
 
763
 
754
 // Preheat Constants
764
 // Preheat Constants

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

838
 //
838
 //
839
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
851
 // @section temperature
842
 
852
 
843
 // Preheat Constants
853
 // Preheat Constants

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

832
 //
832
 //
833
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
845
 // @section temperature
836
 
846
 
837
 // Preheat Constants
847
 // Preheat Constants

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

835
 //
835
 //
836
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
848
 // @section temperature
839
 
849
 
840
 // Preheat Constants
850
 // Preheat Constants

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

835
 //
835
 //
836
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
848
 // @section temperature
839
 
849
 
840
 // Preheat Constants
850
 // Preheat Constants

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

837
 //
837
 //
838
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
850
 // @section temperature
841
 
851
 
842
 // Preheat Constants
852
 // Preheat Constants

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

752
 //
752
 //
753
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
765
 // @section temperature
756
 
766
 
757
 // Preheat Constants
767
 // Preheat Constants

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

743
 //
743
 //
744
 //#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
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
 // @section temperature
756
 // @section temperature
747
 
757
 
748
 // Preheat Constants
758
 // Preheat Constants

+ 3
- 3
Marlin/planner.cpp View File

1155
 
1155
 
1156
   void Planner::autotemp_M109() {
1156
   void Planner::autotemp_M109() {
1157
     autotemp_enabled = code_seen('F');
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
 #endif
1163
 #endif

Loading…
Cancel
Save