From 5e481e77b011b7e68d2d3a1111ec48db090ea5bf Mon Sep 17 00:00:00 2001 From: sixteenmillimeter Date: Tue, 29 Sep 2020 14:00:54 -0400 Subject: [PATCH] Addressing the issue with the JKMM99 projector functionality where frames stop prematurely. Conceivably, the proj_microswitch() function is the only place that calls proj_stop() so the issue is with the logic there. It makes little sense that this function allows for 15ms frames because of the test that requires a 450ms elapsed time before it is stopped. --- ino/mcopy_JKMM99/mcopy_JKMM99.ino | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ino/mcopy_JKMM99/mcopy_JKMM99.ino b/ino/mcopy_JKMM99/mcopy_JKMM99.ino index bae96a0..d4a4a07 100644 --- a/ino/mcopy_JKMM99/mcopy_JKMM99.ino +++ b/ino/mcopy_JKMM99/mcopy_JKMM99.ino @@ -241,6 +241,8 @@ void proj_stop () { digitalWrite(PROJECTOR_FWD, LOW); digitalWrite(PROJECTOR_BWD, LOW); + //evaluate total time + Serial.println(cmd_projector); log("projector()"); proj_running = false; @@ -266,17 +268,21 @@ 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("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