hybridgroup-firmata 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/examples/blink_led.rb +10 -5
- data/examples/blink_led_socket.rb +6 -5
- data/examples/digital_read.rb +15 -5
- data/examples/digital_read_socket.rb +12 -5
- data/examples/wiichuck_read.rb +8 -10
- data/examples/wiichuck_read_socket.rb +29 -0
- data/firmata.gemspec +2 -2
- data/lib/firmata/board.rb +234 -260
- data/lib/firmata/constants.rb +80 -0
- data/lib/firmata/event.rb +1 -1
- data/lib/firmata/version.rb +1 -1
- data/lib/firmata.rb +2 -1
- data/test/board_test.rb +153 -149
- data/test/fake_serial_port.rb +49 -48
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebd228f6dc309942ec522c162d3c5554d1e1cb3e
|
4
|
+
data.tar.gz: 2aff2d08276a96077c4de6d1f51310093f1978ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c08ebeef9a04d7e9634b92b889bbeeefee10b9553e8b030a99b023f72169cb2b7a8756c27384b8c8212c3ace2f044be9463bb0489b44ebda95b97fb1ae3da8a3
|
7
|
+
data.tar.gz: 24177f3dc56e768a08fdcda9341b3228957831ba0ece27ec8067f03a2406949560bac30a25ef3daea24179dc1e589ec28e8f85ccd85aa4bdd98b844dbc43804d
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hybridgroup-firmata (0.4.
|
5
|
-
|
4
|
+
hybridgroup-firmata (0.4.3)
|
5
|
+
event_emitter
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
coderay (1.0.9)
|
11
|
-
|
11
|
+
event_emitter (0.2.5)
|
12
12
|
method_source (0.8.2)
|
13
13
|
minitest (5.0.6)
|
14
14
|
pry (0.9.12.2)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Firmata
|
2
2
|
|
3
|
-
A Ruby implementation of the [Firmata protocol](http://firmata.org/wiki/V2.
|
3
|
+
A Ruby implementation of the [Firmata protocol](http://firmata.org/wiki/V2.3ProtocolDetails).
|
4
4
|
|
5
5
|
This library is inspired by the awesome [firmata](http://jgautier.github.com/firmata/) by [jgautier](https://github.com/jgautier).
|
6
6
|
|
data/examples/blink_led.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'firmata'
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
#sp = 'COM3' # windows
|
6
|
+
#sp = '/dev/ttyACM0' #linux
|
7
|
+
sp = '/dev/tty.usbmodemfa131' #mac
|
2
8
|
|
3
|
-
sp = '/dev/ttyACM0'
|
4
9
|
board = Firmata::Board.new(sp)
|
5
10
|
|
6
11
|
board.connect
|
@@ -8,15 +13,15 @@ board.connect
|
|
8
13
|
puts "Firmware name #{board.firmware_name}"
|
9
14
|
puts "Firmata version #{board.version}"
|
10
15
|
|
11
|
-
pin_number =
|
16
|
+
pin_number = 13
|
12
17
|
rate = 0.5
|
13
18
|
|
14
19
|
10.times do
|
15
|
-
board.digital_write pin_number, Firmata::
|
20
|
+
board.digital_write pin_number, Firmata::PinLevels::HIGH
|
16
21
|
puts '+'
|
17
22
|
board.delay rate
|
18
23
|
|
19
|
-
board.digital_write pin_number, Firmata::
|
24
|
+
board.digital_write pin_number, Firmata::PinLevels::LOW
|
20
25
|
puts '-'
|
21
26
|
board.delay rate
|
22
|
-
end
|
27
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'firmata'
|
2
3
|
require 'socket'
|
3
4
|
|
4
|
-
sp = TCPSocket.
|
5
|
+
sp = TCPSocket.new 'localhost', 8023
|
5
6
|
board = Firmata::Board.new(sp)
|
6
7
|
|
7
8
|
board.connect
|
@@ -9,15 +10,15 @@ board.connect
|
|
9
10
|
puts "Firmware name #{board.firmware_name}"
|
10
11
|
puts "Firmata version #{board.version}"
|
11
12
|
|
12
|
-
pin_number =
|
13
|
+
pin_number = 13
|
13
14
|
rate = 0.5
|
14
15
|
|
15
16
|
10.times do
|
16
|
-
board.digital_write pin_number, Firmata::
|
17
|
+
board.digital_write pin_number, Firmata::PinLevels::HIGH
|
17
18
|
puts '+'
|
18
19
|
board.delay rate
|
19
20
|
|
20
|
-
board.digital_write pin_number, Firmata::
|
21
|
+
board.digital_write pin_number, Firmata::PinLevels::LOW
|
21
22
|
puts '-'
|
22
23
|
board.delay rate
|
23
|
-
end
|
24
|
+
end
|
data/examples/digital_read.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'firmata'
|
2
3
|
|
3
|
-
sp = '
|
4
|
+
#sp = 'COM3' # windows
|
5
|
+
#sp = '/dev/ttyACM0' #linux
|
6
|
+
sp = '/dev/tty.usbmodemfa131' #mac
|
7
|
+
|
4
8
|
board = Firmata::Board.new(sp)
|
5
9
|
|
6
10
|
board.connect
|
@@ -11,13 +15,19 @@ puts "Firmata version #{board.version}"
|
|
11
15
|
pin_number = 2
|
12
16
|
rate = 0.5
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
board.on :digital_read do |pin, value|
|
19
|
+
puts("#{pin}:#{value}")
|
20
|
+
end
|
21
|
+
|
22
|
+
board.on :digital_read_2 do |value|
|
23
|
+
puts "Pin 2: #{value}"
|
24
|
+
end
|
25
|
+
|
26
|
+
board.set_pin_mode(pin_number, Firmata::PinModes::INPUT)
|
17
27
|
board.toggle_pin_reporting(pin_number)
|
18
28
|
|
19
29
|
while true do
|
20
30
|
puts "waiting..."
|
21
|
-
|
31
|
+
board.read_and_process
|
22
32
|
sleep 0.5
|
23
33
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'firmata'
|
2
3
|
require 'socket'
|
3
4
|
|
4
|
-
sp = TCPSocket.
|
5
|
+
sp = TCPSocket.new 'localhost', 8023
|
5
6
|
board = Firmata::Board.new(sp)
|
6
7
|
|
7
8
|
board.connect
|
@@ -12,13 +13,19 @@ puts "Firmata version #{board.version}"
|
|
12
13
|
pin_number = 2
|
13
14
|
rate = 0.5
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
board.on :digital_read do |pin, value|
|
17
|
+
puts("#{pin}:#{value}")
|
18
|
+
end
|
19
|
+
|
20
|
+
board.on :digital_read_2 do |value|
|
21
|
+
puts "Pin 2: #{value}"
|
22
|
+
end
|
23
|
+
|
24
|
+
board.set_pin_mode(pin_number, Firmata::PinModes::INPUT)
|
18
25
|
board.toggle_pin_reporting(pin_number)
|
19
26
|
|
20
27
|
while true do
|
21
28
|
puts "waiting..."
|
22
29
|
board.read_and_process
|
23
|
-
|
30
|
+
sleep 0.5
|
24
31
|
end
|
data/examples/wiichuck_read.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'firmata'
|
2
|
-
require 'socket'
|
3
3
|
|
4
|
-
#sp =
|
5
|
-
sp =
|
4
|
+
#sp = 'COM3' # windows
|
5
|
+
#sp = '/dev/ttyACM0' #linux
|
6
|
+
sp = '/dev/tty.usbmodemfa131' #mac
|
7
|
+
|
6
8
|
board = Firmata::Board.new(sp)
|
7
9
|
|
8
10
|
board.connect
|
@@ -13,13 +15,9 @@ puts "Firmata version #{board.version}"
|
|
13
15
|
rate = 0.5
|
14
16
|
address = 0x52
|
15
17
|
|
16
|
-
|
17
|
-
puts value
|
18
|
-
|
19
|
-
# puts "data: #{n}"
|
20
|
-
#nd
|
21
|
-
}
|
22
|
-
board.on("i2c_reply", listener)
|
18
|
+
board.on :i2c_reply do |value|
|
19
|
+
puts value
|
20
|
+
end
|
23
21
|
|
24
22
|
board.i2c_config(0)
|
25
23
|
board.i2c_write_request(address, 0x40, 0x00)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'firmata'
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
sp = TCPSocket.open 'localhost', 8023
|
6
|
+
board = Firmata::Board.new(sp)
|
7
|
+
|
8
|
+
board.connect
|
9
|
+
|
10
|
+
puts "Firmware name #{board.firmware_name}"
|
11
|
+
puts "Firmata version #{board.version}"
|
12
|
+
|
13
|
+
rate = 0.5
|
14
|
+
address = 0x52
|
15
|
+
|
16
|
+
board.on :i2c_reply do |value|
|
17
|
+
puts value
|
18
|
+
end
|
19
|
+
|
20
|
+
board.i2c_config(0)
|
21
|
+
board.i2c_write_request(address, 0x40, 0x00)
|
22
|
+
|
23
|
+
n = 0
|
24
|
+
while true do
|
25
|
+
board.i2c_write_request(address, 0x00, 0x00)
|
26
|
+
board.i2c_read_request(address, 6)
|
27
|
+
board.read_and_process
|
28
|
+
sleep 0.2
|
29
|
+
end
|
data/firmata.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require File.expand_path('../lib/firmata/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["'Mike Breen', 'Adrian Zankich', 'Ron Evans', 'Isaac A. Murchie'"]
|
5
|
+
gem.authors = ["'Mike Breen', 'Adrian Zankich', 'Ron Evans', 'Isaac A. Murchie', 'Rafael Magaña'"]
|
6
6
|
gem.email = ["info@hybridgroup.com"]
|
7
7
|
gem.description = %q{A lib for working with the Firmata protocol in Ruby.}
|
8
8
|
gem.summary = %q{}
|
@@ -19,5 +19,5 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency("pry")
|
20
20
|
gem.add_development_dependency("minitest")
|
21
21
|
|
22
|
-
gem.add_runtime_dependency("
|
22
|
+
gem.add_runtime_dependency("event_emitter")
|
23
23
|
end
|