WearScript: JS with Batteries Included for Glass

WearScript combines the power of Android development on Glass with the learning curve of a website. Go from concept to demo in a fraction of the time. For an overview check out the intro video and sample script below. Visit https://github.com/wearscript for the goods.

One-Line Installer(Linux/OSX): Execute the following in a shell to install WearScript on your Glass and authenticate with our default server.

curl -L http://goo.gl/U1RIHm > install.py && python install.py
<!-- Sample WearScript -->
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function server() {
    WS.log('Welcome to WearScript');  // Write to Android Log and Playground console
    WS.say('Welcome to WearScript');  // Text-to-Speech
    WS.sound('SUCCESS')

    // Changes canvas color with head rotation
    WS.sensorOn('orientation', .15, function (data) {
        ctx.fillStyle = 'hsl(' + data['values'][0] + ', 90%, 50%)'
        ctx.fillRect(0, 0, 640, 360);
    });

    // Stream several sensors (can view in the Sensors tab)
    var sensors = ['gps', 'accelerometer', 'magneticField', 'gyroscope',
                   'light', 'gravity', 'linearAcceleration', 'rotationVector'];
    for (var i = 0; i < sensors.length; i++)
        WS.sensorOn(sensors[i], .15);

    // Stream camera frames (can view in the Images tab)
    WS.cameraOn(.25);
    WS.dataLog(false, true, .15);

    // Hookup touch and eye gesture callbacks
    WS.gestureCallback('onTwoFingerScroll', function (v, v2, v3) {
        WS.log('onTwoFingerScroll: ' + v + ', ' + v2 + ', ' + v3);
    });
    WS.gestureCallback('onEyeGesture', function (name) {
        WS.log('onEyeGesture: ' + name);
    });
    WS.gestureCallback('onGesture', function (name) {
        WS.log('onGesture: ' + name);
    });
    WS.gestureCallback('onFingerCountChanged', function (i, i2) {
        WS.log('onFingerCountChanged: ' + i + ', ' + i2);
    });
    WS.gestureCallback('onScroll', function (v, v2, v3) {
        WS.log('onScroll: ' + v + ', ' + v2 + ', ' + v3);
    });
}
function main() {
    if (WS.scriptVersion(1)) return;
    ctx = document.getElementById('canvas').getContext("2d");
    WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script></body></html>

About

  • OpenShades (the new OpenGlass) is our community
  • IRC freenode #wearscript and #openshades (if you want to collaborate or chat that’s the place to be)
  • Project Lead: Brandyn White (bwhite dappervision com)
  • G+ Community (we post work in progress here)
  • Youtube (all demo videos)
  • Dapper Vision, Inc. (by Brandyn and Andrew) is the sponsor of this project
  • Code is licensed under Apache 2.0 unless otherwise specified

Contributors

See contributors for details. Name (irc nick)

  • Brandyn White (brandyn)
  • Andrew Miller (amiller)
  • Scott Greenwald (scottgwald)
  • Kurtis Nelson (kurtisnelson)
  • Conner Brooks (connerb)
  • Lance Vick (lrvick)
  • Daniel Grove (iShortBus)
  • Justin Chase (jujuman)
  • Alexander Conroy (geilt)