-
Notifications
You must be signed in to change notification settings - Fork 0
/
jfive-led.html
48 lines (42 loc) · 1.24 KB
/
jfive-led.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<link rel="import" href="../polymer/polymer.html">
<dom-module id="jfive-led">
<script>
class JFiveLED {
beforeRegister() {
this.is = 'rasp-led';
this.properties = {
pin: {
observer: 'initLED'
},
on: {
type: Boolean,
observer: 'onChanged'
}
};
this.jFive = require('johnny-five');
const Raspio = require('raspi-io');
try {
const board = new this.jFive.Board({
io: new Raspio(),
repl: false
});
}
catch(error) {
console.log(error);
}
}
initLED() {
try {
this.LED = new this.jFive.Led(this.pin);
}
catch(error) {
console.log(error);
}
}
onChanged() {
this.on ? this.LED.on() : this.LED.off();
}
}
Polymer(JFiveLED);
</script>
</dom-module>