dwell.{c,h} cleanup
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 23 Mar 2016 21:28:13 +0000 (14:28 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 23 Mar 2016 21:28:13 +0000 (14:28 -0700)
src/canonical_machine.c
src/plan/dwell.c
src/plan/dwell.h [new file with mode: 0644]
src/plan/planner.h

index 55f40586af60f95b0abd06e43493630c0af524be..acc4d56a2d25f8bb718a5e0d0c5324643f9bf218 100644 (file)
 #include "usart.h"            // for serial queue flush
 
 #include "plan/planner.h"
-#include "plan/arc.h"
+#include "plan/dwell.h"
 #include "plan/command.h"
+#include "plan/arc.h"
 
 #include <stdbool.h>
 #include <string.h>
index df28f678852d5c32a75e9a4938239a5a93e7a494..4fa26210f95b6dfaa578e0e7614ec0cf861b6ff3 100644 (file)
 
 \******************************************************************************/
 
+#include "dwell.h"
+
 #include "planner.h"
 #include "canonical_machine.h"
 #include "stepper.h"
 
 
 // Dwells are performed by passing a dwell move to the stepper drivers.
-// When the stepper driver sees a dwell it times the dwell on a separate
-// timer than the stepper pulse timer.
 
 
 /// Dwell execution
 static stat_t _exec_dwell(mpBuf_t *bf) {
   st_prep_dwell(bf->gm.move_time); // in seconds
+
   // free buffer & perform cycle_end if planner is empty
   if (mp_free_run_buffer()) cm_cycle_end();
 
@@ -49,14 +50,15 @@ static stat_t _exec_dwell(mpBuf_t *bf) {
 
 /// Queue a dwell
 stat_t mp_dwell(float seconds) {
-  mpBuf_t *bf;
+  mpBuf_t *bf = mp_get_write_buffer();
 
-  if (!(bf = mp_get_write_buffer())) // get write buffer
-    return cm_hard_alarm(STAT_BUFFER_FULL_FATAL); // never supposed to fail
+  // never supposed to fail
+  if (!bf) return cm_hard_alarm(STAT_BUFFER_FULL_FATAL);
 
   bf->bf_func = _exec_dwell;  // register callback to dwell start
   bf->gm.move_time = seconds; // in seconds, not minutes
   bf->move_state = MOVE_NEW;
+
   // must be final operation before exit
   mp_commit_write_buffer(MOVE_TYPE_DWELL);
 
diff --git a/src/plan/dwell.h b/src/plan/dwell.h
new file mode 100644 (file)
index 0000000..36ea82d
--- /dev/null
@@ -0,0 +1,32 @@
+/******************************************************************************\
+
+                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>
+
+\******************************************************************************/
+
+#pragma once
+
+#include "status.h"
+
+stat_t mp_dwell(const float seconds);
index cf9ee0b39e88505a5d3c836e6bb37442d97beace..a5eb65a1e5f4298af2113f058964575a0c3b3524 100644 (file)
@@ -304,6 +304,3 @@ mpBuf_t *mp_get_last_buffer();
 #define mp_get_next_buffer(b) ((mpBuf_t *)(b->nx))
 void mp_clear_buffer(mpBuf_t *bf);
 void mp_copy_buffer(mpBuf_t *bf, const mpBuf_t *bp);
-
-// dwell.c functions
-stat_t mp_dwell(const float seconds);