Fixed dwell and report dwell time
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Feb 2018 06:01:40 +0000 (22:01 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Feb 2018 06:01:40 +0000 (22:01 -0800)
src/avr/src/command.c
src/avr/src/commands.c
src/avr/src/stepper.c
src/avr/src/vars.def

index 2ad1a95f830387feeda96f825aa449d4cc42d133..4fcea2c2d727186db9c559d2d62a050e23771e7f 100644 (file)
@@ -258,7 +258,7 @@ bool command_exec() {
   unsigned size = _size(code);
 
   static uint8_t data[INPUT_BUFFER_LEN];
-  for (int i = 0; i < size; i++)
+  for (unsigned i = 0; i < size; i++)
     data[i] = sync_q_next();
 
   cmd.count--;
index ee10a8f807332f9393da8ac9226823b85f018073..aa6670c99fae2a15582aa24a991c69de8b798eea 100644 (file)
@@ -34,6 +34,7 @@
 #include "hardware.h"
 #include "report.h"
 #include "state.h"
+#include "exec.h"
 #include "util.h"
 
 #include <string.h>
@@ -48,8 +49,19 @@ stat_t command_dwell(char *cmd) {
 }
 
 
+static stat_t _dwell_exec() {
+  exec_set_cb(0);
+  return STAT_OK;
+}
+
+
 unsigned command_dwell_size() {return sizeof(float);}
-void command_dwell_exec(float *seconds) {st_prep_dwell(*seconds);}
+
+
+void command_dwell_exec(float *seconds) {
+  st_prep_dwell(*seconds);
+  exec_set_cb(_dwell_exec); // Necessary evil
+}
 
 
 // TODO
index a337c1b762bb83efa8201d114b63817219516db3..11b8677caf7a2d156c0d5455f36fd0e0855f77f7 100644 (file)
@@ -64,7 +64,7 @@ typedef struct {
 } stepper_t;
 
 
-static stepper_t st = {0};
+static volatile stepper_t st = {0};
 
 
 void stepper_init() {
@@ -233,3 +233,12 @@ void st_prep_dwell(float seconds) {
 
 // Var callbacks
 uint32_t get_underflow() {return st.underflow;}
+
+
+float get_dwell_time() {
+  float dwell;
+  cli();
+  dwell = st.dwell;
+  sei();
+  return dwell;
+}
index 15b79a55088c7c1b86917bb80791b3f937275f01..2a12f8bcfc15c1ad1f3c5fe38b2429603da2ef7e 100644 (file)
@@ -113,6 +113,7 @@ VAR(hw_id,          hid, str,   0,      0, 1, "Hardware ID")
 VAR(echo,            ec, bool,  0,      1, 1, "Enable or disable echo")
 VAR(estop,           es, bool,  0,      1, 1, "Emergency stop")
 VAR(estop_reason,    er, pstr,  0,      0, 1, "Emergency stop reason")
-VAR(state,           x pstr,  0,      0, 1, "Machine state")
+VAR(state,           xx, pstr,  0,      0, 1, "Machine state")
 VAR(hold_reason,     pr, pstr,  0,      0, 1, "Machine pause reason")
 VAR(underflow,       un, u32,   0,      0, 1, "Stepper underflow count")
+VAR(dwell_time,      dt, f32,   0,      0, 1, "Dwell timer")