-
Notifications
You must be signed in to change notification settings - Fork 4
/
blockly_simple.html
87 lines (82 loc) · 2.13 KB
/
blockly_simple.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
<html>
<head>
<meta charset="utf-8">
<style>
* {
margin: 0;
padding: 0;
}
html, body {
background-color: #fff;
margin: 0;
padding: 0;
height:100%;
overflow:hidden;
}
#header {
position:absolute; left:0px;right:0px; top:0px;
width: 100%;
height: 32px;
}
#send {
margin: 2px;
background-color: #7ff;
display: inline-block;
width : 100px;
height : 24px;
border: 2px solid #077;
border-radius: 5px;
text-align:center;
font-size: 120%;
cursor: pointer;
}
#blockly_container {
position:absolute; left:0px;right:0px; top:32px;bottom:0px;
}
#blockly {
width:100%;height:100%;border:0;
}
</style>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="serial_to_audio.js"></script>
<script>
var Blockly;
window.blocklyLoaded = function(blockly, blocklyWindow) { // see blockly/blockly.html
Blockly = blockly;
if (blocklyWindow) {
blocklyWindow.promptAsync = function(title,value,callback) {
var value = window.prompt(title,value);
callback(value);
};
}
};
$(function() {
$("#send").click(function(e) {
e.preventDefault();
var code = Blockly.JavaScript.workspaceToCode('JavaScript');
// create a 200*11/9600 = ~0.2 sec pause by just adding
// characters that can't be transmitted
var pause = "";
for (var i=0;i<200;i++) pause += "\u0100";
// work out finished string
code = "reset();\n"+pause+code+"\n";
// send it!
console.log("Sending -> "+code);
audio_serial_write(code);
});
$("#txPolarity").change(function() {
audio_serial_invert = $("#txPolarity").is(':checked');
});
});
</script>
</head>
<body>
<div id="header">
<span id="send">Upload</span>
<input type="checkbox" id="txPolarity">TX Polarity<br/>
</div>
<div id="blockly_container">
<iframe id="blockly" src="blockly/blockly.html"></iframe>
</div>
</body>
</html>