Edit addresses the issue implied by #52. In simple tests with improvised hardware, frame cannot complete in less than 450ms, which is half a full frame. Will add another check to proj_stop() to evaluate the time elapsed and throw an error if too high or low (+/- 20%)
This commit is contained in:
parent
5e481e77b0
commit
65292524b1
|
@ -285,7 +285,7 @@ void proj_microswitch () {
|
||||||
proj_micro_state = val; //unneeded?
|
proj_micro_state = val; //unneeded?
|
||||||
proj_stop();
|
proj_stop();
|
||||||
} else {
|
} else {
|
||||||
//delay(1); //some smothing value
|
//delay(2); //some smothing value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,20 +310,24 @@ void proj_direction (boolean state) {
|
||||||
void proj_microswitch () {
|
void proj_microswitch () {
|
||||||
int val = digitalRead(PROJECTOR_MICROSWITCH);
|
int val = digitalRead(PROJECTOR_MICROSWITCH);
|
||||||
long now = millis();
|
long now = millis();
|
||||||
if (!proj_primed && val != proj_micro_state && val == PROJECTOR_MICROSWITCH_OPENED) {
|
if (!proj_primed // if not primed
|
||||||
|
&& val != proj_micro_state // AND if state changes
|
||||||
|
&& val == PROJECTOR_MICROSWITCH_OPENED // AND state changes to open
|
||||||
|
&& now - proj_time > PROJECTOR_HALF_TIME) {
|
||||||
//prime
|
//prime
|
||||||
log("projector primed to stop");
|
log("proj_primed => true");
|
||||||
proj_micro_state = val;
|
proj_micro_state = val;
|
||||||
proj_primed = true;
|
proj_primed = true;
|
||||||
} else if (proj_primed && val != proj_micro_state
|
} else if (proj_primed //if primed
|
||||||
&& val == PROJECTOR_MICROSWITCH_CLOSED
|
&& val != proj_micro_state //AND if state changes
|
||||||
&& now - proj_time > PROJECTOR_HALF_TIME) {
|
&& val == PROJECTOR_MICROSWITCH_CLOSED //AND state changes to open
|
||||||
//turn off
|
&& now - proj_time > PROJECTOR_HALF_TIME) { //AND total elapsed time is greater than half frame time
|
||||||
|
//stop
|
||||||
proj_primed = false;
|
proj_primed = false;
|
||||||
proj_micro_state = val;
|
proj_micro_state = val; //unneeded?
|
||||||
proj_stop();
|
proj_stop();
|
||||||
} else {
|
} else {
|
||||||
//delay(1); //some smothing value
|
//delay(2); //some smothing value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue