Skip to content

Commit 797e958

Browse files
author
Brandyn A. White
committed
Updated with bluetooth
Signed-off-by: Brandyn A. White <[email protected]>
1 parent b7b319a commit 797e958

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

bluetooth.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Bluetooth
2+
=========
3+
4+
5+
Keyboard -> Glass
6+
==================
7+
By connecting a BT keyboard to Glass you can control the timeline and use the keypresses inside WearScript like you would in a normal webpage. Keyboards like this http://www.amazon.com/dp/B005C6CVAE/ work well with Glass. First we have to install the Settings.apk so that we can access the pairing options. Install the Settings.apk from here http://www.glassxe.com/2013/05/23/settings-apk-and-launcher2-apk-from-the-hacking-glass-session-at-google-io/ and start the settings using
8+
9+
.. code-block:: guess
10+
11+
adb am start -a android.intent.action.MAIN -n com.android.settings/.Settings
12+
13+
Put your device into a bluetooth pairing mode. Select Bluetooth, then use the touchpad to select your device. You'll be asked to type a code using the keyboard and then you are all done.
14+
15+
Arduino <-> Glass
16+
=============================
17+
18+
Bluetooth module: http://www.amazon.com/dp/B0093XAV4U
19+
20+
Arduino code. Make sure to plug the RX from BT into TX of arduino which is pin 2 below.
21+
22+
.. code-block:: guess
23+
#include <SoftwareSerial.h>
24+
SoftwareSerial mySerial(3, 2); // RX, TX
25+
void setup() {
26+
Serial.begin(57600);
27+
while (!Serial) {
28+
}
29+
mySerial.begin(9600);
30+
}
31+
32+
void loop() {
33+
if (mySerial.available())
34+
Serial.write(mySerial.read());
35+
if (Serial.available()) {
36+
delay(10); // HACK
37+
mySerial.write(Serial.read());
38+
}
39+
}
40+
41+
.. code-block:: guess
42+
43+
<html style="width:100%; height:100%; overflow:hidden">
44+
<body style="width:100%; height:100%; overflow:hidden; margin:0">
45+
<script>
46+
function main() {
47+
if (WS.scriptVersion(1)) return;
48+
WS.serverConnect('{{WSUrl}}', function () {
49+
WS.bluetoothWrite('20:13:12:05:04:11', 'bluetooth message from glass to arduino');
50+
WS.bluetoothRead('20:13:12:05:04:11', function (c) {
51+
WS.log('BT:' + c)
52+
});
53+
WS.bluetoothList(function (devices) {
54+
WS.log(JSON.stringify(devices));
55+
});
56+
});
57+
}
58+
window.onload = main;
59+
</script>
60+
</body>
61+
</html>

gist.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Gist
2+
====
3+
4+
WearScript uses Github's Gist service to facilitate storing and sharing scripts. The Go server (wearscript-server) communicates with the Gist API and only allows operation on gists that have [wearscript] as the prefix of the description. The default script name for Glass devices is glass.html and there should be a manifest.json file with a field "name" that is the script's name. Gists can be synced to Glass by using the Gist Sync option in the menu when you start WearScript. In the playground gists can be opened, forked from others, and modified.

index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ One-Line Installer(Linux/OSX): Execute the following in a shell to install WearS
5858
camera
5959
pubsub
6060
arduino
61+
bluetooth
6162
ar
6263
eyetracking
6364
myo
65+
gist
6466
tips
6567
wire
6668
contributing

myo.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Myo
22
===
3+
The Myo uses bluetooth-le and can only be connected to Android Kit Kat devices (e.g., Nexus 5). As the SDK is not publicly available you'll need to get the Myo binary of WearScript (currently a private branch) from us. If you are part of the Myo Alpha program we can add you to the repository.
4+
5+
This demonstrates training the Myo, saying out load which gesture is performed. NONE is produced after a gesture is stopped (e.g., a clenched fist will stay FIST until it is released and then will be NONE). It also streams the accelerometer, orientation, and gyro to the sensors tab (see WS.dataLog).
36

47
.. code-block:: guess
58

0 commit comments

Comments
 (0)