Created
April 19, 2014 05:04
-
-
Save bwhite/11074650 to your computer and use it in GitHub Desktop.
[wearscript] AR Tag + Power Tail
This file contains 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
#include <SoftwareSerial.h> | |
SoftwareSerial mySerial(3, 2); // RX, TX | |
void setup() | |
{ | |
Serial.begin(57600); | |
while (!Serial) { | |
} | |
mySerial.begin(9600); | |
pinMode(4, OUTPUT); | |
} | |
void loop() | |
{ | |
if (mySerial.available()) { | |
char c = mySerial.read(); | |
if (c == '0') | |
digitalWrite(4, 0); | |
else if (c == '1') | |
digitalWrite(4, 1); | |
else | |
digitalWrite(4, !digitalRead(4)); | |
Serial.write(c); | |
} | |
if (Serial.available()) { | |
delay(10); // HACK | |
mySerial.write(Serial.read()); | |
} | |
} |
This file contains 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"> | |
<body style="width:100%; height:100%; overflow:hidden; margin:0" bgcolor="#000"> | |
<img width="640" height="360" id="image" /> | |
<script> | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
DB = {}; | |
WS.cameraOnBackgroundUnsafe(1, 360, 640); | |
var model_ar = btoa(msgpack.pack([{'kw': {}, 'name': 'picarus.ARMarkerDetector'}]).map(function (x) {return String.fromCharCode(x)}).join('')); | |
LAST_ID = undefined; | |
ADDR = '00:14:01:17:16:63'; | |
WS.gestureCallback('onEyeGesture', function () { | |
WS.say('blink') | |
WS.bluetoothWrite(ADDR, '2'); | |
}); | |
model = new WS.PicarusModel(model_ar, function () { | |
model.processStream(function (tags) { | |
tags = msgpack.unpack(tags); | |
WS.log(JSON.stringify(tags)); | |
WS.log(JSON.stringify(DB)); | |
if (tags && tags[0].length) { | |
var id = String(tags[0][0]); | |
if (!DB[id]) { | |
DB[id] = {setup: false}; | |
WS.wake(); | |
WS.speechRecognize('Name the tag', function (data) { | |
WS.cameraPhoto(function (path) { | |
DB[id].setup = true; | |
DB[id].label = data; | |
DB[id].photo = path; | |
}); | |
}); | |
} else if (DB[id].setup) { | |
WS.wake(); | |
WS.activityCreate(); | |
LAST_ID = id; | |
WS.say(DB[id].label); | |
document.getElementById('image').setAttribute('src', 'file://' + DB[id].photo); | |
} | |
} | |
}); | |
}) | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
This file contains 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":""} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment