arduino_firmata 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +16 -3
- data/lib/arduino_firmata.rb +1 -1
- data/lib/arduino_firmata/main.rb +9 -2
- data/samples/block.rb +21 -0
- data/test/test_block.rb +13 -0
- metadata +5 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -11,6 +11,7 @@ lib/arduino_firmata/const.rb
|
|
11
11
|
lib/arduino_firmata/main.rb
|
12
12
|
samples/README.md
|
13
13
|
samples/analog_read_write.rb
|
14
|
+
samples/block.rb
|
14
15
|
samples/digital_read.rb
|
15
16
|
samples/led_blink.rb
|
16
17
|
samples/led_fade.rb
|
@@ -19,4 +20,5 @@ script/console
|
|
19
20
|
script/destroy
|
20
21
|
script/generate
|
21
22
|
test/test_arduino_firmata.rb
|
23
|
+
test/test_block.rb
|
22
24
|
test/test_helper.rb
|
data/README.rdoc
CHANGED
@@ -12,10 +12,9 @@ Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
|
12
12
|
|
13
13
|
== SYNOPSIS:
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
or
|
15
|
+
Setup
|
18
16
|
|
17
|
+
arduino = ArduinoFirmata.connect # use default arduino
|
19
18
|
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
|
20
19
|
|
21
20
|
|
@@ -54,6 +53,20 @@ Close
|
|
54
53
|
arduino.close
|
55
54
|
|
56
55
|
|
56
|
+
Block
|
57
|
+
|
58
|
+
ArduinoFirmata.connect do
|
59
|
+
puts "firmata version #{version}"
|
60
|
+
|
61
|
+
30.times do
|
62
|
+
an = analog_read 0
|
63
|
+
analog_write 11, an
|
64
|
+
sleep 0.01
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
57
70
|
see samples https://github.com/shokai/arduino_firmata/tree/gem/samples
|
58
71
|
|
59
72
|
== REQUIREMENTS:
|
data/lib/arduino_firmata.rb
CHANGED
data/lib/arduino_firmata/main.rb
CHANGED
@@ -4,14 +4,21 @@ module ArduinoFirmata
|
|
4
4
|
Dir.entries('/dev').grep(/tty\.?usb/i).map{|fname| "/dev/#{fname}"}
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.connect(serial_name=nil, params={})
|
7
|
+
def self.connect(serial_name=nil, params={}, &block)
|
8
8
|
serial_name = self.list[0] unless serial_name
|
9
9
|
|
10
10
|
Params.default.each do |k,v|
|
11
11
|
params[k] = v unless params[k]
|
12
12
|
end
|
13
13
|
|
14
|
-
Arduino.new serial_name, params
|
14
|
+
arduino = Arduino.new serial_name, params
|
15
|
+
|
16
|
+
unless block_given?
|
17
|
+
return arduino
|
18
|
+
else
|
19
|
+
arduino.instance_eval &block
|
20
|
+
arduino.close
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
end
|
data/samples/block.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#usr/bin/env ruby
|
2
|
+
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
3
|
+
require 'rubygems'
|
4
|
+
require 'arduino_firmata'
|
5
|
+
|
6
|
+
ArduinoFirmata.connect ARGV[0] do
|
7
|
+
puts "firmata version #{version}"
|
8
|
+
led_stat = false
|
9
|
+
|
10
|
+
5.times do
|
11
|
+
digital_write(13, led_stat = !led_stat)
|
12
|
+
puts "led : #{led_stat}"
|
13
|
+
puts "analog : #{analog_read 0}"
|
14
|
+
|
15
|
+
[(0..255).to_a, (0..255).to_a.reverse].flatten.each do |i|
|
16
|
+
analog_write(11, i)
|
17
|
+
sleep 0.01
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/test_block.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
|
3
|
+
class TestBlock < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def test_block
|
6
|
+
version_ = nil
|
7
|
+
ArduinoFirmata.connect do
|
8
|
+
version_ = version
|
9
|
+
end
|
10
|
+
assert version_ and version_ > '2.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arduino_firmata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/arduino_firmata/main.rb
|
105
105
|
- samples/README.md
|
106
106
|
- samples/analog_read_write.rb
|
107
|
+
- samples/block.rb
|
107
108
|
- samples/digital_read.rb
|
108
109
|
- samples/led_blink.rb
|
109
110
|
- samples/led_fade.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- script/destroy
|
113
114
|
- script/generate
|
114
115
|
- test/test_arduino_firmata.rb
|
116
|
+
- test/test_block.rb
|
115
117
|
- test/test_helper.rb
|
116
118
|
- .gemtest
|
117
119
|
homepage: http://github.com/shokai/arduino_firmata
|
@@ -130,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
132
|
version: '0'
|
131
133
|
segments:
|
132
134
|
- 0
|
133
|
-
hash:
|
135
|
+
hash: 3290928914737067579
|
134
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
137
|
none: false
|
136
138
|
requirements:
|
@@ -145,4 +147,5 @@ specification_version: 3
|
|
145
147
|
summary: Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
146
148
|
test_files:
|
147
149
|
- test/test_arduino_firmata.rb
|
150
|
+
- test/test_block.rb
|
148
151
|
- test/test_helper.rb
|