neo_rad 0.4.0
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.
- checksums.yaml +7 -0
- data/History.txt +112 -0
- data/License.txt +282 -0
- data/Manifest.txt +144 -0
- data/README.rdoc +1 -0
- data/Rakefile +142 -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 +112 -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/README.rdoc +5 -0
- data/lib/rad/arduino_plugin.rb +246 -0
- data/lib/rad/arduino_sketch.rb +628 -0
- data/lib/rad/darwin_installer.rb +23 -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 +15 -0
- data/lib/rad/linux_installer.rb +132 -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/lib/rad.rb +5 -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/hello_world_test/Makefile +436 -0
- data/test/hello_world_test/hello_world.cpp +23 -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 +222 -0
|
@@ -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,112 @@
|
|
|
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
|
+
## multidimensional arrays
|
|
28
|
+
array 'int @my_numbers[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}'
|
|
29
|
+
array 'char* @pizzas[2][4] = {{"margherita","funghi","napoletana","prosciutto cotto"},{"veggie","pepperoni","cheese","kitchen sink"}}'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def setup
|
|
36
|
+
|
|
37
|
+
my_lcd.clearscr "toppings: "
|
|
38
|
+
delay 500
|
|
39
|
+
|
|
40
|
+
@toppings.each do |a|
|
|
41
|
+
my_lcd.print a
|
|
42
|
+
my_lcd.print " "
|
|
43
|
+
delay 500
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
my_lcd.setxy 0,1, "pizzas: "
|
|
47
|
+
|
|
48
|
+
pizzas.each do |p|
|
|
49
|
+
my_lcd.print p
|
|
50
|
+
my_lcd.print " "
|
|
51
|
+
delay 500
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
my_lcd.setxy 0,2, "names: "
|
|
55
|
+
|
|
56
|
+
@names.each do |p|
|
|
57
|
+
my_lcd.print p
|
|
58
|
+
my_lcd.print " "
|
|
59
|
+
delay 500
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
delay 3000
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
my_lcd.clearline 1, @names[2]
|
|
67
|
+
my_lcd.print " [ "
|
|
68
|
+
my_lcd.print pizzas[1]
|
|
69
|
+
my_lcd.print " ]"
|
|
70
|
+
|
|
71
|
+
delay 2000
|
|
72
|
+
|
|
73
|
+
my_lcd.clearscr "Multidimensional ?n"
|
|
74
|
+
|
|
75
|
+
0.upto(2) do |f|
|
|
76
|
+
0.upto(3) do |s|
|
|
77
|
+
my_lcd.print @my_numbers[f][s]
|
|
78
|
+
my_lcd.print ", "
|
|
79
|
+
delay 500
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
delay 1000
|
|
84
|
+
|
|
85
|
+
my_lcd.clearscr
|
|
86
|
+
|
|
87
|
+
0.upto(1) do |f|
|
|
88
|
+
0.upto(3) do |s|
|
|
89
|
+
my_lcd.print @pizzas[f][s]
|
|
90
|
+
my_lcd.print ", "
|
|
91
|
+
delay 500
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
delay 2000
|
|
98
|
+
|
|
99
|
+
my_lcd.clearscr "Array Load?n"
|
|
100
|
+
1.upto(20) do |x|
|
|
101
|
+
# buffer[x] = 64 + x # we cannot set array elements yet except to initialize in declaration
|
|
102
|
+
my_lcd.print buffer[x-1]
|
|
103
|
+
my_lcd.print " "
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def loop
|
|
109
|
+
x = THROWAWAY
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
@@ -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
|