2017-08-28 12:49:47 +00:00
|
|
|
'use strict'
|
|
|
|
|
2017-09-17 19:20:38 +00:00
|
|
|
/** Object representing a fake onoff Gpio class */
|
2017-08-28 12:49:47 +00:00
|
|
|
const onoffsim = {
|
2017-09-17 19:20:38 +00:00
|
|
|
/**
|
|
|
|
* Returns a Gpio class in the case of running on a dev machine
|
|
|
|
*
|
|
|
|
* @param {integer} no Number of the GPIO pin
|
|
|
|
* @param {string} dir Dirction of the pin, 'input' or 'output'
|
|
|
|
* @param {string} additional Additional instructions for the GPIO pin, for 'input' type
|
|
|
|
* @returns {object} Fake Gpio object
|
|
|
|
*/
|
2017-08-28 12:49:47 +00:00
|
|
|
Gpio : function (no, dir = 'in', additional = 'none') {
|
|
|
|
return {
|
|
|
|
no : no,
|
|
|
|
dir : dir,
|
|
|
|
additional : additional,
|
|
|
|
val : null,
|
|
|
|
watchFunc : null,
|
|
|
|
set : function (val) {
|
|
|
|
console.log(`onoffsim set ${this.no} to ${val}`)
|
|
|
|
},
|
|
|
|
get : function () {
|
|
|
|
return this.val
|
|
|
|
},
|
|
|
|
watch : function (cb) {
|
|
|
|
this.watchFunc = cb
|
2017-09-26 03:26:47 +00:00
|
|
|
},
|
|
|
|
unexport : function () {
|
2017-08-28 12:49:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = onoffsim
|