Commits

Christophe Combelles committed 34d3902

implemented RX, RI, RV

Comments (0)

Files changed (1)

arduino/pulse_stepper/pulse_stepper.ino

 int rampsteps = 200;
 int curspeed = 0;
 
-
 void moveTo(int target, boolean ramp) {
 
   if (target == x) return;
     digitalWrite(X_DIRECTION, LOW);
   }
   int cur = 0;
-  for (int i=x; i!=target; i+=direction) {
+  for (int i=x; i!=target+direction; i+=direction) {
     curspeed = speed;
-    if (ramp && (cur < rampsteps)) {
-      curspeed = (cur / (float) rampsteps) * speed;
+    if (ramp && (cur <= rampsteps)) {
+      curspeed = (speed / (float) rampsteps) * cur;
     }
     //digitalWrite(X_PULSE, HIGH);
     X_PULSE_PORT |= X_PULSE_BIT;
   if (Serial.available()) {
     curval = Serial.read();
     boolean ramp = false;
+    if (curval == 'R') {
+      while (!Serial.available()) {};
+      curval = Serial.read();
+      if (curval == 'X') {
+        Serial.println(x);
+      }
+      if (curval == 'I') {
+        Serial.println(String("arduino"));
+      }
+      if (curval == 'V') {
+        while (!Serial.available()) {};
+        curval = Serial.read();
+        if (curval == 'H') {   
+          Serial.println(String("0"));
+        }
+        if (curval == 'L') {   
+          Serial.println(String("1"));
+        }
+      }
+    }
     if (curval == 'L') {
       while (!Serial.available()) {};
       curval = Serial.read();