arduino_firmata 0.1.0 → 0.1.1

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 CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.1 2012-10-26
2
+
3
+ * ArduinoFirmata::Arduino#servo_write(pin, angle)
4
+
1
5
  === 0.1.0 2012-10-25
2
6
 
3
7
  * fix samples link
data/Manifest.txt CHANGED
@@ -17,6 +17,7 @@ samples/digital_read.rb
17
17
  samples/led_blink.rb
18
18
  samples/led_fade.rb
19
19
  samples/on_changed.rb
20
+ samples/servo.rb
20
21
  samples/sinatra_arduino.rb
21
22
  samples/tweet_temperature.rb
22
23
  script/console
data/README.rdoc CHANGED
@@ -52,6 +52,15 @@ Analog Read
52
52
  end
53
53
 
54
54
 
55
+ Servo
56
+
57
+ loop do
58
+ angle = rand(180)
59
+ arduino.servo_write 11, angle
60
+ sleep 1
61
+ end
62
+
63
+
55
64
  Close
56
65
 
57
66
  arduino.close
@@ -9,5 +9,5 @@ require 'arduino_firmata/arduino'
9
9
  require 'arduino_firmata/event'
10
10
 
11
11
  module ArduinoFirmata
12
- VERSION = '0.1.0'
12
+ VERSION = '0.1.1'
13
13
  end
@@ -86,6 +86,13 @@ module ArduinoFirmata
86
86
  write(value >> 7)
87
87
  end
88
88
 
89
+ def servo_write(pin, angle)
90
+ pin_mode pin, SERVO
91
+ write(ANALOG_MESSAGE | (pin & 0x0F))
92
+ write(angle & 0x7F)
93
+ write(angle >> 7)
94
+ end
95
+
89
96
  private
90
97
  def write(cmd)
91
98
  @serial.write_nonblock cmd.chr
data/samples/README.md CHANGED
@@ -7,6 +7,7 @@ Digital/Analog IO
7
7
  - led_blink.rb
8
8
  - led_fade.rb
9
9
  - on_changed.rb
10
+ - servo.rb
10
11
 
11
12
 
12
13
  Tweet Temperature
data/samples/servo.rb ADDED
@@ -0,0 +1,13 @@
1
+ #usr/bin/env ruby
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+ require 'rubygems'
4
+ require 'arduino_firmata'
5
+
6
+ arduino = ArduinoFirmata.connect ARGV.shift
7
+
8
+ loop do
9
+ angle = rand 180
10
+ puts angle
11
+ arduino.servo_write 11, angle
12
+ sleep 1
13
+ end
@@ -13,11 +13,11 @@ end
13
13
  get '/on' do
14
14
  analog = arduino.analog_read(0)
15
15
  arduino.digital_write 13, ArduinoFirmata::HIGH
16
- "<p>analog : #{analog}</p><p><a href='./off'>off</a></p>"
16
+ "<p>analog : #{analog}</p><p><a href='./off'>LED OFF</a></p>"
17
17
  end
18
18
 
19
19
  get '/off' do
20
20
  analog = arduino.analog_read(0)
21
21
  arduino.digital_write 13, ArduinoFirmata::LOW
22
- "<p>analog : #{analog}</p><p><a href='./on'>on</a></p>"
22
+ "<p>analog : #{analog}</p><p><a href='./on'>LED ON</a></p>"
23
23
  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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: serialport
@@ -110,6 +110,7 @@ files:
110
110
  - samples/led_blink.rb
111
111
  - samples/led_fade.rb
112
112
  - samples/on_changed.rb
113
+ - samples/servo.rb
113
114
  - samples/sinatra_arduino.rb
114
115
  - samples/tweet_temperature.rb
115
116
  - script/console
@@ -135,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
136
  version: '0'
136
137
  segments:
137
138
  - 0
138
- hash: -1560937414651371914
139
+ hash: -1305837009193017010
139
140
  required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  none: false
141
142
  requirements: