beaglebone 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/beaglebone.gemspec +1 -1
- data/lib/beaglebone/beaglebone.rb +1 -2
- data/lib/beaglebone/gpio.rb +4 -6
- data/lib/beaglebone/i2c.rb +1 -1
- data/lib/beaglebone/pwm.rb +2 -2
- data/lib/beaglebone/spi.rb +1 -1
- data/lib/beaglebone/uart.rb +1 -1
- data/procedural-examples.md +3 -3
- metadata +1 -1
data/README.md
CHANGED
@@ -416,8 +416,8 @@ This example shows how to control PWM output of a specified pin.
|
|
416
416
|
|
417
417
|
```ruby
|
418
418
|
# Initialize pin P9_14 for PWM output
|
419
|
-
# This pin will now output a square wave at 10Hz with a 90% duty cycle.
|
420
|
-
p9_14 = PWMPin.new(:P9_14, 90, 10)
|
419
|
+
# This pin will now output a square wave at 10Hz with a 90% duty cycle, non-inverted.
|
420
|
+
p9_14 = PWMPin.new(:P9_14, 90, 10, :NORMAL)
|
421
421
|
|
422
422
|
# Change frequency to 20Hz. Duty cycle remains 90%
|
423
423
|
p9_14.set_frequency(20)
|
@@ -476,7 +476,7 @@ uart1.writeln("A line feed follows")
|
|
476
476
|
```
|
477
477
|
|
478
478
|
#### UART Reading
|
479
|
-
There are many methods available for reading from UART devices. These are blocking methods and will not return until the requested is available.
|
479
|
+
There are many methods available for reading from UART devices. These are blocking methods and will not return until the requested data is available.
|
480
480
|
|
481
481
|
```ruby
|
482
482
|
# Initialize the pins for device UART1 into UART mode.
|
data/beaglebone.gemspec
CHANGED
@@ -226,7 +226,6 @@ module Beaglebone
|
|
226
226
|
# check if a pin of given type is valid
|
227
227
|
def check_valid_pin(pin, type = nil)
|
228
228
|
#check to see if pin exists
|
229
|
-
pin = pin.to_sym.upcase
|
230
229
|
raise ArgumentError, "No such PIN: #{pin.to_s}" unless PINS[pin]
|
231
230
|
|
232
231
|
if type
|
@@ -256,7 +255,7 @@ module Beaglebone
|
|
256
255
|
File.open("#{get_capemgr_dir}/slots", 'w') { |f| f.write(name) }
|
257
256
|
|
258
257
|
raise StandardError, "Unable to load device tree: #{name}" unless device_tree_loaded?(name)
|
259
|
-
sleep(0.
|
258
|
+
sleep(0.4)
|
260
259
|
true
|
261
260
|
end
|
262
261
|
|
data/lib/beaglebone/gpio.rb
CHANGED
@@ -80,7 +80,7 @@ module Beaglebone #:nodoc:
|
|
80
80
|
raise StandardError, "PIN not in GPIO OUT mode: #{pin}" unless get_gpio_mode(pin) == :OUT
|
81
81
|
|
82
82
|
fd = get_value_fd(pin)
|
83
|
-
fd.write STATES[state.to_sym
|
83
|
+
fd.write STATES[state.to_sym].to_s
|
84
84
|
fd.flush
|
85
85
|
Beaglebone::set_pin_status(pin, :state, state)
|
86
86
|
end
|
@@ -175,7 +175,7 @@ module Beaglebone #:nodoc:
|
|
175
175
|
# wait_for_edge(:P9_11, :RISING, 30) => :RISING
|
176
176
|
def wait_for_edge(pin, edge, timeout = nil, disable=true)
|
177
177
|
check_valid_edge(edge)
|
178
|
-
raise ArgumentError, "Cannot wait for edge trigger NONE: #{pin}" if edge.to_sym
|
178
|
+
raise ArgumentError, "Cannot wait for edge trigger NONE: #{pin}" if edge.to_sym == :NONE
|
179
179
|
|
180
180
|
check_gpio_enabled(pin)
|
181
181
|
raise StandardError, "PIN not in GPIO IN mode: #{pin}" unless get_gpio_mode(pin) == :IN
|
@@ -390,8 +390,6 @@ module Beaglebone #:nodoc:
|
|
390
390
|
#check if pin is valid to use as gpio pin
|
391
391
|
def valid?(pin)
|
392
392
|
#check to see if pin exists
|
393
|
-
pin = pin.to_sym.upcase
|
394
|
-
|
395
393
|
return false unless PINS[pin]
|
396
394
|
return false unless PINS[pin][:gpio]
|
397
395
|
|
@@ -454,14 +452,14 @@ module Beaglebone #:nodoc:
|
|
454
452
|
#ensure state is valid
|
455
453
|
def check_valid_state(state)
|
456
454
|
#check to see if mode is valid
|
457
|
-
state = state.to_sym
|
455
|
+
state = state.to_sym
|
458
456
|
raise ArgumentError, "No such state: #{state.to_s}" unless STATES.include?(state)
|
459
457
|
end
|
460
458
|
|
461
459
|
#ensure mode is valid
|
462
460
|
def check_valid_mode(mode)
|
463
461
|
#check to see if mode is valid
|
464
|
-
mode = mode.to_sym
|
462
|
+
mode = mode.to_sym
|
465
463
|
raise ArgumentError, "No such mode: #{mode.to_s}" unless MODES.include?(mode)
|
466
464
|
end
|
467
465
|
|
data/lib/beaglebone/i2c.rb
CHANGED
@@ -144,7 +144,7 @@ module Beaglebone #:nodoc:
|
|
144
144
|
# ensure valid i2c device
|
145
145
|
def check_i2c_valid(i2c)
|
146
146
|
raise ArgumentError, "Invalid i2c Specified #{i2c.to_s}" unless I2CS[i2c] && I2CS[i2c][:sda]
|
147
|
-
i2cinfo = I2CS[i2c.to_sym
|
147
|
+
i2cinfo = I2CS[i2c.to_sym]
|
148
148
|
|
149
149
|
unless i2cinfo[:scl] && [nil,:i2c].include?(Beaglebone::get_pin_status(i2cinfo[:scl], :type))
|
150
150
|
raise StandardError, "SCL Pin for #{i2c.to_s} in use"
|
data/lib/beaglebone/pwm.rb
CHANGED
@@ -309,7 +309,7 @@ module Beaglebone #:nodoc:
|
|
309
309
|
#ensure pin is valid pwm pin
|
310
310
|
def valid?(pin)
|
311
311
|
#check to see if pin exists
|
312
|
-
pin = pin.to_sym
|
312
|
+
pin = pin.to_sym
|
313
313
|
|
314
314
|
return false unless PINS[pin]
|
315
315
|
return false unless PINS[pin][:pwm]
|
@@ -388,7 +388,7 @@ module Beaglebone #:nodoc:
|
|
388
388
|
#ensure polarity is valid
|
389
389
|
def check_valid_polarity(polarity)
|
390
390
|
#check to see if mode is valid
|
391
|
-
polarity = polarity.to_sym
|
391
|
+
polarity = polarity.to_sym
|
392
392
|
raise ArgumentError, "No such polarity: #{polarity.to_s}" unless POLARITIES.include?(polarity)
|
393
393
|
end
|
394
394
|
|
data/lib/beaglebone/spi.rb
CHANGED
@@ -278,7 +278,7 @@ module Beaglebone #:nodoc:
|
|
278
278
|
#ensure spi is valid
|
279
279
|
def check_spi_valid(spi)
|
280
280
|
raise ArgumentError, "Invalid spi Specified #{spi.to_s}" unless SPIS[spi] && SPIS[spi][:sclk]
|
281
|
-
spiinfo = SPIS[spi.to_sym
|
281
|
+
spiinfo = SPIS[spi.to_sym]
|
282
282
|
|
283
283
|
unless spiinfo[:sclk] && [nil,:spi].include?(Beaglebone::get_pin_status(spiinfo[:sclk], :type))
|
284
284
|
raise StandardError, "SCLK Pin for #{spi.to_s} in use"
|
data/lib/beaglebone/uart.rb
CHANGED
@@ -390,7 +390,7 @@ module Beaglebone #:nodoc:
|
|
390
390
|
# ensure UART is valid
|
391
391
|
def check_uart_valid(uart)
|
392
392
|
raise ArgumentError, "Invalid UART Specified #{uart.to_s}" unless UARTS[uart]
|
393
|
-
uartinfo = UARTS[uart.to_sym
|
393
|
+
uartinfo = UARTS[uart.to_sym]
|
394
394
|
|
395
395
|
unless uartinfo[:tx] && [nil,:uart].include?(Beaglebone::get_pin_status(uartinfo[:tx], :type))
|
396
396
|
raise StandardError, "TX Pin for #{uart.to_s} in use"
|
data/procedural-examples.md
CHANGED
@@ -313,8 +313,8 @@ This example shows how to control PWM output of a specified pin.
|
|
313
313
|
|
314
314
|
```ruby
|
315
315
|
# Initialize pin P9_14 for PWM output
|
316
|
-
# This pin will now output a square wave at 10Hz with a 90% duty cycle.
|
317
|
-
PWM.start(:P9_14, 90, 10)
|
316
|
+
# This pin will now output a square wave at 10Hz with a 90% duty cycle, non-inverted.
|
317
|
+
PWM.start(:P9_14, 90, 10, :NORMAL)
|
318
318
|
|
319
319
|
# Change frequency to 20Hz. Duty cycle remains 90%
|
320
320
|
PWM.set_frequency(:P9_14, 20)
|
@@ -373,7 +373,7 @@ UART.writeln(:UART1, "A line feed follows")
|
|
373
373
|
```
|
374
374
|
|
375
375
|
#### UART Reading
|
376
|
-
There are many methods available for reading from UART devices. These are blocking methods and will not return until the requested is available.
|
376
|
+
There are many methods available for reading from UART devices. These are blocking methods and will not return until the requested data is available.
|
377
377
|
|
378
378
|
```ruby
|
379
379
|
# Initialize the pins for device UART1 into UART mode.
|