Skip to content

Commit 5c80a8f

Browse files
author
Brandyn A. White
committed
Updated index
Signed-off-by: Brandyn A. White <[email protected]>
1 parent 4c5bed8 commit 5c80a8f

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

index.rst

+35-15
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,52 @@ One-Line Installer(Linux/OSX): Execute the following in a shell to install WearS
2121
<body style="width:100%; height:100%; overflow:hidden; margin:0">
2222
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
2323
<script>
24-
function cb(data) { // Changes canvas color depending on head rotation
25-
if (data['type'] == WS.sensor('orientation')) {
26-
ctx.fillStyle = 'hsl(' + data['values'][0] + ', 90%, 50%)'
27-
ctx.fillRect(0, 0, 640, 360);
28-
}
29-
}
3024
function server() {
3125
WS.log('Welcome to WearScript'); // Write to Android Log and Playground console
32-
WS.say('Welcome to WearScript'); // Text-to-speech
33-
// Stream camera images and all sensors to the WearScript Playground Webapp
34-
var sensors = ['gps', 'accelerometer', 'magneticField', 'orientation', 'gyroscope',
35-
'light', 'gravity', 'linearAcceleration', 'rotationVector'];
26+
WS.say('Welcome to WearScript'); // Text-to-Speech
27+
WS.sound('SUCCESS')
28+
29+
// Changes canvas color with head rotation
30+
WS.sensorOn('orientation', .15, function (data) {
31+
ctx.fillStyle = 'hsl(' + data['values'][0] + ', 90%, 50%)'
32+
ctx.fillRect(0, 0, 640, 360);
33+
});
34+
35+
// Stream several sensors (can view in the Sensors tab)
36+
var sensors = ['gps', 'accelerometer', 'magneticField', 'gyroscope',
37+
'light', 'gravity', 'linearAcceleration', 'rotationVector'];
3638
for (var i = 0; i < sensors.length; i++)
37-
WS.sensorOn(WS.sensor(sensors[i]), .15, 'cb');
38-
WS.cameraOn(2);
39+
WS.sensorOn(sensors[i], .15);
40+
41+
// Stream camera frames (can view in the Images tab)
42+
WS.cameraOn(.25);
3943
WS.dataLog(false, true, .15);
44+
45+
// Hookup touch and eye gesture callbacks
46+
WS.gestureCallback('onTwoFingerScroll', function (v, v2, v3) {
47+
WS.log('onTwoFingerScroll: ' + v + ', ' + v2 + ', ' + v3);
48+
});
49+
WS.gestureCallback('onEyeGesture', function (name) {
50+
WS.log('onEyeGesture: ' + name);
51+
});
52+
WS.gestureCallback('onGesture', function (name) {
53+
WS.log('onGesture: ' + name);
54+
});
55+
WS.gestureCallback('onFingerCountChanged', function (i, i2) {
56+
WS.log('onFingerCountChanged: ' + i + ', ' + i2);
57+
});
58+
WS.gestureCallback('onScroll', function (v, v2, v3) {
59+
WS.log('onScroll: ' + v + ', ' + v2 + ', ' + v3);
60+
});
4061
}
4162
function main() {
42-
if (WS.scriptVersion(0)) return;
63+
if (WS.scriptVersion(1)) return;
4364
ctx = document.getElementById('canvas').getContext("2d");
44-
WS.serverConnect('{{WSUrl}}', 'server');
65+
WS.serverConnect('{{WSUrl}}', server);
4566
}
4667
window.onload = main;
4768
</script></body></html>
4869

49-
5070
.. toctree::
5171
:hidden:
5272
:maxdepth: 1

0 commit comments

Comments
 (0)