Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
2 changed files with 13 additions and 6 deletions
Showing only changes of commit 78135c4e77 - Show all commits

View File

@ -49,6 +49,8 @@ class Intval {
active : false active : false
} }
} }
this._releaseMin = 50
this._releaseSequence = 1000
this._declarePins() this._declarePins()
process.on('SIGINT', this._undeclarePins) process.on('SIGINT', this._undeclarePins)
} }
@ -98,6 +100,7 @@ class Intval {
} }
_watchRelease (err, val) { _watchRelease (err, val) {
const NOW = +new Date() const NOW = +new Date()
let press = 0
/* Button + 10K ohm resistor */ /* Button + 10K ohm resistor */
/* 1 = open */ /* 1 = open */
/* 0 = closed */ /* 0 = closed */
@ -106,16 +109,20 @@ class Intval {
} }
console.log(`Release switch val: ${val}`) console.log(`Release switch val: ${val}`)
if (val === 0) { if (val === 0) {
if (this._state.release.time === 0) { if ((!this._state.release.active && this._state.release.time === 0) || (this._state.release.active && (NOW - this._state.release.time) > (this._releaseSequence * 10))
) {
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 (this._state.release.active) { }
if (NOW - this._state.release.time > 100) { } else if (val === 1) {
if (this._state.release.active) {
press = NOW - this._state.release.time
if (press > this._releaseMin && press < this._releaseSequence) {
this.frame() this.frame()
} else if (NOW - this._state.release.time > 1000) { } else if (press >= this._releaseSequence) {
this.sequence() this.sequence()
} }
console.log(`Release closed for ${NOW - this._state.release.time}`) console.log(`Release closed for ${press}`)
this._state.release.time = 0 this._state.release.time = 0
this._state.release.active = false this._state.release.active = false
} }

View File

@ -23,7 +23,7 @@ btn.watch((err, val) => {
//console.log('closed') //console.log('closed')
} }
if (val === 0) { if (val === 0) {
if (saveTime === 0) { if ((!active && saveTime === 0) || (active && NOW - saveTime > 10 * 1000)) {
saveTime = NOW saveTime = NOW
active = true //maybe unncecessary active = true //maybe unncecessary
} else { } else {