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.
Files changed (146) hide show
  1. checksums.yaml +7 -0
  2. data/History.txt +112 -0
  3. data/License.txt +282 -0
  4. data/Manifest.txt +144 -0
  5. data/README.rdoc +1 -0
  6. data/Rakefile +142 -0
  7. data/bin/rad +302 -0
  8. data/lib/examples/add_hysteresis.rb +13 -0
  9. data/lib/examples/basic_blink.rb +10 -0
  10. data/lib/examples/blink_m_address_assignment.rb +104 -0
  11. data/lib/examples/blink_m_hello.rb +14 -0
  12. data/lib/examples/blink_m_multi.rb +61 -0
  13. data/lib/examples/blink_with_serial.rb +16 -0
  14. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  15. data/lib/examples/debounce_methods.rb +49 -0
  16. data/lib/examples/external_variable_fu.rb +26 -0
  17. data/lib/examples/external_variables.rb +32 -0
  18. data/lib/examples/first_sound.rb +23 -0
  19. data/lib/examples/frequency_generator.rb +30 -0
  20. data/lib/examples/hello_array.rb +48 -0
  21. data/lib/examples/hello_array2.rb +112 -0
  22. data/lib/examples/hello_array_eeprom.rb +59 -0
  23. data/lib/examples/hello_clock.rb +84 -0
  24. data/lib/examples/hello_eeprom.rb +51 -0
  25. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  26. data/lib/examples/hello_format_print.rb +94 -0
  27. data/lib/examples/hello_lcd_charset.rb +75 -0
  28. data/lib/examples/hello_pa_lcd.rb +59 -0
  29. data/lib/examples/hello_servos.rb +88 -0
  30. data/lib/examples/hello_spectra_sound.rb +38 -0
  31. data/lib/examples/hello_world.rb +11 -0
  32. data/lib/examples/hello_xbee.rb +12 -0
  33. data/lib/examples/hysteresis_duel.rb +39 -0
  34. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  35. data/lib/examples/midi_beat_box.rb +86 -0
  36. data/lib/examples/midi_scales.rb +94 -0
  37. data/lib/examples/motor_knob.rb +30 -0
  38. data/lib/examples/servo_buttons.rb +23 -0
  39. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  40. data/lib/examples/servo_throttle.rb +40 -0
  41. data/lib/examples/software_serial.rb +10 -0
  42. data/lib/examples/sparkfun_lcd.rb +48 -0
  43. data/lib/examples/spectra_soft_pot.rb +34 -0
  44. data/lib/examples/times_method.rb +8 -0
  45. data/lib/examples/toggle.rb +10 -0
  46. data/lib/examples/twitter.rb +57 -0
  47. data/lib/examples/two_wire.rb +14 -0
  48. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  49. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  50. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  51. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  52. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  53. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  54. data/lib/libraries/DS1307/DS1307.h +66 -0
  55. data/lib/libraries/DS1307/keywords.txt +18 -0
  56. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  57. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  58. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  59. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  60. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  61. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  62. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  63. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  64. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  65. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  66. data/lib/libraries/OneWire/OneWire.h +63 -0
  67. data/lib/libraries/OneWire/keywords.txt +35 -0
  68. data/lib/libraries/OneWire/readme.txt +13 -0
  69. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +296 -0
  70. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +69 -0
  71. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  72. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  73. data/lib/libraries/Servo/Servo.cpp +192 -0
  74. data/lib/libraries/Servo/Servo.h +61 -0
  75. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  76. data/lib/libraries/Stepper/Stepper.h +86 -0
  77. data/lib/libraries/Stepper/keywords.txt +28 -0
  78. data/lib/libraries/Wire/Wire.cpp +262 -0
  79. data/lib/libraries/Wire/Wire.h +67 -0
  80. data/lib/libraries/Wire/keywords.txt +31 -0
  81. data/lib/libraries/Wire/twi.h +57 -0
  82. data/lib/libraries/Wire/utility/twi.c +449 -0
  83. data/lib/libraries/Wire/utility/twi.h +57 -0
  84. data/lib/plugins/bitwise_ops.rb +54 -0
  85. data/lib/plugins/blink.rb +25 -0
  86. data/lib/plugins/blink_m.rb +356 -0
  87. data/lib/plugins/debounce.rb +138 -0
  88. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  89. data/lib/plugins/hysteresis.rb +52 -0
  90. data/lib/plugins/input_output_state.rb +84 -0
  91. data/lib/plugins/lcd_padding.rb +58 -0
  92. data/lib/plugins/mem_test.rb +37 -0
  93. data/lib/plugins/midi.rb +60 -0
  94. data/lib/plugins/parallax_ping.rb +50 -0
  95. data/lib/plugins/servo_pulse.rb +31 -0
  96. data/lib/plugins/servo_setup.rb +86 -0
  97. data/lib/plugins/smoother.rb +54 -0
  98. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  99. data/lib/plugins/spectra_symbol.rb +79 -0
  100. data/lib/plugins/twitter_connect.rb +145 -0
  101. data/lib/rad/README.rdoc +5 -0
  102. data/lib/rad/arduino_plugin.rb +246 -0
  103. data/lib/rad/arduino_sketch.rb +628 -0
  104. data/lib/rad/darwin_installer.rb +23 -0
  105. data/lib/rad/generators/makefile/makefile.erb +243 -0
  106. data/lib/rad/generators/makefile/makefile.rb +38 -0
  107. data/lib/rad/hardware_library.rb +813 -0
  108. data/lib/rad/init.rb +15 -0
  109. data/lib/rad/linux_installer.rb +132 -0
  110. data/lib/rad/progressbar.rb +236 -0
  111. data/lib/rad/rad_processor.rb +128 -0
  112. data/lib/rad/rad_rewriter.rb +94 -0
  113. data/lib/rad/rad_type_checker.rb +26 -0
  114. data/lib/rad/sim/arduino_sketch.rb +57 -0
  115. data/lib/rad/sketch_compiler.rb +47 -0
  116. data/lib/rad/tasks/build_and_make.rake +210 -0
  117. data/lib/rad/tasks/rad.rb +2 -0
  118. data/lib/rad/todo.txt +13 -0
  119. data/lib/rad/variable_processing.rb +153 -0
  120. data/lib/rad/version.rb +9 -0
  121. data/lib/rad.rb +5 -0
  122. data/scripts/txt2html +67 -0
  123. data/setup.rb +1585 -0
  124. data/spec/examples/hello_world.rb +11 -0
  125. data/spec/examples/serial_motor.rb +12 -0
  126. data/spec/models/arduino_sketch_spec.rb +82 -0
  127. data/spec/models/sketch_compiler_spec.rb +96 -0
  128. data/spec/models/spec_helper.rb +2 -0
  129. data/spec/sim/hello_world_spec.rb +42 -0
  130. data/spec/spec.opts +1 -0
  131. data/test/hello_world_test/Makefile +436 -0
  132. data/test/hello_world_test/hello_world.cpp +23 -0
  133. data/test/test_array_processing.rb +179 -0
  134. data/test/test_plugin_loading.rb +151 -0
  135. data/test/test_translation_post_processing.rb +185 -0
  136. data/test/test_variable_processing.rb +238 -0
  137. data/website/examples/assembler_test.rb.html +73 -0
  138. data/website/examples/gps_reader.rb.html +39 -0
  139. data/website/examples/hello_world.rb.html +38 -0
  140. data/website/examples/serial_motor.rb.html +41 -0
  141. data/website/index.html +178 -0
  142. data/website/index.txt +64 -0
  143. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  144. data/website/stylesheets/screen.css +169 -0
  145. data/website/template.rhtml +48 -0
  146. metadata +222 -0
@@ -0,0 +1,243 @@
1
+ # Arduino makefile
2
+ #
3
+ # This makefile allows you to build sketches from the command line
4
+ # without the Arduino environment (or Java).
5
+ #
6
+ # The Arduino environment does preliminary processing on a sketch before
7
+ # compiling it. If you're using this makefile instead, you'll need to do
8
+ # a few things differently:
9
+ #
10
+ # - Give your program's file a .cpp extension (e.g. foo.cpp).
11
+ #
12
+ # - Put this line at top of your code: #include <WProgram.h>
13
+ #
14
+ # - Write prototypes for all your functions (or define them before you
15
+ # call them). A prototype declares the types of parameters a
16
+ # function will take and what type of value it will return. This
17
+ # means that you can have a call to a function before the definition
18
+ # of the function. A function prototype looks like the first line of
19
+ # the function, with a semi-colon at the end. For example:
20
+ # int digitalRead(int pin);
21
+ #
22
+ # - Write a main() function for your program that returns an int, calls
23
+ # init() and setup() once (in that order), and then calls loop()
24
+ # repeatedly():
25
+ #
26
+ # int main()
27
+ # {
28
+ # init();
29
+ # setup();
30
+ #
31
+ # for (;;)
32
+ # loop();
33
+ #
34
+ # return 0;
35
+ # }
36
+ #
37
+ # Instructions for using the makefile:
38
+ #
39
+ # 1. Copy this file into the folder with your sketch.
40
+ #
41
+ # 2. Below, modify the line containing "TARGET" to refer to the name of
42
+ # of your program's file without an extension (e.g. TARGET = foo).
43
+ #
44
+ # 3. Modify the line containg "ARDUINO" to point the directory that
45
+ # contains the Arduino core (for normal Arduino installations, this
46
+ # is the hardware/cores/arduino sub-directory).
47
+ #
48
+ # 4. Modify the line containing "PORT" to refer to the filename
49
+ # representing the USB or serial connection to your Arduino board
50
+ # (e.g. PORT = /dev/tty.USB0). If the exact name of this file
51
+ # changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*).
52
+ #
53
+ # 5. At the command line, change to the directory containing your
54
+ # program's file and the makefile.
55
+ #
56
+ # 6. Type "make" and press enter to compile/verify your program.
57
+ #
58
+ # 7. Type "make upload", reset your Arduino board, and press enter to
59
+ # upload your program to the Arduino board.
60
+ #
61
+ # $Id$
62
+
63
+ PORT = <%= params['serial_port'] %>
64
+ TARGET = <%= params['target'] %>
65
+ ARDUINO = <%= params['arduino_root'] %>/hardware/cores/arduino
66
+ SOFTWARE_SERIAL = <%= params['arduino_root'] %>/hardware/libraries/SoftwareSerial
67
+ LIBRARY_ROOT = <%= params['libraries_root'] %>
68
+ SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
69
+ $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
70
+ $(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
71
+ $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c <%= params['twi_c'] %>
72
+ CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(SOFTWARE_SERIAL)/SoftwareSerial.cpp $(ARDUINO)/Print.cpp<%= params['libraries'].collect{|l| " $(LIBRARY_ROOT)/#{ l }/#{l }.cpp"}.join('') %>
73
+ MCU = <%= params['mcu'] %>
74
+ <% if params['asm_files'] %>ASRC = <%= params['asm_files'].join(' ') %><% end %>
75
+ F_CPU = 16000000
76
+ FORMAT = ihex
77
+ UPLOAD_RATE = 19200
78
+ BIN_DIR = <%= params['arduino_root'] %>/hardware/tools/avr/bin
79
+
80
+ # Name of this Makefile (used for "make depend").
81
+ MAKEFILE = Makefile
82
+
83
+ # Debugging format.
84
+ # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
85
+ # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
86
+ DEBUG = stabs
87
+
88
+ OPT = s
89
+
90
+ # Place -D or -U options here
91
+ CDEFS = -DF_CPU=$(F_CPU)
92
+ CXXDEFS = -DF_CPU=$(F_CPU)
93
+
94
+ # Place -I options here
95
+ CINCS = -I$(ARDUINO) -I$(SOFTWARE_SERIAL)<% params['libraries'].each do |l| %> -I$(LIBRARY_ROOT)/<%= l %><% end %>
96
+ +CXXINCS = -I$(ARDUINO) -I$(SOFTWARE_SERIAL)<% params['libraries'].each do |l| %> -I$(LIBRARY_ROOT)/<%= l %><% end %>
97
+
98
+ # Compiler flag to set the C Standard level.
99
+ # c89 - "ANSI" C
100
+ # gnu89 - c89 plus GCC extensions
101
+ # c99 - ISO C99 standard (not yet fully implemented)
102
+ # gnu99 - c99 plus GCC extensions
103
+ CSTANDARD = -std=gnu99
104
+ CDEBUG = -g$(DEBUG)
105
+ CWARN = -Wall -Wstrict-prototypes
106
+ CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
107
+ #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
108
+
109
+ CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
110
+ CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
111
+ #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
112
+ LDFLAGS = -lm
113
+
114
+
115
+ # Programming support using avrdude. Settings and variables.
116
+ AVRDUDE_PROGRAMMER = stk500
117
+ AVRDUDE_PORT = $(PORT)
118
+ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
119
+ AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
120
+ -b $(UPLOAD_RATE) -C <%= params['arduino_root'] %>/hardware/tools/avr/etc/avrdude.conf
121
+
122
+ # Program settings
123
+ CC = $(BIN_DIR)/avr-gcc
124
+ CXX = $(BIN_DIR)/avr-g++
125
+ OBJCOPY = $(BIN_DIR)/avr-objcopy
126
+ OBJDUMP = $(BIN_DIR)/avr-objdump
127
+ AR = $(BIN_DIR)/avr-ar
128
+ SIZE = $(BIN_DIR)/avr-size
129
+ NM = $(BIN_DIR)/avr-nm
130
+ AVRDUDE = $(BIN_DIR)/avrdude
131
+ REMOVE = rm -f
132
+ MV = mv -f
133
+
134
+ # Define all object files.
135
+ OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
136
+
137
+ # Define all listing files.
138
+ LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
139
+
140
+ # Combine all necessary flags and optional flags.
141
+ # Add target processor to flags.
142
+ ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
143
+ ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
144
+ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
145
+
146
+
147
+ # Default target.
148
+ all: build
149
+
150
+ build: elf hex
151
+
152
+ elf: $(TARGET).elf
153
+ hex: $(TARGET).hex
154
+ eep: $(TARGET).eep
155
+ lss: $(TARGET).lss
156
+ sym: $(TARGET).sym
157
+
158
+ # Program the device.
159
+ upload: $(TARGET).hex
160
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
161
+
162
+
163
+
164
+
165
+ # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
166
+ COFFCONVERT=$(OBJCOPY) --debugging \
167
+ --change-section-address .data-0x800000 \
168
+ --change-section-address .bss-0x800000 \
169
+ --change-section-address .noinit-0x800000 \
170
+ --change-section-address .eeprom-0x810000
171
+
172
+
173
+ coff: $(TARGET).elf
174
+ $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
175
+
176
+
177
+ extcoff: $(TARGET).elf
178
+ $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
179
+
180
+
181
+ .SUFFIXES: .elf .hex .eep .lss .sym
182
+
183
+ .elf.hex:
184
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
185
+
186
+ .elf.eep:
187
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
188
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
189
+
190
+ # Create extended listing file from ELF output file.
191
+ .elf.lss:
192
+ $(OBJDUMP) -h -S $< > $@
193
+
194
+ # Create a symbol table from ELF output file.
195
+ .elf.sym:
196
+ $(NM) -n $< > $@
197
+
198
+
199
+ core.a: $(OBJ)
200
+ @for i in $(OBJ); do echo $(AR) rcs core.a $$i; $(AR) rcs core.a $$i; done
201
+
202
+ # Link: create ELF output file from library.
203
+ $(TARGET).elf: core.a
204
+ $(CC) $(ALL_CFLAGS) -o $@ $(TARGET).cpp -L. core.a $(LDFLAGS)
205
+
206
+ # Compile: create object files from C++ source files.
207
+ .cpp.o:
208
+ $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
209
+
210
+ # Compile: create object files from C source files.
211
+ .c.o:
212
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
213
+
214
+
215
+ # Compile: create assembler files from C source files.
216
+ .c.s:
217
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
218
+
219
+
220
+ # Assemble: create object files from assembler source files.
221
+ .S.o:
222
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
223
+
224
+
225
+
226
+ # Target: clean project.
227
+ clean:
228
+ $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
229
+ $(TARGET).map $(TARGET).sym $(TARGET).lss core.a \
230
+ $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
231
+
232
+ depend:
233
+ if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
234
+ then \
235
+ sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
236
+ $(MAKEFILE).$$$$ && \
237
+ $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
238
+ fi
239
+ echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
240
+ >> $(MAKEFILE); \
241
+ $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
242
+
243
+ .PHONY: all build elf hex eep lss sym program coff extcoff clean depend
@@ -0,0 +1,38 @@
1
+ require 'erb'
2
+ require 'yaml'
3
+
4
+ class Makefile
5
+ class << self
6
+
7
+ # build the sketch Makefile for the given template based on the values in its software and hardware config files
8
+ def compose_for_sketch(build_dir)
9
+ params = hardware_params.merge software_params
10
+ params['target'] = build_dir.split("/").last
11
+
12
+ params['libraries_root'] = "#{File.expand_path(RAD_ROOT)}/vendor/libraries"
13
+ params['libraries'] = $load_libraries # load only libraries used
14
+
15
+ # needed along with ugly hack of including another copy of twi.h in wire, when using the Wire.h library
16
+ params['twi_c'] = $load_libraries.include?("Wire") ? "#{params['arduino_root']}/hardware/libraries/Wire/utility/twi.c" : ""
17
+
18
+ params['asm_files'] = Dir.entries( File.expand_path(RAD_ROOT) + "/" + PROJECT_DIR_NAME ).select{|e| e =~ /\.S/}
19
+
20
+ e = ERB.new File.read("#{File.dirname(__FILE__)}/makefile.erb")
21
+
22
+ File.open("#{build_dir}/Makefile", "w") do |f|
23
+ f << e.result(binding)
24
+ end
25
+ end
26
+
27
+ def hardware_params
28
+ return @hardware_params if @hardware_params
29
+ return @hardware_params = YAML.load_file( "#{RAD_ROOT}/config/hardware.yml")
30
+ end
31
+
32
+ def software_params
33
+ return @software_params if @software_params
34
+ return @software_params = YAML.load_file( "#{RAD_ROOT}/config/software.yml" )
35
+ end
36
+
37
+ end
38
+ end