@dtex/mock-io
Advanced tools
Comparing version 0.0.2 to 0.0.3
import Digital from "./modules/digital.js"; | ||
import PWM from "./modules/pwm.js"; | ||
import I2C from "./modules/i2c.js"; | ||
import Analog from "./modules/analog.js"; | ||
export { Digital, PWM } | ||
export { Digital, PWM, I2C, Analog } |
class Digital { | ||
static Input = 0x00; | ||
static Output = 0x01; | ||
@@ -8,14 +9,26 @@ | ||
this.edge = (undefined === opts.edge) ? 0 : opts.edge; | ||
this.mode = opts.mode; | ||
this.mode = opts.mode || 0x00; | ||
this.onReadable = opts.onReadable; | ||
this.target = opts.target; | ||
this.value = 0x00; | ||
this.Input = 0x00; | ||
this.Output = 0x01; | ||
} | ||
read() { | ||
return this.value; | ||
} | ||
write(value) { | ||
} | ||
if (value != this.value) { | ||
this.value = value; | ||
if (this.mode === this.Input) { | ||
this.onReadable(); | ||
} | ||
} | ||
} | ||
exTrigger(event) { | ||
this.emit(event); | ||
} | ||
@@ -22,0 +35,0 @@ } |
@@ -6,9 +6,12 @@ class PWM { | ||
constructor(opts) { | ||
this.pin = opts.pin; | ||
this.edge = (undefined === opts.edge) ? 0 : opts.edge; | ||
this.mode = opts.mode; | ||
this.onReadable = opts.onReadable; | ||
this.target = opts.target; | ||
this.resolution = 10; | ||
this.value = null; | ||
return (async () => { | ||
console.log(opts.pin); | ||
this.pin = opts.pin; | ||
this.edge = (undefined === opts.edge) ? 0 : opts.edge; | ||
this.mode = opts.mode; | ||
this.onReadable = opts.onReadable; | ||
this.target = opts.target; | ||
this.resolution = 10; | ||
this.value = null; | ||
})(); | ||
} | ||
@@ -15,0 +18,0 @@ |
{ | ||
"name": "@dtex/mock-io", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Mock file for TC-53 IO testing", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3477
8
82