atduskgreg-rad 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +104 -0
- data/License.txt +282 -0
- data/Manifest.txt +142 -0
- data/README.rdoc +55 -0
- data/Rakefile +142 -0
- data/bin/hello_world_test/Makefile +436 -0
- data/bin/hello_world_test/hello_world.cpp +23 -0
- data/bin/rad +302 -0
- 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/software_serial.rb +10 -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/DS1307/keywords.txt +18 -0
- 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 +296 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +69 -0
- 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.rb +5 -0
- data/lib/rad/README.rdoc +5 -0
- data/lib/rad/arduino_plugin.rb +246 -0
- data/lib/rad/arduino_sketch.rb +627 -0
- data/lib/rad/generators/makefile/makefile.erb +243 -0
- data/lib/rad/generators/makefile/makefile.rb +38 -0
- data/lib/rad/hardware_library.rb +813 -0
- data/lib/rad/init.rb +14 -0
- data/lib/rad/progressbar.rb +236 -0
- 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 +210 -0
- data/lib/rad/tasks/rad.rb +2 -0
- data/lib/rad/todo.txt +13 -0
- data/lib/rad/variable_processing.rb +153 -0
- data/lib/rad/version.rb +9 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/spec/examples/hello_world.rb +11 -0
- data/spec/examples/serial_motor.rb +12 -0
- data/spec/models/arduino_sketch_spec.rb +82 -0
- data/spec/models/sketch_compiler_spec.rb +96 -0
- data/spec/models/spec_helper.rb +2 -0
- data/spec/sim/hello_world_spec.rb +42 -0
- data/spec/spec.opts +1 -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/examples/assembler_test.rb.html +73 -0
- data/website/examples/gps_reader.rb.html +39 -0
- data/website/examples/hello_world.rb.html +38 -0
- data/website/examples/serial_motor.rb.html +41 -0
- data/website/index.html +178 -0
- data/website/index.txt +64 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +169 -0
- data/website/template.rhtml +48 -0
- metadata +217 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
class HelloArrayEeprom < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------
|
4
|
+
# Checking out various array operations with I2C serial EEPROM
|
5
|
+
# doing block writes and bloack readbacks with byte arrays
|
6
|
+
#
|
7
|
+
# JD Barnhart - Seattle, WA July 2008
|
8
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
9
|
+
# <brianbr@wulfden.org>
|
10
|
+
#
|
11
|
+
# ----------------------------------------------------------------------
|
12
|
+
|
13
|
+
# still working this out...
|
14
|
+
# for example, new instance style array declaration naming
|
15
|
+
# is at odds with original style array naming
|
16
|
+
|
17
|
+
define "THROWAWAY 0"
|
18
|
+
|
19
|
+
# when we just need to declare an array, or need more control, such as specific type requirements
|
20
|
+
array "byte page_data[20] = {'R', 'A', 'D', ' ', 'i', 's', ' ', 'B', 'A', 'D', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
|
21
|
+
array "byte in_buffer[20]"
|
22
|
+
|
23
|
+
output_pin 19, :as => :mem0, :device => :i2c_eeprom, :address => 1 # w/o :address defaults to :address => 0 which is 0x50
|
24
|
+
output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200
|
25
|
+
|
26
|
+
|
27
|
+
def setup
|
28
|
+
|
29
|
+
my_lcd.clearscr " I2C EEPROM Demo"
|
30
|
+
my_lcd.setxy 0, 1, "block write and read"
|
31
|
+
my_lcd.setxy 0, 2, " back and display"
|
32
|
+
my_lcd.setxy 0, 3, " to the LCD"
|
33
|
+
|
34
|
+
delay 2000
|
35
|
+
|
36
|
+
my_lcd.clearscr " I2C EEPROM Demo?n block write"
|
37
|
+
|
38
|
+
mem0.write_page 0x0100, page_data, 20
|
39
|
+
|
40
|
+
delay 1000
|
41
|
+
|
42
|
+
my_lcd.clearline 1, " block readback"
|
43
|
+
|
44
|
+
mem0.read_buffer 0x0100, in_buffer, 20
|
45
|
+
|
46
|
+
my_lcd.setxy 0, 2
|
47
|
+
|
48
|
+
1.upto(20) do |x|
|
49
|
+
my_lcd.print in_buffer[x-1]
|
50
|
+
my_lcd.print " "
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def loop
|
56
|
+
x = THROWAWAY
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class HelloClock < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------------------
|
4
|
+
# <b>Time and Temp (20 July 2008)</b>
|
5
|
+
# Example #1 - Brian Riley, Underhill Center, VT USA <brianbr@wulden.org>
|
6
|
+
#
|
7
|
+
# Connections
|
8
|
+
# I2C bus - DS1307 Real Time Clock chip
|
9
|
+
# Analog 0 (a.k.a Digital 14) - Wulfden K107 seria LCD Controller
|
10
|
+
# Peter Anderson chip
|
11
|
+
#
|
12
|
+
# Comment
|
13
|
+
# - This is a straight forward program to read the Real Time Clock and Display
|
14
|
+
# delay() calls waiting for temperature conversion readings
|
15
|
+
#
|
16
|
+
# - for the external data busses make sure you have 4.7K pullup resistors on the
|
17
|
+
# the SDA/SCL (I2C)
|
18
|
+
#
|
19
|
+
# ----------------------------------------------------------------------------------
|
20
|
+
|
21
|
+
@flag = int
|
22
|
+
|
23
|
+
array "byte clock[8]"
|
24
|
+
|
25
|
+
@days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
|
26
|
+
@months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
|
27
|
+
|
28
|
+
# implicit in :device => :ds1307 is that this i i2c
|
29
|
+
# :enable => true issues the Wire.begin to ick over i2c
|
30
|
+
output_pin 19, :as => :rtc, :device => :i2c_ds1307, :enable => :true
|
31
|
+
# software serial tx drives LCD display, screen cleared at startup
|
32
|
+
# defines the softare protocol for controller as Peter Anderson
|
33
|
+
output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
34
|
+
loop_timer :as => :mainloop
|
35
|
+
|
36
|
+
|
37
|
+
def setup
|
38
|
+
myLCD.clearscr " --<Date/Time>--"
|
39
|
+
myLCD.setxy 1,3, "looptime = "
|
40
|
+
rtc.get clock, 1
|
41
|
+
print_main
|
42
|
+
@flag = 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def loop
|
46
|
+
mainloop.track
|
47
|
+
myLCD.setxy 12,3, mainloop.get_total
|
48
|
+
rtc.get clock, 1
|
49
|
+
if clock[0] == 0
|
50
|
+
if @flag == 0
|
51
|
+
print_main
|
52
|
+
@flag = 1
|
53
|
+
end
|
54
|
+
else
|
55
|
+
@flag = 0
|
56
|
+
end
|
57
|
+
myLCD.setxy 6,2
|
58
|
+
printlz clock[2]
|
59
|
+
myLCD.print ":"
|
60
|
+
printlz clock[1]
|
61
|
+
myLCD.print ":"
|
62
|
+
printlz clock[0]
|
63
|
+
|
64
|
+
delay 50
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def printlz(w)
|
69
|
+
myLCD.print "0" if w < 10
|
70
|
+
myLCD.print w
|
71
|
+
end
|
72
|
+
|
73
|
+
def print_main
|
74
|
+
myLCD.setxy 1,1, @days[clock[3]-1]
|
75
|
+
myLCD.print ", "
|
76
|
+
myLCD.print @months[clock[5]-1]
|
77
|
+
myLCD.print " "
|
78
|
+
printlz clock[4]
|
79
|
+
myLCD.print ", "
|
80
|
+
printlz clock[6] + 2000
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class HelloEeprom < ArduinoSketch
|
2
|
+
|
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
|
+
|
8
|
+
def loop
|
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
|
31
|
+
|
32
|
+
delay 2000
|
33
|
+
|
34
|
+
myLCD.clearline 2 # clears bottom two lines
|
35
|
+
myLCD.clearline 3
|
36
|
+
|
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
|
+
i = 0 + rtc.get(w,0) # the '0 +' is YARH (Yet Another RubyToc Hack)
|
47
|
+
myLCD.print "0" if i < 10
|
48
|
+
myLCD.print i
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class HelloEepromLcdpa < ArduinoSketch
|
2
|
+
# -----------------------------------------------------------------------
|
3
|
+
# Simple Byte Write and Byte Read-back of I2C EEPROM
|
4
|
+
#
|
5
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
6
|
+
# <brianbr@wulfden.org>
|
7
|
+
#
|
8
|
+
# I2C Routines are in a plugin not a library
|
9
|
+
# No block reads and write yet
|
10
|
+
# Displays to PH Anderson based serial LCD Display
|
11
|
+
#
|
12
|
+
# <b>I2C Serial EEPROM - Byte Read and Byte Write</b>
|
13
|
+
#
|
14
|
+
# i2c_eeprom_write_byte dev_addr, chip_addr, value
|
15
|
+
#
|
16
|
+
# dev_addr (byte) - range 0x50 to 0x57 determined by hardware wiring
|
17
|
+
# chip_addr (unsigned) - 0 to as much as 64K, depends on chip
|
18
|
+
# value (byte) - 0 to 255 (0x00 to 0xFF)
|
19
|
+
#
|
20
|
+
# returns - nothing
|
21
|
+
#
|
22
|
+
# i2c_eeprom_read_byte dev_addr, chip_addr
|
23
|
+
#
|
24
|
+
# dev_addr (byte) - range 0x50 to 0x57 determined by hardware wiring
|
25
|
+
# chip_addr (unsigned) - 0 to as much as 64K, depends on chip
|
26
|
+
#
|
27
|
+
# returns - byte value
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# http://www.arduino.cc/playground/Code/I2CEEPROM
|
31
|
+
# ----------------------------------------------------------------------
|
32
|
+
|
33
|
+
output_pin 19, :as => :mem0, :device => :i2c_eeprom, :enable => :true
|
34
|
+
output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
def setup
|
39
|
+
delay 1500 # give startup screen time to finish and clear
|
40
|
+
myLCD.clearscr " I2C EEPROM Demo"
|
41
|
+
myLCD.setxy 0, 1, "byte write then read"
|
42
|
+
myLCD.setxy 0, 2, " back and display"
|
43
|
+
myLCD.setxy 0, 3, " to the LCD"
|
44
|
+
|
45
|
+
clear_off_test
|
46
|
+
myLCD.clearline 1, " byte write test"
|
47
|
+
|
48
|
+
myLCD.setxy 0, 2
|
49
|
+
32.upto(109) do # write address of byte to that b yte
|
50
|
+
|x| mem0.write_byte x, x+7
|
51
|
+
myLCD.print(".") if x%2
|
52
|
+
delay 10 # EEPROM write _requires_ 3-10 ms pause
|
53
|
+
end
|
54
|
+
|
55
|
+
clear_off_test
|
56
|
+
myLCD.clearline 1, " byte read test "
|
57
|
+
|
58
|
+
myLCD.setxy 0, 2
|
59
|
+
# read and print 39 addresses with printable numbers
|
60
|
+
70.upto(105) { |x| myLCD.print(mem0.read_byte(x)) }
|
61
|
+
|
62
|
+
delay 2000
|
63
|
+
clear_off_test
|
64
|
+
myLCD.clearline 1, "-< tests complete >- "
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def loop
|
70
|
+
x = 4 # loop has to have _something_
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def clear_off_test # clears bottom two lines
|
75
|
+
delay 2000
|
76
|
+
myLCD.clearline 3
|
77
|
+
myLCD.clearline 2 # leaves you at start of a
|
78
|
+
# cleared third line
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
class HelloFormatPrint < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------
|
4
|
+
# Demonstrattion of Crude Adaptaion of C Function sprintf()
|
5
|
+
# to do formatted printing. For now there are some absolutes:
|
6
|
+
# The write_line method atkes as arguemnst the formatting string
|
7
|
+
# and the appropriate arguments. It format them to an internal
|
8
|
+
# buffer sepcified and created when you invoke formatted printing
|
9
|
+
# formatted_print :as => :line_buf, :buffer_size => 80
|
10
|
+
# now, to actual do it you use write_line
|
11
|
+
# write_line "Pies $%02d.%02d", pie_cents/100, pie_cents%100
|
12
|
+
# then print the string pointed at by string_line
|
13
|
+
# my_lcd.setxy 3, 2, line_buf
|
14
|
+
#
|
15
|
+
# Brian Riley - Underhill Center, VT, USA Aug 2008
|
16
|
+
# <brianbr@wulfden.org>
|
17
|
+
#
|
18
|
+
# ----------------------------------------------------------------------
|
19
|
+
|
20
|
+
# demonstrate 4 x 20 pa_lcd toggle between normal and Bignum mode
|
21
|
+
# with @toggle external variable thrown in for fun
|
22
|
+
|
23
|
+
# change your pins to suit your setup
|
24
|
+
|
25
|
+
@toggle = "0, int"
|
26
|
+
@pie_cents = "403, int"
|
27
|
+
@pie_price = "7.08"
|
28
|
+
|
29
|
+
|
30
|
+
input_pin 8, :as => :button_one, :device => :button
|
31
|
+
input_pin 9, :as => :button_two, :device => :button
|
32
|
+
input_pin 10, :as => :button_three, :device => :button
|
33
|
+
|
34
|
+
formatted_print :as => :string_line, :buffer_size => 65 # generally this statement should precede any serial_begin or
|
35
|
+
# LCD display directive
|
36
|
+
|
37
|
+
output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
38
|
+
|
39
|
+
|
40
|
+
def setup
|
41
|
+
my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
|
42
|
+
end
|
43
|
+
|
44
|
+
def loop
|
45
|
+
if millis % 500 == 0
|
46
|
+
write_line "millis()= %ld", millis
|
47
|
+
my_lcd.setxy 1, 2, string_line
|
48
|
+
end
|
49
|
+
say_hello if button_one.read_input
|
50
|
+
say_more if button_two.read_input
|
51
|
+
say_it_large if button_three.read_input
|
52
|
+
end
|
53
|
+
|
54
|
+
def say_hello
|
55
|
+
@toggle = true
|
56
|
+
my_lcd.clearscr "This sketch has?nbeen running for?n "
|
57
|
+
write_line "%ld mins and %d secs?n", millis/60000, (millis/1000)%60
|
58
|
+
my_lcd.print string_line
|
59
|
+
delay 3000
|
60
|
+
my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
|
61
|
+
end
|
62
|
+
|
63
|
+
def say_more # passing print strings to home and setxy (also works on clearscr)
|
64
|
+
@toggle = false
|
65
|
+
my_lcd.clearscr "Food Store Prices"
|
66
|
+
write_line "Pies $%2d.%02d", @pie_cents/100, @pie_cents%100
|
67
|
+
# write_line "Pies $%6.2f", @pie_price # float doessn't seem to work .....
|
68
|
+
my_lcd.setxy 2, 1, string_line
|
69
|
+
# write_line "toggle state is [%s]", @toggle ? "ON" : "OFF" # RubyToC screws this construct up and RAD mistajekl put 1 ad 0
|
70
|
+
# in place of "ON" and "OFF"
|
71
|
+
write_line "toggle state is [%d]", @toggle
|
72
|
+
my_lcd.setxy 2, 3, string_line
|
73
|
+
delay 3000
|
74
|
+
my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def say_it_large
|
79
|
+
|
80
|
+
my_lcd.intoBignum
|
81
|
+
my_lcd.clearscr # line 0, col 0
|
82
|
+
1.upto(32) do |i|
|
83
|
+
my_lcd.setxy 0,1
|
84
|
+
my_lcd.print i * i
|
85
|
+
delay 200
|
86
|
+
end
|
87
|
+
my_lcd.outofBignum
|
88
|
+
delay 3000
|
89
|
+
my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class HelloLcdCharset < ArduinoSketch
|
2
|
+
|
3
|
+
# -------------------------------------------------------------------------
|
4
|
+
# Program to Display the entire lower half (under 0x80) character set
|
5
|
+
#
|
6
|
+
# The class variable @a defined as byte is needed to make RubyToC put
|
7
|
+
# the value to be 'printed' as a byte and thus give us the character
|
8
|
+
# that value represents.
|
9
|
+
#
|
10
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
11
|
+
# <brianbr@wulfden.org>
|
12
|
+
#
|
13
|
+
# ----------------------------------------------------------------------
|
14
|
+
|
15
|
+
|
16
|
+
@a = byte
|
17
|
+
|
18
|
+
output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200
|
19
|
+
output_pin 13, :as => :led
|
20
|
+
|
21
|
+
def loop
|
22
|
+
|
23
|
+
myLCD.clearscr "Alphabet Chars?n"
|
24
|
+
0x41.upto(0x5a) do |i| # A to Z
|
25
|
+
@a = i # forces 'byte' typing to variable
|
26
|
+
myLCD.print @a # so print rouien prints character represented
|
27
|
+
delay 50 # by the index value
|
28
|
+
end
|
29
|
+
0x61.upto(0x7a) do |i| # a to z
|
30
|
+
@a = i
|
31
|
+
myLCD.print @a
|
32
|
+
delay 50
|
33
|
+
end
|
34
|
+
|
35
|
+
delay 3000
|
36
|
+
myLCD.clearscr "Numeric Chars?n"
|
37
|
+
0x30.upto(0x39) do |i| # 0 to 9
|
38
|
+
@a = i
|
39
|
+
myLCD.print @a
|
40
|
+
delay 50
|
41
|
+
end
|
42
|
+
|
43
|
+
delay 3000
|
44
|
+
|
45
|
+
myLCD.clearscr "Other Chars?n"
|
46
|
+
0x21.upto(0x2f) do |i| # punctuation et al
|
47
|
+
@a = i
|
48
|
+
myLCD.print @a
|
49
|
+
delay 50
|
50
|
+
end
|
51
|
+
0x3a.upto(0x40) do |i|
|
52
|
+
@a = i
|
53
|
+
myLCD.print @a
|
54
|
+
delay 50
|
55
|
+
end
|
56
|
+
0x5b.upto(0x60) do |i|
|
57
|
+
@a = i
|
58
|
+
myLCD.print @a
|
59
|
+
delay 50
|
60
|
+
end
|
61
|
+
0x7b.upto(0x7f) do |i|
|
62
|
+
@a = i
|
63
|
+
myLCD.print @a
|
64
|
+
delay 50
|
65
|
+
end
|
66
|
+
|
67
|
+
delay 3000
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
end
|