summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-02-07 00:34:20 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-02-07 00:34:20 +0000
commitb3ebb4c030f14617db7940156d3e14ccb6ea35a9 (patch)
treea2d60e4a07fac2ac6bd124c19d3ca35f6ef60358 /usb-i2c-sl018
parenttimeout implemented in statemachine (diff)
stepper respects limits now
git-svn-id: https://svn.spreadspace.org/avr/trunk@162 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018')
-rw-r--r--usb-i2c-sl018/statemachine.c3
-rw-r--r--usb-i2c-sl018/stepper.c11
2 files changed, 12 insertions, 2 deletions
diff --git a/usb-i2c-sl018/statemachine.c b/usb-i2c-sl018/statemachine.c
index fac0964..9a43385 100644
--- a/usb-i2c-sl018/statemachine.c
+++ b/usb-i2c-sl018/statemachine.c
@@ -111,6 +111,9 @@ void statemachine_task_limits(void)
void statemachine_task_event(void)
{
event_t event = eventqueue_pop();
+ if(event == none)
+ return;
+
switch(state) {
case closing:
case opening:
diff --git a/usb-i2c-sl018/stepper.c b/usb-i2c-sl018/stepper.c
index 1a762cd..7501feb 100644
--- a/usb-i2c-sl018/stepper.c
+++ b/usb-i2c-sl018/stepper.c
@@ -26,6 +26,7 @@
#include "stepper.h"
#include "limits.h"
+#include "eventqueue.h"
uint8_t step_table [] =
{
@@ -58,11 +59,17 @@ inline uint8_t handle_step(void)
{
static uint8_t step_idx = 0;
- // limits_t l = get_limits();
-
+ limits_t l = limits_get();
+ if((step_direction == dir_open && l == open) ||
+ (step_direction == dir_close && l == close) || l == both)
+ step_cnt = STEP_CNT_STOP + 1;
+
if(step_cnt < STEP_CNT_STOP) {
step_idx += (step_direction == dir_open) ? 1 : -1;
step_idx %= LENGTH_STEP_TABLE;
+ } else if(step_cnt == STEP_CNT_STOP) {
+ eventqueue_push(move_timeout);
+ return 0;
}
uint8_t stepper_output = step_table[step_idx];