From eaf6c453beb5d59317c68ee05709de7786b50bce Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 5 Mar 2012 22:25:52 +0100 Subject: [PATCH] Introduce gcode_init() and honor E_ABSOLUTE as the default. --- config.default.h | 2 ++ config.gen3.h | 2 ++ config.gen6.h | 2 ++ config.gen7.h | 2 ++ config.ramps-v1.2.h | 2 ++ config.ramps-v1.3.h | 2 ++ config.sanguinololu-v1.1.h | 2 ++ config.sanguinololu-v1.2.h | 2 ++ gcode_parse.c | 12 ++++++++++++ gcode_parse.h | 2 ++ mendel.c | 2 +- 11 files changed, 31 insertions(+), 1 deletion(-) diff --git a/config.default.h b/config.default.h index b3596ea..529a8c2 100644 --- a/config.default.h +++ b/config.default.h @@ -115,6 +115,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.gen3.h b/config.gen3.h index 837c233..6349ed1 100644 --- a/config.gen3.h +++ b/config.gen3.h @@ -111,6 +111,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.gen6.h b/config.gen6.h index cda4bf6..65194b3 100644 --- a/config.gen6.h +++ b/config.gen6.h @@ -117,6 +117,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.gen7.h b/config.gen7.h index bc52d02..5c300df 100644 --- a/config.gen7.h +++ b/config.gen7.h @@ -120,6 +120,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.ramps-v1.2.h b/config.ramps-v1.2.h index a4cc2e7..058b780 100644 --- a/config.ramps-v1.2.h +++ b/config.ramps-v1.2.h @@ -118,6 +118,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.ramps-v1.3.h b/config.ramps-v1.3.h index a120e20..e2b5bf7 100644 --- a/config.ramps-v1.3.h +++ b/config.ramps-v1.3.h @@ -117,6 +117,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.sanguinololu-v1.1.h b/config.sanguinololu-v1.1.h index f704cc4..e4f78e6 100644 --- a/config.sanguinololu-v1.1.h +++ b/config.sanguinololu-v1.1.h @@ -117,6 +117,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/config.sanguinololu-v1.2.h b/config.sanguinololu-v1.2.h index 52b1e6f..df26f57 100644 --- a/config.sanguinololu-v1.2.h +++ b/config.sanguinololu-v1.2.h @@ -117,6 +117,8 @@ /** \def E_ABSOLUTE Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. + + This is the startup default and can be changed with M82/M83 while running. */ // #define E_ABSOLUTE diff --git a/gcode_parse.c b/gcode_parse.c index 592aaf0..7e7c4fd 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -75,6 +75,18 @@ static int32_t decfloat_to_int(decfloat *df, uint32_t multiplicand) { return df->sign ? -(int32_t)r : (int32_t)r; } +void gcode_init(void) { + // gcc guarantees us all variables are initialised to 0. + + // assume a G1 by default + next_target.seen_G = 1; + next_target.G = 1; + + #ifndef E_ABSOLUTE + next_target.option_e_relative = 1; + #endif +} + // TODO TODO: write a gcode_init(), next_target is used uninitialised. For a hint on what to do, see line 340ff. /// Character Received - add it to our command diff --git a/gcode_parse.h b/gcode_parse.h index 0fac353..8a3da73 100644 --- a/gcode_parse.h +++ b/gcode_parse.h @@ -66,6 +66,8 @@ typedef struct { /// the command being processed extern GCODE_COMMAND next_target; +void gcode_init(void); + /// accept the next character and process it void gcode_parse_char(uint8_t c); diff --git a/mendel.c b/mendel.c index 8282164..fdc034e 100644 --- a/mendel.c +++ b/mendel.c @@ -275,7 +275,7 @@ void init(void) { serial_init(); // set up G-code parsing - // gcode_init(); + gcode_init(); // set up inputs and outputs io_init();