rad 0.2.2 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +34 -0
- data/Manifest.txt +113 -7
- data/{README.txt → README.rdoc} +17 -5
- data/Rakefile +3 -0
- data/bin/rad +106 -1
- data/lib/examples/add_hysteresis.rb +13 -0
- data/lib/examples/basic_blink.rb +10 -0
- data/lib/examples/blink_m_address_assignment.rb +104 -0
- data/lib/examples/blink_m_hello.rb +14 -0
- data/lib/examples/blink_m_multi.rb +61 -0
- data/lib/examples/blink_with_serial.rb +16 -0
- data/lib/examples/configure_pa_lcd_boot.rb +91 -0
- data/lib/examples/debounce_methods.rb +49 -0
- data/lib/examples/external_variable_fu.rb +26 -0
- data/lib/examples/external_variables.rb +32 -0
- data/lib/examples/first_sound.rb +23 -0
- data/lib/examples/frequency_generator.rb +30 -0
- data/lib/examples/hello_array.rb +48 -0
- data/lib/examples/hello_array2.rb +79 -0
- data/lib/examples/hello_array_eeprom.rb +59 -0
- data/lib/examples/hello_clock.rb +84 -0
- data/lib/examples/hello_eeprom.rb +51 -0
- data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
- data/lib/examples/hello_format_print.rb +94 -0
- data/lib/examples/hello_lcd_charset.rb +75 -0
- data/lib/examples/hello_pa_lcd.rb +59 -0
- data/lib/examples/hello_servos.rb +88 -0
- data/lib/examples/hello_spectra_sound.rb +38 -0
- data/lib/examples/hello_world.rb +11 -0
- data/lib/examples/hello_xbee.rb +12 -0
- data/lib/examples/hysteresis_duel.rb +39 -0
- data/lib/examples/i2c_with_clock_chip.rb +124 -0
- data/lib/examples/midi_beat_box.rb +86 -0
- data/lib/examples/midi_scales.rb +94 -0
- data/lib/examples/motor_knob.rb +30 -0
- data/lib/examples/servo_buttons.rb +23 -0
- data/lib/examples/servo_calibrate_continuous.rb +92 -0
- data/lib/examples/servo_throttle.rb +40 -0
- data/lib/examples/sparkfun_lcd.rb +48 -0
- data/lib/examples/spectra_soft_pot.rb +34 -0
- data/lib/examples/times_method.rb +8 -0
- data/lib/examples/toggle.rb +10 -0
- data/lib/examples/twitter.rb +57 -0
- data/lib/examples/two_wire.rb +14 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
- data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
- data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
- data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
- data/lib/libraries/DS1307/DS1307.cpp +162 -0
- data/lib/libraries/DS1307/DS1307.h +66 -0
- data/lib/libraries/{SWSerLCDpa → DS1307}/keywords.txt +1 -1
- data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
- data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
- data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
- data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
- data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
- data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
- data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
- data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
- data/lib/libraries/LoopTimer/keywords.txt +27 -0
- data/lib/libraries/OneWire/OneWire.cpp +194 -0
- data/lib/libraries/OneWire/OneWire.h +63 -0
- data/lib/libraries/OneWire/keywords.txt +35 -0
- data/lib/libraries/OneWire/readme.txt +13 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +93 -47
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +16 -9
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
- data/lib/libraries/Servo/Servo.cpp +192 -0
- data/lib/libraries/Servo/Servo.h +61 -0
- data/lib/libraries/Stepper/Stepper.cpp +220 -0
- data/lib/libraries/Stepper/Stepper.h +86 -0
- data/lib/libraries/Stepper/keywords.txt +28 -0
- data/lib/libraries/Wire/Wire.cpp +262 -0
- data/lib/libraries/Wire/Wire.h +67 -0
- data/lib/libraries/Wire/keywords.txt +31 -0
- data/lib/libraries/Wire/twi.h +57 -0
- data/lib/libraries/Wire/utility/twi.c +449 -0
- data/lib/libraries/Wire/utility/twi.h +57 -0
- data/lib/plugins/bitwise_ops.rb +54 -0
- data/lib/plugins/blink.rb +25 -0
- data/lib/plugins/blink_m.rb +356 -0
- data/lib/plugins/debounce.rb +138 -0
- data/lib/plugins/debug_output_to_lcd.rb +71 -0
- data/lib/plugins/hysteresis.rb +52 -0
- data/lib/plugins/input_output_state.rb +84 -0
- data/lib/plugins/lcd_padding.rb +58 -0
- data/lib/plugins/mem_test.rb +37 -0
- data/lib/plugins/midi.rb +60 -0
- data/lib/plugins/parallax_ping.rb +50 -0
- data/lib/plugins/servo_pulse.rb +31 -0
- data/lib/plugins/servo_setup.rb +86 -0
- data/lib/plugins/smoother.rb +54 -0
- data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
- data/lib/plugins/spectra_symbol.rb +79 -0
- data/lib/plugins/twitter_connect.rb +145 -0
- data/lib/rad/README.rdoc +5 -0
- data/lib/rad/arduino_plugin.rb +246 -0
- data/lib/rad/arduino_sketch.rb +351 -257
- data/lib/rad/generators/makefile/makefile.erb +1 -1
- data/lib/rad/generators/makefile/makefile.rb +9 -10
- data/lib/rad/hardware_library.rb +813 -0
- data/lib/rad/init.rb +3 -1
- data/lib/rad/rad_processor.rb +128 -0
- data/lib/rad/rad_rewriter.rb +94 -0
- data/lib/rad/rad_type_checker.rb +26 -0
- data/lib/rad/sim/arduino_sketch.rb +57 -0
- data/lib/rad/sketch_compiler.rb +47 -0
- data/lib/rad/tasks/build_and_make.rake +146 -24
- data/lib/rad/variable_processing.rb +153 -0
- data/lib/rad/version.rb +1 -1
- data/spec/examples/hello_world.rb +11 -0
- data/spec/examples/serial_motor.rb +12 -0
- data/spec/models/sketch_compiler_spec.rb +96 -0
- data/spec/sim/hello_world_spec.rb +42 -0
- data/test/test_array_processing.rb +179 -0
- data/test/test_plugin_loading.rb +151 -0
- data/test/test_translation_post_processing.rb +185 -0
- data/test/test_variable_processing.rb +238 -0
- data/website/index.html +22 -7
- data/website/stylesheets/screen.css +32 -1
- metadata +130 -13
@@ -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
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class DebounceMethods < ArduinoSketch
|
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
|
9
|
+
|
10
|
+
# depressing and releasing button_one, button_two or button_four do the same thing
|
11
|
+
# with a slightly different syntax and number of blinks
|
12
|
+
# button_three simply toggles the led with the read_and_toggle method
|
13
|
+
# button_five does it with a twist
|
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.digitalWrite HIGH
|
37
|
+
delay 200
|
38
|
+
led.digitalWrite LOW
|
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
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ExternalVariableFu < ArduinoSketch
|
2
|
+
|
3
|
+
@one = int
|
4
|
+
@two = long
|
5
|
+
@three = unsigned
|
6
|
+
@four = short
|
7
|
+
@five = byte
|
8
|
+
@six = 1
|
9
|
+
@seven = 1.2
|
10
|
+
@eight = "0x00"
|
11
|
+
@nine = "arduino"
|
12
|
+
@ten = true
|
13
|
+
@eleven = false
|
14
|
+
@twelve = "1, long"
|
15
|
+
@thirteen = "1, unsigned"
|
16
|
+
@fourteen = "1, byte"
|
17
|
+
@fifteen = HIGH
|
18
|
+
@sixteen = LOW
|
19
|
+
@seventeen = ON
|
20
|
+
@eighteen = OFF
|
21
|
+
|
22
|
+
def loop
|
23
|
+
delay @six
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ExternalVariables < ArduinoSketch
|
2
|
+
|
3
|
+
define "KOOL 10"
|
4
|
+
define "TRUE 1"
|
5
|
+
define "COMMENT true"
|
6
|
+
define "DS1307_CTRL 7"
|
7
|
+
define "DS1308_CTRL 7"
|
8
|
+
array "char buffer[32];"
|
9
|
+
array "char bufferz[32];"
|
10
|
+
|
11
|
+
|
12
|
+
@foo = 1
|
13
|
+
@bidda = "badda"
|
14
|
+
@boom = "1, int"
|
15
|
+
@rad = "1.00"
|
16
|
+
|
17
|
+
def loop
|
18
|
+
delay 1
|
19
|
+
@foo = 2
|
20
|
+
@foo = KOOL
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup # special one time only method
|
24
|
+
delay 100
|
25
|
+
delay 100
|
26
|
+
@foo = 10
|
27
|
+
5.times { delay 200 }
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class FirstSound < ArduinoSketch
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100 # frequency required
|
6
|
+
|
7
|
+
def loop
|
8
|
+
myTone.disable
|
9
|
+
1.upto(400) { |x| tone_out x } # run up the scale to 4000 Hz in 10 Hz steps
|
10
|
+
399.downto(1) { |x| tone_out x } # come back down in 10 Hz steps
|
11
|
+
delay 2000
|
12
|
+
end
|
13
|
+
|
14
|
+
def tone_out(n)
|
15
|
+
myTone.set_frequency 10*n
|
16
|
+
myTone.enable
|
17
|
+
delay 80
|
18
|
+
myTone.disable
|
19
|
+
delay 10
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class FrequencyGenerator < ArduinoSketch
|
2
|
+
|
3
|
+
# need explaination
|
4
|
+
|
5
|
+
output_pin 11, :as => :myTone, :device => :freq_out, :frequency => 100
|
6
|
+
|
7
|
+
def loop
|
8
|
+
uh_oh 4
|
9
|
+
end
|
10
|
+
|
11
|
+
def uh_oh(n)
|
12
|
+
|
13
|
+
|
14
|
+
n.times do
|
15
|
+
myTone.enable
|
16
|
+
myTone.set_frequency 1800
|
17
|
+
delay 500
|
18
|
+
myTone.disable
|
19
|
+
delay 100
|
20
|
+
myTone.enable
|
21
|
+
myTone.set_frequency 1800
|
22
|
+
delay 800
|
23
|
+
myTone.enable
|
24
|
+
end
|
25
|
+
# hack to help translator guess that n is an int
|
26
|
+
f = n + 0
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class HelloArray < ArduinoSketch
|
2
|
+
|
3
|
+
# still working this out...
|
4
|
+
# for example, new instance style array declaration naming
|
5
|
+
# is at odds with original style array naming
|
6
|
+
|
7
|
+
# for simple integer, string, float, and boolean arrays
|
8
|
+
@toppings = [1,2,3]
|
9
|
+
@names = ["ciero", "bianca", "antica"]
|
10
|
+
|
11
|
+
# when we just need to declare an array, or need more control, such as specific type requirements
|
12
|
+
array "int ingredients[10]"
|
13
|
+
array "int pizzas[] = {1,2,3,4}"
|
14
|
+
|
15
|
+
output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
16
|
+
|
17
|
+
|
18
|
+
def loop
|
19
|
+
|
20
|
+
my_lcd.clearscr "toppings: "
|
21
|
+
delay 500
|
22
|
+
|
23
|
+
@toppings.each do |a|
|
24
|
+
my_lcd.print a
|
25
|
+
my_lcd.print " "
|
26
|
+
delay 500
|
27
|
+
end
|
28
|
+
|
29
|
+
my_lcd.setxy 0,1, "pizzas: "
|
30
|
+
|
31
|
+
pizzas.each do |p|
|
32
|
+
my_lcd.print p
|
33
|
+
my_lcd.print " "
|
34
|
+
delay 500
|
35
|
+
end
|
36
|
+
|
37
|
+
my_lcd.setxy 0,2, "names: "
|
38
|
+
|
39
|
+
@names.each do |p|
|
40
|
+
my_lcd.print p
|
41
|
+
my_lcd.print " "
|
42
|
+
delay 500
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class HelloArray2 < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------
|
4
|
+
# Checking out various array operations
|
5
|
+
#
|
6
|
+
# JD Barnhart - Seattle, WA July 2008
|
7
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
8
|
+
# <brianbr@wulfden.org>
|
9
|
+
#
|
10
|
+
# ----------------------------------------------------------------------
|
11
|
+
|
12
|
+
# still working this out...
|
13
|
+
# for example, new instance style array declaration naming
|
14
|
+
# is at odds with original style array naming
|
15
|
+
|
16
|
+
define "THROWAWAY 0"
|
17
|
+
|
18
|
+
# for simple integer, string, float, and boolean arrays
|
19
|
+
@toppings = [1,2,3]
|
20
|
+
@names = ["ciero", "bianca", "zeus", "athena", "apollo"]
|
21
|
+
|
22
|
+
# when we just need to declare an array, or need more control, such as specific type requirements
|
23
|
+
array "int ingredients[10]"
|
24
|
+
array "int pizzas[] = {1,2,3,4}"
|
25
|
+
array "byte buffer[20] = {'A', 'B', 'Z', 'C', 'Y', 'D', 'W', 'E', '%', 'H', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
|
26
|
+
|
27
|
+
output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
28
|
+
|
29
|
+
|
30
|
+
def setup
|
31
|
+
|
32
|
+
my_lcd.clearscr "toppings: "
|
33
|
+
delay 500
|
34
|
+
|
35
|
+
@toppings.each do |a|
|
36
|
+
my_lcd.print a
|
37
|
+
my_lcd.print " "
|
38
|
+
delay 500
|
39
|
+
end
|
40
|
+
|
41
|
+
my_lcd.setxy 0,1, "pizzas: "
|
42
|
+
|
43
|
+
pizzas.each do |p|
|
44
|
+
my_lcd.print p
|
45
|
+
my_lcd.print " "
|
46
|
+
delay 500
|
47
|
+
end
|
48
|
+
|
49
|
+
my_lcd.setxy 0,2, "names: "
|
50
|
+
|
51
|
+
@names.each do |p|
|
52
|
+
my_lcd.print p
|
53
|
+
my_lcd.print " "
|
54
|
+
delay 500
|
55
|
+
end
|
56
|
+
|
57
|
+
delay 3000
|
58
|
+
|
59
|
+
my_lcd.clearline 1, @names[2]
|
60
|
+
my_lcd.print " [ "
|
61
|
+
my_lcd.print pizzas[1]
|
62
|
+
my_lcd.print " ]"
|
63
|
+
|
64
|
+
delay 2000
|
65
|
+
|
66
|
+
my_lcd.clearscr "Array Load?n"
|
67
|
+
1.upto(20) do |x|
|
68
|
+
# buffer[x] = 64 + x # we cannot set array elements yet except to initialize in declaration
|
69
|
+
my_lcd.print buffer[x-1]
|
70
|
+
my_lcd.print " "
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def loop
|
76
|
+
x = THROWAWAY
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|