Commit 465145ae authored by Daniel Stan's avatar Daniel Stan

draft new lotus

parent cfcbbb96
......@@ -33,19 +33,30 @@ void setup()
digitalWrite(RF_M_DRV2, LOW);
}
void move(bool going_up, int target=0, int timeout=0) {
void move(bool going_up, int target=0, int timeout=8000) {
int comp;
int val;
if(target) {
unsigned long deadline;
deadline = millis() + timeout;
if(target)
{
target = min(max(target, POS_LOW), POS_HIGH);
going_up = get_position() < target;
}
else
{
target = going_up?POS_HIGH:POS_LOW;
}
Serial.print("Move:");
Serial.print(going_up?"Up":"Down");
Serial.print(",Target:");
Serial.print(target);
Serial.print(",Timeout:");
Serial.println(timeout);
if(going_up) {
comp=1;
digitalWrite(RF_M_DRV1, HIGH);
......@@ -56,23 +67,17 @@ void move(bool going_up, int target=0, int timeout=0) {
digitalWrite(RF_M_DRV2, HIGH);
}
digitalWrite(RF_M_CONT, HIGH);
if(target) {
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();
do {
delay(1);
val = get_position();
}
if(timeout)
delay(timeout);
while(val *comp < target*comp && millis() < deadline);
// End of move
Serial.print("Done:");
report_pos();
digitalWrite(RF_M_CONT, LOW);
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, LOW);
......
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