-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
260 lines (136 loc) · 7.78 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
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
<html>
<head>
<title>Particle.io web 2page control of the Core or Photon using a hacked websocket.<br> Not very secure but it works </title>
<script>
function myConnect(myValue){ // simplifies sending info to the photon
document.all.myParameter.value=myValue
document.myForm.action = 'https://api.spark.io/v1/devices/' + document.all.myDeviceId.value + '/connect'
document.all.mySend.value = document.myForm.action
document.myForm.submit();
}
function myStop(myValue){ // simplifies sending info to the photon
document.all.myParameter.value=myValue
document.myForm.action = 'https://api.spark.io/v1/devices/' + document.all.myDeviceId.value + '/stop'
document.all.mySend.value = document.myForm.action
document.myForm.submit();
}
function myGo1F(myValue){ // simplifies sending info to the photon
document.all.myParameter.value=myValue
document.myForm.action = 'https://api.spark.io/v1/devices/' + document.all.myDeviceId.value + '/myGo1'
document.all.mySend.value = document.myForm.action
document.myForm.submit();
}
function myNotGo1F(myValue){ // simplifies sending info to the photon
document.all.myParameter.value=myValue
document.myForm.action = 'https://api.spark.io/v1/devices/' + document.all.myDeviceId.value + '/myNotGo1'
document.all.mySend.value = document.myForm.action
document.myForm.submit();
}
</script>
</head>
<body onload="{
myStorage1 = localStorage.getItem('myStoredText1')
if(myStorage1 != null){
document.getElementById('myToken').value = myStorage1
}
myStorage2 = localStorage.getItem('myStoredText2')
if(myStorage2 != null){
document.getElementById('myDeviceId').value = myStorage2
}
}">
<h2 align=center><a href="http://particle.io" >Particle.io</a> web page control of the Core or Photon using a hacked websocket.<br> Not very secure but it works </h2>
<h3>Posenet at <a href="posenet/index.html">Posenet here</a> Testing page Posenet at <a href="index-a.html">Testing here</a></h3>
<h3>Speech Commands page Posenet at <a href="index-speak.html">index-speak.html</a></h3>
The core D7 LED should light for 25 seconds and then turn off. Then Click the connect button and the D7 LED should light. After that the nodeJS server should communicate with your Photon
Type in the boxes then click the buttons to activate your Photon websocket to a node js server.<br><br>
Device ID:<input id="myDeviceId" name="myCoreID" type=password size=50 placeholder="78dd12345678123456">
Get this from the core area when logged in<br>
<input id="myFunctionName" name="myFunction" type=hidden value="my-main" >
<form name="myForm" method="POST" action = "https://api.spark.io/v1/devices/sparkCoreName/myTurnOn" target="myFrameName"><br>
<input id="myParameter" name="params" type=hidden >
Access Token:<input id="myToken" name="access_token" type=password size=50 placeholder="5622ce6bba702ef6bd3456d5ed26aaa4a28d7c9">
Get this from the settings area when logged into <a href="http://spark.io">http://spark.io</a><br><br>
</form>
<input type="button" value="Store Spark Token and ID locally!" onClick="{
localStorage.setItem('myStoredText1', document.all.myToken.value)
localStorage.setItem('myStoredText2', document.all.myDeviceId.value)
alert( document.all.myToken.value + ' ' +document.all.myDeviceId.value + ' \nHas been stored')
}">
<br><br>
<input type="button" style="font-size:25px" value="Connect to the Photon" onClick="{
myConnect('');
}">
<input type="button" style="font-size:25px" value="Stop connection" onClick="{
myStop('');
}"><br><br>
<br><br><br>
<input type=hidden id="mySend" value="">
<iframe style="display:none" width="400" height="200" name="myFrameName" id="myFrameId"></iframe>
<script>
var host = location.origin.replace(/^http/, 'ws')
var ws = new WebSocket(host);
ws.onmessage = function (event) {
document.getElementById('myDiv1').innerHTML = event.data + '<br>'+document.getElementById('myDiv1').innerHTML;
};
ws.onconnection = function (event) {
ws.send('something');
};
</script>
Use this to test new controls flashed to the Photon
<input id="myIn1" type=text value=E ><input type=button value=send onclick="{
ws.send(document.all.myIn1.value)
}"><br><br>
<input id="myOn" type=button style="font-size:25px" value="send D7-ON = A using touchstart" ontouchstart="{ws.send('A');return false;}" onclick="{ws.send('A');}">...
<input id="myOff" type=button style="font-size:25px" value="send D7-OFF = B using touchstart" ontouchstart="{ws.send('B');return false;}" onclick="{ws.send('B');}"><br><br><br><br>
<br><br><br><br>
<h1>C ping Sent every 12 seconds</h1>
<div id="myDiv1"> here<br> </div>
<h2>The following can be deleted</h2 >
<br><br><br><br>
Enter a delay<input type=text id="myDelay" size=20 value=100> milliseconds per command<br>
Timer result <input type=text id="myWaitOut" size=70 > Watch that 10 flashes actually occur. <br>
Lower the ms until only a few flashes occur or the LED does not turn off!<br>
On my network I consistently can get 60 ms per command.<br>
<input type=button value="20 Commands Sent Fast" onclick="{
var mytestInterval = document.all.myDelay.value*1
var myTimer1 = new Date().getMilliseconds();;
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*1);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*2);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*3);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*4);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*5);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*6);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*7);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*8);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*9);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*10);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*11);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*12);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*13);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*14);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*15);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*16);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*17);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*18);
setTimeout(function(){ document.all.myOn.click() }, mytestInterval*19);
setTimeout(function(){ document.all.myOff.click()}, mytestInterval*20);
setTimeout(function(){ document.getElementById('iFrameID').src = 'generic.html' }, mytestInterval*21);
myElapsed = document.all.myDelay.value*20
document.all.myWaitOut.value = myElapsed+ ' milliseconds for 20 Core Commands = '+myElapsed/20 +' ms per command'
}"><br>
<br>
socket.ino main program loop<br>
<textarea rows=20 cols=70>
if (myIncoming == 'A'){ digitalWrite(D7, HIGH);}
if (myIncoming == 'B'){ digitalWrite(D7, LOW);}
if (myIncoming == 'C'){ RGB.brightness(0); }
if (myIncoming == 'D'){ RGB.brightness(100); }
if (myIncoming == 'E'){ RGB.brightness(250); }
</textarea>
<a href="car-control.html">car-control.html</a> <br>
Note: The several hidden items on this webpage must remain on the webpage. Change type=hidden to type=text if you wish to see them.<br>
Use at your own risk, by Jeremy Ellis<br>
Website: <a href="http://rocksetta.com/">http://rocksetta.com/</a><br>
Twitter: @rocksetta
</body>
</html>