ambient-orb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +20 -0
- data/lib/ambient-orb.rb +33 -3
- data/lib/ambient-orb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmI4YmM3MGEyOTZhMDJlNTdhOThkODZiZDI2MzJkZTU5ZmM3MmU2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDEzMzhkMDRlMGRiOWZiNTBiOGQ5Yjc4MWFmMjRiNWEwYzE2NzA4MA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTQ5YzY5MmM3ZWNiYzM5OWNlNjBmOTc5ODkyZTBkMjlkZTY4MjlhYjU1NDdl
|
10
|
+
YTJiNDcyYjM5Y2IxZGY4NTYzNzQyNDljNjM3M2Q4M2RkNDJhY2ExMDg3ZWMy
|
11
|
+
Y2M0NjUzMzdlNzI3MDk4NTlmNWJkOTA4MDZlNDRlZDM0YmJkZjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWNmNGJiY2QyNzBiMWUwMGRjOGYwNmYzOTljZTA3OGJiMTc2MzhkMjZiN2E4
|
14
|
+
Y2Y4NjAxNjNjODE3YjdlZTA3NWUzODNlOTI1MzZjYWJjNDAxOGMyYTg2OWNi
|
15
|
+
M2FhZWE2NDY3NmM3Y2I5NjhkYWIwY2EwNjRiMDM3ZGU0OGFhMGM=
|
data/README.md
CHANGED
@@ -29,3 +29,23 @@ orb = AmbientOrb.new
|
|
29
29
|
sleep(10)
|
30
30
|
end
|
31
31
|
```
|
32
|
+
|
33
|
+
## Hardware Setup
|
34
|
+
|
35
|
+
This gem has been tested with two hardware setups.
|
36
|
+
|
37
|
+
### Arduino Uno R3
|
38
|
+
|
39
|
+
Using the Arduino Uno R3 as a [USB to serial TTL converter](http://www.princetronics.com/arduino-uno-as-usb-to-serial-ttl-converter/). The R3 uses an atmega16u2 chip.
|
40
|
+
|
41
|
+
* Connect Pin 5 (RX) on the Orb to Pin 0 (RX) on the Arduino.
|
42
|
+
* Connect Pin 6 (TX) on the Orb to Pin 1 (TX) on the Arduino.
|
43
|
+
* Connect RESET to GND on the Arduino.
|
44
|
+
|
45
|
+
### FT232R USB to 5V TTL level UART cable
|
46
|
+
|
47
|
+
Using the [EZSync FTDI chip usb to 5v TTL UART serial cable, connector end, 1.5m, TTL-232R-5V compatible](http://www.amazon.com/gp/product/B010KII6VG?psc=1&redirect=true&ref_=oh_aui_detailpage_o00_s00) cable. This cable uses the FT232R chip.
|
48
|
+
|
49
|
+
* Connect Pin 5 (RX) on the Orb to Pin 4 (TXD, Orange) on the cable.
|
50
|
+
* Connect Pin 6 (TX) on the Orb to Pin 5 (RXD, Yellow) on the cable.
|
51
|
+
|
data/lib/ambient-orb.rb
CHANGED
@@ -49,6 +49,20 @@ class AmbientOrb
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def chip
|
53
|
+
@chip ||= begin
|
54
|
+
chip = @opts[:chip] || autodetect_chip
|
55
|
+
|
56
|
+
unless chip
|
57
|
+
raise ArgumentError, 'invalid chip'
|
58
|
+
end
|
59
|
+
|
60
|
+
logger.info("using chip #{chip}")
|
61
|
+
|
62
|
+
chip
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
52
66
|
def logger
|
53
67
|
@logger ||= begin
|
54
68
|
@opts[:logger] || Logger.new(nil)
|
@@ -75,7 +89,7 @@ class AmbientOrb
|
|
75
89
|
private
|
76
90
|
|
77
91
|
def autodetect_device
|
78
|
-
devices = Dir.glob('/dev/*.usbmodem*')
|
92
|
+
devices = Dir.glob('/dev/*.usbmodem*') + Dir.glob('/dev/*.usbserial*')
|
79
93
|
|
80
94
|
devices.each do |dev|
|
81
95
|
logger.debug("autodetect_device found #{dev}")
|
@@ -84,17 +98,33 @@ class AmbientOrb
|
|
84
98
|
devices.first
|
85
99
|
end
|
86
100
|
|
101
|
+
def autodetect_chip
|
102
|
+
case device
|
103
|
+
when /usbmodem/
|
104
|
+
# Arduino Uno R3
|
105
|
+
:atmega16u2
|
106
|
+
when /usbserial/
|
107
|
+
# FT232R USB to 5V TTL level UART cable
|
108
|
+
:ft232r
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
87
112
|
def send(command)
|
88
113
|
SerialPort.open(device,
|
89
114
|
SERIAL_PORT_BAUD_RATE,
|
90
115
|
SERIAL_PORT_DATA_BITS,
|
91
116
|
SERIAL_PORT_STOP_BITS,
|
92
117
|
SERIAL_PORT_PARITY) do |serial_port|
|
93
|
-
|
94
|
-
|
118
|
+
|
119
|
+
if chip == :atmega16u2
|
120
|
+
logger.debug('send "~GT"')
|
121
|
+
serial_port.puts '~GT'
|
122
|
+
end
|
95
123
|
|
96
124
|
logger.debug("send \"#{command}\"")
|
97
125
|
serial_port.puts command
|
126
|
+
|
127
|
+
serial_port.readchar
|
98
128
|
end
|
99
129
|
end
|
100
130
|
|
data/lib/ambient-orb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ambient-orb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Tai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serialport
|