GithubHelp home page GithubHelp logo

wearscript / wearscript-android Goto Github PK

View Code? Open in Web Editor NEW
213.0 36.0 55.0 51.74 MB

JavaScript with Batteries Included for Google Glass

Home Page: wearscript.com

CSS 0.78% JavaScript 2.17% Java 96.98% HTML 0.07%

wearscript-android's Introduction

WearScript

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 http://www.wearscript.com for documentation and more information.

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

intro video

// 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 cb(data) {  // Changes canvas color depending on head rotation
    if (data['type'] == WS.sensor('orientation')) {
        ctx.fillStyle = 'hsl(' + data['values'][0] + ', 90%, 50%)'
        ctx.fillRect(0, 0, 640, 360);
    }
}
function server() {
    WS.log('Welcome to WearScript');  // Write to Android Log and Playground console
    WS.say('Welcome to WearScript');  // Text-to-speech
    // Stream camera images and all sensors to the WearScript Playground Webapp
    var sensors = ['gps', 'accelerometer', 'magneticField', 'orientation', 'gyroscope',
                   'light', 'gravity', 'linearAcceleration', 'rotationVector'];
    for (var i = 0; i < sensors.length; i++)
        WS.sensorOn(WS.sensor(sensors[i]), .15, 'cb');
    WS.cameraOn(2);
    WS.dataLog(false, true, .15);
}
function main() {
    if (WS.scriptVersion(0)) return;
    ctx = document.getElementById('canvas').getContext("2d");
    WS.serverConnect('{{WSUrl}}', 'server');
}
window.onload = main;
</script></body></html>

About

  • Full documentation at http://www.wearscript.com
  • OpenShades (the new OpenGlass) is our community
  • IRC freenode #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 OpenShades 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 (swgreen_mit)
  • Kurtis Nelson (kurtisnelson)
  • Conner Brooks (connerb)
  • Justin Chase (jujuman)
  • Alexander Conroy (geilt)

wearscript-android's People

Contributors

colegleason avatar connerbrooks avatar coryk135 avatar deadprogram avatar jujum4n avatar kurtisnelson avatar lrvick avatar mikedg1 avatar scottgwald avatar timothyclemans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wearscript-android's Issues

refactor glass keyboard

(1) single all-knowing dictionary for event names, event constants, key codes, android commands

will add more as comments

Shake down activity life cycle bugs

When alternating between launch, start, stop, and setup sometimes the mainactivity comes up when the selected activity should. This is likely because the activity is started without a create new flag of some sort.

When you click send to gist, have a modal come up with confirmations if we want to sign it

The signer should check that

  • I believe this script is safe because I 1.) authored it or 2.) understand its operation.
  • I verified that all external requests (JS, Ajax, websockets, images) are safe, from sources I trust, and do not believe they would be used to deliver unsafe content in the future.

There should be an "upload but don't sign" button that skips this for temporary use of Gist. The reason for all this is that the signer isn't necessarily the original author, but they are attesting that they verified the script and will take the blame if it messes with someone's glass.

Too many open files error in WS

10-05 21:35:29.230    2056-2916/? E/WearScript﹕ WS: Error!
    java.net.SocketException: socket failed: EMFILE (Too many open files)
            at libcore.io.IoBridge.socket(IoBridge.java:573)
            at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
            at java.net.Socket.startupSocket(Socket.java:559)
            at java.net.Socket.tryAllAddresses(Socket.java:127)
            at java.net.Socket.<init>(Socket.java:177)
            at java.net.Socket.<init>(Socket.java:149)
            at javax.net.ssl.SSLSocket.<init>(SSLSocket.java:55)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.<init>(OpenSSLSocketImpl.java:122)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:64)
            at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:85)
            at java.lang.Thread.run(Thread.java:856)
     Caused by: libcore.io.ErrnoException: socket failed: EMFILE (Too many open files)
            at libcore.io.Posix.socket(Native Method)
            at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
            at libcore.io.IoBridge.socket(IoBridge.java:558)
            at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
            at java.net.Socket.startupSocket(Socket.java:559)
            at java.net.Socket.tryAllAddresses(Socket.java:127)
            at java.net.Socket.<init>(Socket.java:177)
            at java.net.Socket.<init>(Socket.java:149)
            at javax.net.ssl.SSLSocket.<init>(SSLSocket.java:55)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.<init>(OpenSSLSocketImpl.java:122)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:64)
            at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:85)
            at java.lang.Thread.run(Thread.java:856)
10-05 21:35:29.230    2056-2914/? E/WearScript﹕ WS: Error!
    java.net.SocketException: socket failed: EMFILE (Too many open files)
            at libcore.io.IoBridge.socket(IoBridge.java:573)
            at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
            at java.net.Socket.startupSocket(Socket.java:559)
            at java.net.Socket.tryAllAddresses(Socket.java:127)
            at java.net.Socket.<init>(Socket.java:177)
            at java.net.Socket.<init>(Socket.java:149)
            at javax.net.ssl.SSLSocket.<init>(SSLSocket.java:55)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.<init>(OpenSSLSocketImpl.java:122)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:64)
            at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:85)
            at java.lang.Thread.run(Thread.java:856)
     Caused by: libcore.io.ErrnoException: socket failed: EMFILE (Too many open files)
            at libcore.io.Posix.socket(Native Method)
            at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
            at libcore.io.IoBridge.socket(IoBridge.java:558)
            at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
            at java.net.Socket.startupSocket(Socket.java:559)
            at java.net.Socket.tryAllAddresses(Socket.java:127)
            at java.net.Socket.<init>(Socket.java:177)
            at java.net.Socket.<init>(Socket.java:149)
            at javax.net.ssl.SSLSocket.<init>(SSLSocket.java:55)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.<init>(OpenSSLSocketImpl.java:122)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:64)
            at com.codebutler.android_websockets.WebSocketClient$1.run(WebSocketClient.java:85)
            at java.lang.Thread.run(Thread.java:856)

Location triangulation with wifi

Using the WS.wifi* commands you can get signal strength, MACs, and SSIDs. It should be fairly simple to make a JS library that can provide either relative positioning or (with calibration) absolute positioning.

Add take a picture support

Should be doable just using an intent android.intent.action.CAMERA_BUTTON, we normally sense pictures using the preview image callback but this lets you get full sized frames.

Document signing

We need to document how signing works, including how to setup a new private key for your server and such.

Android Studio preferred update channel

Brandyn got burned by the lastest "canary" update. Scott suggests having users select a more stable update channel when installing. The disadvantage is that some users may have already updated and even potentially have project structures that are not backwards compatible.

Create JavaScript lib that detects environment

We want people to be able to run scripts directly in the browser as if they were on glass, and having to bring in and out a simulator dependency is messy.

  • WS.env returns glass or browser
  • Calls to WS. are stubbed out in browser
  • Calls to server work from browser
  • JS lib is included by default in examples and production

Add WS.barcode(callback, formats)

zxing allows us to scan many different kinds of 1D and 2D barcodes. Let's open that up to people and make WS.QR(callback) an alias such as WS.barcode(callback, ["QR_CODE"])

Move to msgpack as the wire/disk format

JSON is overly bulky, can't support binary (needs b64 which adds 30% overhead to images), and too slow. Here https://github.com/eishay/jvm-serializers/wiki is a Java benchmark of many ser/de libraries and msgpack is the fastest multi-language and self-describing encoding (only barely beaten by kryo and protostuff). This is also a good time to evaluate if the information we have in the format is all that is necessary (maybe leave out sensor names? look into better sensor timestamps?), if we want to add encryption, and if we want to add compression.

Document and find methods to wake the screen

I know we can do it with adb

adb shell input keyevent 66

To use this easier you can use tools/glasskeyboard/monitor.py which simplifies the ADB commands and you can open it in a web browser remotely (and you can make your glass connect to adb wirelessly).

It's clearly possible because they do it when you tilt your head.

Camera locked

It's possible that if the app is reinstalled using ADB while using the camera that it gets locked. You have to restart the device.

Add state display into webapp: sensors and script state

Should display the rate each sensor is being updated at (apparent value vs set value), change log to include the script iteration number. Along with #14 we will want to indicate to the user that we are in the BIOS (basically a hint that their script crashed). If connected to server we should send periodic updates about the state of the javascript.

OpenGlass: Simulator

For the OpenKinect project, I developed a system called Fakenect (on my personal site below but search for Fakenect) that allowed people to use recorded dumps of data from the Kinect. The reason was the device itself was expensive and of limited availability, but many people at universities in the US and basically anyone outside of the US wanted to work with it. Glass is in the same position due to the limited supply and distribution, a priority should be enabling people without glass to participate as much as possible.

  1. That could be through making a simulator that essentially gives your application the "feeling" like it is talking to Google and an active glass user
  2. We can develop device analogues (either rudimentary implementations or mobile phone interfaces) so that people can more easily "think in glass".

Should we start scripts assuming a WS.connect({{WSUrl}})?

This can be changed by the user just calling it again, but in the majority of instances you'd want to call it. I like having things be explicit but at the same time it may confuse people otherwise. It also would possibly reduce the iteration time for scripts because Glass doesn't have to reconnect.

Add WS.QR(callback)

We already have QR support we just need to allow it to be used from wearscript

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.