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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17dc3e201378fa154ef0af296464a1db5ac20087
4
- data.tar.gz: 5798ab035257df5d3d2824a56e0079eb2f42fcf3
3
+ metadata.gz: 321eae0c58f33d2740bd19825f4d936c3fab7480
4
+ data.tar.gz: 4aedb0faad9bb50ef3c565928e96f7df56633065
5
5
  SHA512:
6
- metadata.gz: bb4527e0a44a9770c79de5cd30eef13d21075f59b5cd8069365262ffdd332efdfa50410cca1ce7f0818841be84dd8ccc7dae62185d23f6e15a8d00fa8177ec19
7
- data.tar.gz: 0e35730b59afac125beef3afc431e534d30e878290fd10afd2701a3602ad6d270c2d8e04c1d25232933f34093020348e50f7a34b526b09375824ca12608a14c6
6
+ metadata.gz: e54da4157fdd84f58f14fed003c67928b529d39d13c6cda279d0b18cb2480e4bf4aed757b75e18eaba16278eeb35fbb4987c0fb0c6a2da745f3d4b2c185c25e7
7
+ data.tar.gz: 0e707684dbbe2093263abd9122dbe3b2e0c200d315f2bd2b6e004ac772a9d505ad3f4b89c0448893cb562f1713b3bded5c0e7cbdae1dc0d8fb64350218e6186f
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.3.0 2013-06-16
2
+
3
+ * fix on :digital_read and :analog_read events
4
+
1
5
  === 0.2.9 2013-06-14
2
6
 
3
7
  * modify initialize process to share an arduino between multiple ruby processes
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
- * Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
5
- * http://shokai.github.com/arduino_firmata
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
- digital_inputs = @digital_input_data.clone
213
- @digital_input_data[@multi_byte_channel] = (@stored_input_data[0] << 7) + @stored_input_data[1]
214
- 0.upto(15).each do |i|
215
- current = digital_read i
216
- if current != ((digital_inputs[i >> 3] >> (i & 0x07)) & 0x01 > 0)
217
- emit :digital_read, i, current
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
- unless @analog_input_data[@multi_byte_channel] == analog_value
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
@@ -1,3 +1,3 @@
1
1
  module ArduinoFirmata
2
- VERSION = '0.2.9'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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
- if pin == 2
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.2.9
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-14 00:00:00.000000000 Z
11
+ date: 2013-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serialport