-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathartik.html
527 lines (502 loc) · 22 KB
/
artik.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
<script type="text/javascript">
RED.nodes.registerType('artik_out',{
category: 'Artik',
color: '#FFFFFF',
defaults: {
name: { value:""},
pin: { value:"",required:true},
platform:{value:"", required:true},
state: { value:""},
enableInitialState: { value:""},
initialState: { value:""}
},
icon: "artik.png",
align: "right",
paletteLabel:"artik out",
inputs:1,
outputs:0,
label: function() {
return this.name||"artik out";
},
oneditprepare: function(){
var platformSelected = this.platform;
var pinSelected = this.pin;
var setInitialState = function(){
if ($('#node-input-enableInitialState').is(":checked")) {
$("#node-set-initialState").show();
} else {
$("#node-set-initialState").hide();
}
};
$("#node-input-enableInitialState").change(function () { setInitialState(); });
setInitialState();
var getPinList = function (platformVersion) {
console.log("triggered pin list updated");
$.get("/artikPins",function(data){
var artikPins = $.parseJSON(data)
var items = {};
switch(platformVersion){
case '5':
items=artikPins.artik520.GPIO;
break;
case '7':
items=artikPins.artik710.GPIO;
break;
case '10':
items=artikPins.artik1020.GPIO;
break;
default:
items={
'notSelected':{
'label':'Please select your platform',
'mapping':""
}
};
break;
}
$("#node-input-pin").empty();
$.each(items, function(key,value){
if(!(value.label.includes("SW"))){
$("#node-input-pin").append('<option value="'+value.mapping+'">'+value.label+'</option>')
}
});
$('#node-input-pin').val(pinSelected);
});
};
$("#node-input-platform").change(function(){
var platformNow = $("#node-input-platform").val();
if(platformNow !== platformSelected){
getPinList(platformNow);
} else {
getPinList(platformSelected);
};
});
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('artik_in',{
category: 'Artik',
color: '#FFFFFF',
defaults: {
name: {value:""},
pin: { value:"",required:true},
platform:{value:"", required:true},
enableInterrupt: {value:""},
edge:{value:""},
debounce:{value:""}
},
icon: "artik.png",
paletteLabel:"artik in",
inputs:1,
outputs:1,
label: function() {
return this.name||"artik in";
},
oneditprepare: function(){
var platformSelected = this.platform;
var pinSelected = this.pin;
var setInterrupt = function(){
if ($('#node-input-enableInterrupt').is(":checked")){
$('#node-set-edge').show();
$('#node-set-debounce').show();
} else {
$('#node-set-edge').hide();
$('#node-set-debounce').hide();
}
};
$('#node-input-enableInterrupt').change(function(){setInterrupt();});
setInterrupt();
var getPinList = function (platformVersion) {
console.log("triggered pin list updated");
$.get("/artikPins",function(data){
var artikPins = $.parseJSON(data)
var items = {};
switch(platformVersion){
case '5':
items=artikPins.artik520.GPIO;
break;
case '7':
items=artikPins.artik710.GPIO;
break;
case '10':
items=artikPins.artik1020.GPIO;
break;
default:
items={
'notSelected':{
'label':'Please select your platform',
'mapping':""
}
};
break;
}
$("#node-input-pin").empty();
$.each(items, function(key,value){
if(!(value.label.includes("LED"))){
$("#node-input-pin").append('<option value="'+value.mapping+'">'+value.label+'</option>')
}
});
$('#node-input-pin').val(pinSelected);
});
};
$("#node-input-platform").change(function(){
var platformNow = $("#node-input-platform").val();
if(platformNow !== platformSelected){
getPinList(platformNow);
} else {
getPinList(platformSelected);
};
});
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('artik_adc',{
category: 'Artik',
color: '#FFFFFF',
defaults: {
name: { value:""},
pin: { value:"", required:true},
platform:{ value:"", required:true}
},
icon: "artik.png",
paletteLabel:"artik adc",
inputs:1,
outputs:1,
label: function() {
return this.name||"artik adc";
},
oneditprepare: function(){
var platformSelected = this.platform;
var pinSelected = this.pin;
var getPinList = function (platformVersion) {
console.log("triggered pin list updated");
$.get("/artikPins",function(data){
var artikPins = $.parseJSON(data)
var items = {};
switch(platformVersion){
case '5':
items=artikPins.artik520.ADC;
break;
case '7':
items=artikPins.artik710.ADC;
break;
case '10':
items=artikPins.artik1020.ADC;
break;
default:
items={
'notSelected':{
'label':'Please select your platform',
'mapping':""
}
};
break;
}
$("#node-input-pin").empty();
$.each(items, function(key,value){
$("#node-input-pin").append('<option value="'+value.mapping+'">'+value.label+'</option>')
});
$('#node-input-pin').val(pinSelected);
});
};
$("#node-input-platform").change(function(){
var platformNow = $("#node-input-platform").val();
if(platformNow !== platformSelected){
getPinList(platformNow);
} else {
getPinList(platformSelected);
};
});
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('artik_pwm',{
category: 'Artik',
color: '#FFFFFF',
defaults: {
name: { value:""},
platform:{ value:"", required:true},
pin: { value:"",required:true,validate:RED.validators.number()},
dutyCycle: { value:"", required:true},
period: { value:"", required:true},
state: { value:"", required:true},
enableInitialState: { value:""},
initialState: { value:""},
initialDutyCycle: { value:""},
initialPeriod: { value:""}
},
icon: "artik.png",
align: "right",
inputs:1,
outputs:0,
paletteLabel:"artik pwm",
label: function() {
return this.name||"artik pwm";
},
oneditprepare: function(){
var platformSelected = this.platform;
var pinSelected = this.pin;
var setInitialState = function(){
if ($('#node-input-enableInitialState').is(":checked")) {
$("#node-set-initialState").show();
$("#node-set-initialDutyCycle").show();
$("#node-set-initialPeriod").show();
} else {
$("#node-set-initialState").hide();
$("#node-set-initialDutyCycle").hide();
$("#node-set-initialPeriod").hide();
}
};
$("#node-input-enableInitialState").change(function () { setInitialState(); });
setInitialState();
var getPinList = function (platformVersion) {
console.log("triggered pin list updated");
$.get("/artikPins",function(data){
var artikPins = $.parseJSON(data)
var items = {};
switch(platformVersion){
case '5':
items=artikPins.artik520.PWM;
break;
case '7':
items=artikPins.artik710.PWM;
break;
case '10':
items=artikPins.artik1020.PWM;
break;
default:
items={
'notSelected':{
'label':'Please select your platform',
'mapping':""
}
};
break;
}
$("#node-input-pin").empty();
$.each(items, function(key,value){
$("#node-input-pin").append('<option value="'+value.mapping+'">'+value.label+'</option>')
});
$('#node-input-pin').val(pinSelected);
});
};
$("#node-input-platform").change(function(){
var platformNow = $("#node-input-platform").val();
if(platformNow !== platformSelected){
getPinList(platformNow);
} else {
getPinList(platformSelected);
};
});
}
});
</script>
<script type="text/x-red" data-template-name="artik_out">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-platform"><i class="icon-tag"></i>Platform</label>
<select type="text" id="node-input-platform" style="width: 70%;">
<option value="5">Artik 520</option>
<option value="7">Artik 710</option>
<option value="10">Artik 1020</option>
</select>
</div>
<div class="form-row" >
<label for="node-input-pin"><i class="icon-tag"></i>Pin</label>
<select type="text" id="node-input-pin" style="width: 70%;"> </select>
</div>
<div class="form-row" id="node-set-state">
<label for="node-input-state"><i class="icon-tag"></i>State</label>
<select id="node-input-state" style="width: 250px;">
<option value="1">High</option>
<option value="0">Low</option>
</select>
</div>
<div class="form-row" id="node-set-tick">
<label> </label>
<input type="checkbox" id="node-input-enableInitialState" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-enableInitialState" style="width: 70%;">Set initial state?</label>
</div>
<div class="form-row" id="node-set-initialState">
<label for="node-input-initialState">Initial State</label>
<select id="node-input-initialState" style="width: 250px;">
<option value="1">High</option>
<option value="0">Low</option>
</select>
</div>
</script>
<script type="text/x-red" data-template-name="artik_in">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-platform"><i class="icon-tag"></i>Platform</label>
<select type="text" id="node-input-platform" style="width: 70%;">
<option value="5">Artik 520</option>
<option value="7">Artik 710</option>
<option value="10">Artik 1020</option>
</select>
</div>
<div class="form-row">
<label for="node-input-pin"><i class="icon-tag"></i>Pin</label>
<select type="text" id="node-input-pin" style="width: 70%;"></select>
</div>
<div class="form-row" id="node-set-tick">
<label> </label>
<input type="checkbox" id="node-input-enableInterrupt" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-enableInterrupt" style="width: 70%;">Enable interrupt?</label>
</div>
<div class="form-row" id="node-set-edge">
<label for="node-input-edge"><i class="icon-tag"></i>Set edge</label>
<select id="node-input-edge" style="width: 250px;">
<option value="rising">Rising</option>
<option value="falling">Falling</option>
<option value="both">Both</option>
</select>
</div>
<div class="form-row" id="node-set-debounce">
<label for="node-input-debounce"><i class="icon-tag"></i>Debounce delay</label>
<input type="text" id="node-input-debounce" placeholder="Delay duration">
</div>
</script>
<script type="text/x-red" data-template-name="artik_adc">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" id="node-set-platform">
<label for="node-input-platform">Platform</label>
<select id="node-input-platform" style="width: 250px;">
<option value="5">Artik 520</option>
<option value="7">Artik 710</option>
<option value="10">Artik 1020</option>
</select>
</div>
<div class="form-row">
<label for="node-input-pin"><i class="icon-tag"></i>Pin</label>
<select type="text" id="node-input-pin" style="width: 70%;"></select>
</div>
</script>
<script type="text/x-red" data-template-name="artik_pwm">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" id="node-set-platform">
<label for="node-input-platform">Platform</label>
<select id="node-input-platform" style="width: 250px;">
<option value="5">Artik 520</option>
<option value="7">Artik 710</option>
<option value="10">Artik 1020</option>
</select>
</div>
<div class="form-row">
<label for="node-input-pin"><i class="icon-tag"></i>Pin</label>
<select type="text" id="node-input-pin" style="width: 70%;"></select>
</div>
<div class="form-row">
<label for="node-input-dutyCycle"><i class="icon-tag"></i>Duty cycle</label>
<input type="text" id="node-input-dutyCycle" placeholder="Duty cycle">
</div>
<div class="form-row">
<label for="node-input-period"><i class="icon-tag"></i>Period</label>
<input type="text" id="node-input-period" placeholder="Period">
</div>
<div class="form-row">
<label for="node-input-state"><i class="icon-tag"></i>State</label>
<select type="text" id="node-input-state" style="width: 250px;">
<option value = '1'>High</option>
<option value = '0'>Low</option>
</select>
</div>
<div class="form-row" id="node-set-tick">
<label> </label>
<input type="checkbox" id="node-input-enableInitialState" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-enableInitialState" style="width: 70%;">Set initial state?</label>
</div>
<div class="form-row" id="node-set-initialState">
<label for="node-input-initialState"><i class="icon-tag"></i>Initial State</label>
<select id="node-input-initialState" style="width: 250px;">
<option value="1">High</option>
<option value="0">Low</option>
</select>
</div>
<div class="form-row" id ="node-set-initialDutyCycle">
<label for="node-input-initialDutyCycle"><i class="icon-tag"></i>Duty cycle</label>
<input type="text" id="node-input-initialDutyCycle" placeholder="Initial duty cycle">
</div>
<div class="form-row" id ="node-set-initialPeriod">
<label for="node-input-initialPeriod"><i class="icon-tag"></i>Period</label>
<input type="text" id="node-input-initialPeriod" placeholder="Initial period">
</div>
</script>
<script type="text/x-red" data-help-name="artik_out">
<p>Artik GPIO node that helps controling the Artik board GPIO pins in the <b>OUT</b> direction. </p>
<p>To set a pin as output, set these two properties in configuration tab or in the incoming <code>msg.payload</code>:
<ul>
<li><code>platform</code>: Artik module platform version </li>
<li><code>pin</code>: pin number </li>
<li><code>state</code>: 0 for low, 1 for high, you can overwrite this property in the incoming <code>msg.payload.state</code></li>
</ul>
</p>
<p>If 'Set initial State' is checked:</p>
<p>
<ul>
<li>Initial State: sets the behaviour of the GPIO pin when deployed</li>
</ul>
</p>
<p><b>Note:</b> pin number would be the physical pin location. </p>
</script>
<script type="text/x-red" data-help-name="artik_in">
<p>Artik GPIO node that helps controling the Artik board GPIO pins in IN direction. </p>
<p>To config the node: </p>
<p><code>platform</code> Artik module platform version </p>
<p><code>pin</code> sets the pin number</p>
<p>If 'Enable interrupt' is checked:</p>
<p>
<ul>
<li>Set edge: sets edge for interrupt, values could be 'rising', 'falling' or 'both'. </li>
<li>Debounce delay: sets debouncing delay in milliseconds. </li>
</ul>
</p>
<p><b>Note:</b> pin number would be the physical pin location. When in interrupt mode, user can still use the inject node to trigger manual reading of the GPIO status. </p>
</script>
<script type="text/x-red" data-help-name="artik_adc">
<p>Artik GPIO node that helps controling the Artik board GPIO pins reading ADC.</p>
<p>To set a pin reading ADC, set these properties in configuration tab or in the incoming <code>msg.payload</code>:
<ul>
<li><code>Pin</code>: pin number </li>
<li><code>Platform</code>: specify the platform of your Artik board.</li>
</ul>
</p>
<p>The return value is the ADC reading in mV. </p>
<p><b>Note:</b> pin number would be the physical pin location.</p>
</script>
<script type="text/x-red" data-help-name="artik_pwm">
<p>Artik GPIO node that helps controling the Artik board GPIO pins setting PWM output.</p>
<p>To set a pin as output, set these properties in configuration tab or in the incoming <code>msg.payload</code>:
<p>
<ul>
<li><code>Pin:</code> sets pin for PWM output, values could be either '0' or '1' referring to PWM0 or PWM1 on the Artik board. </li>
<li><code>Duty cycle:</code> sets value of duty cycle for PWM output, values would be in ns( e.g., 500000000 for 500 mS). You can overwrite this property in the incoming <code>msg.payload.dutyCycle</code> to overwrite. </li>
<li><code>Period:</code> sets value of period for PWM output, values would be in ns( e.g., 1000000000 for 1 S). You can overwrite this property in the incoming <code>msg.payload.period</code> to overwrite. </li>
<li><code>State:</code> switch HIGH or LOW for PWM output, values could be either '0' or '1' for LOW or HIGH. You can overwrite this property in the incoming <code>msg.payload.state</code> to overwrite. </li>
</ul>
</p>
<p>If 'Set initial State' is checked:</p>
<p>
<ul>
<li><code>Initial State:</code> switch HIGH or LOW for PWM output when deployed </li>
<li><code>Duty cycle:</code> sets value of duty cycle for PWM output when deployed, values would be in ns </li>
<li><code>Period:</code> sets value of period for PWM output when deployed, values would be in ns </li>
</ul>
</p>
<p><b>Note:</b> pin number would be the physical pin location. The maximun limit for period(ns) and dutycycle(ns) is 1000,000,000 and dutycycle should always be less than period.</p>
</script>