From c731284b07a1e09f8e2a97f6f138cf360fa8e094 Mon Sep 17 00:00:00 2001
From: Jake <jake.read@cba.mit.edu>
Date: Thu, 11 Aug 2022 17:36:19 -0400
Subject: [PATCH] set position, better homing

---
 firmware/axl-stepper/src/axl      |  2 +-
 firmware/axl-stepper/src/main.cpp | 25 ++++++++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/firmware/axl-stepper/src/axl b/firmware/axl-stepper/src/axl
index 71bf902..eb34931 160000
--- a/firmware/axl-stepper/src/axl
+++ b/firmware/axl-stepper/src/axl
@@ -1 +1 @@
-Subproject commit 71bf90214692c6a2fb82d121708b91692648376a
+Subproject commit eb34931b0991d7c6e257968fe60af13b90b1f629
diff --git a/firmware/axl-stepper/src/main.cpp b/firmware/axl-stepper/src/main.cpp
index a35c8e1..42cfefe 100644
--- a/firmware/axl-stepper/src/main.cpp
+++ b/firmware/axl-stepper/src/main.cpp
@@ -12,7 +12,15 @@
 #include "osape_arduino/vp_arduinoSerial.h"
 #include "osape_ucbus/vb_ucBusDrop.h"
 
-OSAP osap("axl-stepper_x");
+//OSAP osap("axl-stepper_z-rear-left");
+//OSAP osap("axl-stepper_z-front-left");
+//OSAP osap("axl-stepper_z-rear-right");
+//OSAP osap("axl-stepper_z-front-right");
+OSAP osap("axl-stepper_y-left");
+//OSAP osap("axl-stepper_y-right");
+//OSAP osap("axl-stepper_x");
+
+//OSAP osap("axl-stepper_e");
 
 VPort_ArduinoSerial vpUSBSerial(&osap, "arduinoUSBSerial", &Serial);
 
@@ -34,10 +42,17 @@ EP_ONDATA_RESPONSES onStateData(uint8_t* data, uint16_t len){
   }
   // set or target?
   if(set){
-    if(mode == AXL_MODE_POSITION){
-      OSAP::error("axl set-pos... havne't written it yet");
-    } else {
-      OSAP::error("we can only 'set' position, others are targs");
+    switch(mode){
+      case AXL_MODE_POSITION:
+        if(axl_isMoving()){
+          OSAP::error("AXL can't set pos while moving");
+          break;
+        }
+        axl_setPosition(targ);
+        break;
+      default:
+        OSAP::error("we can only 'set' position, others are targs");
+        break;
     }
   } else {
     switch(mode){
-- 
GitLab