|
@@ -13,6 +13,7 @@ SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
|
|
|
SLIPEncodedSerial SLIPSerial(Serial);
|
|
|
#endif
|
|
|
|
|
|
+bool update_stepper_status[NUM_OF_STEPPERS];
|
|
|
|
|
|
//// UTILITIES /////////
|
|
|
|
|
@@ -80,6 +81,26 @@ void currentPos_Stepper_OSC(OSCMessage &msg) {
|
|
|
sendOSC("/stepper/currentPos", steppers[msg.getInt(0)].currentPosition());
|
|
|
}
|
|
|
|
|
|
+void status_Stepper_OSC(int stepper_index) {
|
|
|
+ OSCMessage OSCmsg("/stepper/status");
|
|
|
+ OSCmsg.add(stepper_index);
|
|
|
+ OSCmsg.add(steppers[stepper_index].currentPosition());
|
|
|
+ OSCmsg.add(steppers[stepper_index].targetPosition());
|
|
|
+ OSCmsg.add(steppers[stepper_index].speed());
|
|
|
+ OSCmsg.add(steppers[stepper_index].maxSpeed());
|
|
|
+ SLIPSerial.beginPacket();
|
|
|
+ //Udp.beginPacket(outIp, outPort);
|
|
|
+ OSCmsg.send(SLIPSerial); // send the bytes to the SLIP stream
|
|
|
+// OSCmsg.send(Udp); // send the bytes to the SLIP stream
|
|
|
+ SLIPSerial.endPacket();
|
|
|
+ //Udp.endPacket(); // mark the end of the OSC Packet
|
|
|
+ OSCmsg.empty(); // free space occupied by message
|
|
|
+}
|
|
|
+
|
|
|
+void getStatus_stepper_OSC(OSCMessage &msg) {
|
|
|
+ status_Stepper_OSC(msg.getInt(0)) ;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
////// OSC DECLARATIONS /////////
|
|
|
|
|
@@ -95,6 +116,16 @@ void setup_OSC(){
|
|
|
|
|
|
void handleOSCIn() {
|
|
|
|
|
|
+ //send stepper status while it is running
|
|
|
+ for(int i ; i < NUM_OF_STEPPERS ; i++ ) {
|
|
|
+ if (update_stepper_status[i]) {
|
|
|
+ status_Stepper_OSC(i) ;
|
|
|
+ }
|
|
|
+ if (!steppers[i].isRunning()) { update_stepper_status[i] = 0 ;}
|
|
|
+ else update_stepper_status[i] = 1 ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//define OSC message to function relationships
|
|
|
OSCMessage OSCin;
|
|
@@ -116,6 +147,7 @@ void handleOSCIn() {
|
|
|
|
|
|
// //STEPPER CONTROL
|
|
|
// OSCin.dispatch("/stepper/init", init_Stepper_OSC);
|
|
|
+ OSCin.dispatch("/stepper/status", getStatus_stepper_OSC);
|
|
|
OSCin.dispatch("/stepper/currentPos", currentPos_Stepper_OSC);
|
|
|
OSCin.dispatch("/stepper/moveTo", moveTo_Stepper_OSC);
|
|
|
OSCin.dispatch("/stepper/move", move_Stepper_OSC);
|