forked from fustyles/webduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartSeriesBit.html
93 lines (84 loc) · 3.56 KB
/
SmartSeriesBit.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
<!doctype html>
<!--
Created using JS Bin
http://bin.webduino.io
Copyright (c) 2019 by anonymous (http://bin.webduino.io/foyuhi/1/edit)
Released under the MIT license: http://jsbin.mit-license.org
-->
<meta name="robots" content="noindex">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Webduino Blockly Demo 01</title>
<!-- Smart -->
<script src="https://blocklypro.webduino.io/components/jquery/dist/jquery.min.js?rev=4a356126b9573eb7bd1e9a7494737410"></script>
<script src="https://blocklypro.webduino.io/dist/lib/webduino-all-0.4.20.min.js?rev=4426739c00d85325cb2d3d701fa50666"></script>
<script src="https://blocklypro.webduino.io/dist/webduino-blockly.min.js?rev=736fa9a2fba9fa461db7c329f6651493"></script>
<script src="https://blocklypro.webduino.io/dist/lib/firebase.min.js?rev=c0bfd493efd477d098a4ae9e92b13880"></script>
<script src="https://blocklypro.webduino.io/dist/lib/runtime.min.js?rev=683a69503433786202911b4d9f766100"></script>
<!-- Bit -->
<script src="https://bit.webduino.io/blockly/components/jquery/dist/jquery.min.js"></script>
<script src="https://bit.webduino.io/blockly/dist/lib/webduino-all.min.js"></script>
<script src="https://bit.webduino.io/blockly/dist/MessageTransport.min.js"></script>
<script src="https://bit.webduino.io/blockly/dist/webduino-blockly.min.js"></script>
<script src="https://bit.webduino.io/blockly/dist/lib/firebase.min.js"></script>
<script src="https://bit.webduino.io/blockly/dist/lib/runtime.min.js"></script>
<script src="https://bit.webduino.io/blockly/components/webduino-bit-module-led-matrix/BitLedMatrix-blockly.js"></script>
<script src="https://bit.webduino.io/blockly/components/webduino-bit-module-led-matrix/BitLedMatrix.js"></script>
<style id="jsbin-css">
#demo-area-01-show { font-size: 60px; pointer-events: auto!important; }
</style>
</head>
<body>
<div><span id="demo-area-01-show">123</span></div>
<script id="jsbin-javascript">
var photocell;
var matrix;
if (window.readyBoardLength) {
window.readyBoardLength = window.readyBoardLength + 1;
} else {
window.readyBoardLength = 1;
}
boardReady({board: 'Bit', device: 'xxxxxxxxxx', transport: 'mqtt'}, function (board) {
board.samplingInterval = 250;
matrix = getMatrix(board, 4, 25);
if (window.boardReadyNumber) {
window.boardReadyNumber = window.boardReadyNumber +1;
} else {
window.boardReadyNumber = 1;
}
allBoardReady(window.boardReadyNumber);
});
if (window.readyBoardLength) {
window.readyBoardLength = window.readyBoardLength + 1;
} else {
window.readyBoardLength = 1;
}
boardReady({board: 'Smart', device: 'xxxxxxxxxx', transport: 'mqtt'}, function (board) {
board.samplingInterval = 50;
photocell = getPhotocell(board, 0);
photocell.measure(function (val) {
photocell.detectedVal = val;
});
if (window.boardReadyNumber) {
window.boardReadyNumber = window.boardReadyNumber + 1;
} else {
window.boardReadyNumber = 1;
}
allBoardReady(window.boardReadyNumber);
});
async function allBoardReady(boardReadyNumber) {
if (window.boardReadyNumber==window.readyBoardLength) {
while (true) {
matrix.setColor((1 - 1 + ( 1 - 1) * 5 ), '#ff0000');
await delay(0.2);
document.getElementById('demo-area-01-show').innerHTML = (Math.round((photocell.detectedVal)*100))/100;
matrix.setColor((1 - 1 + ( 1 - 1) * 5 ), '#000000');
await delay(0.2);
}
}
}
</script>
</body>
</html>