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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8df41a6eb45e2f5a66737b460b071cb1c66cad8c
4
- data.tar.gz: bf350aefd94fd49b8777aae8a8974c0352dee48e
3
+ metadata.gz: ebd228f6dc309942ec522c162d3c5554d1e1cb3e
4
+ data.tar.gz: 2aff2d08276a96077c4de6d1f51310093f1978ce
5
5
  SHA512:
6
- metadata.gz: a7398b7bde99983a239b7346e533dc9c180ab62abafa6f9c380b2145223a8a05033ed29a3e7c59acf3c40f35472d8fe53e16b9c8c1da08e3da6bb45f26438e4f
7
- data.tar.gz: e8ee53a07f9d14155be744449b11e2d7a8984455fd62ecf93ae4334d84b8ad2403ad0472666c9cb79b4c360dc5a1be539ca1046fa32fe2dd6fb029317fb6b5f4
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.2)
5
- event_spitter
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
- event_spitter (0.5.0)
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.2ProtocolDetails).
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
 
@@ -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 = 3
16
+ pin_number = 13
12
17
  rate = 0.5
13
18
 
14
19
  10.times do
15
- board.digital_write pin_number, Firmata::Board::HIGH
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::Board::LOW
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.open 'localhost', 4567
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 = 3
13
+ pin_number = 13
13
14
  rate = 0.5
14
15
 
15
16
  10.times do
16
- board.digital_write pin_number, Firmata::Board::HIGH
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::Board::LOW
21
+ board.digital_write pin_number, Firmata::PinLevels::LOW
21
22
  puts '-'
22
23
  board.delay rate
23
- end
24
+ end
@@ -1,6 +1,10 @@
1
+ require 'bundler/setup'
1
2
  require 'firmata'
2
3
 
3
- sp = '/dev/ttyACM0'
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
- listener = ->(pin, value) { puts("#{pin}:#{value}") }
15
- board.on('digital-read', listener)
16
- board.set_pin_mode(pin_number, Firmata::Board::INPUT)
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
- board.read_and_process
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.open 'localhost', 4567
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
- listener = ->(pin, value) { puts("#{pin}:#{value}") }
16
- board.on('digital-read', listener)
17
- board.set_pin_mode(pin_number, Firmata::Board::INPUT)
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
- sleep 0.5
30
+ sleep 0.5
24
31
  end
@@ -1,8 +1,10 @@
1
+ require 'bundler/setup'
1
2
  require 'firmata'
2
- require 'socket'
3
3
 
4
- #sp = TCPSocket.open 'localhost', 4567
5
- sp = "/dev/ttyACM0"
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
- listener = ->(value) {
17
- puts value
18
- #value[:data].each do |n|
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("event_spitter")
22
+ gem.add_runtime_dependency("event_emitter")
23
23
  end