@@ -21,32 +21,52 @@ One-Line Installer(Linux/OSX): Execute the following in a shell to install WearS
21
21
<body style =" width :100% ; height :100% ; overflow :hidden ; margin :0 " >
22
22
<canvas id =" canvas" width =" 640" height =" 360" style =" display :block " ></canvas >
23
23
<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
- }
30
24
function server () {
31
25
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' ];
36
38
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 );
39
43
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
+ });
40
61
}
41
62
function main () {
42
- if (WS .scriptVersion (0 )) return ;
63
+ if (WS .scriptVersion (1 )) return ;
43
64
ctx = document .getElementById (' canvas' ).getContext (" 2d" );
44
- WS .serverConnect (' {{WSUrl}}' , ' server' );
65
+ WS .serverConnect (' {{WSUrl}}' , server);
45
66
}
46
67
window .onload = main;
47
68
</script ></body ></html >
48
69
49
-
50
70
.. toctree ::
51
71
:hidden:
52
72
:maxdepth: 1
0 commit comments