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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzNhZjNlNGY3MDc5ZTA0YTNjMTZkM2Y4Yjc1M2U3MGRhYWMzMzQyYw==
4
+ NmI4YmM3MGEyOTZhMDJlNTdhOThkODZiZDI2MzJkZTU5ZmM3MmU2ZQ==
5
5
  data.tar.gz: !binary |-
6
- ODhlYTcyNTM2NGYwNjBlOTgzMmNiNDQyNjc4OTEyMTNjYjc1MWIyYQ==
6
+ MDEzMzhkMDRlMGRiOWZiNTBiOGQ5Yjc4MWFmMjRiNWEwYzE2NzA4MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGNiN2IwNTkwNGFkNWE2MmM1MDQ3Njk0MTFjOTY1MjZlNjg0Y2EzNjg4MTJl
10
- NDNlM2MxNjVmYzhjYzkzNGFkZGM1NzgxZDUzMzQ0YjBlMDY2Y2M2NmE5Zjcw
11
- ZjcwN2UzMzJiOGVhZWNkM2FhY2M0Nzg2MjQ2ZTViOGUzZmFhYzE=
9
+ YTQ5YzY5MmM3ZWNiYzM5OWNlNjBmOTc5ODkyZTBkMjlkZTY4MjlhYjU1NDdl
10
+ YTJiNDcyYjM5Y2IxZGY4NTYzNzQyNDljNjM3M2Q4M2RkNDJhY2ExMDg3ZWMy
11
+ Y2M0NjUzMzdlNzI3MDk4NTlmNWJkOTA4MDZlNDRlZDM0YmJkZjQ=
12
12
  data.tar.gz: !binary |-
13
- NmZjNDRlZmZmNGExMjBjNTZhODQ0MGUyMGMzNjIwNTcxNzU1MWUzY2JiNmM3
14
- NWI2MDc0OGVhYzlkZDU3NGMxMDIyMGYzODVkNDk2OWU5YTA2MzIyZWM5ZDVm
15
- NmJiMjI5YWNmY2EzNzI3N2YyYWQ3M2VjMWNiOGUzYTczYTdkNDA=
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
+
@@ -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
- logger.debug('send "~GT"')
94
- serial_port.puts '~GT'
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
 
@@ -1,3 +1,3 @@
1
1
  class AmbientOrb
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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-16 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport