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.
- data/History.txt +14 -0
- data/Manifest.txt +41 -18
- data/Rakefile +5 -0
- data/bin/rad +16 -6
- data/lib/examples/blink_m_address_assignment.rb +104 -0
- data/lib/examples/blink_m_multi.rb +61 -0
- data/lib/examples/configure_pa_lcd_boot.rb +91 -0
- data/lib/examples/external_variables.rb +5 -1
- data/lib/examples/hello_array.rb +48 -0
- data/lib/examples/hello_array2.rb +79 -0
- data/lib/examples/hello_array_eeprom.rb +61 -0
- data/lib/examples/hello_eeprom.rb +4 -7
- data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
- data/lib/examples/hello_lcd_charset.rb +75 -0
- data/lib/examples/hello_pa_lcd.rb +59 -0
- data/lib/examples/hysteresis_duel.rb +39 -0
- data/lib/examples/motor_knob.rb +30 -0
- data/lib/examples/orig_servo_throttle.rb +1 -1
- data/lib/examples/servo_calibrate_continuous.rb +92 -0
- data/lib/examples/servo_throttle.rb +1 -1
- data/lib/examples/sparkfun_lcd.rb +2 -2
- data/lib/examples/spectra_soft_pot.rb +34 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +60 -25
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +8 -2
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +46 -27
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +5 -2
- 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/utility/twi.c +449 -0
- data/lib/libraries/Wire/utility/twi.h +57 -0
- data/lib/plugins/blink_m.rb +79 -46
- data/lib/plugins/hysteresis.rb +52 -0
- data/lib/plugins/lcd_padding.rb +39 -0
- data/lib/plugins/spectra_symbol.rb +79 -0
- data/lib/rad/arduino_plugin.rb +21 -0
- data/lib/rad/arduino_sketch.rb +231 -53
- data/lib/rad/init.rb +2 -2
- data/lib/rad/rad_processor.rb +42 -1
- data/lib/rad/rad_type_checker.rb +26 -0
- data/lib/rad/sim/arduino_sketch.rb +57 -0
- data/lib/rad/tasks/build_and_make.rake +4 -4
- data/lib/rad/variable_processing.rb +49 -12
- data/lib/rad/version.rb +1 -1
- 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/{lib/test → test}/test_variable_processing.rb +63 -13
- data/website/index.html +8 -7
- metadata +66 -30
- data/lib/test/test_array_processing.rb +0 -78
@@ -1,5 +1,8 @@
|
|
1
1
|
class ExternalVariables < ArduinoSketch
|
2
2
|
|
3
|
+
define "KOOL 10"
|
4
|
+
define "TRUE 1"
|
5
|
+
define "COMMENT true"
|
3
6
|
define "DS1307_CTRL 7"
|
4
7
|
define "DS1308_CTRL 7"
|
5
8
|
array "char buffer[32];"
|
@@ -17,7 +20,7 @@ class ExternalVariables < ArduinoSketch
|
|
17
20
|
|
18
21
|
delay 1
|
19
22
|
@foo = 2
|
20
|
-
|
23
|
+
@foo = KOOL
|
21
24
|
end
|
22
25
|
|
23
26
|
def setup # special one time only method
|
@@ -25,6 +28,7 @@ class ExternalVariables < ArduinoSketch
|
|
25
28
|
delay 100
|
26
29
|
@foo = 10
|
27
30
|
5.times { delay 200 }
|
31
|
+
|
28
32
|
end
|
29
33
|
|
30
34
|
|
@@ -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
|
@@ -0,0 +1,61 @@
|
|
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
|
+
define "EEPROM_ADDR 0x50"
|
19
|
+
|
20
|
+
|
21
|
+
# when we just need to declare an array, or need more control, such as specific type requirements
|
22
|
+
array "byte page_data[20] = {'A', 'B', 'Z', 'C', 'Y', 'D', 'W', 'E', '%', 'H', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
|
23
|
+
array "byte in_buffer[20]"
|
24
|
+
|
25
|
+
output_pin 19, :as => :mem0, :device => :i2c_eeprom, :enable => :true
|
26
|
+
output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200
|
27
|
+
|
28
|
+
|
29
|
+
def setup
|
30
|
+
|
31
|
+
my_lcd.clearscr " I2C EEPROM Demo"
|
32
|
+
my_lcd.setxy 0, 1, "block write and read"
|
33
|
+
my_lcd.setxy 0, 2, " back and display"
|
34
|
+
my_lcd.setxy 0, 3, " to the LCD"
|
35
|
+
|
36
|
+
delay 2000
|
37
|
+
|
38
|
+
my_lcd.clearscr " I2C EEPROM Demo?n block write"
|
39
|
+
|
40
|
+
i2c_eeprom_write_page 0x50, 0x0040, page_data, 20
|
41
|
+
|
42
|
+
delay 1000
|
43
|
+
|
44
|
+
my_lcd.clearline 1, " block readback"
|
45
|
+
|
46
|
+
i2c_eeprom_read_buffer 0x50, 0x0040, in_buffer, 20
|
47
|
+
|
48
|
+
my_lcd.setxy 0, 2
|
49
|
+
|
50
|
+
1.upto(20) do |x|
|
51
|
+
my_lcd.print in_buffer[x-1]
|
52
|
+
my_lcd.print " "
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def loop
|
58
|
+
x = THROWAWAY
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -6,7 +6,7 @@ class HelloEeprom < ArduinoSketch
|
|
6
6
|
output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200
|
7
7
|
|
8
8
|
def loop
|
9
|
-
myLCD.
|
9
|
+
myLCD.setxy 0,0 # set to 0,0
|
10
10
|
myLCD.print rtc.get(5, 1) # refresh registers (=1) get month
|
11
11
|
myLCD.print "/"
|
12
12
|
myLCD.print rtc.get(4, 0) # no need to refresh (=0) get day
|
@@ -31,13 +31,10 @@ class HelloEeprom < ArduinoSketch
|
|
31
31
|
|
32
32
|
delay 2000
|
33
33
|
|
34
|
-
myLCD.
|
35
|
-
myLCD.
|
36
|
-
myLCD.setxy 0,3
|
37
|
-
myLCD.print "?l"
|
34
|
+
myLCD.clearline 2 # clears bottom two lines
|
35
|
+
myLCD.clearline 3
|
38
36
|
|
39
|
-
myLCD.setxy 10,0
|
40
|
-
myLCD.print "read test "
|
37
|
+
myLCD.setxy 10,0, "read test "
|
41
38
|
myLCD.setxy 0,2
|
42
39
|
# read and print 39 addresses with printable numbers
|
43
40
|
75.upto(113) { |x| myLCD.print(i2c_eeprom_read_byte(0x50, x)) }
|
@@ -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| i2c_eeprom_write_byte 0x50, x, x
|
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
|
+
75.upto(113) { |x| myLCD.print(i2c_eeprom_read_byte(0x50, 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,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
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class HelloPaLcd < ArduinoSketch
|
2
|
+
|
3
|
+
|
4
|
+
# demonstrate 4 x 20 pa_lcd toggle between normal and Bignum mode
|
5
|
+
# with @toggle external variable thrown in for fun
|
6
|
+
|
7
|
+
# change your pins to suit your setup
|
8
|
+
|
9
|
+
@toggle = false
|
10
|
+
|
11
|
+
input_pin 6, :as => :button_one, :device => :button
|
12
|
+
input_pin 7, :as => :button_two, :device => :button
|
13
|
+
input_pin 8, :as => :button_three, :device => :button
|
14
|
+
|
15
|
+
output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
16
|
+
|
17
|
+
def setup
|
18
|
+
delay 3000
|
19
|
+
my_lcd.setxy 0,0
|
20
|
+
my_lcd.print "Press button"
|
21
|
+
my_lcd.setxy 0,1
|
22
|
+
my_lcd.print "One, two or three...."
|
23
|
+
end
|
24
|
+
|
25
|
+
def loop
|
26
|
+
say_hello if button_one.read_input
|
27
|
+
say_more if button_two.read_input
|
28
|
+
say_it_large if button_three.read_input
|
29
|
+
end
|
30
|
+
|
31
|
+
def say_hello
|
32
|
+
@toggle = true
|
33
|
+
my_lcd.clearscr "Any sufficiently advanced technology"
|
34
|
+
my_lcd.setxy 0,2
|
35
|
+
my_lcd.setxy 0,3, "toggle state: "
|
36
|
+
my_lcd.print @toggle
|
37
|
+
end
|
38
|
+
|
39
|
+
def say_more # passing print strings to home and setxy (also works on clearscr)
|
40
|
+
@toggle = false
|
41
|
+
my_lcd.clearscr "is indistinguishablefrom magic"
|
42
|
+
my_lcd.setxy 0,3, "toggle state: "
|
43
|
+
my_lcd.print @toggle
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def say_it_large
|
48
|
+
|
49
|
+
my_lcd.intoBignum
|
50
|
+
my_lcd.clearscr # line 0, col 0
|
51
|
+
1.upto(32) do |i|
|
52
|
+
my_lcd.setxy 0,1
|
53
|
+
my_lcd.print i * i
|
54
|
+
delay 200
|
55
|
+
end
|
56
|
+
my_lcd.outofBignum
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|