madrona-rad 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/History.txt +14 -0
  2. data/Manifest.txt +41 -18
  3. data/Rakefile +5 -0
  4. data/bin/rad +16 -6
  5. data/lib/examples/blink_m_address_assignment.rb +104 -0
  6. data/lib/examples/blink_m_multi.rb +61 -0
  7. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  8. data/lib/examples/external_variables.rb +5 -1
  9. data/lib/examples/hello_array.rb +48 -0
  10. data/lib/examples/hello_array2.rb +79 -0
  11. data/lib/examples/hello_array_eeprom.rb +61 -0
  12. data/lib/examples/hello_eeprom.rb +4 -7
  13. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  14. data/lib/examples/hello_lcd_charset.rb +75 -0
  15. data/lib/examples/hello_pa_lcd.rb +59 -0
  16. data/lib/examples/hysteresis_duel.rb +39 -0
  17. data/lib/examples/motor_knob.rb +30 -0
  18. data/lib/examples/orig_servo_throttle.rb +1 -1
  19. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  20. data/lib/examples/servo_throttle.rb +1 -1
  21. data/lib/examples/sparkfun_lcd.rb +2 -2
  22. data/lib/examples/spectra_soft_pot.rb +34 -0
  23. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +60 -25
  24. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +8 -2
  25. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +46 -27
  26. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +5 -2
  27. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  28. data/lib/libraries/Stepper/Stepper.h +86 -0
  29. data/lib/libraries/Stepper/keywords.txt +28 -0
  30. data/lib/libraries/Wire/utility/twi.c +449 -0
  31. data/lib/libraries/Wire/utility/twi.h +57 -0
  32. data/lib/plugins/blink_m.rb +79 -46
  33. data/lib/plugins/hysteresis.rb +52 -0
  34. data/lib/plugins/lcd_padding.rb +39 -0
  35. data/lib/plugins/spectra_symbol.rb +79 -0
  36. data/lib/rad/arduino_plugin.rb +21 -0
  37. data/lib/rad/arduino_sketch.rb +231 -53
  38. data/lib/rad/init.rb +2 -2
  39. data/lib/rad/rad_processor.rb +42 -1
  40. data/lib/rad/rad_type_checker.rb +26 -0
  41. data/lib/rad/sim/arduino_sketch.rb +57 -0
  42. data/lib/rad/tasks/build_and_make.rake +4 -4
  43. data/lib/rad/variable_processing.rb +49 -12
  44. data/lib/rad/version.rb +1 -1
  45. data/test/test_array_processing.rb +179 -0
  46. data/test/test_plugin_loading.rb +151 -0
  47. data/test/test_translation_post_processing.rb +185 -0
  48. data/{lib/test → test}/test_variable_processing.rb +63 -13
  49. data/website/index.html +8 -7
  50. metadata +66 -30
  51. data/lib/test/test_array_processing.rb +0 -78
data/History.txt CHANGED
@@ -1,3 +1,17 @@
1
+ == 0.2.6 2008-07-30
2
+ * Tres grand update:
3
+ - added support for spectra_soft_pots
4
+ - added support and examples for blinkMs
5
+ - added multi sensor hysteresis -- formerly one sensor only
6
+ - added testing for plugin loading
7
+ - external arrays now have cool instance style plus
8
+ - drop down the metal style declarations
9
+ - iteration on external arrays now works. internal still problematic
10
+ - defines now work handily
11
+ - numerous lcd library changes plus enhancements: setxy 0,1, "print_something"
12
+ - lots of examples
13
+ - and much more
14
+
1
15
  == 0.2.5 2008-07-21
2
16
  * 1ish large post Bastille Day update:
3
17
  - added i2c capability
data/Manifest.txt CHANGED
@@ -5,78 +5,101 @@ README.rdoc
5
5
  Rakefile
6
6
  bin/rad
7
7
  lib/examples/add_hysteresis.rb
8
+ lib/examples/blink_m_address_assignment.rb
8
9
  lib/examples/blink_m_hello.rb
10
+ lib/examples/blink_m_multi.rb
11
+ lib/examples/configure_pa_lcd_boot.rb
9
12
  lib/examples/debounce_methods.rb
10
- lib/examples/external_variables.rb
11
13
  lib/examples/external_variable_fu.rb
14
+ lib/examples/external_variables.rb
12
15
  lib/examples/first_sound.rb
13
16
  lib/examples/frequency_generator.rb
17
+ lib/examples/hello_array.rb
18
+ lib/examples/hello_array2.rb
19
+ lib/examples/hello_array_eeprom.rb
14
20
  lib/examples/hello_eeprom.rb
21
+ lib/examples/hello_eeprom_lcdpa.rb
22
+ lib/examples/hello_lcd_charset.rb
23
+ lib/examples/hello_pa_lcd.rb
15
24
  lib/examples/hello_servos.rb
16
25
  lib/examples/hello_world.rb
26
+ lib/examples/hysteresis_duel.rb
17
27
  lib/examples/i2c_with_clock_chip.rb
28
+ lib/examples/motor_knob.rb
18
29
  lib/examples/orig_servo_throttle.rb
19
30
  lib/examples/servo_buttons.rb
31
+ lib/examples/servo_calibrate_continuous.rb
20
32
  lib/examples/servo_throttle.rb
21
33
  lib/examples/sparkfun_lcd.rb
34
+ lib/examples/spectra_soft_pot.rb
22
35
  lib/examples/times_method.rb
23
36
  lib/examples/toggle.rb
24
37
  lib/examples/two_wire.rb
25
38
  lib/libraries/DS1307/DS1307.cpp
26
39
  lib/libraries/DS1307/DS1307.h
27
40
  lib/libraries/DS1307/keywords.txt
28
- lib/libraries/FrequencyTimer2/keywords.txt
29
41
  lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp
30
42
  lib/libraries/FrequencyTimer2/FrequencyTimer2.h
31
- lib/libraries/OneWire/keywords.txt
43
+ lib/libraries/FrequencyTimer2/keywords.txt
32
44
  lib/libraries/OneWire/OneWire.cpp
33
45
  lib/libraries/OneWire/OneWire.h
46
+ lib/libraries/OneWire/keywords.txt
34
47
  lib/libraries/OneWire/readme.txt
35
- lib/libraries/Servo/keywords.txt
36
- lib/libraries/Servo/Servo.cpp
37
- lib/libraries/Servo/Servo.h
38
48
  lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp
39
49
  lib/libraries/SWSerLCDpa/SWSerLCDpa.h
40
50
  lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
41
51
  lib/libraries/SWSerLCDsf/SWSerLCDsf.h
52
+ lib/libraries/Servo/Servo.cpp
53
+ lib/libraries/Servo/Servo.h
54
+ lib/libraries/Servo/keywords.txt
55
+ lib/libraries/Stepper/Stepper.cpp
56
+ lib/libraries/Stepper/Stepper.h
57
+ lib/libraries/Stepper/keywords.txt
42
58
  lib/libraries/Wire/Wire.cpp
43
- lib/libraries/Wire/keywords.txt
44
59
  lib/libraries/Wire/Wire.h
60
+ lib/libraries/Wire/keywords.txt
45
61
  lib/libraries/Wire/twi.h
46
- lib/libraries/Wire/utilities/twi.c
47
- lib/libraries/Wire/utilities/twi.h
62
+ lib/libraries/Wire/utility/twi.c
63
+ lib/libraries/Wire/utility/twi.h
48
64
  lib/plugins/bitwise_ops.rb
49
65
  lib/plugins/blink_m.rb
50
66
  lib/plugins/debounce.rb
51
67
  lib/plugins/debug_output_to_lcd.rb
68
+ lib/plugins/hysteresis.rb
52
69
  lib/plugins/i2c_eeprom.rb
53
70
  lib/plugins/input_output_state.rb
71
+ lib/plugins/lcd_padding.rb
54
72
  lib/plugins/mem_test.rb
55
73
  lib/plugins/servo_pulse.rb
56
74
  lib/plugins/servo_setup.rb
57
75
  lib/plugins/smoother.rb
58
76
  lib/plugins/spark_fun_serial_lcd.rb
77
+ lib/plugins/spectra_symbol.rb
59
78
  lib/rad.rb
60
- lib/rad/arduino_sketch.rb
61
79
  lib/rad/arduino_plugin.rb
80
+ lib/rad/arduino_sketch.rb
81
+ lib/rad/generators/makefile/makefile.erb
82
+ lib/rad/generators/makefile/makefile.rb
83
+ lib/rad/init.rb
62
84
  lib/rad/rad_processor.rb
63
85
  lib/rad/rad_rewriter.rb
64
- lib/rad/variable_processing.rb
65
- lib/rad/init.rb
66
- lib/rad/todo.txt
86
+ lib/rad/rad_type_checker.rb
87
+ lib/rad/sim/arduino_sketch.rb
67
88
  lib/rad/tasks/build_and_make.rake
68
89
  lib/rad/developer.rake
69
90
  lib/rad/tasks/rad.rb
91
+ lib/rad/todo.txt
92
+ lib/rad/variable_processing.rb
70
93
  lib/rad/version.rb
71
- lib/rad/generators/makefile/makefile.erb
72
- lib/rad/generators/makefile/makefile.rb
73
- lib/test/test_array_processing.rb
74
- lib/test/test_variable_processing.rb
75
94
  scripts/txt2html
76
95
  setup.rb
77
96
  spec/models/spec_helper.rb
78
97
  spec/models/arduino_sketch_spec.rb
79
98
  spec/spec.opts
99
+ test/test_array_processing.rb
100
+ test/test_plugin_loading.rb
101
+ test/test_translation_post_processing.rb
102
+ test/test_variable_processing.rb
80
103
  website/index.html
81
104
  website/index.txt
82
105
  website/javascripts/rounded_corners_lite.inc.js
@@ -85,4 +108,4 @@ website/template.rhtml
85
108
  website/examples/assembler_test.rb.html
86
109
  website/examples/gps_reader.rb.html
87
110
  website/examples/hello_world.rb.html
88
- website/examples/serial_motor.rb.html
111
+ website/examples/serial_motor.rb.html
data/Rakefile CHANGED
@@ -8,6 +8,11 @@ require 'rake/rdoctask'
8
8
  require 'rake/contrib/rubyforgepublisher'
9
9
  require 'fileutils'
10
10
  require 'hoe'
11
+
12
+ RAD_ROOT = File.expand_path(File.dirname(__FILE__))
13
+
14
+ load "#{RAD_ROOT}/project_dev.rake"
15
+
11
16
  begin
12
17
  require 'spec/rake/spectask'
13
18
  rescue LoadError
data/bin/rad CHANGED
@@ -119,6 +119,10 @@ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Servo/.", "#{sketch_n
119
119
  puts "Installed Servo into #{sketch_name}/vendor/libraries"
120
120
  puts
121
121
 
122
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
123
+ puts "Installed Stepper into #{sketch_name}/vendor/libraries"
124
+ puts
125
+
122
126
  FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDpa/.", "#{sketch_name}/vendor/libraries/SWSerLCDpa"
123
127
  puts "Installed SWSerLCDpa into #{sketch_name}/vendor/libraries"
124
128
  puts
@@ -127,6 +131,10 @@ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{ske
127
131
  puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
128
132
  puts
129
133
 
134
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
135
+ puts "Installed Stepper into #{sketch_name}/vendor/libraries"
136
+ puts
137
+
130
138
  FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
131
139
  puts "Installed Wire into #{sketch_name}/vendor/libraries"
132
140
  puts
@@ -142,12 +150,14 @@ puts
142
150
 
143
151
  # Build test -- used testing
144
152
 
145
- FileUtils.mkdir_p "#{sketch_name}/test"
146
- puts "Successfully created your test directory."
147
-
148
- FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
149
- puts "Installed tests into #{sketch_name}/test"
150
- puts
153
+ # FIXME: this should put the tests into the vendor/tests directory instead.
154
+
155
+ # FileUtils.mkdir_p "#{sketch_name}/test"
156
+ # puts "Successfully created your test directory."
157
+ #
158
+ # FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
159
+ # puts "Installed tests into #{sketch_name}/test"
160
+ # puts
151
161
 
152
162
  # Build vendor/plugins:
153
163
 
@@ -0,0 +1,104 @@
1
+ class BlinkMAddressAssignment < ArduinoSketch
2
+
3
+ # want to use more than one blink m?
4
+ # since each blink m arrives with the same address,
5
+ # we can't address each one individually
6
+ #
7
+ # so the first thing we need to do is give each one a new address
8
+ # that's the purpose of this sketch
9
+ #
10
+ # install one blinkm at a time
11
+ # a pa_lcd screen makes this easier
12
+ # the screen will start at address ten and increment approximately every
13
+ # four seconds. Pressing during the first four seconds sets the blnikm
14
+ # address to 10, during the next four seconds to 11 and so on
15
+ # difficult without a screen.
16
+ # if you need to, program an led to help with the timing
17
+
18
+
19
+ @blink_m_start_address = 10
20
+ @flag = false
21
+ @addr1 = "10, byte"
22
+ @addr2 = "11, byte"
23
+ @addr3 = "12, byte"
24
+
25
+ output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
26
+ input_pin 7, :as => :button_one, :device => :button
27
+ input_pin 8, :as => :button_two, :device => :button
28
+ input_pin 9, :as => :button_three, :device => :button
29
+
30
+ output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
31
+
32
+ def setup
33
+ delay 1000
34
+ my_lcd.setxy 0,0, "bienvenue"
35
+ delay 5000
36
+ end
37
+
38
+ def loop
39
+
40
+ if @flag == false
41
+ staging
42
+ else
43
+ test_address
44
+ end
45
+ delay 100
46
+ end
47
+
48
+ def staging
49
+ my_lcd.setxy 0,0, "press button one to"
50
+ my_lcd.setxy 0,1, "set address to "
51
+ my_lcd.print @blink_m_start_address
52
+ my_lcd.setxy 0,2, "or two for status"
53
+ delay 60
54
+ my_lcd.setxy 0,3, " "
55
+ my_lcd.setxy 0,3
56
+ 800.times do |i|
57
+ return 0 if @flag == true
58
+ my_lcd.print "." if i % 50 == 0
59
+ delay 5
60
+ if button_one.read_input
61
+ assign_address
62
+ elsif button_two.read_input
63
+ test_address
64
+ end
65
+ end
66
+ @blink_m_start_address += 1
67
+ end
68
+
69
+ def assign_address
70
+ @flag = true
71
+ my_lcd.clearscr "setting to "
72
+ my_lcd.print @blink_m_start_address
73
+ delay 100
74
+ BlinkM_setAddress @blink_m_start_address
75
+ my_lcd.clearscr "done"
76
+ control_it
77
+ end
78
+
79
+ def control_it
80
+ delay 500
81
+ my_lcd.clearscr "stopping script"
82
+ BlinkM_stopScript @blink_m_start_address
83
+ my_lcd.clearscr "stopping script.."
84
+ delay 500
85
+ my_lcd.clearscr "fade to purple.."
86
+ BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
87
+ my_lcd.clearscr "fade to purple"
88
+ delay 500
89
+ BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
90
+ end
91
+
92
+
93
+ def test_address
94
+ my_lcd.clearscr
95
+ my_lcd.setxy 0,0, "testing address"
96
+ my_lcd.setxy 0,1
97
+ my_lcd.print blink_m_check_address_message @blink_m_start_address
98
+ delay 5000
99
+ end
100
+
101
+
102
+
103
+
104
+ end
@@ -0,0 +1,61 @@
1
+ class BlinkMMulti < ArduinoSketch
2
+
3
+ # demonstrate control of individual blinkms
4
+ # this assumes the leds have been assigned addresses 10, 11, 12
5
+ # which can be done with blink m address assignment
6
+
7
+ # two ways to address the blinkms, array and individual variables
8
+ @blink_addresses = [10,11,12]
9
+ @addr_all = "0, byte"
10
+ @addr1 = "10, byte"
11
+ @addr2 = "11, byte"
12
+ @addr3 = "12, byte"
13
+
14
+ output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
15
+ input_pin 7, :as => :button_one, :device => :button
16
+ input_pin 8, :as => :button_two, :device => :button
17
+ input_pin 9, :as => :button_three, :device => :button
18
+ input_pin 10, :as => :button_four, :device => :button
19
+
20
+ # display the action on a 4x20 pa_lcd, yours may be 9200 instead of 19,200
21
+
22
+ output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
23
+
24
+
25
+ def loop
26
+ stop_and_fade(@addr1) if button_one.read_input
27
+ stop_and_fade(@addr2) if button_two.read_input
28
+ stop_and_fade(@addr3) if button_three.read_input
29
+ dance if button_four.read_input
30
+ end
31
+
32
+ def stop_and_fade(addr)
33
+ f = 1 + addr # hack to coerce addr to int
34
+ my_lcd.clearscr
35
+ my_lcd.setxy 0,0, "blinkm # "
36
+ my_lcd.print addr
37
+ delay 700
38
+ BlinkM_stopScript addr
39
+ my_lcd.setxy 0,1, "stopping script.."
40
+ delay 700
41
+ my_lcd.setxy 0,2, "fade to purple.."
42
+ BlinkM_fadeToRGB(addr, 0xff,0x00,0xff)
43
+ end
44
+
45
+ def dance
46
+ BlinkM_setFadeSpeed(@addr_all, 20) # 1-255, with 1 producing the slowest fade
47
+ my_lcd.clearscr
48
+ my_lcd.setxy 0,0, "Do the shimmy.."
49
+ my_lcd.setxy 0,1
50
+ @blink_addresses.each do |a|
51
+ BlinkM_fadeToRGB(a, 1,166,138)
52
+ delay 100
53
+ end
54
+ @blink_addresses.each do |a|
55
+ BlinkM_fadeToRGB(a, 35,0,112)
56
+ delay 100
57
+ end
58
+ end
59
+
60
+
61
+ end
@@ -0,0 +1,91 @@
1
+ class ConfigurePaLcdBoot < ArduinoSketch
2
+
3
+ ## important!
4
+ ## most pa_lcd rates are set to 9200, but there are some newer at 19200
5
+ ## if you have a 19200, uncomment the end of line 38
6
+
7
+ ## purpose:
8
+ ## change cursor to none
9
+ ## and add custom boot screen
10
+ ##
11
+ ## jd's preferred setup for pa_lcd
12
+ ##
13
+ ## assumes 4 x 20 pa_lcd
14
+ ##
15
+ ## no blinking cursor press button 1
16
+ ## configure custom start up screen - press button 2
17
+ ## configure lcd to use custom startup screen - press button 3
18
+ ##
19
+ ## press buttons one, two and three
20
+ ## or season to taste
21
+ ##
22
+ ## refernce
23
+ ## K107 LCD Controller Board Manual
24
+ ## page 11 for cursors
25
+ ## page 13 for custom boot
26
+ ## http://wulfden.org/downloads/manuals/K107manual.pdf
27
+ ##
28
+ ##
29
+
30
+ ## set pins to your setup
31
+
32
+
33
+ input_pin 8, :as => :button_one, :device => :button
34
+ input_pin 9, :as => :button_two, :device => :button
35
+ input_pin 10, :as => :button_three, :device => :button
36
+
37
+ ## note, most of these controllers are set to 9200
38
+ output_pin 14, :as => :my_lcd, :device => :pa_lcd #, :rate => 19200
39
+
40
+
41
+ def loop
42
+ set_cursor if button_one.read_input
43
+ set_custom_screen if button_two.read_input
44
+ change_boot_to_custom if button_three.read_input
45
+ end
46
+
47
+ ## assumes 4 x 20 screen
48
+ ## maintain 20 characters after ?Cn
49
+ ## wny delays? the controller needs them to give it
50
+ ## enough time to write 20 bytes to internl EEPROM
51
+ def set_custom_screen
52
+ my_lcd.clearscr
53
+ my_lcd.print "?C0 RAD & Arduino "
54
+ delay 400
55
+ my_lcd.print "?C1 Development "
56
+ delay 400
57
+ my_lcd.print "?C2 "
58
+ delay 400
59
+ my_lcd.print "?C3 v0.3.0 "
60
+ end
61
+
62
+
63
+ ## ?c0 for no cursor
64
+ ## ?c2 for non blinking cursor
65
+ ## ?c3 for blinking cursor
66
+ def set_cursor
67
+ my_lcd.clearscr
68
+ my_lcd.print "Changing to "
69
+ my_lcd.setxy 0,1
70
+ my_lcd.print "no cursor. "
71
+ my_lcd.setxy 0,3
72
+ my_lcd.print "Reboot to view... "
73
+
74
+ my_lcd.print("?c0")
75
+ end
76
+
77
+ ## "?S0 for blank screen
78
+ ## ?S1 for configuration settings
79
+ ## ?S2 for custom text screen
80
+ def change_boot_to_custom
81
+ my_lcd.clearscr
82
+ my_lcd.print "Changing to "
83
+ my_lcd.setxy 0,1
84
+ my_lcd.print "custom boot screen. "
85
+ my_lcd.setxy 0,3
86
+ my_lcd.print "Reboot to view... "
87
+ my_lcd.print("?S2")
88
+ end
89
+
90
+
91
+ end