-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
134 lines (108 loc) · 4.44 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="msapplication-TileColor" content="#2196f3">
<meta name="msapplication-config" content="browserconfig.xml">
<meta name="theme-color" content="#2196f3">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="msapplication-starturl" content="./">
<meta name="description"
content="Progressive Web Application for serial communication with your own Bluetooth Low Energy (Smart) devices">
<title>Remote Control</title>
<!-- <link rel="manifest" href="manifest.json"> -->
<link rel="apple-touch-icon" sizes="180x180" href="icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">
<link rel="mask-icon" href="icons/safari-pinned-tab.svg" color="#2196f3">
<link rel="shortcut icon" href="icons/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/normalize.css" rel="stylesheet">
<link href="css/tabs.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<div class="app">
<div class="toolbar">
<div id="device-name" class="name">Not Connected</div>
<div class="buttons">
<button id="connect" type="button" aria-label="Connect">
<i class="material-icons">bluetooth_connected</i>
</button>
<button id="disconnect" type="button" aria-label="Disconnect">
<i class="material-icons">bluetooth_disabled</i>
</button>
</div>
</div>
<div class="pc-tab">
<input checked="checked" id="tab1" type="radio" name="pct" />
<input id="tab2" type="radio" name="pct" />
<!-- <input id="tab1" type="radio" name="pct" /> -->
<!-- <input checked="checked" id="tab2" type="radio" name="pct" /> -->
<nav>
<ul>
<li class="tab1">
<label for="tab1">Control</label>
</li>
<li class="tab2">
<label for="tab2">Terminal</label>
</li>
</ul>
</nav>
<section>
<div class="tab1">
<div id="recv_text"> Incoming Message </div>
<div id="joyDiv" style="width:200px;height:200px;margin-bottom:20px; margin-left: auto; margin-right: auto;"></div>
<div class="slidecontainer">
<input type="range" min="-100" max="100" value="0" class="slider" id="myRange" style="display: block; margin-left: auto; margin-right: auto;">
</div>
<div class="buttoncontainder">
<button type="button" id="candy_button" onclick="button_count+=1" style="display: block; margin-left: auto; margin-right: auto;">Dispense Candy</button>
</div>
<div id="sent_text"> </div>
</div>
<div class="tab2 vexpand">
<div class="terminal-tab">
<div id="terminal_container" style="flex-grow: 1;">
<div id="terminal" class="terminal"></div>
</div>
<form id="send-form" class="send-form">
<input id="input" type="text" aria-label="Input" autocomplete="off" placeholder="Type something to send...">
<button type="submit" aria-label="Send">
<i class="material-icons">send</i>
</button>
</form>
</div>
</div>
</section>
</div>
</div>
<script src="js/BluetoothTerminal.js"></script>
<script src="js/main.js"></script>
<script src="js/joy.js"></script>
<!-- <script src="js/companion.js" data-service-worker="sw.js"></script> -->
<script type="text/javascript">
var joy = new JoyStick('joyDiv', { internalFillColor: "#E97777",
internalStrokeColor: "#E97777",
externalStrokeColor: "#FF9F9F" ,
boundsType: "diamond"});
var slider = document.getElementById("myRange")
var output = document.getElementById("sent_text")
var button_count = 0
setInterval(function(){
message = "S" + joy.GetX() + ","
+ joy.GetY() + ","
+ slider.value + ","
+ button_count + "E";
if (terminal.getDeviceName() != ""){
terminal.send(message).then(() => {});
}
console.log(message);
output.innerHTML = message;
}, 100);
</script>
</body>
</html>