Last active
November 30, 2020 19:34
-
-
Save mikedg1/9448858 to your computer and use it in GitHub Desktop.
[wearscript]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html style="width:100%; height:100%; overflow:hidden"> | |
| <head> | |
| <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>--> | |
| </head> | |
| <body style="width:100%; height:100%; overflow:hidden; margin:0"> | |
| <canvas id="canvas" width="640" height="360" style="display:block"></canvas> | |
| <script> | |
| //test 2 | |
| function cb(data) { | |
| // Changes canvas color with head rotation | |
| if (data['type'] == WS.sensor('orientation')) { | |
| ctx.fillStyle = 'hsl(' + data['values'][0] + ', 90%, 50%)' | |
| ctx.fillRect(0, 0, 640, 360); | |
| } | |
| } | |
| function onEyeGesture(name) { | |
| WS.log('onEyeGesture: ' + name); | |
| } | |
| function onGesture(name) { | |
| WS.log('onGesture: ' + name); | |
| } | |
| function onFingerCountChanged(i, i2) { | |
| WS.log('onFingerCountChanged: ' + i + ', ' + i2); | |
| } | |
| function onScroll(v, v2, v3) { | |
| WS.log('onScroll: ' + v + ', ' + v2 + ', ' + v3); | |
| } | |
| function onTwoFingerScroll(v, v2, v3) { | |
| WS.log('onTwoFingerScroll: ' + v + ', ' + v2 + ', ' + v3); | |
| } | |
| function speech(data) { | |
| WS.log('speech: ' + data); | |
| WS.say('you said ' + data); | |
| } | |
| function server() { | |
| WS.log('Welcome to WearScript'); | |
| WS.say('Welcome to WearScript'); | |
| var sensors = ['gps', 'accelerometer', 'magneticField', 'orientation', 'gyroscope', | |
| 'light', 'gravity', 'linearAcceleration', 'rotationVector', 'pupil']; | |
| // for (var i = 0; i < sensors.length; i++) | |
| // WS.sensorOn(WS.sensor(sensors[i]), .15, 'cb'); | |
| // WS.cameraOn(.25); | |
| // WS.dataLog(false, true, .15); | |
| // var gestures = ['onGesture', 'onFingerCountChanged', 'onScroll', 'onTwoFingerScroll', 'onEyeGesture']; | |
| // for (var i = 0; i < gestures.length; i++) | |
| // WS.gestureCallback(gestures[i], gestures[i]); | |
| // WS.liveCardCreate(false, .2); | |
| WS.sound('SUCCESS') | |
| // Below this are simple examples, uncomment to use them | |
| /* | |
| var tree = new WS.Cards(); | |
| tree.add('Body text', 'Footer text', function () {WS.say('selected')}, function () {WS.say('tapped')}, 'Menu0', function () {WS.say('menu0')}, 'Menu1', function () {WS.say('menu1')}); | |
| tree.add('Body text', 'Footer text', (new WS.Cards()).add('Child0', '0').add('Child1', '1')); | |
| WS.cardTree(tree); | |
| WS.displayCardTree(); | |
| */ | |
| //WS.speechRecognize('Say Something', 'speech'); | |
| //WS.cameraPhoto(); | |
| //WS.cameraVideo(); | |
| //WS.cameraOff(); | |
| //WS.shutdown(); | |
| WS.subscribe('pong', function (chan, timestamp0, timestamp1, groupDevice) { | |
| WS.log('Pong: ' + groupDevice + ': Remote - Glass0: ' + (timestamp1 - timestamp0) + ' Glass1 - Glass0: ' + ((new Date).getTime() / 1000) - timestamp0); | |
| }); | |
| setInterval(function () { | |
| WS.publish('ping', 'pong', (new Date).getTime() / 1000); | |
| }, 250); | |
| } | |
| function main() { | |
| if (WS.scriptVersion(1)) return; | |
| ctx = document.getElementById('canvas').getContext("2d"); | |
| WS.serverConnect('{{WSUrl}}', 'server'); | |
| } | |
| function pup() { | |
| WS.log('pupil cb'); | |
| } | |
| function testing() { | |
| WS.sensor('pupil'); | |
| WS.sensorOn('pupil', .15, 'pup'); | |
| } | |
| function subcb(chan, timestamp0, timestamp1, groupDevice) { | |
| WS.say('subbed'); | |
| WS.log('sub logged'); | |
| } | |
| function testSub() { | |
| WS.subscribe("pong", subcb) | |
| } | |
| function testPub() { | |
| WS.publish("ping", "pong", 0); | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Sample 1" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment