Ok backwards frames are apparently doing fine. This commit uses a better organized object structure for release variables.

This commit is contained in:
mmcw-dev 2017-10-20 20:54:35 -04:00
parent 190732de13
commit e09f1adbcd
1 changed files with 10 additions and 8 deletions

View File

@ -58,9 +58,11 @@ intval.init = function () {
primed : false //is ready to stop frame primed : false //is ready to stop frame
} }
} }
intval._frame = {}
intval._releaseMin = 50 intval._release = {
intval._releaseSequence = 1000 min : 20,
seq : 1000
}
intval._microDelay = 10 // delay after stop signal before stopping motors intval._microDelay = 10 // delay after stop signal before stopping motors
intval._declarePins() intval._declarePins()
@ -184,8 +186,8 @@ intval._watchMicro = function (err, val) {
* *
* 1) If closed, start timer. * 1) If closed, start timer.
* 2) If opened, check timer AND * 2) If opened, check timer AND
* 3) If `press` (`now - intval._state.release.time`) greater than minimum and less than `intval._releaseSequence`, start frame * 3) If `press` (`now - intval._state.release.time`) greater than minimum and less than `intval._release.seq`, start frame
* 4) If `press` greater than `intval._releaseSequence`, start sequence * 4) If `press` greater than `intval._release.seq`, start sequence
* *
* Button + 10K ohm resistor * Button + 10K ohm resistor
* * 1 === open * * 1 === open
@ -212,9 +214,9 @@ intval._watchRelease = function (err, val) {
//opened //opened
if (intval._state.release.active) { if (intval._state.release.active) {
press = now - intval._state.release.time press = now - intval._state.release.time
if (press > intval._releaseMin && press < intval._releaseSequence) { if (press > intval._release.min && press < intval._release.seq) {
intval.frame() intval.frame()
} else if (press >= intval._releaseSequence) { } else if (press >= intval._release.seq) {
intval.sequence() intval.sequence()
} }
log.info(`Release closed for ${press}ms`) log.info(`Release closed for ${press}ms`)
@ -228,7 +230,7 @@ intval._releaseClosedState = function (now) {
if (!intval._state.release.active && intval._state.release.time === 0) { if (!intval._state.release.active && intval._state.release.time === 0) {
return true return true
} }
if (intval._state.release.active && (now - intval._state.release.time) > (intval._releaseSequence * 10)) { if (intval._state.release.active && (now - intval._state.release.time) > (intval._release.seq * 10)) {
return true return true
} }
return false return false