BBB 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/examples/analog_pin.rb +25 -1
- data/examples/light_switch.rb +56 -0
- data/lib/BBB/adc/analog_pin.rb +1 -1
- data/lib/BBB/version.rb +1 -1
- metadata +5 -4
data/.travis.yml
CHANGED
data/examples/analog_pin.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# To run this example do this first:
|
3
|
+
#
|
4
|
+
# Make sure you run as root
|
5
|
+
# > sudo su
|
6
|
+
#
|
7
|
+
# Install BBB gem version 0.0.9 or higher
|
8
|
+
# > gem install BBB
|
9
|
+
#
|
10
|
+
# Then activate the ADC using the cape
|
11
|
+
# > echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots
|
12
|
+
#
|
13
|
+
# No open up an IRB console and copy paste in this code
|
14
|
+
# > irb
|
15
|
+
#
|
16
|
+
# BE CAREFUL:
|
17
|
+
# The AIN pins only take 1.8V at max. So if you connect an output pin
|
18
|
+
# to an input pin make sure you use a voltage divider circuit. See here:
|
19
|
+
# http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/adc
|
20
|
+
#
|
1
21
|
require 'BBB'
|
2
22
|
|
3
23
|
##
|
@@ -20,9 +40,13 @@ class TemperatureExampleApp < BBB::Application
|
|
20
40
|
# Connect the circuit to the board
|
21
41
|
circuit Circuit.new
|
22
42
|
|
43
|
+
def initialize
|
44
|
+
end
|
45
|
+
|
46
|
+
|
23
47
|
# This is the basic run loop
|
24
48
|
def run
|
25
|
-
|
49
|
+
print "value: #{thermometer.read}\r"
|
26
50
|
end
|
27
51
|
end
|
28
52
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# To run this example do this first:
|
3
|
+
#
|
4
|
+
# Make sure you run as root
|
5
|
+
# > sudo su
|
6
|
+
#
|
7
|
+
# Install BBB gem version 0.0.9 or higher
|
8
|
+
# > gem install BBB
|
9
|
+
#
|
10
|
+
# Then activate the ADC using the cape
|
11
|
+
# > echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots
|
12
|
+
#
|
13
|
+
# No open up an IRB console and copy paste in this code
|
14
|
+
# > irb
|
15
|
+
#
|
16
|
+
# BE CAREFUL:
|
17
|
+
# The AIN pins only take 1.8V at max. So if you connect an output pin
|
18
|
+
# to an input pin make sure you use a voltage divider circuit. See here:
|
19
|
+
# http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/adc
|
20
|
+
#
|
21
|
+
require 'BBB'
|
22
|
+
|
23
|
+
##
|
24
|
+
# Setup the AnalogPin Circuit
|
25
|
+
#
|
26
|
+
class Circuit < BBB::Circuit
|
27
|
+
def initialize
|
28
|
+
# Attach temperature sensor to pin P9_40
|
29
|
+
attach BBB::Components::AnalogComponent, pin: :P9_40, as: :ldr
|
30
|
+
attach BBB::Components::Led, pin: :P8_10, as: :led
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Setup the actual Applicaiton
|
36
|
+
#
|
37
|
+
class LightSwitch < BBB::Application
|
38
|
+
# Run this on the BeagleBoneBlack
|
39
|
+
board BBB::Board::Base.new
|
40
|
+
|
41
|
+
# Connect the circuit to the board
|
42
|
+
circuit Circuit.new
|
43
|
+
|
44
|
+
# This is the basic run loop
|
45
|
+
def run
|
46
|
+
if ldr.read < 70
|
47
|
+
led.on!
|
48
|
+
else
|
49
|
+
led.off!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initialize the app
|
55
|
+
app = LightSwitch.new
|
56
|
+
app.start
|
data/lib/BBB/adc/analog_pin.rb
CHANGED
data/lib/BBB/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BBB
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- Rakefile
|
91
91
|
- examples/analog_pin.rb
|
92
92
|
- examples/led.rb
|
93
|
+
- examples/light_switch.rb
|
93
94
|
- examples/sketches.rb
|
94
95
|
- lib/BBB.rb
|
95
96
|
- lib/BBB/adc/analog_pin.rb
|
@@ -144,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
145
|
version: '0'
|
145
146
|
segments:
|
146
147
|
- 0
|
147
|
-
hash: -
|
148
|
+
hash: -1458336021692175408
|
148
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
150
|
none: false
|
150
151
|
requirements:
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
version: '0'
|
154
155
|
segments:
|
155
156
|
- 0
|
156
|
-
hash: -
|
157
|
+
hash: -1458336021692175408
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
160
|
rubygems_version: 1.8.25
|