Lol. Was a little overzealous with a replace all. _state.release.time should never have been changed to exposure.

This commit is contained in:
mmcw-dev 2017-10-21 11:54:45 -04:00
parent e2ee307824
commit 41360405c3
1 changed files with 7 additions and 7 deletions

View File

@ -188,7 +188,7 @@ intval._watchMicro = function (err, val) {
*
* 1) If closed, start timer.
* 2) If opened, check timer AND
* 3) If `press` (`now - intval._state.release.exposure`) greater than minimum and less than `intval._release.seq`, 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._release.seq`, start sequence
*
* Button + 10K ohm resistor
@ -205,34 +205,34 @@ intval._watchRelease = function (err, val) {
if (err) {
return log.error(err)
}
log.info(`Release switch val: ${val}`)
//log.info(`Release switch val: ${val}`)
if (val === 0) {
//closed
if (intval._releaseClosedState(now)) {
intval._state.release.exposure = now
intval._state.release.time = now
intval._state.release.active = true //maybe unncecessary
}
} else if (val === 1) {
//opened
if (intval._state.release.active) {
press = now - intval._state.release.exposure
press = now - intval._state.release.time
if (press > intval._release.min && press < intval._release.seq) {
intval.frame()
} else if (press >= intval._release.seq) {
intval.sequence()
}
//log.info(`Release closed for ${press}ms`)
intval._state.release.exposure = 0
intval._state.release.time = 0
intval._state.release.active = false
}
}
}
intval._releaseClosedState = function (now) {
if (!intval._state.release.active && intval._state.release.exposure === 0) {
if (!intval._state.release.active && intval._state.release.time === 0) {
return true
}
if (intval._state.release.active && (now - intval._state.release.exposure) > (intval._release.seq * 10)) {
if (intval._state.release.active && (now - intval._state.release.time) > (intval._release.seq * 10)) {
return true
}
return false