Permalink
Browse files

brought the madrona branch up to date and added ruby 1.9.x support --…

… very beta
  • Loading branch information...
1 parent 10ae4b0 commit cbd801bb5761982cb9d29ed4fd28a21e68230a17 @madrona committed Aug 17, 2009
Showing with 17,523 additions and 1,398 deletions.
  1. +4 −16 History.txt
  2. +38 −5 Manifest.txt
  3. +19 −7 README.rdoc
  4. +3 −2 Rakefile
  5. +214 −130 bin/rad
  6. +10 −0 lib/examples/basic_blink.rb
  7. +16 −0 lib/examples/blink_with_serial.rb
  8. +21 −19 lib/examples/external_variable_fu.rb
  9. +0 −3 lib/examples/external_variables.rb
  10. +34 −1 lib/examples/hello_array2.rb
  11. +4 −6 lib/examples/hello_array_eeprom.rb
  12. +84 −0 lib/examples/hello_clock.rb
  13. +3 −3 lib/examples/hello_eeprom.rb
  14. +2 −2 lib/examples/hello_eeprom_lcdpa.rb
  15. +94 −0 lib/examples/hello_format_print.rb
  16. +38 −0 lib/examples/hello_spectra_sound.rb
  17. +3 −3 lib/examples/hello_world.rb
  18. +12 −0 lib/examples/hello_xbee.rb
  19. +86 −0 lib/examples/midi_beat_box.rb
  20. +94 −0 lib/examples/midi_scales.rb
  21. +10 −0 lib/examples/software_serial.rb
  22. +57 −0 lib/examples/twitter.rb
  23. +321 −0 lib/libraries/AFSoftSerial/AFSoftSerial.cpp
  24. +61 −0 lib/libraries/AFSoftSerial/AFSoftSerial.h
  25. +18 −25 lib/libraries/{Servo → AFSoftSerial}/keywords.txt
  26. +166 −0 lib/libraries/AF_XPort/AF_XPort.cpp
  27. +48 −0 lib/libraries/AF_XPort/AF_XPort.h
  28. +10 −9 lib/libraries/DS1307/DS1307.cpp
  29. +6 −4 lib/libraries/DS1307/DS1307.h
  30. +120 −0 lib/libraries/I2CEEPROM/I2CEEPROM.cpp
  31. +70 −0 lib/libraries/I2CEEPROM/I2CEEPROM.h
  32. +21 −0 lib/libraries/I2CEEPROM/keywords.txt
  33. +35 −0 lib/libraries/LoopTimer/LoopTimer.cpp
  34. +34 −0 lib/libraries/LoopTimer/LoopTimer.h
  35. +27 −0 lib/libraries/LoopTimer/keywords.txt
  36. +42 −48 lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp
  37. +11 −12 lib/libraries/SWSerLCDpa/SWSerLCDpa.h
  38. +38 −0 lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
  39. +9 −2 lib/libraries/SWSerLCDsf/SWSerLCDsf.h
  40. BIN lib/plugins/.DS_Store
  41. +25 −0 lib/plugins/blink.rb
  42. +3 −3 lib/plugins/blink_m.rb
  43. +0 −70 lib/plugins/i2c_eeprom.rb
  44. +60 −0 lib/plugins/midi.rb
  45. +50 −0 lib/plugins/parallax_ping.rb
  46. +1 −1 lib/plugins/servo_setup.rb
  47. +145 −0 lib/plugins/twitter_connect.rb
  48. +5 −0 lib/rad/README.rdoc
  49. +93 −851 lib/rad/arduino_sketch.rb
  50. +23 −0 lib/rad/darwin_installer.rb
  51. +1 −1 lib/rad/generators/makefile/makefile.erb
  52. +3 −3 lib/rad/generators/makefile/makefile.rb
  53. +813 −0 lib/rad/hardware_library.rb
  54. +4 −2 lib/rad/init.rb
  55. +132 −0 lib/rad/linux_installer.rb
  56. +236 −0 lib/rad/progressbar.rb
  57. +56 −9 lib/rad/rad_processor.rb
  58. +7 −2 lib/rad/rad_rewriter.rb
  59. +1 −1 lib/rad/rad_type_checker.rb
  60. +47 −0 lib/rad/sketch_compiler.rb
  61. +41 −47 lib/rad/tasks/build_and_make.rake
  62. +0 −93 lib/rad/tasks/developer.rake
  63. +2 −2 lib/rad/version.rb
  64. BIN pkg/rad-0.3.1.gem
  65. BIN pkg/rad-0.3.1.tgz
  66. +109 −0 pkg/rad-0.3.1/History.txt
  67. +282 −0 pkg/rad-0.3.1/License.txt
  68. +144 −0 pkg/rad-0.3.1/Manifest.txt
  69. +63 −0 pkg/rad-0.3.1/README.rdoc
  70. +145 −0 pkg/rad-0.3.1/Rakefile
  71. +302 −0 pkg/rad-0.3.1/bin/rad
  72. +13 −0 pkg/rad-0.3.1/lib/examples/add_hysteresis.rb
  73. +10 −0 pkg/rad-0.3.1/lib/examples/basic_blink.rb
  74. +104 −0 pkg/rad-0.3.1/lib/examples/blink_m_address_assignment.rb
  75. +14 −0 pkg/rad-0.3.1/lib/examples/blink_m_hello.rb
  76. +61 −0 pkg/rad-0.3.1/lib/examples/blink_m_multi.rb
  77. +16 −0 pkg/rad-0.3.1/lib/examples/blink_with_serial.rb
  78. +91 −0 pkg/rad-0.3.1/lib/examples/configure_pa_lcd_boot.rb
  79. +49 −0 pkg/rad-0.3.1/lib/examples/debounce_methods.rb
  80. +26 −0 pkg/rad-0.3.1/lib/examples/external_variable_fu.rb
  81. +32 −0 pkg/rad-0.3.1/lib/examples/external_variables.rb
  82. +23 −0 pkg/rad-0.3.1/lib/examples/first_sound.rb
  83. +30 −0 pkg/rad-0.3.1/lib/examples/frequency_generator.rb
  84. +48 −0 pkg/rad-0.3.1/lib/examples/hello_array.rb
  85. +112 −0 pkg/rad-0.3.1/lib/examples/hello_array2.rb
  86. +59 −0 pkg/rad-0.3.1/lib/examples/hello_array_eeprom.rb
  87. +84 −0 pkg/rad-0.3.1/lib/examples/hello_clock.rb
  88. +51 −0 pkg/rad-0.3.1/lib/examples/hello_eeprom.rb
  89. +81 −0 pkg/rad-0.3.1/lib/examples/hello_eeprom_lcdpa.rb
  90. +94 −0 pkg/rad-0.3.1/lib/examples/hello_format_print.rb
  91. +75 −0 pkg/rad-0.3.1/lib/examples/hello_lcd_charset.rb
  92. +59 −0 pkg/rad-0.3.1/lib/examples/hello_pa_lcd.rb
  93. +88 −0 pkg/rad-0.3.1/lib/examples/hello_servos.rb
  94. +38 −0 pkg/rad-0.3.1/lib/examples/hello_spectra_sound.rb
  95. +11 −0 pkg/rad-0.3.1/lib/examples/hello_world.rb
  96. +12 −0 pkg/rad-0.3.1/lib/examples/hello_xbee.rb
  97. +39 −0 pkg/rad-0.3.1/lib/examples/hysteresis_duel.rb
  98. +124 −0 pkg/rad-0.3.1/lib/examples/i2c_with_clock_chip.rb
  99. +86 −0 pkg/rad-0.3.1/lib/examples/midi_beat_box.rb
  100. +94 −0 pkg/rad-0.3.1/lib/examples/midi_scales.rb
  101. +30 −0 pkg/rad-0.3.1/lib/examples/motor_knob.rb
  102. +23 −0 pkg/rad-0.3.1/lib/examples/servo_buttons.rb
  103. +92 −0 pkg/rad-0.3.1/lib/examples/servo_calibrate_continuous.rb
  104. +9 −15 lib/examples/orig_servo_throttle.rb → pkg/rad-0.3.1/lib/examples/servo_throttle.rb
  105. +10 −0 pkg/rad-0.3.1/lib/examples/software_serial.rb
  106. +48 −0 pkg/rad-0.3.1/lib/examples/sparkfun_lcd.rb
  107. +34 −0 pkg/rad-0.3.1/lib/examples/spectra_soft_pot.rb
  108. +8 −0 pkg/rad-0.3.1/lib/examples/times_method.rb
  109. +10 −0 pkg/rad-0.3.1/lib/examples/toggle.rb
  110. +57 −0 pkg/rad-0.3.1/lib/examples/twitter.rb
  111. +14 −0 pkg/rad-0.3.1/lib/examples/two_wire.rb
  112. +321 −0 pkg/rad-0.3.1/lib/libraries/AFSoftSerial/AFSoftSerial.cpp
  113. +61 −0 pkg/rad-0.3.1/lib/libraries/AFSoftSerial/AFSoftSerial.h
  114. +18 −0 pkg/rad-0.3.1/lib/libraries/AFSoftSerial/keywords.txt
  115. +166 −0 pkg/rad-0.3.1/lib/libraries/AF_XPort/AF_XPort.cpp
  116. +48 −0 pkg/rad-0.3.1/lib/libraries/AF_XPort/AF_XPort.h
  117. +162 −0 pkg/rad-0.3.1/lib/libraries/DS1307/DS1307.cpp
  118. +66 −0 pkg/rad-0.3.1/lib/libraries/DS1307/DS1307.h
  119. +18 −0 pkg/rad-0.3.1/lib/libraries/DS1307/keywords.txt
  120. +144 −0 pkg/rad-0.3.1/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp
  121. +42 −0 pkg/rad-0.3.1/lib/libraries/FrequencyTimer2/FrequencyTimer2.h
  122. +22 −0 pkg/rad-0.3.1/lib/libraries/FrequencyTimer2/keywords.txt
  123. +120 −0 pkg/rad-0.3.1/lib/libraries/I2CEEPROM/I2CEEPROM.cpp
  124. +70 −0 pkg/rad-0.3.1/lib/libraries/I2CEEPROM/I2CEEPROM.h
  125. +21 −0 pkg/rad-0.3.1/lib/libraries/I2CEEPROM/keywords.txt
  126. +35 −0 pkg/rad-0.3.1/lib/libraries/LoopTimer/LoopTimer.cpp
  127. +34 −0 pkg/rad-0.3.1/lib/libraries/LoopTimer/LoopTimer.h
  128. +27 −0 pkg/rad-0.3.1/lib/libraries/LoopTimer/keywords.txt
  129. +194 −0 pkg/rad-0.3.1/lib/libraries/OneWire/OneWire.cpp
  130. +63 −0 pkg/rad-0.3.1/lib/libraries/OneWire/OneWire.h
  131. +35 −0 pkg/rad-0.3.1/lib/libraries/OneWire/keywords.txt
  132. +13 −0 pkg/rad-0.3.1/lib/libraries/OneWire/readme.txt
  133. +296 −0 pkg/rad-0.3.1/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp
  134. +69 −0 pkg/rad-0.3.1/lib/libraries/SWSerLCDpa/SWSerLCDpa.h
  135. +311 −0 pkg/rad-0.3.1/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
  136. +67 −0 pkg/rad-0.3.1/lib/libraries/SWSerLCDsf/SWSerLCDsf.h
  137. +192 −0 pkg/rad-0.3.1/lib/libraries/Servo/Servo.cpp
  138. +61 −0 pkg/rad-0.3.1/lib/libraries/Servo/Servo.h
  139. +220 −0 pkg/rad-0.3.1/lib/libraries/Stepper/Stepper.cpp
  140. +86 −0 pkg/rad-0.3.1/lib/libraries/Stepper/Stepper.h
  141. +28 −0 pkg/rad-0.3.1/lib/libraries/Stepper/keywords.txt
  142. +262 −0 pkg/rad-0.3.1/lib/libraries/Wire/Wire.cpp
  143. +67 −0 pkg/rad-0.3.1/lib/libraries/Wire/Wire.h
  144. +31 −0 pkg/rad-0.3.1/lib/libraries/Wire/keywords.txt
  145. +57 −0 pkg/rad-0.3.1/lib/libraries/Wire/twi.h
  146. +449 −0 pkg/rad-0.3.1/lib/libraries/Wire/utility/twi.c
  147. +57 −0 pkg/rad-0.3.1/lib/libraries/Wire/utility/twi.h
  148. +54 −0 pkg/rad-0.3.1/lib/plugins/bitwise_ops.rb
  149. +25 −0 pkg/rad-0.3.1/lib/plugins/blink.rb
  150. +356 −0 pkg/rad-0.3.1/lib/plugins/blink_m.rb
  151. +138 −0 pkg/rad-0.3.1/lib/plugins/debounce.rb
  152. +71 −0 pkg/rad-0.3.1/lib/plugins/debug_output_to_lcd.rb
  153. +52 −0 pkg/rad-0.3.1/lib/plugins/hysteresis.rb
  154. +84 −0 pkg/rad-0.3.1/lib/plugins/input_output_state.rb
  155. +58 −0 pkg/rad-0.3.1/lib/plugins/lcd_padding.rb
  156. +37 −0 pkg/rad-0.3.1/lib/plugins/mem_test.rb
  157. +60 −0 pkg/rad-0.3.1/lib/plugins/midi.rb
  158. +50 −0 pkg/rad-0.3.1/lib/plugins/parallax_ping.rb
  159. +31 −0 pkg/rad-0.3.1/lib/plugins/servo_pulse.rb
  160. +86 −0 pkg/rad-0.3.1/lib/plugins/servo_setup.rb
  161. +54 −0 pkg/rad-0.3.1/lib/plugins/smoother.rb
  162. +100 −0 pkg/rad-0.3.1/lib/plugins/spark_fun_serial_lcd.rb
  163. +79 −0 pkg/rad-0.3.1/lib/plugins/spectra_symbol.rb
  164. +145 −0 pkg/rad-0.3.1/lib/plugins/twitter_connect.rb
  165. +5 −0 pkg/rad-0.3.1/lib/rad.rb
  166. +5 −0 pkg/rad-0.3.1/lib/rad/README.rdoc
  167. +246 −0 pkg/rad-0.3.1/lib/rad/arduino_plugin.rb
  168. +628 −0 pkg/rad-0.3.1/lib/rad/arduino_sketch.rb
  169. +23 −0 pkg/rad-0.3.1/lib/rad/darwin_installer.rb
  170. +243 −0 pkg/rad-0.3.1/lib/rad/generators/makefile/makefile.erb
  171. +38 −0 pkg/rad-0.3.1/lib/rad/generators/makefile/makefile.rb
  172. +813 −0 pkg/rad-0.3.1/lib/rad/hardware_library.rb
  173. +16 −0 pkg/rad-0.3.1/lib/rad/init.rb
  174. +132 −0 pkg/rad-0.3.1/lib/rad/linux_installer.rb
  175. +236 −0 pkg/rad-0.3.1/lib/rad/progressbar.rb
  176. +165 −0 pkg/rad-0.3.1/lib/rad/rad_processor.rb
  177. +99 −0 pkg/rad-0.3.1/lib/rad/rad_rewriter.rb
  178. +26 −0 pkg/rad-0.3.1/lib/rad/rad_type_checker.rb
  179. +57 −0 pkg/rad-0.3.1/lib/rad/sim/arduino_sketch.rb
  180. +47 −0 pkg/rad-0.3.1/lib/rad/sketch_compiler.rb
  181. +211 −0 pkg/rad-0.3.1/lib/rad/tasks/build_and_make.rake
  182. +2 −0 pkg/rad-0.3.1/lib/rad/tasks/rad.rb
  183. +13 −0 pkg/rad-0.3.1/lib/rad/todo.txt
  184. +153 −0 pkg/rad-0.3.1/lib/rad/variable_processing.rb
  185. +9 −0 pkg/rad-0.3.1/lib/rad/version.rb
  186. +67 −0 pkg/rad-0.3.1/scripts/txt2html
  187. +1,585 −0 pkg/rad-0.3.1/setup.rb
  188. +4 −1 spec/examples/hello_world.rb~ → pkg/rad-0.3.1/spec/examples/hello_world.rb
  189. +12 −0 pkg/rad-0.3.1/spec/examples/serial_motor.rb
  190. +82 −0 pkg/rad-0.3.1/spec/models/arduino_sketch_spec.rb
  191. +96 −0 pkg/rad-0.3.1/spec/models/sketch_compiler_spec.rb
  192. +2 −0 pkg/rad-0.3.1/spec/models/spec_helper.rb
  193. 0 { → pkg/rad-0.3.1}/spec/sim/hello_world_spec.rb
  194. +1 −0 pkg/rad-0.3.1/spec/spec.opts
  195. +436 −0 pkg/rad-0.3.1/test/hello_world_test/Makefile
  196. +23 −0 pkg/rad-0.3.1/test/hello_world_test/hello_world.cpp
Sorry, we could not display the entire diff because it was too big.
View
20 History.txt
@@ -1,19 +1,7 @@
-== 0.2.7 2008-07-31
-* Forcing gem build
-
-== 0.2.6 2008-07-30
-* Tres grand update:
- - added support for spectra_soft_pots
- - added support and examples for blinkMs
- - added multi sensor hysteresis -- formerly one sensor only
- - added testing for plugin loading
- - external arrays now have cool instance style plus
- - drop down the metal style declarations
- - iteration on external arrays now works. internal still problematic
- - defines now work handily
- - numerous lcd library changes plus enhancements: setxy 0,1, "print_something"
- - lots of examples
- - and much more
+== 0.3.0 2008-09-22
+* Pushing to rubyforge..
+ - added rad install arduino
+ - added rad test arduino
== 0.2.5 2008-07-21
* 1ish large post Bastille Day update:
View
43 Manifest.txt
@@ -5,9 +5,11 @@ README.rdoc
Rakefile
bin/rad
lib/examples/add_hysteresis.rb
+lib/examples/basic_blink.rb
lib/examples/blink_m_address_assignment.rb
lib/examples/blink_m_hello.rb
lib/examples/blink_m_multi.rb
+lib/examples/blink_with_serial.rb
lib/examples/configure_pa_lcd_boot.rb
lib/examples/debounce_methods.rb
lib/examples/external_variable_fu.rb
@@ -17,30 +19,48 @@ lib/examples/frequency_generator.rb
lib/examples/hello_array.rb
lib/examples/hello_array2.rb
lib/examples/hello_array_eeprom.rb
+lib/examples/hello_clock.rb
lib/examples/hello_eeprom.rb
lib/examples/hello_eeprom_lcdpa.rb
+lib/examples/hello_format_print.rb
lib/examples/hello_lcd_charset.rb
lib/examples/hello_pa_lcd.rb
lib/examples/hello_servos.rb
+lib/examples/hello_spectra_sound.rb
lib/examples/hello_world.rb
+lib/examples/hello_xbee.rb
lib/examples/hysteresis_duel.rb
lib/examples/i2c_with_clock_chip.rb
+lib/examples/midi_beat_box.rb
+lib/examples/midi_scales.rb
lib/examples/motor_knob.rb
-lib/examples/orig_servo_throttle.rb
lib/examples/servo_buttons.rb
lib/examples/servo_calibrate_continuous.rb
lib/examples/servo_throttle.rb
+lib/examples/software_serial.rb
lib/examples/sparkfun_lcd.rb
lib/examples/spectra_soft_pot.rb
lib/examples/times_method.rb
lib/examples/toggle.rb
+lib/examples/twitter.rb
lib/examples/two_wire.rb
+lib/libraries/AFSoftSerial/AFSoftSerial.cpp
+lib/libraries/AFSoftSerial/AFSoftSerial.h
+lib/libraries/AFSoftSerial/keywords.txt
+lib/libraries/AF_XPort/AF_XPort.cpp
+lib/libraries/AF_XPort/AF_XPort.h
lib/libraries/DS1307/DS1307.cpp
lib/libraries/DS1307/DS1307.h
lib/libraries/DS1307/keywords.txt
lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp
lib/libraries/FrequencyTimer2/FrequencyTimer2.h
lib/libraries/FrequencyTimer2/keywords.txt
+lib/libraries/I2CEEPROM/I2CEEPROM.cpp
+lib/libraries/I2CEEPROM/I2CEEPROM.h
+lib/libraries/I2CEEPROM/keywords.txt
+lib/libraries/LoopTimer/LoopTimer.cpp
+lib/libraries/LoopTimer/LoopTimer.h
+lib/libraries/LoopTimer/keywords.txt
lib/libraries/OneWire/OneWire.cpp
lib/libraries/OneWire/OneWire.h
lib/libraries/OneWire/keywords.txt
@@ -51,7 +71,6 @@ lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp
lib/libraries/SWSerLCDsf/SWSerLCDsf.h
lib/libraries/Servo/Servo.cpp
lib/libraries/Servo/Servo.h
-lib/libraries/Servo/keywords.txt
lib/libraries/Stepper/Stepper.cpp
lib/libraries/Stepper/Stepper.h
lib/libraries/Stepper/keywords.txt
@@ -62,40 +81,54 @@ lib/libraries/Wire/twi.h
lib/libraries/Wire/utility/twi.c
lib/libraries/Wire/utility/twi.h
lib/plugins/bitwise_ops.rb
+lib/plugins/blink.rb
lib/plugins/blink_m.rb
lib/plugins/debounce.rb
lib/plugins/debug_output_to_lcd.rb
lib/plugins/hysteresis.rb
-lib/plugins/i2c_eeprom.rb
lib/plugins/input_output_state.rb
lib/plugins/lcd_padding.rb
lib/plugins/mem_test.rb
+lib/plugins/midi.rb
+lib/plugins/parallax_ping.rb
lib/plugins/servo_pulse.rb
lib/plugins/servo_setup.rb
lib/plugins/smoother.rb
lib/plugins/spark_fun_serial_lcd.rb
lib/plugins/spectra_symbol.rb
+lib/plugins/twitter_connect.rb
lib/rad.rb
+lib/rad/README.rdoc
lib/rad/arduino_plugin.rb
lib/rad/arduino_sketch.rb
+lib/rad/darwin_installer.rb
lib/rad/generators/makefile/makefile.erb
lib/rad/generators/makefile/makefile.rb
+lib/rad/hardware_library.rb
lib/rad/init.rb
+lib/rad/linux_installer.rb
+lib/rad/progressbar.rb
lib/rad/rad_processor.rb
lib/rad/rad_rewriter.rb
lib/rad/rad_type_checker.rb
lib/rad/sim/arduino_sketch.rb
+lib/rad/sketch_compiler.rb
lib/rad/tasks/build_and_make.rake
-lib/rad/developer.rake
lib/rad/tasks/rad.rb
lib/rad/todo.txt
lib/rad/variable_processing.rb
lib/rad/version.rb
scripts/txt2html
setup.rb
-spec/models/spec_helper.rb
+spec/examples/hello_world.rb
+spec/examples/serial_motor.rb
spec/models/arduino_sketch_spec.rb
+spec/models/sketch_compiler_spec.rb
+spec/models/spec_helper.rb
+spec/sim/hello_world_spec.rb
spec/spec.opts
+test/hello_world_test/Makefile
+test/hello_world_test/hello_world.cpp
test/test_array_processing.rb
test/test_plugin_loading.rb
test/test_translation_post_processing.rb
View
26 README.rdoc
@@ -12,22 +12,26 @@ See also the Arduino Software reference: http://www.arduino.cc/en/Reference/Home
==Examples
-See the examples directory for lots of examples of RAD in action: http://rad.rubyforge.org/examples
-Madrona Fork Screencast is here: http://www.vimeo.com/1272402
-Occasional commentary here: http://senplicity.wordpress.com/
+See the examples directory for lots of examples of RAD in action:
+http://github.com/atduskgreg/rad/tree/master/lib/examples
+
+The atduskgreg/rad wiki also contains a growing library of examples and hardware tutorials:
+http://github.com/atduskgreg/rad/wikis
==Getting Started
-To install the madrona fork gem:
+To install the edge gem:
- $ Update to RubyGems 1.2.0 before proceeding!!
+ # Update to RubyGems 1.2.0 before proceeding!
$ gem sources -a http://gems.github.com (you only have to do this once)
- $ sudo gem install madrona-rad
+ $ sudo gem install atduskgreg-rad
-To install the original rad:
+A very old and feature poor (though slightly more 'stable' RAD) is available from RubyGems:
$ sudo gem install rad
+We plan to push tagged releases to RubyGems at key points. The 0.3 release should be coming up soon.
+
Run the rad command to create a new project:
$ rad my_project
@@ -46,6 +50,14 @@ Attach your Arduino and use rake to complile and upload your sketch:
$ rake make:upload
+==Installing the Arduino Software
+
+Installing RAD and the Arduino software on Linux can be a little more difficult than on OS X. Thankfully, the RAD command line tool can help. Run:
+
+ $ rad install arduino
+
+And RAD will do its best to get the Arduino software installed on your system.
+
==Get Involved
Cheers? Jeers? Wanna help out? Contact Greg Borenstein: greg [dot] borenstein [at] gmail [dot] com
View
5 Rakefile
@@ -9,9 +9,10 @@ require 'rake/contrib/rubyforgepublisher'
require 'fileutils'
require 'hoe'
-RAD_ROOT = File.expand_path(File.dirname(__FILE__))
+$: << "../lib/" # HACK while I work out r2c/rad incompatibilities
+gem "RubyToC" # HACK to deal with rubygems beta version activation bug
-load "#{RAD_ROOT}/project_dev.rake"
+RAD_ROOT = File.expand_path(File.dirname(__FILE__))
begin
require 'spec/rake/spectask'
View
344 bin/rad 100755 → 100644
@@ -9,8 +9,13 @@ end
require 'optparse'
require 'fileutils'
require 'yaml'
+require 'open-uri'
+require 'readline'
-
+require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/version.rb"
+require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/progressbar.rb"
+require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/linux_installer.rb"
+require File.expand_path(File.dirname(__FILE__)) + "/../lib/rad/darwin_installer.rb"
class OptionParser #:nodoc:
@@ -23,7 +28,7 @@ class OptionParser #:nodoc:
"physical_reset" => false
},
"software" => {
- "arduino_root" => "/Applications/arduino-0011"
+ "arduino_root" => "/Applications/arduino-0012"
}
}
@@ -60,6 +65,13 @@ Usage: #{File.basename($0)} <sketch_dir_name> <options for config>
" (default: #{options['software']['arduino_root']})") do |arduino|
options["software"]["arduino_root"] = arduino if arduino
end
+
+ opts.on("-v", "--version [VERSION]",
+ "RAD version number",
+ " (#{Rad::VERSION::STRING})") do
+ puts Rad::VERSION::STRING
+ exit
+ end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
@@ -83,136 +95,208 @@ end
#
-# Handle options:
-options, parser = OptionParser.parse(ARGV)
-sketch_name = ARGV[0]
-parser.parse!(["-h"]) unless sketch_name
+if ARGV[0] == "install"
+ case RUBY_PLATFORM
+ when /linux/
+ LinuxInstaller.install!
+ when /darwin/
+ DarwinInstaller.install!
+ else
+ raise "Sorry. Can only install Arduino on Mac OS X. See here for Linux instructions: http://www.arduino.cc/playground/Learning/Linux"
+ end
-# Build vendor/rad:
+elsif ARGV[0] == "test"
+ test_dir = File.expand_path(File.dirname(__FILE__)) + "/../test/hello_world_test"
+ puts "Compiling hello_world.cpp to test your Arduino."
+ puts "cd #{test_dir}; make depend; make;"
+ `cd #{test_dir}; make depend; make;`
+ puts
+ puts "Compilation successful."
+ puts
+ puts "Make sure your Arduino is connected and then hit return."
+ Readline::readline('')
-FileUtils.mkdir_p "#{sketch_name}/vendor/rad"
-puts "Successfully created your sketch directory."
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/rad/.", "#{sketch_name}/vendor/rad"
-puts "Installed RAD into #{sketch_name}/vendor/rad"
-puts
-
-# Build vendor/libraries:
-
-FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
-puts "Successfully created your libraries directory."
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/DS1307/.", "#{sketch_name}/vendor/libraries/DS1307"
-puts "Installed DS1307 into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/FrequencyTimer2/.", "#{sketch_name}/vendor/libraries/FrequencyTimer2"
-puts "Installed FrequencyTimer2 into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/OneWire/.", "#{sketch_name}/vendor/libraries/OneWire"
-puts "Installed OneWire into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Servo/.", "#{sketch_name}/vendor/libraries/Servo"
-puts "Installed Servo into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
-puts "Installed Stepper into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDpa/.", "#{sketch_name}/vendor/libraries/SWSerLCDpa"
-puts "Installed SWSerLCDpa into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{sketch_name}/vendor/libraries/SWSerLCDsf"
-puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
-puts "Installed Stepper into #{sketch_name}/vendor/libraries"
-puts
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
-puts "Installed Wire into #{sketch_name}/vendor/libraries"
-puts
-
-# Build examples -- used for basic testing
-
-FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
-puts "Successfully created your examples directory."
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/examples/.", "#{sketch_name}/examples"
-puts "Installed examples into #{sketch_name}/examples"
-puts
-
-# Build test -- used testing
-
-# FIXME: this should put the tests into the vendor/tests directory instead.
-
-# FileUtils.mkdir_p "#{sketch_name}/test"
-# puts "Successfully created your test directory."
-#
-# FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
-# puts "Installed tests into #{sketch_name}/test"
-# puts
-
-# Build vendor/plugins:
-
-FileUtils.mkdir_p "#{sketch_name}/vendor/plugins"
-puts "Successfully created your plugins directory."
-
-FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/plugins/.", "#{sketch_name}/vendor/plugins"
-puts "Installed Default plugins into #{sketch_name}/vendor/plugins"
-puts
-
-# Add an default sketch directory # needed to run test:compile
-
-FileUtils.mkdir_p "#{sketch_name}/#{sketch_name}"
-puts "Successfully created your default sketch directory."
-
-# Build sketch files, etc.:
-
-FileUtils.touch "#{sketch_name}/#{sketch_name}.rb"
-File.open("#{sketch_name}/#{sketch_name}.rb", "w") do |file|
- file << <<-EOS
-class #{sketch_name.split("_").collect{|c| c.capitalize}.join("")} < ArduinoSketch
-
- # looking for hints? check out the examples directory
- # example sketches can be uploaded to your arduino with
- # rake make:upload sketch=examples/hello_world
- # just replace hello_world with other examples
-
- def loop
- # your code here
- end
+ `cd #{test_dir}; make upload`
+
+ # find the USB port to make sure the Arduino's actually plugged in
+ options, parser = OptionParser.parse(ARGV)
+ usb_port = options["hardware"]["serial_port"]
+ port_name = usb_port.split("/").last
+ port_dir = usb_port.split("/")[0..(usb_port.split("/").length-2)].join("/")
+ unless `ls #{port_dir}`.split(/\n/).any?{|d| d.match(/#{port_name}/)}
+ puts
+ puts "******************************************************"
+ puts "*** It looks like your Arduino is not plugged in. ***"
+ puts "*** Plug it in and try again. ***"
+ puts "*** ***"
+ puts "*** NOTE: If your usb port is not /dev/tty.usb* ***"
+ puts "*** pass it in to this script with the -p option. ***"
+ puts "******************************************************"
+ else
+ puts
+ puts "******************************************************"
+ puts "*** Success! ***"
+ puts "*** If your Arduino's light starts blinking soon, ***"
+ puts "*** then your Arduino environment is ***"
+ puts "*** correctly configured. ***"
+ puts "*** ***"
+ puts "*** Otherwise something is not hooked up properly. ***"
+ puts "******************************************************"
+ end
+ puts
+ puts "cleaning up..."
+ `rm #{test_dir}/hello_world.hex #{test_dir}/core.a #{test_dir}/hello_world.elf`
+else
+ # Handle options:
+ options, parser = OptionParser.parse(ARGV)
+ sketch_name = ARGV[0]
+ parser.parse!(["-h"]) unless sketch_name
-end
- EOS
-end
-puts "Added #{sketch_name}/#{sketch_name}.rb"
-
-File.open("#{sketch_name}/Rakefile", 'w') do |file|
- file << <<-EOS
-require 'vendor/rad/init.rb'
- EOS
-end
-puts "Added #{sketch_name}/Rakefile"
-
-FileUtils.mkdir_p "#{sketch_name}/config"
-puts "Added #{sketch_name}/config"
-
-File.open("#{sketch_name}/config/hardware.yml", 'w') do |file|
- file << options["hardware"].to_yaml
-end
-puts "Added #{sketch_name}/config/hardware.yml"
-
-File.open("#{sketch_name}/config/software.yml", 'w') do |file|
- file << options["software"].to_yaml
-end
-puts "Added #{sketch_name}/config/software.yml"
+
+ # Build vendor/rad:
+
+ FileUtils.mkdir_p "#{sketch_name}/vendor/rad"
+ puts "Successfully created your sketch directory."
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/rad/.", "#{sketch_name}/vendor/rad"
+ puts "Installed RAD into #{sketch_name}/vendor/rad"
+ puts
+
+ # Build vendor/libraries:
+
+ FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
+ puts "Successfully created your libraries directory."
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AF_XPort/.", "#{sketch_name}/vendor/libraries/AF_XPort"
+ puts "Installed AF_XPort into #{sketch_name}/vendor/libraries"
+ puts
-puts
-puts "Run 'rake -T' inside your sketch dir to learn how to compile and upload it."
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/AFSoftSerial/.", "#{sketch_name}/vendor/libraries/AFSoftSerial"
+ puts "Installed AFSoftSerial into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/DS1307/.", "#{sketch_name}/vendor/libraries/DS1307"
+ puts "Installed DS1307 into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/FrequencyTimer2/.", "#{sketch_name}/vendor/libraries/FrequencyTimer2"
+ puts "Installed FrequencyTimer2 into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/I2CEEPROM/.", "#{sketch_name}/vendor/libraries/I2CEEPROM"
+ puts "Installed I2CEEPROM into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/LoopTimer/.", "#{sketch_name}/vendor/libraries/LoopTimer"
+ puts "Installed LoopTimer into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/OneWire/.", "#{sketch_name}/vendor/libraries/OneWire"
+ puts "Installed OneWire into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Servo/.", "#{sketch_name}/vendor/libraries/Servo"
+ puts "Installed Servo into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Stepper/.", "#{sketch_name}/vendor/libraries/Stepper"
+ puts "Installed Stepper into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDpa/.", "#{sketch_name}/vendor/libraries/SWSerLCDpa"
+ puts "Installed SWSerLCDpa into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/SWSerLCDsf/.", "#{sketch_name}/vendor/libraries/SWSerLCDsf"
+ puts "Installed SWSerLCDsf into #{sketch_name}/vendor/libraries"
+ puts
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/libraries/Wire/.", "#{sketch_name}/vendor/libraries/Wire"
+ puts "Installed Wire into #{sketch_name}/vendor/libraries"
+ puts
+
+ # Build examples -- used for basic testing
+
+ FileUtils.mkdir_p "#{sketch_name}/vendor/libraries"
+ puts "Successfully created your examples directory."
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/examples/.", "#{sketch_name}/examples"
+ puts "Installed examples into #{sketch_name}/examples"
+ puts
+
+ # Build test -- used testing
+
+ # FIXME: this should put the tests into the vendor/tests directory instead.
+
+ # FileUtils.mkdir_p "#{sketch_name}/test"
+ # puts "Successfully created your test directory."
+ #
+ # FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/test/.", "#{sketch_name}/test"
+ # puts "Installed tests into #{sketch_name}/test"
+ # puts
+
+ # Build vendor/plugins:
+
+ FileUtils.mkdir_p "#{sketch_name}/vendor/plugins"
+ puts "Successfully created your plugins directory."
+
+ FileUtils.cp_r "#{File.dirname(__FILE__)}/../lib/plugins/.", "#{sketch_name}/vendor/plugins"
+ puts "Installed Default plugins into #{sketch_name}/vendor/plugins"
+ puts
+
+ # Add an default sketch directory # needed to run test:compile
+
+ FileUtils.mkdir_p "#{sketch_name}/#{sketch_name}"
+ puts "Successfully created your default sketch directory."
+
+ # Build sketch files, etc.:
+
+ FileUtils.touch "#{sketch_name}/#{sketch_name}.rb"
+ File.open("#{sketch_name}/#{sketch_name}.rb", "w") do |file|
+ file << <<-EOS
+ class #{sketch_name.split("_").collect{|c| c.capitalize}.join("")} < ArduinoSketch
+
+ # looking for hints? check out the examples directory
+ # example sketches can be uploaded to your arduino with
+ # rake make:upload sketch=examples/hello_world
+ # just replace hello_world with other examples
+
+ def loop
+ # your code here
+ end
+
+ end
+ EOS
+ end
+ puts "Added #{sketch_name}/#{sketch_name}.rb"
+
+ File.open("#{sketch_name}/Rakefile", 'w') do |file|
+ file << <<-EOS
+ require 'vendor/rad/init.rb'
+ EOS
+ end
+ puts "Added #{sketch_name}/Rakefile"
+
+ FileUtils.mkdir_p "#{sketch_name}/config"
+ puts "Added #{sketch_name}/config"
+
+ File.open("#{sketch_name}/config/hardware.yml", 'w') do |file|
+ file << options["hardware"].to_yaml
+ end
+ puts "Added #{sketch_name}/config/hardware.yml"
+
+ File.open("#{sketch_name}/config/software.yml", 'w') do |file|
+ file << options["software"].to_yaml
+ end
+ puts "Added #{sketch_name}/config/software.yml"
+
+ puts
+ puts "Run 'rake -T' inside your sketch dir to learn how to compile and upload it."
+
+ puts "***************************************************"
+ puts "*** Please note: This version supports ***"
+ puts "*** Arduino 12 only! ***"
+ puts "*** run rad install arduino to upgrade ***"
+ puts "***************************************************"
+end
View
10 lib/examples/basic_blink.rb
@@ -0,0 +1,10 @@
+class BasicBlink < ArduinoSketch
+ # hello world (uncomment to run)
+
+ output_pin 13, :as => :led
+
+ def loop
+ blink led, 100
+ x = 4
+ end
+end
View
16 lib/examples/blink_with_serial.rb
@@ -0,0 +1,16 @@
+class BlinkWithSerial < ArduinoSketch
+
+ # hello world (uncomment to run)
+ @i = "0, long"
+
+ output_pin 13, :as => :led
+
+ serial_begin
+
+ def loop
+ @i += 1
+ serial_println @i
+ blink led, 100
+ end
+
+end
View
40 lib/examples/external_variable_fu.rb
@@ -1,24 +1,26 @@
class ExternalVariableFu < ArduinoSketch
-@one = int
-@two = long
-@three = unsigned
-@four = short
-@five = byte
-@six = 1
-@seven = 1.2
-@eight = "0x00"
-@nine = "arduino"
-@ten = true
-@eleven = false
-@twelve = "1, long"
-@thirteen = "1, unsigned"
-@fourteen = "1, byte"
+ @one = int
+ @two = long
+ @three = unsigned
+ @four = short
+ @five = byte
+ @six = 1
+ @seven = 1.2
+ @eight = "0x00"
+ @nine = "arduino"
+ @ten = true
+ @eleven = false
+ @twelve = "1, long"
+ @thirteen = "1, unsigned"
+ @fourteen = "1, byte"
+ @fifteen = HIGH
+ @sixteen = LOW
+ @seventeen = ON
+ @eighteen = OFF
-
-
- def loop
- delay @six
- end
+ def loop
+ delay @six
+ end
end
View
3 lib/examples/external_variables.rb
@@ -14,10 +14,7 @@ class ExternalVariables < ArduinoSketch
@boom = "1, int"
@rad = "1.00"
-
-
def loop
-
delay 1
@foo = 2
@foo = KOOL
View
35 lib/examples/hello_array2.rb
@@ -24,7 +24,12 @@ class HelloArray2 < ArduinoSketch
array "int pizzas[] = {1,2,3,4}"
array "byte buffer[20] = {'A', 'B', 'Z', 'C', 'Y', 'D', 'W', 'E', '%', 'H', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
- output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
+ ## multidimensional arrays
+ array 'int @my_numbers[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}'
+ array 'char* @pizzas[2][4] = {{"margherita","funghi","napoletana","prosciutto cotto"},{"veggie","pepperoni","cheese","kitchen sink"}}'
+
+
+ output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
def setup
@@ -56,13 +61,41 @@ def setup
delay 3000
+
+
my_lcd.clearline 1, @names[2]
my_lcd.print " [ "
my_lcd.print pizzas[1]
my_lcd.print " ]"
delay 2000
+ my_lcd.clearscr "Multidimensional ?n"
+
+ 0.upto(2) do |f|
+ 0.upto(3) do |s|
+ my_lcd.print @my_numbers[f][s]
+ my_lcd.print ", "
+ delay 500
+ end
+ end
+
+ delay 1000
+
+ my_lcd.clearscr
+
+ 0.upto(1) do |f|
+ 0.upto(3) do |s|
+ my_lcd.print @pizzas[f][s]
+ my_lcd.print ", "
+ delay 500
+ end
+ end
+
+
+
+ delay 2000
+
my_lcd.clearscr "Array Load?n"
1.upto(20) do |x|
# buffer[x] = 64 + x # we cannot set array elements yet except to initialize in declaration
View
10 lib/examples/hello_array_eeprom.rb
@@ -15,14 +15,12 @@ class HelloArrayEeprom < ArduinoSketch
# is at odds with original style array naming
define "THROWAWAY 0"
- define "EEPROM_ADDR 0x50"
-
# when we just need to declare an array, or need more control, such as specific type requirements
- array "byte page_data[20] = {'A', 'B', 'Z', 'C', 'Y', 'D', 'W', 'E', '%', 'H', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
+ array "byte page_data[20] = {'R', 'A', 'D', ' ', 'i', 's', ' ', 'B', 'A', 'D', '*', '!', ')', '=', 'P', '-', '+', 'R', 'I', 'K'}"
array "byte in_buffer[20]"
- output_pin 19, :as => :mem0, :device => :i2c_eeprom, :enable => :true
+ output_pin 19, :as => :mem0, :device => :i2c_eeprom, :address => 1 # w/o :address defaults to :address => 0 which is 0x50
output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200
@@ -37,13 +35,13 @@ def setup
my_lcd.clearscr " I2C EEPROM Demo?n block write"
- i2c_eeprom_write_page 0x50, 0x0040, page_data, 20
+ mem0.write_page 0x0100, page_data, 20
delay 1000
my_lcd.clearline 1, " block readback"
- i2c_eeprom_read_buffer 0x50, 0x0040, in_buffer, 20
+ mem0.read_buffer 0x0100, in_buffer, 20
my_lcd.setxy 0, 2
View
84 lib/examples/hello_clock.rb
@@ -0,0 +1,84 @@
+class HelloClock < ArduinoSketch
+
+# ----------------------------------------------------------------------------------
+# <b>Time and Temp (20 July 2008)</b>
+# Example #1 - Brian Riley, Underhill Center, VT USA <brianbr@wulden.org>
+#
+# Connections
+# I2C bus - DS1307 Real Time Clock chip
+# Analog 0 (a.k.a Digital 14) - Wulfden K107 seria LCD Controller
+# Peter Anderson chip
+#
+# Comment
+# - This is a straight forward program to read the Real Time Clock and Display
+# delay() calls waiting for temperature conversion readings
+#
+# - for the external data busses make sure you have 4.7K pullup resistors on the
+# the SDA/SCL (I2C)
+#
+# ----------------------------------------------------------------------------------
+
+ @flag = int
+
+ array "byte clock[8]"
+
+ @days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
+ @months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
+
+ # implicit in :device => :ds1307 is that this i i2c
+ # :enable => true issues the Wire.begin to ick over i2c
+ output_pin 19, :as => :rtc, :device => :i2c_ds1307, :enable => :true
+ # software serial tx drives LCD display, screen cleared at startup
+ # defines the softare protocol for controller as Peter Anderson
+ output_pin 14, :as => :myLCD, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
+ loop_timer :as => :mainloop
+
+
+ def setup
+ myLCD.clearscr " --<Date/Time>--"
+ myLCD.setxy 1,3, "looptime = "
+ rtc.get clock, 1
+ print_main
+ @flag = 1
+ end
+
+ def loop
+ mainloop.track
+ myLCD.setxy 12,3, mainloop.get_total
+ rtc.get clock, 1
+ if clock[0] == 0
+ if @flag == 0
+ print_main
+ @flag = 1
+ end
+ else
+ @flag = 0
+ end
+ myLCD.setxy 6,2
+ printlz clock[2]
+ myLCD.print ":"
+ printlz clock[1]
+ myLCD.print ":"
+ printlz clock[0]
+
+ delay 50
+
+ end
+
+ def printlz(w)
+ myLCD.print "0" if w < 10
+ myLCD.print w
+ end
+
+ def print_main
+ myLCD.setxy 1,1, @days[clock[3]-1]
+ myLCD.print ", "
+ myLCD.print @months[clock[5]-1]
+ myLCD.print " "
+ printlz clock[4]
+ myLCD.print ", "
+ printlz clock[6] + 2000
+
+ end
+
+end
View
6 lib/examples/hello_eeprom.rb
@@ -12,7 +12,7 @@ def loop
myLCD.print rtc.get(4, 0) # no need to refresh (=0) get day
myLCD.print "/"
myLCD.print rtc.get(6, 0) # get year
- myLCD.setxy(1,1) # set in 1 byte line 1 (second line)
+ myLCD.setxy(0,1) # set in 1 byte line 1 (second line)
printlz 2 # print hours with lead zero
myLCD.print ":"
printlz 1 # print minutes with lead zero
@@ -24,7 +24,7 @@ def loop
myLCD.print "write test"
myLCD.setxy 0,2
32.upto(109) do # write address of byte to that b yte
- |x| i2c_eeprom_write_byte 0x50, x, x
+ |x| mem0.write_byte x, x
myLCD.print(".") if x%2
delay 10
end
@@ -37,7 +37,7 @@ def loop
myLCD.setxy 10,0, "read test "
myLCD.setxy 0,2
# read and print 39 addresses with printable numbers
- 75.upto(113) { |x| myLCD.print(i2c_eeprom_read_byte(0x50, x)) }
+ 75.upto(113) { |x| myLCD.print(mem0.read_byte(x)) }
delay 10000
myLCD.clearscr
end
View
4 lib/examples/hello_eeprom_lcdpa.rb
@@ -47,7 +47,7 @@ def setup
myLCD.setxy 0, 2
32.upto(109) do # write address of byte to that b yte
- |x| i2c_eeprom_write_byte 0x50, x, x
+ |x| mem0.write_byte x, x+7
myLCD.print(".") if x%2
delay 10 # EEPROM write _requires_ 3-10 ms pause
end
@@ -57,7 +57,7 @@ def setup
myLCD.setxy 0, 2
# read and print 39 addresses with printable numbers
- 75.upto(113) { |x| myLCD.print(i2c_eeprom_read_byte(0x50, x)) }
+ 70.upto(105) { |x| myLCD.print(mem0.read_byte(x)) }
delay 2000
clear_off_test
View
94 lib/examples/hello_format_print.rb
@@ -0,0 +1,94 @@
+class HelloFormatPrint < ArduinoSketch
+
+ # ----------------------------------------------------------------------
+ # Demonstrattion of Crude Adaptaion of C Function sprintf()
+ # to do formatted printing. For now there are some absolutes:
+ # The write_line method atkes as arguemnst the formatting string
+ # and the appropriate arguments. It format them to an internal
+ # buffer sepcified and created when you invoke formatted printing
+ # formatted_print :as => :line_buf, :buffer_size => 80
+ # now, to actual do it you use write_line
+ # write_line "Pies $%02d.%02d", pie_cents/100, pie_cents%100
+ # then print the string pointed at by string_line
+ # my_lcd.setxy 3, 2, line_buf
+ #
+ # Brian Riley - Underhill Center, VT, USA Aug 2008
+ # <brianbr@wulfden.org>
+ #
+ # ----------------------------------------------------------------------
+
+# demonstrate 4 x 20 pa_lcd toggle between normal and Bignum mode
+# with @toggle external variable thrown in for fun
+
+# change your pins to suit your setup
+
+ @toggle = "0, int"
+ @pie_cents = "403, int"
+ @pie_price = "7.08"
+
+
+ input_pin 8, :as => :button_one, :device => :button
+ input_pin 9, :as => :button_two, :device => :button
+ input_pin 10, :as => :button_three, :device => :button
+
+ formatted_print :as => :string_line, :buffer_size => 65 # generally this statement should precede any serial_begin or
+ # LCD display directive
+
+ output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
+
+
+ def setup
+ my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
+ end
+
+ def loop
+ if millis % 500 == 0
+ write_line "millis()= %ld", millis
+ my_lcd.setxy 1, 2, string_line
+ end
+ say_hello if button_one.read_input
+ say_more if button_two.read_input
+ say_it_large if button_three.read_input
+ end
+
+ def say_hello
+ @toggle = true
+ my_lcd.clearscr "This sketch has?nbeen running for?n "
+ write_line "%ld mins and %d secs?n", millis/60000, (millis/1000)%60
+ my_lcd.print string_line
+ delay 3000
+ my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
+ end
+
+ def say_more # passing print strings to home and setxy (also works on clearscr)
+ @toggle = false
+ my_lcd.clearscr "Food Store Prices"
+ write_line "Pies $%2d.%02d", @pie_cents/100, @pie_cents%100
+# write_line "Pies $%6.2f", @pie_price # float doessn't seem to work .....
+ my_lcd.setxy 2, 1, string_line
+# write_line "toggle state is [%s]", @toggle ? "ON" : "OFF" # RubyToC screws this construct up and RAD mistajekl put 1 ad 0
+ # in place of "ON" and "OFF"
+ write_line "toggle state is [%d]", @toggle
+ my_lcd.setxy 2, 3, string_line
+ delay 3000
+ my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
+ end
+
+
+ def say_it_large
+
+ my_lcd.intoBignum
+ my_lcd.clearscr # line 0, col 0
+ 1.upto(32) do |i|
+ my_lcd.setxy 0,1
+ my_lcd.print i * i
+ delay 200
+ end
+ my_lcd.outofBignum
+ delay 3000
+ my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
+ end
+
+
+
+end
View
38 lib/examples/hello_spectra_sound.rb
@@ -0,0 +1,38 @@
+class HelloSpectraSound < ArduinoSketch
+
+ # demonstrate capability to use soft pot as traditional pot
+ # the last pot reading remains "locked" to the last touch point
+ # similar same behavior as ipod
+ #
+ # this sketch assumes a pa_lcd operating at 19200 and one
+ # spectra symbol softpot connected to analog pin 3
+ #
+ @reading = int
+ output_pin 14, :as => :my_lcd, :device => :pa_lcd, :rate => 9600, :clear_screen => :true
+ output_pin 11, :as => :sound, :device => :freq_out, :frequency => 100, :enable => :true
+ input_pin 3, :as => :sensor_one, :device => :spectra
+
+
+ def setup
+ delay 1000
+ my_lcd.setxy 0,0, "spectra symbol"
+ my_lcd.setxy 0,1, "soft pot sound"
+ delay 3000
+ my_lcd.clearscr
+ end
+
+ def loop
+ my_lcd.setxy 0,1
+ # since lcd's have issues clearing tens and hundreds digits when reading ones,
+ # we use pad_int_to_str, which is a hack to display these cleanly
+ # pad_int_to_str takes two arguments: an integer and the final string length
+ #
+# my_lcd.print pad_int_to_str analogRead(sensor_one), 5
+ @reading = sensor_one.soft_lock
+ sound.set_frequency @reading * 10
+ my_lcd.print pad_int_to_str @reading, 3
+ delay 30
+ end
+
+
+end
View
6 lib/examples/hello_world.rb
@@ -2,9 +2,9 @@ class HelloWorld < ArduinoSketch
output_pin 13, :as => :led
- def loop
- blink led, 100
- end
+ def loop
+ blink led, 100
+ end
end
View
12 lib/examples/hello_xbee.rb
@@ -0,0 +1,12 @@
+class HelloXbee < ArduinoSketch
+
+ output_pin 13, :as => :led
+
+ serial_begin
+ def loop
+ led.blink 200
+ serial_print "...testing..."
+ delay 1000
+ end
+
+end
View
86 lib/examples/midi_beat_box.rb
@@ -0,0 +1,86 @@
+class MidiBeatBox < ArduinoSketch
+
+ # midi synthesiser output on channel 2
+ # with speed controlled by spectra soft pot
+
+ @channel = 2
+ input_pin 1, :as => :sensor_one, :device => :spectra
+ output_pin 13, :as => :led
+
+ serial_begin :rate => 31250
+
+ def setup
+ delay 3000
+ end
+
+ def loop
+ 8.times {first}
+ 2.times do
+ second
+ third
+ end
+ 4.times {first}
+ 2.times {second}
+ end
+
+ def first
+ play 39, 52, 37
+ play 0, 0, 0
+ play 36, 52, 0
+ play 37, 52, 39
+
+ play 37, 0, 0
+ play 36, 0, 0
+ play 39, 50, 0
+ play 0, 0, 0
+
+ play 52, 36, 37
+ play 0, 0, 0
+ play 39, 0, 0
+ play 36, 37, 0
+
+ play 36, 37, 39
+ play 36, 38, 0
+ play 50, 0, 0
+ play 0, 0, 0
+ end
+
+ def second
+ play 39, 52, 37
+ play 36, 0, 0
+ play 0, 0, 0
+ play 37, 52, 39
+
+ play 38, 0, 0
+ play 36, 0, 0
+ play 39, 50, 0
+ play 0, 0, 0
+ end
+
+ def third
+ play 0, 36, 37
+ play 0, 0, 0
+ play 39, 36, 0
+ play 36, 37, 50
+
+ play 36, 37, 39
+ play 36, 37, 0
+ play 50, 0, 0
+ play 39, 0, 0
+ end
+
+
+ def play(one, two, three)
+ n = 1 + one + two + three # ack to coerce parameters to int
+ note_on(@channel, one, 127) unless one == 0
+ note_on(@channel, two, 127) unless two == 0
+ note_on(@channel, three, 127) unless three == 0
+ delay 310 - sensor_one.soft_lock # start slowly
+ note_off(@channel, one, 0) unless one == 0
+ note_off(@channel, two, 0) unless two == 0
+ note_off(@channel, three, 0) unless three == 0
+ end
+
+
+
+end
View
94 lib/examples/midi_scales.rb
@@ -0,0 +1,94 @@
+class MidiScales < ArduinoSketch
+
+# purpose
+# trigger midi output with buttons and
+# spectra soft pots
+#
+#
+
+
+ @current_note = int
+ @last_note_one = 0
+ @last_note_two = 0
+ @last_note_three = 0
+ @note = int
+
+ input_pin 1, :as => :sensor_one, :device => :spectra
+ input_pin 2, :as => :sensor_two, :device => :spectra
+ input_pin 3, :as => :sensor_three, :device => :spectra
+ input_pin 7, :as => :button_one, :device => :button
+ input_pin 8, :as => :button_two, :device => :button
+ input_pin 9, :as => :button_three, :device => :button
+ output_pin 13, :as => :led
+
+ serial_begin :rate => 31250
+
+ def setup
+ delay 3000
+ end
+
+ def loop
+ change_tone if button_one.read_input
+ change_pressure if button_two.read_input
+ change_channels if button_three.read_input
+ read_sensor_one
+ read_sensor_two
+ read_sensor_three
+ end
+
+ def change_tone
+ 110.upto(127) do |note|
+ play 0, note, 127
+ end
+ end
+
+ def change_pressure
+ 110.upto(127) do |pressure|
+ play 0, 45, pressure
+ end
+ end
+
+ def change_channels
+ 0.upto(6) do |channel|
+ play channel, 50, 100
+ end
+ end
+
+ def read_sensor_one
+ @current_note = sensor_one.soft_lock
+ pre_play(@current_note, @last_note_one, 13)
+ @last_note_one = @current_note
+ end
+
+ def read_sensor_two
+ @current_note = sensor_two.soft_lock
+ pre_play(@current_note, @last_note_two, 14)
+ @last_note_two = @current_note
+ end
+
+ def read_sensor_three
+ @current_note = sensor_three.soft_lock
+ pre_play(@current_note, @last_note_three, 15)
+ @last_note_three = @current_note
+ end
+
+ def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
+ n = 1 + channel
+ unless current_note == last_note
+ @note = ((current_note /16) + 40)
+ play_with_no_delay( channel, @note, 100 )
+ end
+ end
+
+ def play(chan, note, pressure)
+ note_on(chan, note, pressure)
+ delay 100 # adjust to need
+ note_off(chan, note, 0)
+ end
+
+ def play_with_no_delay(chan, note, pressure) # note is not turned off
+ note_on(chan, note, pressure)
+ end
+
+
+end
View
10 lib/examples/software_serial.rb
@@ -0,0 +1,10 @@
+class SoftwareSerial < ArduinoSketch
+ output_pin 13, :as => :led
+ software_serial 6, 7, :as => :gps
+ serial_begin
+
+ def loop
+ digitalWrite(led, true)
+ serial_print(gps.read)
+ end
+end
View
57 lib/examples/twitter.rb
@@ -0,0 +1,57 @@
+class Twitter < ArduinoSketch
+
+ #include <avr/io.h>
+ #include <string.h>
+
+
+
+ define "TWEETLEN 141"
+ define "HOSTNAME www.twitter.com"
+
+ define 'IPADDR "128.121.146.100"' # twitter.com
+ define "PORT 80" # // HTTP
+ define "HTTPPATH /atduskgreg/" # // the person we want to follow
+
+
+ define "TWEETLEN 141"
+ array "char linebuffer[256]" # // our large buffer for data
+ array "char tweet[TWEETLEN]" # // the tweet
+ @lines = 0
+
+
+ define "XPORT_RXPIN 2"
+ define "XPORT_TXPIN 3"
+ define "XPORT_RESETPIN 4"
+ define "XPORT_DTRPIN 5"
+ define "XPORT_CTSPIN 6"
+ define "XPORT_RTSPIN 7"
+
+
+ @errno = 0
+ @laststatus = 0
+ @currstatus = 0
+
+
+
+# in setup
+#xport = AF_XPort(XPORT_RX, XPORT_TX, XPORT_RESET, XPORT_DTR, XPORT_RTS, XPORT_CTS)
+
+
+ output_pin 10, :as => :shield, :device => :ethernet
+
+ serial_begin :rate => 57600
+
+ def loop
+
+# local_connect()
+ # kind of a problem... fixed
+ get_tweet
+ fetchtweet
+ delay 30000
+
+
+ end
+
+
+
+end
View
321 lib/libraries/AFSoftSerial/AFSoftSerial.cpp
@@ -0,0 +1,321 @@
+/*
+ SoftwareSerial.cpp - Software serial library
+ Copyright (c) 2006 David A. Mellis. All right reserved. - hacked by ladyada
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include <avr/interrupt.h>
+#include "WConstants.h"
+#include "AFSoftSerial.h"
+
+/******************************************************************************
+ * Definitions
+ ******************************************************************************/
+
+#define AFSS_MAX_RX_BUFF 64
+
+/******************************************************************************
+ * Statics
+ ******************************************************************************/
+static uint8_t _receivePin;
+static uint8_t _transmitPin;
+static int _bitDelay;
+
+static char _receive_buffer[AFSS_MAX_RX_BUFF];
+static uint8_t _receive_buffer_index;
+
+#if (F_CPU == 16000000)
+void whackDelay(uint16_t delay) {
+ uint8_t tmp=0;
+
+ asm volatile("sbiw %0, 0x01 \n\t"
+ "ldi %1, 0xFF \n\t"
+ "cpi %A0, 0xFF \n\t"
+ "cpc %B0, %1 \n\t"
+ "brne .-10 \n\t"
+ : "+r" (delay), "+a" (tmp)
+ : "0" (delay)
+ );
+}
+#endif
+
+/******************************************************************************
+ * Interrupts
+ ******************************************************************************/
+
+SIGNAL(SIG_PIN_CHANGE0) {
+ if ((_receivePin >=8) && (_receivePin <= 13)) {
+ recv();
+ }
+}
+SIGNAL(SIG_PIN_CHANGE2)
+{
+ if (_receivePin <8) {
+ recv();
+ }
+}
+
+
+void recv(void) {
+ char i, d = 0;
+ if (digitalRead(_receivePin))
+ return; // not ready!
+ whackDelay(_bitDelay - 8);
+ for (i=0; i<8; i++) {
+ //PORTB |= _BV(5);
+ whackDelay(_bitDelay*2 - 6); // digitalread takes some time
+ //PORTB &= ~_BV(5);
+ if (digitalRead(_receivePin))
+ d |= (1 << i);
+ }
+ whackDelay(_bitDelay*2);
+ if (_receive_buffer_index >= AFSS_MAX_RX_BUFF)
+ return;
+ _receive_buffer[_receive_buffer_index] = d; // save data
+ _receive_buffer_index++; // got a byte
+}
+
+
+
+/******************************************************************************
+ * Constructors
+ ******************************************************************************/
+
+AFSoftSerial::AFSoftSerial(uint8_t receivePin, uint8_t transmitPin)
+{
+ _receivePin = receivePin;
+ _transmitPin = transmitPin;
+ _baudRate = 0;
+}
+
+void AFSoftSerial::setTX(uint8_t tx) {
+ _transmitPin = tx;
+}
+void AFSoftSerial::setRX(uint8_t rx) {
+ _receivePin = rx;
+}
+
+/******************************************************************************
+ * User API
+ ******************************************************************************/
+
+void AFSoftSerial::begin(long speed)
+{
+ pinMode(_transmitPin, OUTPUT);
+ digitalWrite(_transmitPin, HIGH);
+
+ pinMode(_receivePin, INPUT);
+ digitalWrite(_receivePin, HIGH); // pullup!
+
+ _baudRate = speed;
+ switch (_baudRate) {
+ case 115200: // For xmit -only-!
+ _bitDelay = 4; break;
+ case 57600:
+ _bitDelay = 14; break;
+ case 38400:
+ _bitDelay = 24; break;
+ case 31250:
+ _bitDelay = 31; break;
+ case 19200:
+ _bitDelay = 54; break;
+ case 9600:
+ _bitDelay = 113; break;
+ case 4800:
+ _bitDelay = 232; break;
+ case 2400:
+ _bitDelay = 470; break;
+ default:
+ _bitDelay = 0;
+ }
+
+ if (_receivePin < 8) {
+ // a PIND pin, PCINT16-23
+ PCMSK2 |= _BV(_receivePin);
+ PCICR |= _BV(2);
+ } else if (_receivePin <= 13) {
+ // a PINB pin, PCINT0-5
+ PCICR |= _BV(0);
+ PCMSK0 |= _BV(_receivePin-8);
+ }
+
+ whackDelay(_bitDelay*2); // if we were low this establishes the end
+}
+
+int AFSoftSerial::read(void)
+{
+ uint8_t d,i;
+
+ if (! _receive_buffer_index)
+ return -1;
+
+ d = _receive_buffer[0]; // grab first byte
+ // if we were awesome we would do some nifty queue action
+ // sadly, i dont care
+ for (i=0; i<_receive_buffer_index; i++) {
+ _receive_buffer[i] = _receive_buffer[i+1];
+ }
+ _receive_buffer_index--;
+ return d;
+}
+
+uint8_t AFSoftSerial::available(void)
+{
+ return _receive_buffer_index;
+}
+
+void AFSoftSerial::print(uint8_t b)
+{
+ if (_baudRate == 0)
+ return;
+ byte mask;
+
+ cli(); // turn off interrupts for a clean txmit
+
+ digitalWrite(_transmitPin, LOW); // startbit
+ whackDelay(_bitDelay*2);
+
+ for (mask = 0x01; mask; mask <<= 1) {
+ if (b & mask){ // choose bit
+ digitalWrite(_transmitPin,HIGH); // send 1
+ }
+ else{
+ digitalWrite(_transmitPin,LOW); // send 1
+ }
+ whackDelay(_bitDelay*2);
+ }
+
+ digitalWrite(_transmitPin, HIGH);
+ sei(); // turn interrupts back on. hooray!
+ whackDelay(_bitDelay*2);
+}
+
+void AFSoftSerial::print(const char *s)
+{
+ while (*s)
+ print(*s++);
+}
+
+void AFSoftSerial::print(char c)
+{
+ print((uint8_t) c);
+}
+
+void AFSoftSerial::print(int n)
+{
+ print((long) n);
+}
+
+void AFSoftSerial::print(unsigned int n)
+{
+ print((unsigned long) n);
+}
+
+void AFSoftSerial::print(long n)
+{
+ if (n < 0) {
+ print('-');
+ n = -n;
+ }
+ printNumber(n, 10);
+}
+
+void AFSoftSerial::print(unsigned long n)
+{
+ printNumber(n, 10);
+}
+
+void AFSoftSerial::print(long n, int base)
+{
+ if (base == 0)
+ print((char) n);
+ else if (base == 10)
+ print(n);
+ else
+ printNumber(n, base);
+}
+
+void AFSoftSerial::println(void)
+{
+ print('\r');
+ print('\n');
+}
+
+void AFSoftSerial::println(char c)
+{
+ print(c);
+ println();
+}
+
+void AFSoftSerial::println(const char c[])
+{
+ print(c);
+ println();
+}
+
+void AFSoftSerial::println(uint8_t b)
+{
+ print(b);
+ println();
+}
+
+void AFSoftSerial::println(int n)
+{
+ print(n);
+ println();
+}
+
+void AFSoftSerial::println(long n)
+{
+ print(n);
+ println();
+}
+
+void AFSoftSerial::println(unsigned long n)
+{
+ print(n);
+ println();
+}
+
+void AFSoftSerial::println(long n, int base)
+{
+ print(n, base);
+ println();
+}
+
+// Private Methods /////////////////////////////////////////////////////////////
+
+void AFSoftSerial::printNumber(unsigned long n, uint8_t base)
+{
+ unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
+ unsigned long i = 0;
+
+ if (n == 0) {
+ print('0');
+ return;
+ }
+
+ while (n > 0) {
+ buf[i++] = n % base;
+ n /= base;
+ }
+
+ for (; i > 0; i--)
+ print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10));
+}
View
61 lib/libraries/AFSoftSerial/AFSoftSerial.h
@@ -0,0 +1,61 @@
+/*
+ SoftwareSerial.h - Software serial library
+ Copyright (c) 2006 David A. Mellis. All right reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef AFSoftSerial_h
+#define AFSoftSerial_h
+
+#include <inttypes.h>
+
+uint16_t whackDelay2(uint16_t delay);
+
+static void recv(void);
+
+class AFSoftSerial
+{
+ private:
+ long _baudRate;
+ void printNumber(unsigned long, uint8_t);
+
+ public:
+ AFSoftSerial(uint8_t, uint8_t);
+ void setTX(uint8_t tx);
+ void setRX(uint8_t rx);
+ void begin(long);
+ int read();
+ uint8_t available(void);
+ void print(char);
+ void print(const char[]);
+ void print(uint8_t);
+ void print(int);
+ void print(unsigned int);
+ void print(long);
+ void print(unsigned long);
+ void print(long, int);
+ void println(void);
+ void println(char);
+ void println(const char[]);
+ void println(uint8_t);
+ void println(int);
+ void println(long);
+ void println(unsigned long);
+ void println(long, int);
+};
+
+#endif
+
View
43 lib/libraries/Servo/keywords.txt → lib/libraries/AFSoftSerial/keywords.txt 100644 → 100755
@@ -1,25 +1,18 @@
-#######################################
-# Syntax Coloring Map Servo
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-Servo KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-attach KEYWORD2
-detach KEYWORD2
-write KEYWORD2
-read KEYWORD2
-attached KEYWORD2
-setMinimumPulse KEYWORD2
-setMaximumPulse KEYWORD2
-refresh KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
+#######################################
+# Syntax Coloring Map For Ultrasound
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+AFSoftSerial KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+
View
166 lib/libraries/AF_XPort/AF_XPort.cpp
@@ -0,0 +1,166 @@
+#include <avr/io.h>
+#include "WProgram.h"
+#include "AFSoftSerial.h"
+#include "AF_XPort.h"
+
+static AFSoftSerial xportserial = AFSoftSerial(0,0); // we dont know the pins yet
+
+AF_XPort::AF_XPort(uint8_t rx, uint8_t tx, uint8_t reset, uint8_t dtr, uint8_t rts, uint8_t cts) {
+ rxpin = rx;
+ txpin = tx;
+ resetpin = reset;
+ if (resetpin) {
+ pinMode(resetpin, OUTPUT);
+ digitalWrite(resetpin, HIGH);
+ }
+
+ dtrpin = dtr;
+ rtspin = rts;
+ ctspin = cts;
+ if (ctspin) {
+ digitalWrite(ctspin, HIGH);
+ pinMode(ctspin, OUTPUT);
+ }
+}
+
+void AF_XPort::begin(uint16_t b) {
+ xportserial.setTX(rxpin);
+ xportserial.setRX(txpin);
+ xportserial.begin(b);
+}
+
+uint8_t AF_XPort::reset(void) {
+ char d;
+
+ if (resetpin) {
+ digitalWrite(resetpin, LOW);
+ delay(50);
+ digitalWrite(resetpin, HIGH);
+ }
+
+ // wait for 'D' for disconnected
+ if (serialavail_timeout(5000)) { // 3 second timeout
+ d = xportserial.read();
+ //Serial.print("Read: "); Serial.print(d, HEX);
+ if (d != 'D'){
+ return ERROR_BADRESP;
+ } else {
+ return 0;
+ }
+ }
+ return ERROR_TIMEDOUT;
+}
+
+uint8_t AF_XPort::disconnected(void) {
+ if (dtrpin != 0) {
+ return digitalRead(dtrpin);
+ }
+ return 0;
+}
+
+
+uint8_t AF_XPort::connect(char *ipaddr, long port) {
+ char ret;
+
+ xportserial.print('C');
+ xportserial.print(ipaddr);
+ xportserial.print('/');
+ xportserial.println(port);
+ // wait for 'C'
+ if (serialavail_timeout(3000)) { // 3 second timeout
+ ret = xportserial.read();
+ //Serial.print("Read: "); Serial.print(d, HEX);
+ if (ret != 'C') {
+ return ERROR_BADRESP;
+ }
+ } else {
+ return ERROR_TIMEDOUT;
+ }
+ return 0;
+}
+
+
+// check to see what data is available from the xport
+uint8_t AF_XPort::serialavail_timeout(int timeout) { // in ms
+ while (timeout) {
+ if (xportserial.available()) {
+ if (ctspin) { // we read some stuff, time to stop!
+ digitalWrite(ctspin, HIGH);
+ }
+ return 1;
+ }
+ // nothing in the queue, tell it to send something
+ if (ctspin) {
+ digitalWrite(ctspin, LOW);
+ }
+ timeout -= 1;
+ delay(1);
+ }
+ if (ctspin) { // we may need to process some stuff, so stop now
+ digitalWrite(ctspin, HIGH);
+ }
+ return 0;
+}
+