boolean flags in parser
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 11 Sep 2016 12:03:53 +0000 (05:03 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 11 Sep 2016 12:03:53 +0000 (05:03 -0700)
12 files changed:
src/gcode_parser.c
src/gcode_parser.h
src/gcode_state.c [new file with mode: 0644]
src/gcode_state.def [new file with mode: 0644]
src/gcode_state.h
src/homing.c
src/machine.c
src/machine.h
src/plan/arc.c
src/probing.c
src/probing.h
src/varcb.c

index cc602c9b8e29392049d25a05d039d98e7109cb8b..72657e26987c7b716bc75d5df1b754dcd8dd6681 100644 (file)
@@ -45,10 +45,10 @@ parser_t parser = {{0}};
 
 
 #define SET_MODAL(m, parm, val) \
-  {parser.gn.parm = val; parser.gf.parm = 1; modals[m] += 1; break;}
+  {parser.gn.parm = val; parser.gf.parm = true; modals[m] += 1; break;}
 #define SET_NON_MODAL(parm, val) \
-  {parser.gn.parm = val; parser.gf.parm = 1; break;}
-#define EXEC_FUNC(f, parm) if ((uint8_t)parser.gf.parm) f(parser.gn.parm)
+  {parser.gn.parm = val; parser.gf.parm = true; break;}
+#define EXEC_FUNC(f, parm) if (parser.gf.parm) f(parser.gn.parm)
 
 
 static uint8_t modals[MODAL_GROUP_COUNT]; // collects modal groups in a block
@@ -241,13 +241,13 @@ static stat_t _validate_gcode_block() {
 static stat_t _execute_gcode_block() {
   stat_t status = STAT_OK;
 
-  mach_set_model_line(parser.gn.line);
+  mach_set_line(parser.gn.line);
   EXEC_FUNC(mach_set_feed_mode, feed_mode);
   EXEC_FUNC(mach_set_feed_rate, feed_rate);
   EXEC_FUNC(mach_feed_override_factor, feed_override_factor);
   EXEC_FUNC(mach_set_spindle_speed, spindle_speed);
   EXEC_FUNC(mach_spindle_override_factor, spindle_override_factor);
-  EXEC_FUNC(mach_select_tool, tool_select);
+  EXEC_FUNC(mach_select_tool, tool);
   EXEC_FUNC(mach_change_tool, tool_change);
   EXEC_FUNC(mach_set_spindle_mode, spindle_mode);
   EXEC_FUNC(mach_mist_coolant_control, mist_coolant);
@@ -371,7 +371,7 @@ static stat_t _parse_gcode_block(char *buf) {
 
   // set initial state for new move
   memset(modals, 0, sizeof(modals));              // clear all parser values
-  memset(&parser.gf, 0, sizeof(gcode_state_t));   // clear all next-state flags
+  memset(&parser.gf, 0, sizeof(gcode_flags_t));   // clear all next-state flags
   memset(&parser.gn, 0, sizeof(gcode_state_t));   // clear all next-state values
 
   // get motion mode from previous block
@@ -508,7 +508,7 @@ static stat_t _parse_gcode_block(char *buf) {
       }
       break;
 
-    case 'T': SET_NON_MODAL(tool_select, (uint8_t)trunc(value));
+    case 'T': SET_NON_MODAL(tool, (uint8_t)trunc(value));
     case 'F': SET_NON_MODAL(feed_rate, value);
       // used for dwell time, G10 coord select, rotations
     case 'P': SET_NON_MODAL(parameter, value);
index 037fef118bbbf19786fb19441bb8026fa2c51acf..4d729a0961727e2e7594db3714e9cc0a5d16f816 100644 (file)
@@ -56,8 +56,8 @@ typedef enum {   // Used for detecting gcode errors. See NIST section 3.4
 
 
 typedef struct {
-  gcode_state_t gn;                    // gcode input values
-  gcode_state_t gf;                    // gcode input flags
+  gcode_state_t gn; // gcode input values
+  gcode_flags_t gf; // gcode input flags
 } parser_t;
 
 
diff --git a/src/gcode_state.c b/src/gcode_state.c
new file mode 100644 (file)
index 0000000..c368b29
--- /dev/null
@@ -0,0 +1,97 @@
+/******************************************************************************\
+
+                This file is part of the Buildbotics firmware.
+
+                  Copyright (c) 2015 - 2016 Buildbotics LLC
+                            All rights reserved.
+
+     This file ("the software") is free software: you can redistribute it
+     and/or modify it under the terms of the GNU General Public License,
+      version 2 as published by the Free Software Foundation. You should
+      have received a copy of the GNU General Public License, version 2
+     along with the software. If not, see <http://www.gnu.org/licenses/>.
+
+     The software is distributed in the hope that it will be useful, but
+          WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+               Lesser General Public License for more details.
+
+       You should have received a copy of the GNU Lesser General Public
+                License along with the software.  If not, see
+                       <http://www.gnu.org/licenses/>.
+
+                For information regarding this software email:
+                  "Joseph Coffland" <joseph@buildbotics.com>
+
+\******************************************************************************/
+
+#include "gcode_state.h"
+
+
+PGM_P gs_get_units_pgmstr(units_t mode) {
+  switch (mode) {
+  case INCHES:      return PSTR("IN");
+  case MILLIMETERS: return PSTR("MM");
+  case DEGREES:     return PSTR("DEG");
+  }
+
+  return PSTR("INVALID");
+}
+
+
+PGM_P gs_get_feed_mode_pgmstr(feed_mode_t mode) {
+  switch (mode) {
+  case INVERSE_TIME_MODE:         return PSTR("INVERSE TIME");
+  case UNITS_PER_MINUTE_MODE:     return PSTR("PER MIN");
+  case UNITS_PER_REVOLUTION_MODE: return PSTR("PER REV");
+  }
+
+  return PSTR("INVALID");
+}
+
+
+PGM_P gs_get_plane_pgmstr(plane_t plane) {
+  switch (plane) {
+  case PLANE_XY: return PSTR("XY");
+  case PLANE_XZ: return PSTR("XZ");
+  case PLANE_YZ: return PSTR("YZ");
+  }
+
+  return PSTR("INVALID");
+}
+
+
+PGM_P gs_get_coord_system_pgmstr(coord_system_t cs) {
+  switch (cs) {
+  case ABSOLUTE_COORDS: return PSTR("ABS");
+  case G54: return PSTR("G54");
+  case G55: return PSTR("G55");
+  case G56: return PSTR("G56");
+  case G57: return PSTR("G57");
+  case G58: return PSTR("G58");
+  case G59: return PSTR("G59");
+  }
+
+  return PSTR("INVALID");
+}
+
+
+PGM_P gs_get_path_mode_pgmstr(path_mode_t mode) {
+  switch (mode) {
+  case PATH_EXACT_PATH: return PSTR("EXACT PATH");
+  case PATH_EXACT_STOP: return PSTR("EXACT STOP");
+  case PATH_CONTINUOUS: return PSTR("CONTINUOUS");
+  }
+
+  return PSTR("INVALID");
+}
+
+
+PGM_P gs_get_distance_mode_pgmstr(distance_mode_t mode) {
+  switch (mode) {
+  case ABSOLUTE_MODE:    return PSTR("ABSOLUTE");
+  case INCREMENTAL_MODE: return PSTR("INCREMENTAL");
+  }
+
+  return PSTR("INVALID");
+}
diff --git a/src/gcode_state.def b/src/gcode_state.def
new file mode 100644 (file)
index 0000000..90d7e48
--- /dev/null
@@ -0,0 +1,69 @@
+/******************************************************************************\
+
+                This file is part of the Buildbotics firmware.
+
+                  Copyright (c) 2015 - 2016 Buildbotics LLC
+                  Copyright (c) 2010 - 2015 Alden S. Hart, Jr.
+                            All rights reserved.
+
+     This file ("the software") is free software: you can redistribute it
+     and/or modify it under the terms of the GNU General Public License,
+      version 2 as published by the Free Software Foundation. You should
+      have received a copy of the GNU General Public License, version 2
+     along with the software. If not, see <http://www.gnu.org/licenses/>.
+
+     The software is distributed in the hope that it will be useful, but
+          WITHOUT ANY WARRANTY; without even the implied warranty of
+      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+               Lesser General Public License for more details.
+
+       You should have received a copy of the GNU Lesser General Public
+                License along with the software.  If not, see
+                       <http://www.gnu.org/licenses/>.
+
+                For information regarding this software email:
+                  "Joseph Coffland" <joseph@buildbotics.com>
+
+\******************************************************************************/
+
+MEMBER(uint32_t, line)                      // Gcode block line number
+
+MEMBER(uint8_t, tool)                       // T - sets this value
+
+MEMBER(float, feed_rate)                    // F - mm/min or inverse time mode
+MEMBER(feed_mode_t, feed_mode)
+MEMBER(float, feed_override_factor)         // 1.0000 x F feed rate
+MEMBER(bool, feed_override_enable)          // M48, M49
+
+MEMBER(float, spindle_speed)                // in RPM
+MEMBER(spindle_mode_t, spindle_mode)
+MEMBER(float, spindle_override_factor)      // 1.0000 x S spindle speed
+MEMBER(bool, spindle_override_enable)       // true = override enabled
+
+MEMBER(motion_mode_t, motion_mode)          // Group 1 modal motion
+MEMBER(plane_t, plane)                      // G17, G18, G19
+MEMBER(units_t, units)                      // G20, G21
+MEMBER(coord_system_t, coord_system)        // G54-G59 - select coord system 1-9
+MEMBER(bool, absolute_mode)                 // G53 move in machine coordinates
+MEMBER(path_mode_t, path_mode)              // G61
+MEMBER(distance_mode_t, distance_mode)      // G91
+MEMBER(distance_mode_t, arc_distance_mode)  // G91.1
+
+MEMBER(bool, mist_coolant)                  // mist on (M7), off (M9)
+MEMBER(bool, flood_coolant)                 // mist on (M8), off (M9)
+
+MEMBER(next_action_t, next_action)          // G group 1 moves & non-modals
+MEMBER(program_flow_t, program_flow)        // used only by the gcode_parser
+
+// TODO unimplemented gcode parameters
+// MEMBER(float cutter_radius)      // D - cutter radius compensation (0 is off)
+// MEMBER(float cutter_length)      // H - cutter length compensation (0 is off)
+
+// Used for input only
+MEMBER(float, target[AXES])                 // XYZABC where the move should go
+MEMBER(bool, override_enables)              // feed and spindle enable
+MEMBER(bool, tool_change)                   // M6 tool change flag
+
+MEMBER(float, parameter)                    // P - dwell & G10 coord select
+MEMBER(float, arc_radius)                   // R - in arc radius mode
+MEMBER(float, arc_offset[3])                // IJK - used by arc commands
index 03cf2c1ae0798452349affc317bb6a869677edb0..af30e96bf1e9c385d04e8e368492310df1cb48db 100644 (file)
 
 #pragma once
 
+#include "config.h"
+
+#include <avr/pgmspace.h>
+
 #include <stdint.h>
 #include <stdbool.h>
 
@@ -180,46 +184,22 @@ typedef enum {
 
 /// Gcode model state
 typedef struct {
-  uint32_t line;                      // Gcode block line number
-
-  uint8_t tool;                       // Tool after T and M6
-  uint8_t tool_select;                // T - sets this value
-
-  float feed_rate;                    // F - in mm/min or inverse time mode
-  feed_mode_t feed_mode;
-  float feed_override_factor;         // 1.0000 x F feed rate
-  bool feed_override_enable;          // M48, M49
-
-  float spindle_speed;                // in RPM
-  spindle_mode_t spindle_mode;
-  float spindle_override_factor;      // 1.0000 x S spindle speed
-  bool spindle_override_enable;       // true = override enabled
-
-  motion_mode_t motion_mode;          // Group 1 modal motion
-  plane_t plane;                      // G17, G18, G19
-  units_t units;                      // G20, G21
-  coord_system_t coord_system;        // G54-G59 - select coordinate system 1-9
-  bool absolute_mode;                 // G53 true = move in machine coordinates
-  path_mode_t path_mode;              // G61
-  distance_mode_t distance_mode;      // G91
-  distance_mode_t arc_distance_mode;  // G91.1
-
-  bool mist_coolant;                  // true = mist on (M7), false = off (M9)
-  bool flood_coolant;                 // true = mist on (M8), false = off (M9)
-
-  next_action_t next_action;          // handles G group 1 moves & non-modals
-  program_flow_t program_flow;        // used only by the gcode_parser
-
-  // TODO unimplemented gcode parameters
-  // float cutter_radius;           // D - cutter radius compensation (0 is off)
-  // float cutter_length;           // H - cutter length compensation (0 is off)
-
-  // Used for input only
-  float target[AXES];                 // XYZABC where the move should go
-  bool override_enables;              // feed and spindle enable
-  bool tool_change;                   // M6 tool change flag
-
-  float parameter;                    // P - dwell time in sec, G10 coord select
-  float arc_radius;                   // R - radius value in arc radius mode
-  float arc_offset[3];                // IJK - used by arc commands
+#define MEMBER(TYPE, VAR) TYPE VAR;
+#include "gcode_state.def"
+#undef MEMBER
 } gcode_state_t;
+
+
+typedef struct {
+#define MEMBER(TYPE, VAR) bool VAR;
+#include "gcode_state.def"
+#undef MEMBER
+} gcode_flags_t;
+
+
+PGM_P gs_get_units_pgmstr(units_t mode);
+PGM_P gs_get_feed_mode_pgmstr(feed_mode_t mode);
+PGM_P gs_get_plane_pgmstr(plane_t plane);
+PGM_P gs_get_coord_system_pgmstr(coord_system_t cs);
+PGM_P gs_get_path_mode_pgmstr(path_mode_t mode);
+PGM_P gs_get_distance_mode_pgmstr(distance_mode_t mode);
index b6a80aa0f1100b90e3fc19f1376cae85278d0d42..bd7898927e00b6cd79d183118f9612683bcef64d 100644 (file)
@@ -171,12 +171,12 @@ static homing_t hm = {0};
  */
 static int8_t _get_next_axis(int8_t axis) {
   switch (axis) {
-  case     -1: if (fp_TRUE(parser.gf.target[AXIS_Z])) return AXIS_Z;
-  case AXIS_Z: if (fp_TRUE(parser.gf.target[AXIS_X])) return AXIS_X;
-  case AXIS_X: if (fp_TRUE(parser.gf.target[AXIS_Y])) return AXIS_Y;
-  case AXIS_Y: if (fp_TRUE(parser.gf.target[AXIS_A])) return AXIS_A;
-  case AXIS_A: if (fp_TRUE(parser.gf.target[AXIS_B])) return AXIS_B;
-  case AXIS_B: if (fp_TRUE(parser.gf.target[AXIS_C])) return AXIS_C;
+  case     -1: if (parser.gf.target[AXIS_Z]) return AXIS_Z;
+  case AXIS_Z: if (parser.gf.target[AXIS_X]) return AXIS_X;
+  case AXIS_X: if (parser.gf.target[AXIS_Y]) return AXIS_Y;
+  case AXIS_Y: if (parser.gf.target[AXIS_A]) return AXIS_A;
+  case AXIS_A: if (parser.gf.target[AXIS_B]) return AXIS_B;
+  case AXIS_B: if (parser.gf.target[AXIS_C]) return AXIS_C;
   }
 
   return axis == -1 ? -2 : -1; // error or done
@@ -206,7 +206,7 @@ static void _homing_error_exit(stat_t status) {
 /// Execute moves
 static void _homing_axis_move(int8_t axis, float target, float velocity) {
   float vect[AXES] = {0};
-  float flags[AXES] = {0};
+  bool flags[AXES] = {0};
 
   vect[axis] = target;
   flags[axis] = true;
index 009d4156900602280c238cce5bde6cc9248b34b0..ba654c10374d7283fd74e916110979499fb1b6cb 100644 (file)
@@ -71,6 +71,7 @@
 #include "util.h"
 #include "report.h"
 #include "homing.h"
+#include "gcode_state.h"
 
 #include "plan/planner.h"
 #include "plan/runtime.h"
@@ -144,75 +145,6 @@ distance_mode_t mach_get_distance_mode() {return mach.gm.distance_mode;}
 distance_mode_t mach_get_arc_distance_mode() {return mach.gm.arc_distance_mode;}
 
 
-PGM_P mach_get_units_pgmstr(units_t mode) {
-  switch (mode) {
-  case INCHES:      return PSTR("IN");
-  case MILLIMETERS: return PSTR("MM");
-  case DEGREES:     return PSTR("DEG");
-  }
-
-  return PSTR("INVALID");
-}
-
-
-PGM_P mach_get_feed_mode_pgmstr(feed_mode_t mode) {
-  switch (mode) {
-  case INVERSE_TIME_MODE:         return PSTR("INVERSE TIME");
-  case UNITS_PER_MINUTE_MODE:     return PSTR("PER MIN");
-  case UNITS_PER_REVOLUTION_MODE: return PSTR("PER REV");
-  }
-
-  return PSTR("INVALID");
-}
-
-
-PGM_P mach_get_plane_pgmstr(plane_t plane) {
-  switch (plane) {
-  case PLANE_XY: return PSTR("XY");
-  case PLANE_XZ: return PSTR("XZ");
-  case PLANE_YZ: return PSTR("YZ");
-  }
-
-  return PSTR("INVALID");
-}
-
-
-PGM_P mach_get_coord_system_pgmstr(coord_system_t cs) {
-  switch (cs) {
-  case ABSOLUTE_COORDS: return PSTR("ABS");
-  case G54: return PSTR("G54");
-  case G55: return PSTR("G55");
-  case G56: return PSTR("G56");
-  case G57: return PSTR("G57");
-  case G58: return PSTR("G58");
-  case G59: return PSTR("G59");
-  }
-
-  return PSTR("INVALID");
-}
-
-
-PGM_P mach_get_path_mode_pgmstr(path_mode_t mode) {
-  switch (mode) {
-  case PATH_EXACT_PATH: return PSTR("EXACT PATH");
-  case PATH_EXACT_STOP: return PSTR("EXACT STOP");
-  case PATH_CONTINUOUS: return PSTR("CONTINUOUS");
-  }
-
-  return PSTR("INVALID");
-}
-
-
-PGM_P mach_get_distance_mode_pgmstr(distance_mode_t mode) {
-  switch (mode) {
-  case ABSOLUTE_MODE:    return PSTR("ABSOLUTE");
-  case INCREMENTAL_MODE: return PSTR("INCREMENTAL");
-  }
-
-  return PSTR("INVALID");
-}
-
-
 void mach_set_motion_mode(motion_mode_t motion_mode) {
   mach.gm.motion_mode = motion_mode;
 }
@@ -253,7 +185,7 @@ void mach_set_absolute_mode(bool absolute_mode) {
 }
 
 
-void mach_set_model_line(uint32_t line) {mach.gm.line = line;}
+void mach_set_line(uint32_t line) {mach.gm.line = line;}
 
 
 /* Coordinate systems and offsets
@@ -453,7 +385,7 @@ float mach_calc_move_time(const float axis_length[],
 }
 
 
-/* Set target vector in GM model
+/*** Calculate target vector
  *
  * This is a core routine. It handles:
  *    - conversion of linear units to internal canonical form (mm)
@@ -473,12 +405,11 @@ float mach_calc_move_time(const float axis_length[],
  *    Target coordinates are provided in target[]
  *    Axes that need processing are signaled in flag[]
  */
-
 void mach_calc_model_target(float target[], const float values[],
-                            const float flags[]) {
+                            const bool flags[]) {
   // process XYZABC for lower modes
   for (int axis = AXIS_X; axis <= AXIS_Z; axis++) {
-    if (fp_FALSE(flags[axis]) || axes[axis].axis_mode == AXIS_DISABLED)
+    if (!flags[axis] || axes[axis].axis_mode == AXIS_DISABLED)
       continue; // skip axis if not flagged for update or its disabled
 
     if (axes[axis].axis_mode == AXIS_STANDARD ||
@@ -492,7 +423,7 @@ void mach_calc_model_target(float target[], const float values[],
 
   // Note: The ABC loop below relies on the XYZ loop having been run first
   for (int axis = AXIS_A; axis <= AXIS_C; axis++) {
-    if (fp_FALSE(flags[axis]) || axes[axis].axis_mode == AXIS_DISABLED)
+    if (!flags[axis] || axes[axis].axis_mode == AXIS_DISABLED)
       continue; // skip axis if not flagged for update or its disabled
 
     float tmp;
@@ -603,11 +534,11 @@ void mach_set_arc_distance_mode(distance_mode_t mode) {
  * This function applies the offset to the GM model.
  */
 void mach_set_coord_offsets(coord_system_t coord_system, float offset[],
-                            float flag[]) {
+                            bool flags[]) {
   if (coord_system < G54 || G59 < coord_system) return;
 
   for (int axis = 0; axis < AXES; axis++)
-    if (fp_TRUE(flag[axis]))
+    if (flags[axis])
       mach.offset[coord_system][axis] = TO_MILLIMETERS(offset[axis]);
 }
 
@@ -671,7 +602,7 @@ static stat_t _exec_absolute_origin(mp_buffer_t *bf) {
   const float *flags = bf->unit;
 
   for (int axis = 0; axis < AXES; axis++)
-    if (fp_TRUE(flags[axis])) {
+    if (flags[axis]) {
       mp_runtime_set_axis_position(axis, origin[axis]);
       mach_set_homed(axis, true);  // G28.3 is not considered homed until here
     }
@@ -694,11 +625,11 @@ static stat_t _exec_absolute_origin(mp_buffer_t *bf) {
  * recording done by the encoders.  At that point any axis that is set
  * is also marked as homed.
  */
-void mach_set_absolute_origin(float origin[], float flags[]) {
+void mach_set_absolute_origin(float origin[], bool flags[]) {
   float value[AXES];
 
   for (int axis = 0; axis < AXES; axis++)
-    if (fp_TRUE(flags[axis])) {
+    if (flags[axis]) {
       value[axis] = TO_MILLIMETERS(origin[axis]);
       mach.position[axis] = value[axis];           // set model position
       mp_set_axis_position(axis, value[axis]);     // set mm position
@@ -716,11 +647,11 @@ void mach_set_absolute_origin(float origin[], float flags[]) {
  */
 
 /// G92
-void mach_set_origin_offsets(float offset[], float flag[]) {
+void mach_set_origin_offsets(float offset[], bool flags[]) {
   // set offsets in the Gcode model extended context
   mach.origin_offset_enable = true;
   for (int axis = 0; axis < AXES; axis++)
-    if (fp_TRUE(flag[axis]))
+    if (flags[axis])
       mach.origin_offset[axis] = mach.position[axis] -
         mach.offset[mach.gm.coord_system][axis] - TO_MILLIMETERS(offset[axis]);
 }
@@ -749,7 +680,7 @@ void mach_resume_origin_offsets() {
 // Free Space Motion (4.3.4)
 
 /// G0 linear rapid
-stat_t mach_rapid(float values[], float flags[]) {
+stat_t mach_rapid(float values[], bool flags[]) {
   mach.gm.motion_mode = MOTION_MODE_RAPID;
 
   float target[AXES];
@@ -773,14 +704,14 @@ void mach_set_g28_position() {copy_vector(mach.g28_position, mach.position);}
 
 
 /// G28
-stat_t mach_goto_g28_position(float target[], float flags[]) {
+stat_t mach_goto_g28_position(float target[], bool flags[]) {
   mach_set_absolute_mode(true);
 
   // move through intermediate point, or skip
   mach_rapid(target, flags);
 
   // execute actual stored move
-  float f[] = {1, 1, 1, 1, 1, 1};
+  bool f[] = {true, true, true, true, true, true};
   return mach_rapid(mach.g28_position, f);
 }
 
@@ -790,14 +721,14 @@ void mach_set_g30_position() {copy_vector(mach.g30_position, mach.position);}
 
 
 /// G30
-stat_t mach_goto_g30_position(float target[], float flags[]) {
+stat_t mach_goto_g30_position(float target[], bool flags[]) {
   mach_set_absolute_mode(true);
 
   // move through intermediate point, or skip
   mach_rapid(target, flags);
 
   // execute actual stored move
-  float f[] = {1, 1, 1, 1, 1, 1};
+  bool f[] = {true, true, true, true, true, true};
   return mach_rapid(mach.g30_position, f);
 }
 
@@ -838,7 +769,7 @@ stat_t mach_dwell(float seconds) {
 
 
 /// G1
-stat_t mach_feed(float values[], float flags[]) {
+stat_t mach_feed(float values[], bool flags[]) {
   // trap zero feed rate condition
   if (fp_ZERO(mach.gm.feed_rate) ||
       (mach.gm.feed_mode == INVERSE_TIME_MODE && !parser.gf.feed_rate))
@@ -867,7 +798,7 @@ stat_t mach_feed(float values[], float flags[]) {
 // Tool Functions (4.3.8)
 
 /// T parameter
-void mach_select_tool(uint8_t tool_select) {mach.gm.tool_select = tool_select;}
+void mach_select_tool(uint8_t tool) {mach.gm.tool = tool;}
 
 
 static stat_t _exec_change_tool(mp_buffer_t *bf) {
@@ -878,8 +809,6 @@ static stat_t _exec_change_tool(mp_buffer_t *bf) {
 
 /// M6 This might become a complete tool change cycle
 void mach_change_tool(bool x) {
-  mach.gm.tool = mach.gm.tool_select;
-
   mp_buffer_t *bf = mp_queue_get_tail();
   bf->value = mach.gm.tool;
   mp_queue_push(_exec_change_tool, mach_get_line());
@@ -930,7 +859,7 @@ void mach_override_enables(bool flag) {
 
 /// M50
 void mach_feed_override_enable(bool flag) {
-  if (fp_TRUE(parser.gf.parameter) && fp_ZERO(parser.gn.parameter))
+  if (parser.gf.parameter && fp_ZERO(parser.gn.parameter))
     mach.gm.feed_override_enable = false;
   else mach.gm.feed_override_enable = true;
 }
@@ -945,7 +874,7 @@ void mach_feed_override_factor(bool flag) {
 
 /// M51
 void mach_spindle_override_enable(bool flag) {
-  if (fp_TRUE(parser.gf.parameter) && fp_ZERO(parser.gn.parameter))
+  if (parser.gf.parameter && fp_ZERO(parser.gn.parameter))
     mach.gm.spindle_override_enable = false;
   else mach.gm.spindle_override_enable = true;
 }
@@ -1051,11 +980,3 @@ void mach_program_end() {
   mach_set_feed_mode(UNITS_PER_MINUTE_MODE);    // G94
   mach_set_motion_mode(MOTION_MODE_CANCEL_MOTION_MODE);
 }
-
-
-/// return ASCII char for axis given the axis number
-char mach_get_axis_char(int8_t axis) {
-  char axis_char[] = "XYZABC";
-  if (axis < 0 || axis > AXES) return ' ';
-  return axis_char[axis];
-}
index 2c668403dc780d61c962d6a1fdfb4e7760faaf83..317ebbeaa974d0b5c1713fd0e16e868748500a8f 100644 (file)
@@ -33,8 +33,6 @@
 #include "status.h"
 #include "gcode_state.h"
 
-#include <avr/pgmspace.h>
-
 
 #define TO_MILLIMETERS(a) (mach_get_units() == INCHES ? (a) * MM_PER_INCH : a)
 
@@ -53,18 +51,11 @@ path_mode_t mach_get_path_mode();
 distance_mode_t mach_get_distance_mode();
 distance_mode_t mach_get_arc_distance_mode();
 
-PGM_P mach_get_units_pgmstr(units_t mode);
-PGM_P mach_get_feed_mode_pgmstr(feed_mode_t mode);
-PGM_P mach_get_plane_pgmstr(plane_t plane);
-PGM_P mach_get_coord_system_pgmstr(coord_system_t cs);
-PGM_P mach_get_path_mode_pgmstr(path_mode_t mode);
-PGM_P mach_get_distance_mode_pgmstr(distance_mode_t mode);
-
 void mach_set_motion_mode(motion_mode_t motion_mode);
 void mach_set_spindle_mode(spindle_mode_t spindle_mode);
 void mach_set_spindle_speed(float speed);
 void mach_set_absolute_mode(bool absolute_mode);
-void mach_set_model_line(uint32_t line);
+void mach_set_line(uint32_t line);
 
 // Coordinate systems and offsets
 float mach_get_active_coord_offset(uint8_t axis);
@@ -76,7 +67,7 @@ float mach_get_axis_position(uint8_t axis);
 // Critical helpers
 float mach_calc_move_time(const float axis_length[], const float axis_square[]);
 void mach_calc_model_target(float target[], const float values[],
-                            const float flags[]);
+                            const bool flags[]);
 stat_t mach_test_soft_limits(float target[]);
 
 // machining functions defined by NIST [organized by NIST Gcode doc]
@@ -90,26 +81,26 @@ void mach_set_units(units_t mode);
 void mach_set_distance_mode(distance_mode_t mode);
 void mach_set_arc_distance_mode(distance_mode_t mode);
 void mach_set_coord_offsets(coord_system_t coord_system, float offset[],
-                            float flag[]);
+                            bool flags[]);
 
 void mach_set_axis_position(unsigned axis, float position);
-void mach_set_absolute_origin(float origin[], float flag[]);
+void mach_set_absolute_origin(float origin[], bool flags[]);
 
 stat_t mach_zero_all();
 stat_t mach_zero_axis(unsigned axis);
 
 void mach_set_coord_system(coord_system_t coord_system);
-void mach_set_origin_offsets(float offset[], float flag[]);
+void mach_set_origin_offsets(float offset[], bool flags[]);
 void mach_reset_origin_offsets();
 void mach_suspend_origin_offsets();
 void mach_resume_origin_offsets();
 
 // Free Space Motion (4.3.4)
-stat_t mach_rapid(float target[], float flags[]);
+stat_t mach_rapid(float target[], bool flags[]);
 void mach_set_g28_position();
-stat_t mach_goto_g28_position(float target[], float flags[]);
+stat_t mach_goto_g28_position(float target[], bool flags[]);
 void mach_set_g30_position();
-stat_t mach_goto_g30_position(float target[], float flags[]);
+stat_t mach_goto_g30_position(float target[], bool flags[]);
 
 // Machining Attributes (4.3.5)
 void mach_set_feed_rate(float feed_rate);
@@ -117,9 +108,9 @@ void mach_set_feed_mode(feed_mode_t mode);
 void mach_set_path_mode(path_mode_t mode);
 
 // Machining Functions (4.3.6)
-stat_t mach_feed(float target[], float flags[]);
-stat_t mach_arc_feed(float target[], float flags[], float offsets[],
-                     float offset_f[], float radius, bool radius_f,
+stat_t mach_feed(float target[], bool flags[]);
+stat_t mach_arc_feed(float target[], bool flags[], float offsets[],
+                     bool offset_f[], float radius, bool radius_f,
                      float P, bool P_f, bool modal_g1_f, uint8_t motion_mode);
 stat_t mach_dwell(float seconds);
 
@@ -146,5 +137,3 @@ void mach_program_stop();
 void mach_optional_program_stop();
 void mach_pallet_change_stop();
 void mach_program_end();
-
-char mach_get_axis_char(int8_t axis);
index 1874b13cbd6124951ffcf9db5a1ffcd7cd2f4bbe..b822ce65ae51ee4aa42869e1b6209c8600022ae4 100644 (file)
@@ -342,10 +342,10 @@ static stat_t _compute_arc(bool radius_f, const float position[],
  * Generates an arc by queuing line segments to the move buffer. The arc is
  * approximated by generating a large number of tiny, linear segments.
  */
-stat_t mach_arc_feed(float values[], float values_f[],   // arc endpoints
-                     float offsets[], float offsets_f[], // arc offsets
-                     float radius,  bool radius_f,       // radius
-                     float P, bool P_f,                  // parameter
+stat_t mach_arc_feed(float values[], bool values_f[],   // arc endpoints
+                     float offsets[], bool offsets_f[], // arc offsets
+                     float radius,  bool radius_f,      // radius
+                     float P, bool P_f,                 // parameter
                      bool modal_g1_f,
                      uint8_t motion_mode) { // defined motion mode
 
index ab7dcc30db50c0c55bbf95ca94ab58648526a7d9..e37bbee9fd0129f912b43b994b632aed48543392 100644 (file)
@@ -68,7 +68,7 @@ typedef struct {
   // probe destination
   float start_position[AXES];
   float target[AXES];
-  float flags[AXES];
+  bool flags[AXES];
 } probing_t;
 
 
@@ -191,15 +191,14 @@ bool mach_is_probing() {
 
 
 /// G38.2 homing cycle using limit switches
-stat_t mach_probe(float target[], float flags[]) {
+stat_t mach_probe(float target[], bool flags[]) {
   // trap zero feed rate condition
   if (mach_get_feed_mode() != INVERSE_TIME_MODE &&
       fp_ZERO(mach_get_feed_rate()))
     return STAT_GCODE_FEEDRATE_NOT_SPECIFIED;
 
   // trap no axes specified
-  if (fp_NOT_ZERO(flags[AXIS_X]) && fp_NOT_ZERO(flags[AXIS_Y]) &&
-      fp_NOT_ZERO(flags[AXIS_Z]))
+  if (!flags[AXIS_X] && !flags[AXIS_Y] && !flags[AXIS_Z])
     return STAT_GCODE_AXIS_IS_MISSING;
 
   // set probe move endpoint
index 870eed6f7722d9cc3c3c152772a494716473eafb..0e3fc011a0052e14ac3603f9cfe3cc15f02c6590 100644 (file)
@@ -33,5 +33,5 @@
 
 
 bool mach_is_probing();
-stat_t mach_probe(float target[], float flags[]);
+stat_t mach_probe(float target[], bool flags[]);
 void mach_probe_callback();
index 3ccb3a27371eb609a386b63c740c3675327eef2f..9ef970edafa56a07955bb3f3bfdaeb6398e969fc 100644 (file)
@@ -38,36 +38,36 @@ float get_position(int index) {return mp_runtime_get_axis_position(index);}
 
 // GCode
 int32_t get_line() {return mp_runtime_get_line();}
-PGM_P get_unit() {return mach_get_units_pgmstr(mach_get_units());}
+PGM_P get_unit() {return gs_get_units_pgmstr(mach_get_units());}
 float get_speed() {return spindle_get_speed();}
 float get_feed() {return mach_get_feed_rate();} // TODO get runtime value
 uint8_t get_tool() {return mp_runtime_get_tool();}
 
 
 PGM_P get_feed_mode() {
-  return mach_get_feed_mode_pgmstr(mach_get_feed_mode());
+  return gs_get_feed_mode_pgmstr(mach_get_feed_mode());
 }
 
 
-PGM_P get_plane() {return mach_get_plane_pgmstr(mach_get_plane());}
+PGM_P get_plane() {return gs_get_plane_pgmstr(mach_get_plane());}
 
 
 PGM_P get_coord_system() {
-  return mach_get_coord_system_pgmstr(mach_get_coord_system());
+  return gs_get_coord_system_pgmstr(mach_get_coord_system());
 }
 
 
 bool get_abs_override() {return mach_get_absolute_mode();}
-PGM_P get_path_mode() {return mach_get_path_mode_pgmstr(mach_get_path_mode());}
+PGM_P get_path_mode() {return gs_get_path_mode_pgmstr(mach_get_path_mode());}
 
 
 PGM_P get_distance_mode() {
-  return mach_get_distance_mode_pgmstr(mach_get_distance_mode());
+  return gs_get_distance_mode_pgmstr(mach_get_distance_mode());
 }
 
 
 PGM_P get_arc_dist_mode() {
-  return mach_get_distance_mode_pgmstr(mach_get_arc_distance_mode());
+  return gs_get_distance_mode_pgmstr(mach_get_arc_distance_mode());
 }