-
Notifications
You must be signed in to change notification settings - Fork 14
/
wa-stepper.html
103 lines (95 loc) · 2.32 KB
/
wa-stepper.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<html>
<head>
<script type="text/javascript" src="../webduino-js/src/module/Stepper.js"></script>
</head>
<body>
<script>
(function() {
var proto = Object.create(HTMLElement.prototype, {
stepperNumber: {
get: function() {
return this.getAttribute('stepperNumber');
},
set: function(val) {
this.setAttribute('stepperNumber', val);
}
},
interface: {
get: function() {
return this.getAttribute('interface');
},
set: function(val) {
this.setAttribute('interface', val);
}
},
stepsPerRevolution: {
get: function() {
return this.getAttribute('stepsPerRevolution');
},
set: function(val) {
this.setAttribute('stepsPerRevolution', val);
}
},
pin1: {
get: function() {
return this.getAttribute('pin1');
},
set: function(val) {
this.setAttribute('pin1', val);
}
},
pin2: {
get: function() {
return this.getAttribute('pin2');
},
set: function(val) {
this.setAttribute('pin2', val);
}
},
pin3: {
get: function() {
return this.getAttribute('pin3');
},
set: function(val) {
this.setAttribute('pin3', val);
}
},
pin4: {
get: function() {
return this.getAttribute('pin4');
},
set: function(val) {
this.setAttribute('pin4', val);
}
}
});
proto.init_ = function(board) {
var Stepper = webduino.module.Stepper;
var infoObj = {
"stepperNumber": this.stepperNumber,
"interface": this.interface,
"stepsPerRevolution": this.stepsPerRevolution,
"pin1": this.pin1,
"pin2": this.pin2,
"pin3": this.pin3,
"pin4": this.pin4
};
this.stepper = new Stepper(board, infoObj);
};
proto.on = function(command, callback) {
if (typeof callback === 'function') {
this.stepper.on(command, function(val) {
callback(val);
});
}
};
proto.detachedCallback = function() {
this.stepper.off();
};
document.registerElement('wa-stepper', {
prototype: proto
});
})();
</script>
</body>
</html>