Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
1 changed files with 7 additions and 7 deletions
Showing only changes of commit 41360405c3 - Show all commits

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