-
Notifications
You must be signed in to change notification settings - Fork 14
/
wa-rgbled.html
61 lines (53 loc) · 1.31 KB
/
wa-rgbled.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
49
50
51
52
53
54
55
56
57
58
59
60
61
<html>
<head>
<script type="text/javascript" src="../webduino-js/src/module/Led.js"></script>
<script type="text/javascript" src="../webduino-js/src/module/RGBLed.js"></script>
</head>
<body>
<script>
(function() {
var proto = Object.create(HTMLElement.prototype, {
red: {
get: function() {
return this.getAttribute('red');
},
set: function(val) {
this.setAttribute('red', val);
}
},
green: {
get: function() {
return this.getAttribute('green');
},
set: function(val) {
this.setAttribute('green', val);
}
},
blue: {
get: function() {
return this.getAttribute('blue');
},
set: function(val) {
this.setAttribute('blue', val);
}
}
});
proto.init_ = function(board) {
var RGBLed = webduino.module.RGBLed;
this.rgbled = new RGBLed(
board,
board.getDigitalPin(this.red),
board.getDigitalPin(this.green),
board.getDigitalPin(this.blue),
RGBLed.COMMON_ANODE);
};
proto.setColor = function(r, g, b, callback) {
this.rgbled.setColor(r, g, b, callback);
}
document.registerElement('wa-rgbled', {
prototype: proto
});
})();
</script>
</body>
</html>