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

lotus: some debug and fixes

parent e36fca84
......@@ -11,8 +11,8 @@
#define PIN_POS A0
// Position hautes et basses
#define POS_HIGH 280
#define POS_LOW 107
#define POS_HIGH 275
#define POS_LOW 105
#define BOUNCE 3
void setup()
......@@ -38,7 +38,7 @@ void move(bool going_up, int target=0, int timeout=0) {
int val;
if(target) {
target = min(max(target, POS_LOW), POS_HIGH);
going_up = target < get_position();
going_up = get_position() < target;
}
Serial.print("Move:");
Serial.print(going_up?"Up":"Down");
......@@ -48,12 +48,10 @@ void move(bool going_up, int target=0, int timeout=0) {
Serial.println(timeout);
if(going_up) {
comp=1;
target = POS_HIGH;
digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_DRV2, LOW);
} else {
comp=-1;
target = POS_LOW;
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, HIGH);
}
......@@ -62,8 +60,15 @@ void move(bool going_up, int target=0, int timeout=0) {
do {
delay(1);
val = get_position();
}
while(val *comp < target*comp);
Serial.print("Endmove:");
Serial.print(val);
Serial.print(",");
Serial.print(comp);
Serial.print(",");
Serial.println(target);
report_pos();
}
if(timeout)
......@@ -99,10 +104,10 @@ void loop() {
move(true, 0, 500);
break;
case 'U':
move(false, 1024);
move(true, 1024);
break;
case 'D':
move(true, 0);
move(false, 1);
break;
case 'm':
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