Commit 76d8a358 authored by Daniel Stan's avatar Daniel Stan

lotus: some debug and fixes

parent e36fca84
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#define PIN_POS A0 #define PIN_POS A0
// Position hautes et basses // Position hautes et basses
#define POS_HIGH 280 #define POS_HIGH 275
#define POS_LOW 107 #define POS_LOW 105
#define BOUNCE 3 #define BOUNCE 3
void setup() void setup()
...@@ -38,7 +38,7 @@ void move(bool going_up, int target=0, int timeout=0) { ...@@ -38,7 +38,7 @@ void move(bool going_up, int target=0, int timeout=0) {
int val; int val;
if(target) { if(target) {
target = min(max(target, POS_LOW), POS_HIGH); target = min(max(target, POS_LOW), POS_HIGH);
going_up = target < get_position(); going_up = get_position() < target;
} }
Serial.print("Move:"); Serial.print("Move:");
Serial.print(going_up?"Up":"Down"); Serial.print(going_up?"Up":"Down");
...@@ -48,12 +48,10 @@ void move(bool going_up, int target=0, int timeout=0) { ...@@ -48,12 +48,10 @@ void move(bool going_up, int target=0, int timeout=0) {
Serial.println(timeout); Serial.println(timeout);
if(going_up) { if(going_up) {
comp=1; comp=1;
target = POS_HIGH;
digitalWrite(RF_M_DRV1, HIGH); digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_DRV2, LOW); digitalWrite(RF_M_DRV2, LOW);
} else { } else {
comp=-1; comp=-1;
target = POS_LOW;
digitalWrite(RF_M_DRV1, LOW); digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, HIGH); digitalWrite(RF_M_DRV2, HIGH);
} }
...@@ -62,8 +60,15 @@ void move(bool going_up, int target=0, int timeout=0) { ...@@ -62,8 +60,15 @@ void move(bool going_up, int target=0, int timeout=0) {
do { do {
delay(1); delay(1);
val = get_position(); val = get_position();
} }
while(val *comp < target*comp); while(val *comp < target*comp);
Serial.print("Endmove:");
Serial.print(val);
Serial.print(",");
Serial.print(comp);
Serial.print(",");
Serial.println(target);
report_pos(); report_pos();
} }
if(timeout) if(timeout)
...@@ -99,10 +104,10 @@ void loop() { ...@@ -99,10 +104,10 @@ void loop() {
move(true, 0, 500); move(true, 0, 500);
break; break;
case 'U': case 'U':
move(false, 1024); move(true, 1024);
break; break;
case 'D': case 'D':
move(true, 0); move(false, 1);
break; break;
case 'm': case 'm':
move(false, Serial.parseInt()); move(false, Serial.parseInt());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment