arduino_mega 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. data/lib/arduino_mega.rb +15 -7
  2. metadata +2 -2
data/lib/arduino_mega.rb CHANGED
@@ -157,22 +157,30 @@ end
157
157
 
158
158
  class ArduinoMega < Arduino
159
159
 
160
- attr_accessor :p13h
160
+ @@pins = (6..13).to_a
161
+ attr_accessor *@@pins.map{|x| "p#{x}h".to_sym }
162
+
161
163
 
162
164
  def initialize(args=[])
163
165
  super(*args)
164
- output(13) # declare output pins
166
+
167
+ methods = @@pins.map do |x|
168
+ "def p#{x}h=(bflag)" + \
169
+ " @p#{x}h = bflag\n" + \
170
+ " send (bflag == true ? :set_high : :set_low), #{x}\n" + \
171
+ "end"
172
+ end
173
+ self.instance_eval methods.join("\n")
174
+
175
+ #output(*[13,12,11,10,9,8,7,6]) # declare output pins
176
+ output(*@@pins) # declare output pins
177
+
165
178
  if block_given? then
166
179
  yield(self)
167
180
  close()
168
181
  end
169
182
  end
170
183
 
171
- def p13h=(bflag)
172
- @p13h = bflag
173
- send (bflag == true ? :set_high : :set_low), 13
174
- end
175
-
176
184
  def to_s()
177
185
  end
178
186
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: arduino_mega
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-24 00:00:00 +01:00
13
+ date: 2012-04-26 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency