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 15 additions and 6 deletions
Showing only changes of commit e27add8da7 - Show all commits

View File

@ -172,7 +172,7 @@ class Intval {
* *
* 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 - this._state.release.time`) greater than minimum and less than `this._releaseSequence`, start frame * 3) If `press` (`now - this._state.release.time`) greater than minimum and less than `this._releaseSequence`, start frame
* 4) If `press` greater than `this._releaseSequence`, start sequence * 4) If `press` greater than `this._releaseSequence`, start sequence
* *
* Button + 10K ohm resistor * Button + 10K ohm resistor
@ -184,7 +184,7 @@ class Intval {
* *
*/ */
_watchRelease (err, val) { _watchRelease (err, val) {
const NOW = +new Date() const now = +new Date()
let press = 0 let press = 0
if (err) { if (err) {
return log.error(err) return log.error(err)
@ -192,15 +192,14 @@ class Intval {
log.info(`Release switch val: ${val}`) log.info(`Release switch val: ${val}`)
if (val === 0) { if (val === 0) {
//closed //closed
if ((!this._state.release.active && this._state.release.time === 0) || (this._state.release.active && (NOW - this._state.release.time) > (this._releaseSequence * 10)) if (this._releaseClosedState(now)) {
) { this._state.release.time = now
this._state.release.time = NOW
this._state.release.active = true //maybe unncecessary this._state.release.active = true //maybe unncecessary
} }
} else if (val === 1) { } else if (val === 1) {
//opened //opened
if (this._state.release.active) { if (this._state.release.active) {
press = NOW - this._state.release.time press = now - this._state.release.time
if (press > this._releaseMin && press < this._releaseSequence) { if (press > this._releaseMin && press < this._releaseSequence) {
this.frame() this.frame()
} else if (press >= this._releaseSequence) { } else if (press >= this._releaseSequence) {
@ -213,6 +212,16 @@ class Intval {
} }
log.info('completed if statement') log.info('completed if statement')
} }
_releaseClosedState (now) {
if (!this._state.release.active && this._state.release.time === 0) {
return true
}
if (this._state.release.active && (now - this._state.release.time) > (this._releaseSequence * 10)) {
return true
}
return false
}
/** /**
* Set the default direction of the camera. * Set the default direction of the camera.
* * forward = true * * forward = true