From 65292524b1d08927bcb4dda45b3b9a9dee3e7402 Mon Sep 17 00:00:00 2001 From: sixteenmillimeter Date: Tue, 29 Sep 2020 15:13:22 -0400 Subject: [PATCH] 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%) --- ino/mcopy_JKMM99/mcopy_JKMM99.ino | 2 +- .../mcopy_JKMM99_intval.ino | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ino/mcopy_JKMM99/mcopy_JKMM99.ino b/ino/mcopy_JKMM99/mcopy_JKMM99.ino index d4a4a07..31b9d0b 100644 --- a/ino/mcopy_JKMM99/mcopy_JKMM99.ino +++ b/ino/mcopy_JKMM99/mcopy_JKMM99.ino @@ -285,7 +285,7 @@ void proj_microswitch () { proj_micro_state = val; //unneeded? proj_stop(); } else { - //delay(1); //some smothing value + //delay(2); //some smothing value } } diff --git a/ino/mcopy_JKMM99_intval/mcopy_JKMM99_intval.ino b/ino/mcopy_JKMM99_intval/mcopy_JKMM99_intval.ino index cbc276f..4c878fa 100644 --- a/ino/mcopy_JKMM99_intval/mcopy_JKMM99_intval.ino +++ b/ino/mcopy_JKMM99_intval/mcopy_JKMM99_intval.ino @@ -310,20 +310,24 @@ void proj_direction (boolean state) { void proj_microswitch () { int val = digitalRead(PROJECTOR_MICROSWITCH); 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 - log("projector primed to stop"); + log("proj_primed => true"); proj_micro_state = val; proj_primed = true; - } else if (proj_primed && val != proj_micro_state - && val == PROJECTOR_MICROSWITCH_CLOSED - && now - proj_time > PROJECTOR_HALF_TIME) { - //turn off + } else if (proj_primed //if primed + && val != proj_micro_state //AND if state changes + && val == PROJECTOR_MICROSWITCH_CLOSED //AND state changes to open + && now - proj_time > PROJECTOR_HALF_TIME) { //AND total elapsed time is greater than half frame time + //stop proj_primed = false; - proj_micro_state = val; + proj_micro_state = val; //unneeded? proj_stop(); } else { - //delay(1); //some smothing value + //delay(2); //some smothing value } }