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.
pull/1/head
Reid Rankin 9 years ago
committed by Scott Lahteine
parent
commit
16212432c9
  1. 10
      Marlin/Configuration.h
  2. 5
      Marlin/M100_Free_Mem_Chk.cpp
  3. 18
      Marlin/Marlin.h
  4. 493
      Marlin/Marlin_main.cpp
  5. 10
      Marlin/example_configurations/Felix/Configuration.h
  6. 10
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  7. 10
      Marlin/example_configurations/Hephestos/Configuration.h
  8. 10
      Marlin/example_configurations/Hephestos_2/Configuration.h
  9. 10
      Marlin/example_configurations/K8200/Configuration.h
  10. 10
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  11. 10
      Marlin/example_configurations/RigidBot/Configuration.h
  12. 10
      Marlin/example_configurations/SCARA/Configuration.h
  13. 10
      Marlin/example_configurations/TAZ4/Configuration.h
  14. 10
      Marlin/example_configurations/WITBOX/Configuration.h
  15. 10
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  16. 10
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  17. 10
      Marlin/example_configurations/delta/generic/Configuration.h
  18. 10
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  19. 10
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  20. 10
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  21. 10
      Marlin/example_configurations/makibox/Configuration.h
  22. 10
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  23. 6
      Marlin/planner.cpp

10
Marlin/Configuration.h

@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

5
Marlin/M100_Free_Mem_Chk.cpp

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

18
Marlin/Marlin.h

@ -217,6 +217,9 @@ enum AxisEnum {NO_AXIS = -1, X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, B_AXIS = 1, Z_A
#define _AXIS(AXIS) AXIS ##_AXIS
typedef enum { LINEARUNIT_MM = 0, LINEARUNIT_INCH = 1 } LinearUnit;
typedef enum { TEMPUNIT_C = 0, TEMPUNIT_K = 1, TEMPUNIT_F = 2 } TempUnit;
void enable_all_steppers();
void disable_all_steppers();
@ -288,9 +291,20 @@ extern bool axis_homed[3]; // axis[n].is_homed
// GCode support for external objects
bool code_seen(char);
float code_value();
float code_value_float();
unsigned long code_value_ulong();
long code_value_long();
int16_t code_value_short();
int code_value_int();
uint16_t code_value_ushort();
uint8_t code_value_byte();
bool code_value_bool();
float code_value_linear_units();
float code_value_per_axis_unit(int axis);
float code_value_axis_units(int axis);
float code_value_temp_abs();
float code_value_temp_diff();
millis_t code_value_millis();
millis_t code_value_millis_from_seconds();
#if ENABLED(DELTA)
extern float delta[3];

493
Marlin/Marlin_main.cpp

File diff suppressed because it is too large

10
Marlin/example_configurations/Felix/Configuration.h

@ -732,6 +732,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/Felix/DUAL/Configuration.h

@ -730,6 +730,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/Hephestos/Configuration.h

@ -741,6 +741,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/Hephestos_2/Configuration.h

@ -743,6 +743,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/K8200/Configuration.h

@ -766,6 +766,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h

@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/RigidBot/Configuration.h

@ -744,6 +744,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/SCARA/Configuration.h

@ -757,6 +757,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/TAZ4/Configuration.h

@ -770,6 +770,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/WITBOX/Configuration.h

@ -741,6 +741,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/adafruit/ST7565/Configuration.h

@ -749,6 +749,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/delta/biv2.5/Configuration.h

@ -838,6 +838,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/delta/generic/Configuration.h

@ -832,6 +832,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/delta/kossel_mini/Configuration.h

@ -835,6 +835,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/delta/kossel_pro/Configuration.h

@ -835,6 +835,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/delta/kossel_xl/Configuration.h

@ -837,6 +837,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/makibox/Configuration.h

@ -752,6 +752,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

10
Marlin/example_configurations/tvrrug/Round2/Configuration.h

@ -743,6 +743,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
//
//#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//
// G20/G21 Inch mode support
//
//#define INCH_MODE_SUPPORT
//
// M149 Set temperature units support
//
//#define TEMPERATURE_UNITS_SUPPORT
// @section temperature
// Preheat Constants

6
Marlin/planner.cpp

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

Loading…
Cancel
Save