Skip to content

Instantly share code, notes, and snippets.

@bwhite
bwhite / glass.html
Created May 3, 2014
[wearscript] BT Battery Discharge
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function btsend(data) {
var addr = '00:00:12:06:57:19';
WS.bluetoothPair(addr, function () {
WS.log('Sending: ' + data);
WS.bluetoothWrite(addr, data);
});
}
@bwhite
bwhite / glass.html
Created May 2, 2014
[wearscript] IBeacon Basics
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0" bgcolor="#000">
<script>
function server() {
WS.beaconOn();
WS.subscribe('ibeacon', function (channel, uuid, rssid, major, minor, proximity) {
WS.log(channel + ' ' + uuid + ' ' + rssid + ' ' + major + ' ' + minor + ' ' + proximity);
WS.say(proximity)
})
}
@bwhite
bwhite / arduino.ino
Last active Aug 29, 2015
[wearscript] Beacon Powertail
View arduino.ino
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2); // RX, TX
unsigned long timeOff = 0;
void setup()
{
Serial.begin(57600);
while (!Serial) {
@bwhite
bwhite / glass.html
Created May 2, 2014
[wearscript] Tango overhead
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<head>
<script src="https://gist.githubusercontent.com/amiller/11100038/raw/pacman.js"></script>
<!-- You can include external scripts here like so... -->
<!--<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">
<div id="pacman"></div>
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
@bwhite
bwhite / glass.html
Last active Aug 29, 2015
[wearscript] Crazy tetris
View glass.html
<html>
<head>
<script>
function main() {
var fs = "1111:01|01|01|01*011|110:010|011|001*110|011:001|011|010*111|010:01|11|01:010|111:10|11|10*11|11*010|010|011:111|100:11|01|01:001|111*01|01|11:100|111:11|10|10:111|001", now = [3,0], pos = [4,0];
var gP = function(x,y) { return document.querySelector('[data-y="'+y+'"] [data-x="'+x+'"]'); };
var draw = function(ch, cls) {
var f = fs.split('*')[now[0]].split(':')[now[1]].split('|').map(function(a){return a.split('')});
for(var y=0; y<f.length; y++)
for(var x=0; x<f[y].length; x++)
@bwhite
bwhite / glass.html
Created May 2, 2014
[wearscript] Magnet ring phone to glass
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function main() {
if (WS.scriptVersion(1)) return;
}
window.onload = main;
</script></body></html>
@bwhite
bwhite / glass.html
Created Apr 27, 2014
[wearscript] Phone + Glass
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0" bgcolor="#000">
<script>
function server() {
WS.gestureCallback('onGestureTAP', function () {
WS.publish('say', 'Tapped');
});
}
function main() {
if (WS.scriptVersion(1)) return;
@bwhite
bwhite / glass.html
Last active Aug 29, 2015
[wearscript] Tetris
View glass.html
<html>
<head>
<script>
function main() {
var fs = "1111:01|01|01|01*011|110:010|011|001*110|011:001|011|010*111|010:01|11|01:010|111:10|11|10*11|11*010|010|011:111|100:11|01|01:001|111*01|01|11:100|111:11|10|10:111|001", now = [3,0], pos = [4,0];
var gP = function(x,y) { return document.querySelector('[data-y="'+y+'"] [data-x="'+x+'"]'); };
var draw = function(ch, cls) {
var f = fs.split('*')[now[0]].split(':')[now[1]].split('|').map(function(a){return a.split('')});
for(var y=0; y<f.length; y++)
for(var x=0; x<f[y].length; x++)
View cpu.js
/*
JSNES, based on Jamie Sanders' vNES
Copyright (C) 2010 Ben Firshman
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@bwhite
bwhite / glass.html
Created Apr 27, 2014
[wearscript] AR Tag Reader
View glass.html
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0" bgcolor="#000">
<script>
function main() {
if (WS.scriptVersion(1)) return;
WS.picarusARTagFactory(function (model) {
model.processStream(function (tags) {
WS.log(JSON.stringify(tags));
var out = 'Tag';
for (var i = 0; i < tags.length; i++)