Etienne Landon před 7 roky
rodič
revize
c34159615b
2 změnil soubory, kde provedl 28 přidání a 55 odebrání
  1. 24 24
      osc.h
  2. 4 31
      stepper.h

+ 24 - 24
osc.h

@@ -44,26 +44,26 @@ void printTest(OSCMessage &msg) {
 
 
 void homing_Stepper_OSC(OSCMessage &msg) {
-  homing_Stepper();
-  sendOSC("/stepper/homing",3, "done" );
+  homing_steppers();
+  sendOSC("/homing",3, "done" );
 }
 
 
 void setCurrentPosition_Stepper_OSC (OSCMessage &msg) {
   int index = msg.getInt(0);
   steppers[index].setCurrentPosition(msg.getInt(1));
-  sendOSC("/stepper/setPosition/", index,  "position set");
+  sendOSC("/setPosition/", index,  "position set");
 }
 
 void drivingMode_Stepper_OSC (OSCMessage &msg) {
   driveMode = msg.getInt(0);
-  sendOSC("/stepper/driveMode/", 3,  "set to " + driveMode);
+  sendOSC("/driveMode/", 3,  "set to " + driveMode);
 }
 
 void moveTo_Stepper_OSC (OSCMessage &msg){
   int index = msg.getInt(0);
   long int distance = moveTo_Stepper(index, msg.getInt(1));
-  sendOSC("/stepper/distanceToGo", index, distance );
+  sendOSC("/distanceToGo", index, distance );
 //  while (!stepper.distanceToGo()==0)
 //    stepper.run();
 }
@@ -71,34 +71,34 @@ void moveTo_Stepper_OSC (OSCMessage &msg){
 void move_Stepper_OSC (OSCMessage &msg){
   int index = msg.getInt(0);
   long int distance = move_Stepper(index, msg.getInt(1));
-  sendOSC("/stepper/distanceToGo", index, distance );
+  sendOSC("/distanceToGo", index, distance );
 }
 
 void setSpeed_Stepper (OSCMessage &msg){
   int index = msg.getInt(0);
   steppers[index].setSpeed(msg.getInt(1));
-  sendOSC("/stepper/speed", index, steppers[index].speed() );
+  sendOSC("/speed", index, steppers[index].speed() );
 }
 
 void maxSpeed_Stepper (OSCMessage &msg){
   int index = msg.getInt(0);
   long int max_speed = maxSpeed_Stepper(index, msg.getInt(1));
-  sendOSC("/stepper/maxSpeed", index, max_speed );
+  sendOSC("/maxSpeed", index, max_speed );
 }
 
 void acceleration_Stepper (OSCMessage &msg){
   int index = msg.getInt(0);
   long int acceleration = acceleration_Stepper(index, msg.getInt(1));
-  sendOSC("/stepper/acceleration", index, acceleration );
+  sendOSC("/acceleration", index, acceleration );
 }
 
 void currentPos_Stepper_OSC(OSCMessage &msg) {
   int index = msg.getInt(0);
-  sendOSC("/stepper/currentPos", index, steppers[index].currentPosition());
+  sendOSC("/currentPos", index, steppers[index].currentPosition());
 }
 
 void status_Stepper_OSC(int stepper_index) {
-  OSCMessage OSCmsg("/stepper/status");
+  OSCMessage OSCmsg("/status");
   OSCmsg.add(stepper_index);  
   OSCmsg.add(steppers[stepper_index].currentPosition());
   //OSCmsg.add(steppers[stepper_index].targetPosition());
@@ -186,19 +186,19 @@ void handleOSCIn() {
 
 
 //      //STEPPER CONTROL
-//      OSCin.dispatch("/stepper/init", init_Stepper_OSC);
-    OSCin.dispatch("/stepper/getStatus", getStatus_stepper_OSC);
-    OSCin.dispatch("/stepper/setCurrentPosition", setCurrentPosition_Stepper_OSC);
-    OSCin.dispatch("/stepper/currentPosition", currentPos_Stepper_OSC);  
-    OSCin.dispatch("/stepper/driveMode", drivingMode_Stepper_OSC);
-    OSCin.dispatch("/stepper/moveTo", moveTo_Stepper_OSC);
-    OSCin.dispatch("/stepper/move", move_Stepper_OSC);
-//      OSCin.dispatch("/stepper/moveTo/cm", moveToCm_Stepper_OSC);
-//      OSCin.dispatch("/stepper/move/cm", moveCm_Stepper_OSC);
-    OSCin.dispatch("/stepper/setSpeed", setSpeed_Stepper);
-    OSCin.dispatch("/stepper/maxSpeed", maxSpeed_Stepper);
-    OSCin.dispatch("/stepper/acceleration", acceleration_Stepper);
-//      OSCin.dispatch("/stepper/randomMove", randomMove_Stepper_OSC);
+//      OSCin.dispatch("/init", init_Stepper_OSC);
+    OSCin.dispatch("/getStatus", getStatus_stepper_OSC);
+    OSCin.dispatch("/setCurrentPosition", setCurrentPosition_Stepper_OSC);
+    OSCin.dispatch("/currentPosition", currentPos_Stepper_OSC);  
+    OSCin.dispatch("/driveMode", drivingMode_Stepper_OSC);
+    OSCin.dispatch("/moveTo", moveTo_Stepper_OSC);
+    OSCin.dispatch("/move", move_Stepper_OSC);
+//      OSCin.dispatch("/moveTo/cm", moveToCm_Stepper_OSC);
+//      OSCin.dispatch("/move/cm", moveCm_Stepper_OSC);
+    OSCin.dispatch("/setSpeed", setSpeed_Stepper);
+    OSCin.dispatch("/maxSpeed", maxSpeed_Stepper);
+    OSCin.dispatch("/acceleration", acceleration_Stepper);
+//      OSCin.dispatch("/randomMove", randomMove_Stepper_OSC);
 //
 //      //LEDS
 //      OSCin.dispatch("/led/value", valueLed_OSC);

+ 4 - 31
stepper.h

@@ -25,7 +25,7 @@ int MICROSTEPPING = 8 ; //stepper driver
 int REDUCTION_RATIO = 70 ;  // mechanical reduction ration to real camera rotation
 
 // homing switch pins
-const int homing_Pins = { 2, 3 } ; 
+const int homing_Pins[NUM_OF_STEPPERS] = { 2, 3 } ; 
 bool homing[NUM_OF_STEPPERS] ; 
 
 int driveMode ; // global stepper driving mode : default position with acceleration, 1 position with constant speed, 2 constant speed
@@ -110,38 +110,11 @@ float homing_steppers(){
 }
 
 
-
-
-//  stepper.setSpeed(-1*speedLimit[1]); 
-//  while(digitalRead(switchLow)) {
-//    stepper.runSpeed();
-//  }
-//  stepper.stop();
-//  //this is the new 0 step
-//  stepper.setCurrentPosition(0);
-//
-//
-//
-//  delay(1000); //take a breath
-//
-//  //run at constant speed until hitting switchHigh
-//  stepper.setSpeed(speedLimit[1]);
-//  while(digitalRead(switchHigh)) {
-//    stepper.runSpeed(); 
-//  }
-//  stepper.stop();
-//  maxPos = stepper.currentPosition() / stepToCm ;
-//
-//  delay(1000);
-//
-//  stepper.runToNewPosition(maxPos * stepToCm / 2) ; 
-//  return maxPos ;
-}
-
 ///////////////////// SETUP ///////////////////////////
 void setup_steppers(){
-  pinMode (switchLow, INPUT_PULLUP);
-//  pinMode (switchHigh, INPUT_PULLUP);
+  for (int i; i++; i<NUM_OF_STEPPERS) {  
+    pinMode(homing_Pins[i], INPUT_PULLUP); 
+  }
 //  stepper.moveTo(rand() % 200000);
   for(int i ; i < NUM_OF_STEPPERS ; i++ ) {
     steppers[i].setMaxSpeed( 20000);