IDLE->READY, Added speed, feed and tool vars back in
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 28 Aug 2016 00:13:28 +0000 (17:13 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 28 Aug 2016 00:13:28 +0000 (17:13 -0700)
src/machine.c
src/machine.h
src/plan/calibrate.c
src/plan/exec.c
src/plan/jog.c
src/plan/planner.c
src/varcb.c
src/vars.def

index 8b583b928efe80abbd67e862ebc9350401e665e0..462d60c1ed29f1c1a9b9a316b26410db5dc5bb93 100644 (file)
@@ -182,7 +182,7 @@ machine_t mach = {
     }
   },
 
-  ._state = STATE_IDLE,
+  ._state = STATE_READY,
   ._cycle = CYCLE_MACHINING,
 
   // State
@@ -206,7 +206,7 @@ uint32_t mach_get_line() {return mach.gm.line;}
 
 PGM_P mach_get_state_pgmstr(machState_t state) {
   switch (state) {
-  case STATE_IDLE:     return PSTR("idle");
+  case STATE_READY:    return PSTR("ready");
   case STATE_ESTOPPED: return PSTR("estopped");
   case STATE_RUNNING:  return PSTR("running");
   case STATE_STOPPING: return PSTR("stopping");
@@ -256,7 +256,7 @@ void mach_set_state(machState_t state) {
 void mach_set_cycle(machCycle_t cycle) {
   if (mach._cycle == cycle) return; // No change
 
-  if (mach._state != STATE_IDLE) {
+  if (mach._state != STATE_READY) {
     STATUS_ERROR(STAT_INTERNAL_ERROR, "Cannot transition to %S while %S",
                  mach_get_cycle_pgmstr(cycle),
                  mach_get_state_pgmstr(mach._state));
@@ -1173,7 +1173,7 @@ void mach_feedhold_callback() {
 
   // Only flush queue when we are stopped or holding
   if (mach.queue_flush_requested &&
-      (mach_get_state() == STATE_IDLE || mach_get_state() == STATE_HOLDING) &&
+      (mach_get_state() == STATE_READY || mach_get_state() == STATE_HOLDING) &&
       !mach_get_runtime_busy()) {
     mach.queue_flush_requested = false;
     mach_queue_flush();
@@ -1188,7 +1188,7 @@ void mach_feedhold_callback() {
 
       // Check if any moves are buffered
       if (mp_get_run_buffer()) mach_set_state(STATE_RUNNING);
-      else mach_set_state(STATE_IDLE);
+      else mach_set_state(STATE_READY);
     }
   }
 
@@ -1197,7 +1197,7 @@ void mach_feedhold_callback() {
 
 
 static void _exec_program_finalize(float *value, float *flag) {
-  mach_set_state(STATE_IDLE);
+  mach_set_state(STATE_READY);
   mach.hold_state = FEEDHOLD_OFF;     // if in feedhold, end it
   mach.cycle_start_requested = false; // cancel any pending cycle start request
   mp_zero_segment_velocity();         // for reporting purposes
@@ -1267,7 +1267,7 @@ stat_t mach_queue_flush() {
 
 /// Do a cycle start right now
 void mach_cycle_start() {
-  if (mach_get_state() == STATE_IDLE) mach_set_state(STATE_RUNNING);
+  if (mach_get_state() == STATE_READY) mach_set_state(STATE_RUNNING);
 }
 
 
index f9c2a0fd94567861f83130224d8ef7a460f0ea0f..63550d0e4098a58425438ad1522a808b07b1635a 100644 (file)
@@ -45,7 +45,7 @@
 
 
 typedef enum {
-  STATE_IDLE,
+  STATE_READY,
   STATE_ESTOPPED,
   STATE_RUNNING,
   STATE_STOPPING,
@@ -395,6 +395,7 @@ machDistanceMode_t mach_get_distance_mode();
 machFeedRateMode_t mach_get_feed_rate_mode();
 uint8_t mach_get_tool();
 machSpindleMode_t mach_get_spindle_mode();
+inline float mach_get_spindle_speed() {return mach.gm.spindle_speed;}
 bool mach_get_runtime_busy();
 float mach_get_feed_rate();
 
index 289e8ba77a675d346bc61c5762bb168cf1e08a76..d11a2e46602e3b36a9e15265e88a4bf10dd15b04 100644 (file)
@@ -163,7 +163,7 @@ void calibrate_set_stallguard(int motor, uint16_t sg) {
 
 
 uint8_t command_calibrate(int argc, char *argv[]) {
-  if (mach_get_cycle() != CYCLE_MACHINING || mach_get_state() != STATE_IDLE)
+  if (mach_get_cycle() != CYCLE_MACHINING || mach_get_state() != STATE_READY)
     return 0;
 
   mpBuf_t *bf = mp_get_write_buffer();
index e87bb5dfe8cf38532b7b72e570d2ddc11425e9c1..6a0f26de551d44fe6959f7368999e554ade0826f 100644 (file)
@@ -804,7 +804,7 @@ stat_t mp_exec_move() {
   if (!bf) return STAT_NOOP; // nothing running
   if (!bf->bf_func) return CM_ALARM(STAT_INTERNAL_ERROR);
 
-  if (mach_get_state() == STATE_IDLE) mach_set_state(STATE_RUNNING);
+  if (mach_get_state() == STATE_READY) mach_set_state(STATE_RUNNING);
 
   return bf->bf_func(bf); // move callback
 }
index ca978843e7fb8fa849c0986f20954affe157904e..46c5c79f8ab01702642f51ecef79475a0014f30c 100644 (file)
@@ -117,7 +117,7 @@ bool mp_jog_busy() {return mach_get_cycle() == CYCLE_JOGGING;}
 
 uint8_t command_jog(int argc, char *argv[]) {
   if (!mp_jog_busy() &&
-      (mach_get_state() != STATE_IDLE || mach_get_cycle() != CYCLE_MACHINING))
+      (mach_get_state() != STATE_READY || mach_get_cycle() != CYCLE_MACHINING))
     return STAT_NOOP;
 
   float velocity[AXES];
index 1cd969ee5cf9f55349a2f982ed96353f005f2498..cb1a396331f73ceda5a0c4b506b73afba398ce0d 100644 (file)
@@ -89,7 +89,7 @@ void planner_init() {
 void mp_flush_planner() {
   mach_abort_arc();
   mp_init_buffers();
-  mach_set_state(STATE_IDLE);
+  mach_set_state(STATE_READY);
 }
 
 
index 488d0916860a6816cd6de669067dede833f6e70a..e75a1695c57d1fd89476c640278c3f7d808463cc 100644 (file)
@@ -34,6 +34,9 @@
 
 float get_position(int index) {return mp_get_runtime_absolute_position(index);}
 float get_velocity() {return mp_get_runtime_velocity();}
+float get_speed() {return mach_get_spindle_speed();}
+float get_feed() {return mach_get_feed_rate();}
+uint8_t get_tool() {return mach_get_tool();}
 bool get_echo() {return usart_is_set(USART_ECHO);}
 void set_echo(bool value) {return usart_set(USART_ECHO, value);}
 uint16_t get_queue() {return mp_get_planner_buffer_room();}
index e65bf1499aa4a7091ab923895d9e14e3e6b016c9..f62b3762153d40367f3cbfd40c6584798bf2a975 100644 (file)
@@ -93,11 +93,14 @@ VAR(switch_type,    "sw", uint8_t,  SWITCHES, 1, 1, "Normally open or closed")
 
 // System
 VAR(velocity,        "v", float,    0,      0, 0, "Current velocity")
+VAR(speed,           "s", float,    0,      0, 0, "Current spindle speed")
+VAR(feed,            "f", float,    0,      0, 0, "Current feed rate")
+VAR(tool,            "t", uint8_t,  0,      0, 0, "Current tool")
 VAR(hw_id,          "id", string,   0,      0, 0, "Hardware ID")
 VAR(echo,           "ec", bool,     0,      1, 0, "Enable or disable echo")
 VAR(estop,          "es", bool,     0,      1, 0, "Emergency stop")
 VAR(estop_reason,   "er", pstring,  0,      0, 0, "Emergency stop reason")
 VAR(line,           "ln", int32_t,  0,      0, 0, "Last GCode line executed")
 VAR(queue,          "q",  uint16_t, 0,      0, 0, "Space in planner queue")
-VAR(state,          "s",  pstring,  0,      0, 0, "Machine state")
-VAR(cycle,          "c",  pstring,  0,      0, 0, "Current machine cycle")
+VAR(state,          "x",  pstring,  0,      0, 0, "Machine state")
+VAR(cycle,          "c",  pstring,  0,      0, 0, "Machine cycle")