artoo-arduino 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -17
- data/README.md +8 -63
- data/artoo-arduino.gemspec +4 -3
- data/examples/analog_sensor.rb +31 -0
- data/examples/{firmata_blink_led.rb → blink_led.rb} +1 -1
- data/examples/{firmata_blink_led_with_toggle.rb → blink_led_with_toggle.rb} +1 -1
- data/examples/{firmata_button_and_led.rb → button_and_led.rb} +0 -0
- data/examples/{firmata_dc_motor_speed.rb → dc_motor_speed.rb} +1 -1
- data/examples/{firmata_dc_motor_speed_h-bridge_2_pins.rb → dc_motor_speed_h-bridge_2_pins.rb} +1 -1
- data/examples/{firmata_dc_motor_switch.rb → dc_motor_switch.rb} +1 -1
- data/examples/{firmata_dc_motor_switch_h-bridge_2_pins.rb → dc_motor_switch_h-bridge_2_pins.rb} +1 -1
- data/examples/{firmata_led_brightness.rb → led_brightness.rb} +1 -1
- data/examples/led_brightness_with_analog_input.rb +29 -0
- data/examples/{firmata_led_with_button_toggle.rb → led_with_button_toggle.rb} +1 -1
- data/examples/{firmata_maxbotix.rb → maxbotix.rb} +2 -2
- data/examples/{firmata_motor.rb → motor.rb} +1 -1
- data/examples/motor_speed_with_analog_input.rb +30 -0
- data/examples/{firmata_servo.rb → servo.rb} +1 -1
- data/examples/{firmata_wiichuck.rb → wiichuck.rb} +0 -0
- data/lib/artoo-arduino/version.rb +1 -1
- data/lib/artoo/adaptors/firmata.rb +51 -9
- data/test/adaptors/firmata_test.rb +30 -0
- metadata +43 -48
- data/examples/littlewire_blink_led_with_toggle.rb +0 -17
- data/examples/littlewire_button_and_led.rb +0 -16
- data/examples/littlewire_dc_motor_speed.rb +0 -31
- data/examples/littlewire_maxbotix.rb +0 -19
- data/lib/artoo/adaptors/littlewire.rb +0 -63
- data/lib/artoo/drivers/board.rb +0 -10
- data/lib/artoo/drivers/button.rb +0 -43
- data/lib/artoo/drivers/led.rb +0 -59
- data/lib/artoo/drivers/maxbotix.rb +0 -44
- data/lib/artoo/drivers/motor.rb +0 -167
- data/lib/artoo/drivers/servo.rb +0 -49
- data/lib/artoo/drivers/wiichuck.rb +0 -61
- data/lib/artoo/drivers/wiiclassic.rb +0 -139
- data/lib/artoo/drivers/wiidriver.rb +0 -103
- data/test/adaptors/littlewire_test.rb +0 -25
- data/test/drivers/firmata_board_test.rb +0 -21
- data/test/drivers/led_test.rb +0 -92
- data/test/drivers/maxbotix_test.rb +0 -25
- data/test/drivers/motor_test.rb +0 -204
- data/test/drivers/servo_test.rb +0 -43
- data/test/drivers/wiichuck_test.rb +0 -11
- data/test/drivers/wiiclassic_test.rb +0 -11
- data/test/drivers/wiidriver_test.rb +0 -54
@@ -22,4 +22,34 @@ describe Artoo::Adaptors::Firmata do
|
|
22
22
|
|
23
23
|
@adaptor.connected?.must_equal false
|
24
24
|
end
|
25
|
+
|
26
|
+
describe "device info interface" do
|
27
|
+
it "#firmware_name"
|
28
|
+
it "#version"
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "digital GPIO interface" do
|
32
|
+
it "#digital_read"
|
33
|
+
it "#digital_write"
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "analog GPIO interface" do
|
37
|
+
it "#analog_read"
|
38
|
+
it "#analog_write"
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "PWM GPIO interface" do
|
42
|
+
it "#pwm_write"
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "servo GPIO interface" do
|
46
|
+
it "#servo_write"
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "i2c interface" do
|
50
|
+
it "#i2c_start"
|
51
|
+
it "#i2c_end"
|
52
|
+
it "#i2c_read"
|
53
|
+
it "#i2c_write"
|
54
|
+
end
|
25
55
|
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artoo-arduino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ron Evans
|
8
8
|
- Adrian Zankich
|
9
9
|
- Rafael Magaña
|
10
|
+
- Edgar Silva
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2013-09-
|
14
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: artoo
|
@@ -18,42 +19,56 @@ dependencies:
|
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
22
|
+
version: 1.2.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
29
|
+
version: 1.2.0
|
29
30
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
31
|
+
name: artoo-gpio
|
31
32
|
requirement: !ruby/object:Gem::Requirement
|
32
33
|
requirements:
|
33
|
-
- -
|
34
|
+
- - '>='
|
34
35
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0
|
36
|
+
version: '0'
|
36
37
|
type: :runtime
|
37
38
|
prerelease: false
|
38
39
|
version_requirements: !ruby/object:Gem::Requirement
|
39
40
|
requirements:
|
40
|
-
- -
|
41
|
+
- - '>='
|
41
42
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0
|
43
|
+
version: '0'
|
43
44
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
45
|
+
name: artoo-i2c
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: hybridgroup-firmata
|
45
60
|
requirement: !ruby/object:Gem::Requirement
|
46
61
|
requirements:
|
47
62
|
- - ~>
|
48
63
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
64
|
+
version: 0.4.5
|
50
65
|
type: :runtime
|
51
66
|
prerelease: false
|
52
67
|
version_requirements: !ruby/object:Gem::Requirement
|
53
68
|
requirements:
|
54
69
|
- - ~>
|
55
70
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
71
|
+
version: 0.4.5
|
57
72
|
- !ruby/object:Gem::Dependency
|
58
73
|
name: minitest
|
59
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,46 +127,26 @@ files:
|
|
112
127
|
- README.md
|
113
128
|
- Rakefile
|
114
129
|
- artoo-arduino.gemspec
|
115
|
-
- examples/
|
116
|
-
- examples/
|
117
|
-
- examples/
|
118
|
-
- examples/
|
119
|
-
- examples/
|
120
|
-
- examples/
|
121
|
-
- examples/
|
122
|
-
- examples/
|
123
|
-
- examples/
|
124
|
-
- examples/
|
125
|
-
- examples/
|
126
|
-
- examples/
|
127
|
-
- examples/
|
128
|
-
- examples/
|
129
|
-
- examples/
|
130
|
-
- examples/
|
131
|
-
- examples/littlewire_maxbotix.rb
|
130
|
+
- examples/analog_sensor.rb
|
131
|
+
- examples/blink_led.rb
|
132
|
+
- examples/blink_led_with_toggle.rb
|
133
|
+
- examples/button_and_led.rb
|
134
|
+
- examples/dc_motor_speed.rb
|
135
|
+
- examples/dc_motor_speed_h-bridge_2_pins.rb
|
136
|
+
- examples/dc_motor_switch.rb
|
137
|
+
- examples/dc_motor_switch_h-bridge_2_pins.rb
|
138
|
+
- examples/led_brightness.rb
|
139
|
+
- examples/led_brightness_with_analog_input.rb
|
140
|
+
- examples/led_with_button_toggle.rb
|
141
|
+
- examples/maxbotix.rb
|
142
|
+
- examples/motor.rb
|
143
|
+
- examples/motor_speed_with_analog_input.rb
|
144
|
+
- examples/servo.rb
|
145
|
+
- examples/wiichuck.rb
|
132
146
|
- lib/artoo-arduino.rb
|
133
147
|
- lib/artoo-arduino/version.rb
|
134
148
|
- lib/artoo/adaptors/firmata.rb
|
135
|
-
- lib/artoo/adaptors/littlewire.rb
|
136
|
-
- lib/artoo/drivers/board.rb
|
137
|
-
- lib/artoo/drivers/button.rb
|
138
|
-
- lib/artoo/drivers/led.rb
|
139
|
-
- lib/artoo/drivers/maxbotix.rb
|
140
|
-
- lib/artoo/drivers/motor.rb
|
141
|
-
- lib/artoo/drivers/servo.rb
|
142
|
-
- lib/artoo/drivers/wiichuck.rb
|
143
|
-
- lib/artoo/drivers/wiiclassic.rb
|
144
|
-
- lib/artoo/drivers/wiidriver.rb
|
145
149
|
- test/adaptors/firmata_test.rb
|
146
|
-
- test/adaptors/littlewire_test.rb
|
147
|
-
- test/drivers/firmata_board_test.rb
|
148
|
-
- test/drivers/led_test.rb
|
149
|
-
- test/drivers/maxbotix_test.rb
|
150
|
-
- test/drivers/motor_test.rb
|
151
|
-
- test/drivers/servo_test.rb
|
152
|
-
- test/drivers/wiichuck_test.rb
|
153
|
-
- test/drivers/wiiclassic_test.rb
|
154
|
-
- test/drivers/wiidriver_test.rb
|
155
150
|
- test/test_helper.rb
|
156
151
|
homepage: https://github.com/hybridgroup/artoo-arduino
|
157
152
|
licenses:
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'artoo'
|
2
|
-
|
3
|
-
# Uses Digispark USB board (http://digistump.com/products/1)
|
4
|
-
# with Little Wire protocol (http://littlewire.cc)
|
5
|
-
|
6
|
-
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
|
7
|
-
device :board, :driver => :board
|
8
|
-
device :led, :driver => :led, :pin => 1
|
9
|
-
|
10
|
-
work do
|
11
|
-
puts "Firmware name: #{board.firmware_name}"
|
12
|
-
puts "Firmware version: #{board.version}"
|
13
|
-
|
14
|
-
every 1.second do
|
15
|
-
led.toggle
|
16
|
-
end
|
17
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'artoo'
|
2
|
-
|
3
|
-
# Circuit and schematic here: http://arduino.cc/en/tutorial/button
|
4
|
-
|
5
|
-
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
|
6
|
-
device :board, :driver => :board
|
7
|
-
device :led, :driver => :led, :pin => 1
|
8
|
-
device :button, :driver => :button, :pin => 0, :interval => 0.01
|
9
|
-
|
10
|
-
work do
|
11
|
-
puts "Firmware name: #{board.firmware_name}"
|
12
|
-
puts "Firmware version: #{board.version}"
|
13
|
-
puts "Press the button connected on pin #{button.pin}..."
|
14
|
-
|
15
|
-
on button, :push => proc { led.toggle }
|
16
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'artoo'
|
2
|
-
|
3
|
-
#Circuit's breadboard layout here: http://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/breadboard-layout
|
4
|
-
|
5
|
-
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
|
6
|
-
device :board, :driver => :board
|
7
|
-
device :motor, :driver => :motor, :speed_pin => 1 # Use a PWM pin
|
8
|
-
|
9
|
-
work do
|
10
|
-
puts "Firmware name: #{board.firmware_name}"
|
11
|
-
puts "Firmata version: #{board.version}"
|
12
|
-
puts "Stopping motor..."
|
13
|
-
motor.min # same as 'motor.stop' or 'motor.speed(0)'
|
14
|
-
sleep 3
|
15
|
-
puts "Setting to maximum speed..."
|
16
|
-
motor.max # same as 'motor.start'
|
17
|
-
sleep 3
|
18
|
-
|
19
|
-
speed = 0
|
20
|
-
step = 50
|
21
|
-
|
22
|
-
every 3.seconds do
|
23
|
-
motor.speed(speed)
|
24
|
-
puts "Current speed: #{motor.current_speed}"
|
25
|
-
speed += step
|
26
|
-
if [0, 250].include?(speed)
|
27
|
-
step = -step
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'artoo'
|
2
|
-
|
3
|
-
# Circuit and schematic here: http://www.electrojoystick.com/tutorial/?page_id=285
|
4
|
-
|
5
|
-
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
|
6
|
-
device :sonar, :driver => :maxbotix, :pin => 0, :interval => 0.5
|
7
|
-
device :board, :driver => :board
|
8
|
-
|
9
|
-
work do
|
10
|
-
on sonar, :range => :sonar_reading
|
11
|
-
|
12
|
-
puts "Firmware name: #{board.firmware_name}"
|
13
|
-
puts "Firmata version: #{board.version}"
|
14
|
-
puts "starting sonar..."
|
15
|
-
end
|
16
|
-
|
17
|
-
def sonar_reading(*args)
|
18
|
-
puts args[1] * 1000
|
19
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'artoo/adaptors/adaptor'
|
2
|
-
|
3
|
-
module Artoo
|
4
|
-
module Adaptors
|
5
|
-
# Connect to Digispark or Littlewire device using Little Wire protocol
|
6
|
-
# @see http://littlewire.cc/
|
7
|
-
class Littlewire < Adaptor
|
8
|
-
attr_reader :littlewire, :vendor, :product, :usb
|
9
|
-
|
10
|
-
def initialize(params={})
|
11
|
-
super
|
12
|
-
|
13
|
-
params[:additional_params] ||= {}
|
14
|
-
@vendor = params[:additional_params][:vendor] || 0x1781
|
15
|
-
@product = params[:additional_params][:product] || 0x0c9f
|
16
|
-
end
|
17
|
-
|
18
|
-
# Creates connection with littlewire board
|
19
|
-
# @return [Boolean]
|
20
|
-
def connect
|
21
|
-
require 'littlewire' unless defined?(::LittleWire)
|
22
|
-
@littlewire = ::LittleWire.new(connect_to_usb)
|
23
|
-
super
|
24
|
-
return true
|
25
|
-
end
|
26
|
-
|
27
|
-
# Closes connection with littlewire board
|
28
|
-
# @return [Boolean]
|
29
|
-
def disconnect
|
30
|
-
littlewire.finished
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns firmware name of littlewire board
|
35
|
-
# @return [String]
|
36
|
-
def firmware_name
|
37
|
-
"Little Wire"
|
38
|
-
end
|
39
|
-
|
40
|
-
def digital_read(pin)
|
41
|
-
littlewire.digital_write(pin, true)
|
42
|
-
littlewire.digital_read(pin)
|
43
|
-
end
|
44
|
-
|
45
|
-
def pwm_write(pin, level)
|
46
|
-
littlewire.software_pwm_write(pin, level)
|
47
|
-
end
|
48
|
-
|
49
|
-
def connect_to_usb
|
50
|
-
@usb = LIBUSB::Context.new.devices(
|
51
|
-
:idVendor => vendor,
|
52
|
-
:idProduct => product
|
53
|
-
).first
|
54
|
-
end
|
55
|
-
|
56
|
-
# Uses method missing to call Littlewire methods
|
57
|
-
# @see https://github.com/Bluebie/littlewire.rb
|
58
|
-
def method_missing(method_name, *arguments, &block)
|
59
|
-
littlewire.send(method_name, *arguments, &block)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/artoo/drivers/board.rb
DELETED
data/lib/artoo/drivers/button.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'artoo/drivers/driver'
|
2
|
-
|
3
|
-
module Artoo
|
4
|
-
module Drivers
|
5
|
-
# Button driver behaviors
|
6
|
-
class Button < Driver
|
7
|
-
COMMANDS = [:is_pressed?].freeze
|
8
|
-
|
9
|
-
DOWN = 1
|
10
|
-
UP = 0
|
11
|
-
|
12
|
-
# @return [Boolean] True if pressed
|
13
|
-
def is_pressed?
|
14
|
-
(@pressed_val == 1) ? true : false
|
15
|
-
end
|
16
|
-
|
17
|
-
def start_driver
|
18
|
-
@pressed_val = 0
|
19
|
-
|
20
|
-
every(interval) do
|
21
|
-
new_value = connection.digital_read(pin)
|
22
|
-
update(new_value) if !new_value.nil? && new_value != is_pressed?
|
23
|
-
end
|
24
|
-
|
25
|
-
super
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
# Publishes events according to the button feedback
|
30
|
-
def update(new_val)
|
31
|
-
if new_val == 1
|
32
|
-
@pressed_val = 1
|
33
|
-
publish(event_topic_name("update"), "push", new_val)
|
34
|
-
publish(event_topic_name("push"), new_val)
|
35
|
-
else
|
36
|
-
@pressed_val = 0
|
37
|
-
publish(event_topic_name("update"), "release", new_val)
|
38
|
-
publish(event_topic_name("release"), new_val)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/artoo/drivers/led.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'artoo/drivers/driver'
|
2
|
-
|
3
|
-
module Artoo
|
4
|
-
module Drivers
|
5
|
-
# The LED driver behaviors
|
6
|
-
class Led < Driver
|
7
|
-
|
8
|
-
COMMANDS = [:on, :off, :toggle,
|
9
|
-
:brightness,
|
10
|
-
:on?, :off?].freeze
|
11
|
-
|
12
|
-
def initialize(params = {})
|
13
|
-
@is_on = false
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
# @return [Boolean] True if on
|
18
|
-
def on?
|
19
|
-
@is_on
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [Boolean] True if off
|
23
|
-
def off?
|
24
|
-
(not on?)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Sets led to level HIGH
|
28
|
-
def on
|
29
|
-
change_state(pin, :high)
|
30
|
-
@is_on = true
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
# Sets led to level LOW
|
35
|
-
def off
|
36
|
-
change_state(pin, :low)
|
37
|
-
@is_on = false
|
38
|
-
true
|
39
|
-
end
|
40
|
-
|
41
|
-
# Toggle status
|
42
|
-
# @example on > off, off > on
|
43
|
-
def toggle
|
44
|
-
on? ? off : on
|
45
|
-
end
|
46
|
-
|
47
|
-
# Change brightness level
|
48
|
-
# @param [Integer] level
|
49
|
-
def brightness(level=0)
|
50
|
-
connection.pwm_write(pin, level)
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
def change_state(pin, level)
|
55
|
-
connection.digital_write(pin, level)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|