madrona-rad 0.3.7 → 0.3.8

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.
@@ -1,60 +1,49 @@
1
1
  class DebounceMethods < ArduinoSketch
2
-
3
- # IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
4
- # the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
5
- output_pin 13, :as => :led
6
-
7
- def loop
8
- blink led, 100
9
- x = 4
10
- end
11
-
12
- ##
13
-
14
- # output_pin 13, :as => :led
15
- # input_pin 6, :as => :button_one, :device => :button # can also :adjust => 300
16
- # input_pin 7, :as => :button_two, :device => :button
17
- # input_pin 8, :as => :button_three, :device => :button
18
- # input_pin 9, :as => :button_four, :device => :button
19
- # input_pin 10, :as => :button_five, :device => :button
2
+
3
+ output_pin 13, :as => :led
4
+ input_pin 6, :as => :button_one, :device => :button # can also :adjust => 300
5
+ input_pin 7, :as => :button_two, :device => :button
6
+ input_pin 8, :as => :button_three, :device => :button
7
+ input_pin 9, :as => :button_four, :device => :button
8
+ input_pin 10, :as => :button_five, :device => :button
20
9
  #
21
10
  # # depressing and releasing button_one, button_two or button_four do the same thing
22
11
  # # with a slightly different syntax and number of blinks
23
12
  # # button_three simply toggles the led with the read_and_toggle method
24
13
  # # button_five does it with a twist
25
- #
26
- # def loop
27
- # blink_twice if read_input button_one
28
- # blink_three_times if read_input button_two
29
- # button_three.read_and_toggle led #
30
- # blink_three_times_basic if read_input button_four
31
- # blink_with_a_twist if read_input button_five
32
- # end
33
- #
34
- # def blink_twice
35
- # 2.times do |i|
36
- # led.blink 200 + i
37
- # end
38
- # end
39
- #
40
- # def blink_three_times
41
- # 3.times { led.blink 200 }
42
- # end
43
- #
44
- # # no blink helper
45
- # def blink_three_times_basic
46
- # 4.times do
47
- # led.digitalWrite HIGH
48
- # delay 200
49
- # led.digitalWrite LOW
50
- # delay 200
51
- # end
52
- # end
53
- #
54
- # def blink_with_a_twist
55
- # 20.times do |i|
56
- # led.blink i * 10
57
- # end
58
- # end
14
+
15
+ def loop
16
+ blink_twice if read_input button_one
17
+ blink_three_times if read_input button_two
18
+ button_three.read_and_toggle led #
19
+ blink_three_times_basic if read_input button_four
20
+ blink_with_a_twist if read_input button_five
21
+ end
22
+
23
+ def blink_twice
24
+ 2.times do |i|
25
+ led.blink 200 + i
26
+ end
27
+ end
28
+
29
+ def blink_three_times
30
+ 3.times { led.blink 200 }
31
+ end
32
+
33
+ # no blink helper
34
+ def blink_three_times_basic
35
+ 4.times do
36
+ led.on
37
+ delay 200
38
+ led.off
39
+ delay 200
40
+ end
41
+ end
42
+
43
+ def blink_with_a_twist
44
+ 20.times do |i|
45
+ led.blink i * 10
46
+ end
47
+ end
59
48
 
60
49
  end
@@ -1,62 +1,52 @@
1
1
  class HelloEeprom < ArduinoSketch
2
2
 
3
- # IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
4
- # the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
5
- output_pin 13, :as => :led
6
-
3
+ output_pin 19, :as => :rtc, :device => :i2c_ds1307, :enable => :true
4
+ output_pin 19, :as => :mem0, :device => :i2c_eeprom
5
+
6
+ output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200
7
+
7
8
  def loop
8
- blink led, 100
9
- x = 4
10
- end
9
+ myLCD.setxy 0,0 # set to 0,0
10
+ myLCD.print rtc.get(5, 1) # refresh registers (=1) get month
11
+ myLCD.print "/"
12
+ myLCD.print rtc.get(4, 0) # no need to refresh (=0) get day
13
+ myLCD.print "/"
14
+ myLCD.print rtc.get(6, 0) # get year
15
+ myLCD.setxy(0,1) # set in 1 byte line 1 (second line)
16
+ printlz 2 # print hours with lead zero
17
+ myLCD.print ":"
18
+ printlz 1 # print minutes with lead zero
19
+ myLCD.print ":"
20
+ printlz 0 # print seconds with lead zero
21
+
22
+
23
+ myLCD.setxy 10,0
24
+ myLCD.print "write test"
25
+ myLCD.setxy 0,2
26
+ 32.upto(109) do # write address of byte to that b yte
27
+ |x| mem0.write_byte x, x
28
+ myLCD.print(".") if x%2
29
+ delay 10
30
+ end
11
31
 
12
- ##
32
+ delay 2000
33
+
34
+ myLCD.clearline 2 # clears bottom two lines
35
+ myLCD.clearline 3
13
36
 
14
- # output_pin 19, :as => :rtc, :device => :i2c_ds1307, :enable => :true
15
- # output_pin 19, :as => :mem0, :device => :i2c_eeprom
16
- #
17
- # output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200
18
- #
19
- # def loop
20
- # myLCD.setxy 0,0 # set to 0,0
21
- # myLCD.print rtc.get(5, 1) # refresh registers (=1) get month
22
- # myLCD.print "/"
23
- # myLCD.print rtc.get(4, 0) # no need to refresh (=0) get day
24
- # myLCD.print "/"
25
- # myLCD.print rtc.get(6, 0) # get year
26
- # myLCD.setxy(0,1) # set in 1 byte line 1 (second line)
27
- # printlz 2 # print hours with lead zero
28
- # myLCD.print ":"
29
- # printlz 1 # print minutes with lead zero
30
- # myLCD.print ":"
31
- # printlz 0 # print seconds with lead zero
32
- #
33
- #
34
- # myLCD.setxy 10,0
35
- # myLCD.print "write test"
36
- # myLCD.setxy 0,2
37
- # 32.upto(109) do # write address of byte to that b yte
38
- # |x| mem0.write_byte x, x
39
- # myLCD.print(".") if x%2
40
- # delay 10
41
- # end
42
- #
43
- # delay 2000
44
- #
45
- # myLCD.clearline 2 # clears bottom two lines
46
- # myLCD.clearline 3
47
- #
48
- # myLCD.setxy 10,0, "read test "
49
- # myLCD.setxy 0,2
50
- # # read and print 39 addresses with printable numbers
51
- # 75.upto(113) { |x| myLCD.print(mem0.read_byte(x)) }
52
- # delay 10000
53
- # myLCD.clearscr
54
- # end
55
- #
56
- # def printlz(w)
57
- # i = 0 + rtc.get(w,0) # the '0 +' is YARH (Yet Another RubyToc Hack)
58
- # myLCD.print "0" if i < 10
59
- # myLCD.print i
60
- # end
37
+ myLCD.setxy 10,0, "read test "
38
+ myLCD.setxy 0,2
39
+ # read and print 39 addresses with printable numbers
40
+ 75.upto(113) { |x| myLCD.print(mem0.read_byte(x)) }
41
+ delay 10000
42
+ myLCD.clearscr
43
+ end
44
+
45
+ def printlz(w)
46
+ f = 1 + w # hack to coerce w to int
47
+ i = rtc.get(w,0)
48
+ myLCD.print "0" if i < 10
49
+ myLCD.print i
50
+ end
61
51
 
62
52
  end
@@ -1,5 +1,7 @@
1
1
  class I2cWithClockChip < ArduinoSketch
2
2
 
3
+ # until is an unsupported node type
4
+
3
5
  # IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
4
6
  # the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
5
7
  output_pin 13, :as => :led
@@ -1,16 +1,5 @@
1
1
  class MidiScales < ArduinoSketch
2
2
 
3
- # IMPORTANT -- This is one for four examples that fails with Ruby 1.9 support (latest ruby2c and parsetree)
4
- # the failing example is commented out and replaced with this hello world until I have a chance to resolve the issue -- jd
5
- output_pin 13, :as => :led
6
-
7
- def loop
8
- blink led, 100
9
- x = 4
10
- end
11
-
12
- ##
13
-
14
3
  # purpose
15
4
  # trigger midi output with buttons and
16
5
  # spectra soft pots
@@ -18,88 +7,90 @@ class MidiScales < ArduinoSketch
18
7
  #
19
8
 
20
9
 
21
- # @current_note = int
22
- # @last_note_one = 0
23
- # @last_note_two = 0
24
- # @last_note_three = 0
25
- # @note = int
26
- #
27
- # input_pin 1, :as => :sensor_one, :device => :spectra
28
- # input_pin 2, :as => :sensor_two, :device => :spectra
29
- # input_pin 3, :as => :sensor_three, :device => :spectra
30
- # input_pin 7, :as => :button_one, :device => :button
31
- # input_pin 8, :as => :button_two, :device => :button
32
- # input_pin 9, :as => :button_three, :device => :button
33
- # output_pin 13, :as => :led
34
- #
35
- # serial_begin :rate => 31250
36
- #
37
- # def setup
38
- # delay 3000
39
- # end
40
- #
41
- # def loop
42
- # change_tone if button_one.read_input
43
- # change_pressure if button_two.read_input
44
- # change_channels if button_three.read_input
45
- # read_sensor_one
46
- # read_sensor_two
47
- # read_sensor_three
48
- # end
49
- #
50
- # def change_tone
51
- # 110.upto(127) do |note|
52
- # play 0, note, 127
53
- # end
54
- # end
55
- #
56
- # def change_pressure
57
- # 110.upto(127) do |pressure|
58
- # play 0, 45, pressure
59
- # end
60
- # end
61
- #
62
- # def change_channels
63
- # 0.upto(6) do |channel|
64
- # play channel, 50, 100
65
- # end
66
- # end
67
- #
68
- # def read_sensor_one
69
- # @current_note = sensor_one.soft_lock
70
- # pre_play(@current_note, @last_note_one, 13)
71
- # @last_note_one = @current_note
72
- # end
73
- #
74
- # def read_sensor_two
75
- # @current_note = sensor_two.soft_lock
76
- # pre_play(@current_note, @last_note_two, 14)
77
- # @last_note_two = @current_note
78
- # end
79
- #
80
- # def read_sensor_three
81
- # @current_note = sensor_three.soft_lock
82
- # pre_play(@current_note, @last_note_three, 15)
83
- # @last_note_three = @current_note
84
- # end
85
- #
86
- # def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
87
- # n = 1 + channel
88
- # unless current_note == last_note
89
- # @note = ((current_note /16) + 40)
90
- # play_with_no_delay( channel, @note, 100 )
91
- # end
92
- # end
93
- #
94
- # def play(chan, note, pressure)
95
- # note_on(chan, note, pressure)
96
- # delay 100 # adjust to need
97
- # note_off(chan, note, 0)
98
- # end
99
- #
100
- # def play_with_no_delay(chan, note, pressure) # note is not turned off
101
- # note_on(chan, note, pressure)
102
- # end
10
+ @current_note = int
11
+ @last_note_one = 0
12
+ @last_note_two = 0
13
+ @last_note_three = 0
14
+ @note = int
15
+
16
+ input_pin 1, :as => :sensor_one, :device => :spectra
17
+ input_pin 2, :as => :sensor_two, :device => :spectra
18
+ input_pin 3, :as => :sensor_three, :device => :spectra
19
+ input_pin 7, :as => :button_one, :device => :button
20
+ input_pin 8, :as => :button_two, :device => :button
21
+ input_pin 9, :as => :button_three, :device => :button
22
+ output_pin 13, :as => :led
23
+
24
+ serial_begin :rate => 31250
25
+
26
+ def setup
27
+ delay 3000
28
+ end
29
+
30
+ def loop
31
+ change_tone if button_one.read_input
32
+ change_pressure if button_two.read_input
33
+ change_channels if button_three.read_input
34
+ read_sensor_one
35
+ read_sensor_two
36
+ read_sensor_three
37
+ end
38
+
39
+ def change_tone
40
+ 110.upto(127) do |note|
41
+ play 0, note, 127
42
+ end
43
+ end
44
+
45
+ def change_pressure
46
+ 110.upto(127) do |pressure|
47
+ play 0, 45, pressure
48
+ end
49
+ end
50
+
51
+ def change_channels
52
+ 0.upto(6) do |channel|
53
+ play channel, 50, 100
54
+ end
55
+ end
56
+
57
+ def read_sensor_one
58
+ @current_note = sensor_one.soft_lock
59
+ pre_play(@current_note, @last_note_one, 13)
60
+ @last_note_one = @current_note
61
+ end
62
+
63
+ def read_sensor_two
64
+ @current_note = sensor_two.soft_lock
65
+ pre_play(@current_note, @last_note_two, 14)
66
+ @last_note_two = @current_note
67
+ end
68
+
69
+ def read_sensor_three
70
+ @current_note = sensor_three.soft_lock
71
+ pre_play(@current_note, @last_note_three, 15)
72
+ @last_note_three = @current_note
73
+ end
74
+
75
+ def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
76
+ n = 1 + channel
77
+ unless current_note == last_note
78
+ @note = ((current_note /16) + 40)
79
+ play_with_no_delay( channel, @note, 100 )
80
+ end
81
+ end
82
+
83
+ def play(chan, note, pressure)
84
+ f = 1 + chan + note + pressure # hack to coerce args to int
85
+ note_on(chan, note, pressure)
86
+ delay 100 # adjust to need
87
+ note_off(chan, note, 0)
88
+ end
89
+
90
+ def play_with_no_delay(chan, note, pressure) # note is not turned off
91
+ f = 1 + chan + note + pressure # hack to coerce args to int
92
+ note_on(chan, note, pressure)
93
+ end
103
94
 
104
95
 
105
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madrona-rad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Borenstein
@@ -204,7 +204,6 @@ files:
204
204
  - website/examples/serial_motor.rb.html
205
205
  has_rdoc: true
206
206
  homepage: http://github.com/atduskreg/rad
207
- licenses:
208
207
  post_install_message:
209
208
  rdoc_options:
210
209
  - --main
@@ -226,9 +225,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
225
  requirements: []
227
226
 
228
227
  rubyforge_project: rad
229
- rubygems_version: 1.3.5
228
+ rubygems_version: 1.2.0
230
229
  signing_key:
231
230
  specification_version: 2
232
- summary: "RAD: Ruby Arduino Development - 0.3.7 -- 1.9 Ready"
231
+ summary: "RAD: Ruby Arduino Development - 0.3.8 -- 1.9 Ready"
233
232
  test_files: []
234
233