arduino_firmata 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/README.md +7 -2
- data/lib/arduino_firmata/arduino.rb +8 -10
- data/lib/arduino_firmata/version.rb +1 -1
- data/samples/on_digital_read.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 321eae0c58f33d2740bd19825f4d936c3fab7480
|
4
|
+
data.tar.gz: 4aedb0faad9bb50ef3c565928e96f7df56633065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54da4157fdd84f58f14fed003c67928b529d39d13c6cda279d0b18cb2480e4bf4aed757b75e18eaba16278eeb35fbb4987c0fb0c6a2da745f3d4b2c185c25e7
|
7
|
+
data.tar.gz: 0e707684dbbe2093263abd9122dbe3b2e0c200d315f2bd2b6e004ac772a9d505ad3f4b89c0448893cb562f1713b3bded5c0e7cbdae1dc0d8fb64350218e6186f
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
arduino_firmata
|
2
2
|
===============
|
3
|
+
Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
3
4
|
|
4
|
-
*
|
5
|
-
*
|
5
|
+
* Firmata is a protocol to controll Arduino from software on PC.
|
6
|
+
* You can embed Arduino code into Ruby application.
|
7
|
+
* Support sharing an Arduino between multiple processes.
|
8
|
+
* http://shokai.github.io/arduino_firmata
|
6
9
|
|
7
10
|
|
8
11
|
Install
|
@@ -73,6 +76,7 @@ Digital Read
|
|
73
76
|
arduino.pin_mode 7, ArduinoFirmata::INPUT
|
74
77
|
puts arduino.digital_read 7 # => true/false
|
75
78
|
|
79
|
+
## regist event
|
76
80
|
arduino.on :digital_read do |pin, status|
|
77
81
|
if pin == 7
|
78
82
|
puts "digital pin #{pin} changed : #{status}"
|
@@ -92,6 +96,7 @@ Analog Read
|
|
92
96
|
```ruby
|
93
97
|
puts arduino.analog_read 0 # => 0 ~ 1023
|
94
98
|
|
99
|
+
## regist event
|
95
100
|
arduino.on :analog_read do |pin, value|
|
96
101
|
if pin == 0
|
97
102
|
puts "analog pin #{pin} changed : #{value}"
|
@@ -209,20 +209,18 @@ module ArduinoFirmata
|
|
209
209
|
if @execute_multi_byte_command != 0 and @wait_for_data == 0
|
210
210
|
case @execute_multi_byte_command
|
211
211
|
when DIGITAL_MESSAGE
|
212
|
-
|
213
|
-
@digital_input_data[@multi_byte_channel]
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
end
|
212
|
+
input_data = (@stored_input_data[0] << 7) + @stored_input_data[1]
|
213
|
+
diff = @digital_input_data[@multi_byte_channel] ^ input_data
|
214
|
+
@digital_input_data[@multi_byte_channel] = input_data
|
215
|
+
0.upto(13).each do |i|
|
216
|
+
next unless (0x01 << i) & diff > 0
|
217
|
+
emit :digital_read, i, (input_data & diff > 0)
|
219
218
|
end
|
220
219
|
when ANALOG_MESSAGE
|
221
220
|
analog_value = (@stored_input_data[0] << 7) + @stored_input_data[1]
|
222
|
-
|
223
|
-
emit :analog_read, @multi_byte_channel, analog_value
|
224
|
-
end
|
221
|
+
old = analog_read(@multi_byte_channel)
|
225
222
|
@analog_input_data[@multi_byte_channel] = analog_value
|
223
|
+
emit :analog_read, @multi_byte_channel, analog_value if old != analog_value
|
226
224
|
when REPORT_VERSION
|
227
225
|
@version = "#{@stored_input_data[1]}.#{@stored_input_data[0]}"
|
228
226
|
end
|
data/samples/on_digital_read.rb
CHANGED
@@ -7,9 +7,7 @@ arduino = ArduinoFirmata.connect ARGV.shift
|
|
7
7
|
arduino.pin_mode 2, ArduinoFirmata::INPUT
|
8
8
|
|
9
9
|
arduino.on :digital_read do |pin, status|
|
10
|
-
|
11
|
-
puts "digital pin #{pin} changed : #{status}"
|
12
|
-
end
|
10
|
+
puts "digital pin #{pin} changed : #{status}"
|
13
11
|
end
|
14
12
|
|
15
13
|
led_stat = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arduino_firmata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serialport
|