Ok backwards frames are apparently doing fine. This commit uses a better organized object structure for release variables.
This commit is contained in:
parent
190732de13
commit
e09f1adbcd
|
@ -58,9 +58,11 @@ intval.init = function () {
|
|||
primed : false //is ready to stop frame
|
||||
}
|
||||
}
|
||||
|
||||
intval._releaseMin = 50
|
||||
intval._releaseSequence = 1000
|
||||
intval._frame = {}
|
||||
intval._release = {
|
||||
min : 20,
|
||||
seq : 1000
|
||||
}
|
||||
intval._microDelay = 10 // delay after stop signal before stopping motors
|
||||
|
||||
intval._declarePins()
|
||||
|
@ -184,8 +186,8 @@ intval._watchMicro = function (err, val) {
|
|||
*
|
||||
* 1) If closed, start timer.
|
||||
* 2) If opened, check timer AND
|
||||
* 3) If `press` (`now - intval._state.release.time`) greater than minimum and less than `intval._releaseSequence`, start frame
|
||||
* 4) If `press` greater than `intval._releaseSequence`, start sequence
|
||||
* 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
|
||||
* * 1 === open
|
||||
|
@ -212,9 +214,9 @@ intval._watchRelease = function (err, val) {
|
|||
//opened
|
||||
if (intval._state.release.active) {
|
||||
press = now - intval._state.release.time
|
||||
if (press > intval._releaseMin && press < intval._releaseSequence) {
|
||||
if (press > intval._release.min && press < intval._release.seq) {
|
||||
intval.frame()
|
||||
} else if (press >= intval._releaseSequence) {
|
||||
} else if (press >= intval._release.seq) {
|
||||
intval.sequence()
|
||||
}
|
||||
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) {
|
||||
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 false
|
||||
|
|
Loading…
Reference in New Issue