atduskgreg-rad 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/History.txt +104 -0
  2. data/License.txt +282 -0
  3. data/Manifest.txt +142 -0
  4. data/README.rdoc +55 -0
  5. data/Rakefile +142 -0
  6. data/bin/hello_world_test/Makefile +436 -0
  7. data/bin/hello_world_test/hello_world.cpp +23 -0
  8. data/bin/rad +302 -0
  9. data/lib/examples/add_hysteresis.rb +13 -0
  10. data/lib/examples/basic_blink.rb +10 -0
  11. data/lib/examples/blink_m_address_assignment.rb +104 -0
  12. data/lib/examples/blink_m_hello.rb +14 -0
  13. data/lib/examples/blink_m_multi.rb +61 -0
  14. data/lib/examples/blink_with_serial.rb +16 -0
  15. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  16. data/lib/examples/debounce_methods.rb +49 -0
  17. data/lib/examples/external_variable_fu.rb +26 -0
  18. data/lib/examples/external_variables.rb +32 -0
  19. data/lib/examples/first_sound.rb +23 -0
  20. data/lib/examples/frequency_generator.rb +30 -0
  21. data/lib/examples/hello_array.rb +48 -0
  22. data/lib/examples/hello_array2.rb +79 -0
  23. data/lib/examples/hello_array_eeprom.rb +59 -0
  24. data/lib/examples/hello_clock.rb +84 -0
  25. data/lib/examples/hello_eeprom.rb +51 -0
  26. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  27. data/lib/examples/hello_format_print.rb +94 -0
  28. data/lib/examples/hello_lcd_charset.rb +75 -0
  29. data/lib/examples/hello_pa_lcd.rb +59 -0
  30. data/lib/examples/hello_servos.rb +88 -0
  31. data/lib/examples/hello_spectra_sound.rb +38 -0
  32. data/lib/examples/hello_world.rb +11 -0
  33. data/lib/examples/hello_xbee.rb +12 -0
  34. data/lib/examples/hysteresis_duel.rb +39 -0
  35. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  36. data/lib/examples/midi_beat_box.rb +86 -0
  37. data/lib/examples/midi_scales.rb +94 -0
  38. data/lib/examples/motor_knob.rb +30 -0
  39. data/lib/examples/servo_buttons.rb +23 -0
  40. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  41. data/lib/examples/servo_throttle.rb +40 -0
  42. data/lib/examples/software_serial.rb +10 -0
  43. data/lib/examples/sparkfun_lcd.rb +48 -0
  44. data/lib/examples/spectra_soft_pot.rb +34 -0
  45. data/lib/examples/times_method.rb +8 -0
  46. data/lib/examples/toggle.rb +10 -0
  47. data/lib/examples/twitter.rb +57 -0
  48. data/lib/examples/two_wire.rb +14 -0
  49. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  50. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  51. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  52. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  53. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  54. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  55. data/lib/libraries/DS1307/DS1307.h +66 -0
  56. data/lib/libraries/DS1307/keywords.txt +18 -0
  57. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  58. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  59. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  60. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  61. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  62. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  63. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  64. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  65. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  66. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  67. data/lib/libraries/OneWire/OneWire.h +63 -0
  68. data/lib/libraries/OneWire/keywords.txt +35 -0
  69. data/lib/libraries/OneWire/readme.txt +13 -0
  70. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +296 -0
  71. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +69 -0
  72. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  73. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  74. data/lib/libraries/Servo/Servo.cpp +192 -0
  75. data/lib/libraries/Servo/Servo.h +61 -0
  76. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  77. data/lib/libraries/Stepper/Stepper.h +86 -0
  78. data/lib/libraries/Stepper/keywords.txt +28 -0
  79. data/lib/libraries/Wire/Wire.cpp +262 -0
  80. data/lib/libraries/Wire/Wire.h +67 -0
  81. data/lib/libraries/Wire/keywords.txt +31 -0
  82. data/lib/libraries/Wire/twi.h +57 -0
  83. data/lib/libraries/Wire/utility/twi.c +449 -0
  84. data/lib/libraries/Wire/utility/twi.h +57 -0
  85. data/lib/plugins/bitwise_ops.rb +54 -0
  86. data/lib/plugins/blink.rb +25 -0
  87. data/lib/plugins/blink_m.rb +356 -0
  88. data/lib/plugins/debounce.rb +138 -0
  89. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  90. data/lib/plugins/hysteresis.rb +52 -0
  91. data/lib/plugins/input_output_state.rb +84 -0
  92. data/lib/plugins/lcd_padding.rb +58 -0
  93. data/lib/plugins/mem_test.rb +37 -0
  94. data/lib/plugins/midi.rb +60 -0
  95. data/lib/plugins/parallax_ping.rb +50 -0
  96. data/lib/plugins/servo_pulse.rb +31 -0
  97. data/lib/plugins/servo_setup.rb +86 -0
  98. data/lib/plugins/smoother.rb +54 -0
  99. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  100. data/lib/plugins/spectra_symbol.rb +79 -0
  101. data/lib/plugins/twitter_connect.rb +145 -0
  102. data/lib/rad.rb +5 -0
  103. data/lib/rad/README.rdoc +5 -0
  104. data/lib/rad/arduino_plugin.rb +246 -0
  105. data/lib/rad/arduino_sketch.rb +627 -0
  106. data/lib/rad/generators/makefile/makefile.erb +243 -0
  107. data/lib/rad/generators/makefile/makefile.rb +38 -0
  108. data/lib/rad/hardware_library.rb +813 -0
  109. data/lib/rad/init.rb +14 -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/scripts/txt2html +67 -0
  122. data/setup.rb +1585 -0
  123. data/spec/examples/hello_world.rb +11 -0
  124. data/spec/examples/serial_motor.rb +12 -0
  125. data/spec/models/arduino_sketch_spec.rb +82 -0
  126. data/spec/models/sketch_compiler_spec.rb +96 -0
  127. data/spec/models/spec_helper.rb +2 -0
  128. data/spec/sim/hello_world_spec.rb +42 -0
  129. data/spec/spec.opts +1 -0
  130. data/test/test_array_processing.rb +179 -0
  131. data/test/test_plugin_loading.rb +151 -0
  132. data/test/test_translation_post_processing.rb +185 -0
  133. data/test/test_variable_processing.rb +238 -0
  134. data/website/examples/assembler_test.rb.html +73 -0
  135. data/website/examples/gps_reader.rb.html +39 -0
  136. data/website/examples/hello_world.rb.html +38 -0
  137. data/website/examples/serial_motor.rb.html +41 -0
  138. data/website/index.html +178 -0
  139. data/website/index.txt +64 -0
  140. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  141. data/website/stylesheets/screen.css +169 -0
  142. data/website/template.rhtml +48 -0
  143. metadata +217 -0
@@ -0,0 +1,63 @@
1
+ #ifndef OneWire_h
2
+ #define OneWire_h
3
+
4
+ #include <inttypes.h>
5
+
6
+ // you can exclude onewire_search by defining that to 0
7
+ #ifndef ONEWIRE_SEARCH
8
+ #define ONEWIRE_SEARCH 0
9
+ #endif
10
+
11
+ // You can exclude onewire_crc16 by defining that to 0
12
+ #ifndef ONEWIRE_CRC16
13
+ #define ONEWIRE_CRC16 0
14
+ #endif
15
+
16
+ class OneWire
17
+ {
18
+ private:
19
+ uint8_t pin;
20
+ uint8_t port;
21
+ uint8_t bitmask;
22
+ volatile uint8_t *outputReg;
23
+ volatile uint8_t *inputReg;
24
+ volatile uint8_t *modeReg;
25
+
26
+ public:
27
+ OneWire( uint8_t pin);
28
+
29
+ // Perform a 1-Wire reset cycle. Returns 1 if a device responds
30
+ // with a presence pulse. Returns 0 if there is no device or the
31
+ // bus is shorted or otherwise held low for more than 250uS
32
+ uint8_t reset();
33
+
34
+ // Issue a 1-Wire rom skip command, to address all on bus.
35
+ void skip();
36
+
37
+ // Write a byte. If 'power' is one then the wire is held high at
38
+ // the end for parasitically powered devices. You are responsible
39
+ // for eventually depowering it by calling depower() or doing
40
+ // another read or write.
41
+ void write( uint8_t v, uint8_t power = 0);
42
+
43
+ // Read a byte.
44
+ uint8_t read();
45
+
46
+ // Write a bit. The bus is always left powered at the end, see
47
+ // note in write() about that.
48
+ void write_bit( uint8_t v);
49
+
50
+ // Read a bit.
51
+ uint8_t read_bit();
52
+
53
+ // Stop forcing power onto the bus. You only need to do this if
54
+ // you used the 'power' flag to write() or used a write_bit() call
55
+ // and aren't about to do another read or write. You would rather
56
+ // not leave this powered if you don't have to, just in case
57
+ // someone shorts your bus.
58
+ void depower();
59
+
60
+
61
+ };
62
+
63
+ #endif
@@ -0,0 +1,35 @@
1
+ #######################################
2
+ # Syntax Coloring Map For OneWire
3
+ #######################################
4
+
5
+ #######################################
6
+ # Datatypes (KEYWORD1)
7
+ #######################################
8
+
9
+ OneWire KEYWORD1
10
+
11
+ #######################################
12
+ # Methods and Functions (KEYWORD2)
13
+ #######################################
14
+
15
+ reset KEYWORD2
16
+ write_bit KEYWORD2
17
+ read_bit KEYWORD2
18
+ write KEYWORD2
19
+ read KEYWORD2
20
+ select KEYWORD2
21
+ skip KEYWORD2
22
+ depower KEYWORD2
23
+ reset_search KEYWORD2
24
+ search KEYWORD2
25
+ crc8 KEYWORD2
26
+ crc16 KEYWORD2
27
+
28
+ #######################################
29
+ # Instances (KEYWORD2)
30
+ #######################################
31
+
32
+
33
+ #######################################
34
+ # Constants (LITERAL1)
35
+ #######################################
@@ -0,0 +1,13 @@
1
+ See:
2
+ http://www.arduino.cc/playground/Learning/OneWire
3
+ http://www.federated.com/~jim/onewire/
4
+
5
+ The version of the OneWire library at federated.com works with arduino-0007.
6
+ The version here works with arduino-0008, thanks to the very helpful Jim Studt.
7
+
8
+ To use, make a new directory: arduino-0008/lib/targets/libraries/OneWire/
9
+ and put OneWire.cpp, OneWire.h and keywords.txt in it.
10
+
11
+ --Josh Larios
12
+ hades (at) elsewhere (dot) org
13
+ 2007/07/06
@@ -0,0 +1,296 @@
1
+ /*
2
+ SWSerLCDpa.cpp - Software serial to Peter Anderson controller chip based
3
+ LCD display library Adapted from SoftwareSerial.cpp (c) 2006 David A. Mellis
4
+ by Brian B. Riley, Underhill Center, Vermont, USA, July 2007
5
+
6
+ This library is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License as published by the Free Software Foundation; either
9
+ version 2.1 of the License, or (at your option) any later version.
10
+
11
+ This library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public
17
+ License along with this library; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ /******************************************************************************
22
+ * Includes
23
+ ******************************************************************************/
24
+
25
+ #include "WConstants.h"
26
+ #include "SWSerLCDpa.h"
27
+
28
+ /******************************************************************************
29
+ * Definitions
30
+ ******************************************************************************/
31
+
32
+ /******************************************************************************
33
+ * Constructors
34
+ ******************************************************************************/
35
+
36
+ SWSerLCDpa::SWSerLCDpa(uint8_t transmitPin)
37
+ {
38
+ _transmitPin = transmitPin;
39
+ _baudRate = 0;
40
+ pinMode(_transmitPin, OUTPUT);
41
+ _geometry = 0;
42
+ }
43
+
44
+ SWSerLCDpa::SWSerLCDpa(uint8_t transmitPin, int geometry)
45
+ {
46
+ _transmitPin = transmitPin;
47
+ _baudRate = 0;
48
+ pinMode(_transmitPin, OUTPUT);
49
+ _geometry = geometry;
50
+ }
51
+
52
+
53
+
54
+ /******************************************************************************
55
+ * User API
56
+ ******************************************************************************/
57
+
58
+ void SWSerLCDpa::begin(long speed)
59
+ {
60
+ _baudRate = speed;
61
+ _bitPeriod = 1000000 / _baudRate;
62
+
63
+ digitalWrite(_transmitPin, HIGH);
64
+ delayMicroseconds( _bitPeriod); // if we were low this establishes the end
65
+ delay(50);
66
+ if (_geometry)
67
+ setgeo(_geometry);
68
+ }
69
+
70
+ void SWSerLCDpa::print(uint8_t b)
71
+ {
72
+ if (_baudRate == 0)
73
+ return;
74
+
75
+ int bitDelay = _bitPeriod - clockCyclesToMicroseconds(50); // a digitalWrite is about 50 cycles
76
+ byte mask;
77
+
78
+ digitalWrite(_transmitPin, LOW);
79
+ delayMicroseconds(bitDelay);
80
+
81
+ for (mask = 0x01; mask; mask <<= 1) {
82
+ if (b & mask){ // choose bit
83
+ digitalWrite(_transmitPin,HIGH); // send 1
84
+ }
85
+ else{
86
+ digitalWrite(_transmitPin,LOW); // send 1
87
+ }
88
+ delayMicroseconds(bitDelay);
89
+ }
90
+
91
+ digitalWrite(_transmitPin, HIGH);
92
+ delayMicroseconds(bitDelay);
93
+ }
94
+
95
+ void SWSerLCDpa::print(const char *s)
96
+ {
97
+ while (*s) {
98
+ print(*s++);
99
+ delay(2);
100
+ }
101
+ }
102
+
103
+ void SWSerLCDpa::print(char c)
104
+ {
105
+ print((uint8_t) c);
106
+ }
107
+
108
+ void SWSerLCDpa::print(int n)
109
+ {
110
+ print((long) n);
111
+ }
112
+
113
+ void SWSerLCDpa::print(unsigned int n)
114
+ {
115
+ print((unsigned long) n);
116
+ }
117
+
118
+ void SWSerLCDpa::print(long n)
119
+ {
120
+ if (n < 0) {
121
+ print('-');
122
+ n = -n;
123
+ }
124
+ printNumber(n, 10);
125
+ }
126
+
127
+ void SWSerLCDpa::print(unsigned long n)
128
+ {
129
+ printNumber(n, 10);
130
+ }
131
+
132
+ void SWSerLCDpa::print(long n, int base)
133
+ {
134
+ if (base == 0)
135
+ print((char) n);
136
+ else if (base == 10)
137
+ print(n);
138
+ else
139
+ printNumber(n, base);
140
+ }
141
+
142
+ // -------- PHA unique codes -------------------------
143
+
144
+
145
+ void SWSerLCDpa::clearscr(void)
146
+ {
147
+ print("?f");
148
+ delay(30);
149
+ }
150
+
151
+ void SWSerLCDpa::clearscr(const char *s)
152
+ {
153
+ clearscr();
154
+ print(s);
155
+ }
156
+
157
+ void SWSerLCDpa::clearscr(int n)
158
+ {
159
+ clearscr();
160
+ print(n);
161
+ }
162
+
163
+ void SWSerLCDpa::clearscr(long n, int base)
164
+ {
165
+ clearscr();
166
+ print(n, base);
167
+ }
168
+
169
+
170
+ void SWSerLCDpa::clearline(int line)
171
+ {
172
+ setxy(0,line);
173
+ print("?l");
174
+ delay(20);
175
+ }
176
+
177
+ void SWSerLCDpa::clearline(int line, const char *s)
178
+ {
179
+ clearline(line);
180
+ print(s);
181
+ }
182
+
183
+ void SWSerLCDpa::clearline(int line, int n)
184
+ {
185
+ clearline(line);
186
+ print(n);
187
+ }
188
+
189
+ void SWSerLCDpa::clearline(int line, long n, int base)
190
+ {
191
+ clearline(line);
192
+ print(n, base);
193
+ }
194
+
195
+ void SWSerLCDpa::setxy(int x, int y)
196
+ {
197
+ print("?y");
198
+ print(y);
199
+ print("?x");
200
+ if (x < 10)
201
+ print('0');
202
+ print(x);
203
+ delay(10);
204
+ }
205
+
206
+ void SWSerLCDpa::setxy(int x, int y, const char *s)
207
+ {
208
+ setxy(x,y);
209
+ print(s);
210
+ }
211
+
212
+ void SWSerLCDpa::setxy(int x, int y, int n)
213
+ {
214
+ setxy(x,y);
215
+ print(n);
216
+ }
217
+
218
+ void SWSerLCDpa::setxy(int x, int y, long n, int base)
219
+ {
220
+ setxy(x,y);
221
+ print(n, base);
222
+ }
223
+
224
+ void SWSerLCDpa::home(void)
225
+ {
226
+ print("?a");
227
+ delay(10);
228
+ }
229
+
230
+ void SWSerLCDpa::home(const char *s)
231
+ {
232
+ home();
233
+ print(s);
234
+ }
235
+
236
+ void SWSerLCDpa::home(int n)
237
+ {
238
+ home();
239
+ print(n);
240
+ }
241
+
242
+ void SWSerLCDpa::home(long n, int base)
243
+ {
244
+ home();
245
+ print(n, base);
246
+ }
247
+
248
+ void SWSerLCDpa::setgeo(int geometry)
249
+ {
250
+ print("?G");
251
+ print(geometry);
252
+ delay(200);
253
+ }
254
+
255
+ void SWSerLCDpa::setintensity(int intensity)
256
+ {
257
+ print("?B");
258
+ if (intensity < 16)
259
+ print('0');
260
+ print(intensity, 16);
261
+ delay(200);
262
+ }
263
+
264
+ void SWSerLCDpa::intoBignum(void)
265
+ {
266
+ print("?>3");
267
+ }
268
+
269
+ void SWSerLCDpa::outofBignum(void)
270
+ {
271
+ print("?<");
272
+ }
273
+
274
+ // Private Methods /////////////////////////////////////////////////////////////
275
+
276
+ void SWSerLCDpa::printNumber(unsigned long n, uint8_t base)
277
+ {
278
+ unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
279
+ unsigned long i = 0;
280
+
281
+ if (n == 0) {
282
+ print('0');
283
+ return;
284
+ }
285
+
286
+ while (n > 0) {
287
+ buf[i++] = n % base;
288
+ n /= base;
289
+ }
290
+
291
+ for (; i > 0; i--) {
292
+ print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10));
293
+ delay(2);
294
+ }
295
+
296
+ }
@@ -0,0 +1,69 @@
1
+ /*
2
+ SWSerLCDpa.h - Software serial to Peter Anderson controller chip based
3
+ LCD display library Adapted from SoftwareSerial.cpp (c) 2006 David A. Mellis
4
+ by Brian B. Riley, Underhill Center, Vermont, USA, July 2007
5
+
6
+ This library is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License as published by the Free Software Foundation; either
9
+ version 2.1 of the License, or (at your option) any later version.
10
+
11
+ This library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public
17
+ License along with this library; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ #ifndef SWSerLCDpa_h
22
+ #define SWSerLCDpa_h
23
+
24
+ #include <inttypes.h>
25
+
26
+ class SWSerLCDpa
27
+ {
28
+ private:
29
+ uint8_t _transmitPin;
30
+ long _baudRate;
31
+ int _bitPeriod;
32
+ int _geometry;
33
+ void printNumber(unsigned long, uint8_t);
34
+ public:
35
+ SWSerLCDpa(uint8_t, int);
36
+ SWSerLCDpa(uint8_t);
37
+ void begin(long);
38
+ void print(char);
39
+ void print(const char[]);
40
+ void print(uint8_t);
41
+ void print(int);
42
+ void print(unsigned int);
43
+ void print(long);
44
+ void print(unsigned long);
45
+ void print(long, int);
46
+ void clearscr(void);
47
+ void clearscr(const char[]);
48
+ void clearscr(int);
49
+ void clearscr(long, int);
50
+ void clearline(int);
51
+ void clearline(int, const char[]);
52
+ void clearline(int, int);
53
+ void clearline(int, long, int);
54
+ void home(void);
55
+ void home(const char[]);
56
+ void home(int);
57
+ void home(long, int);
58
+ void setxy(int, int);
59
+ void setxy(int, int, const char[]);
60
+ void setxy(int, int, int);
61
+ void setxy(int, int, long, int);
62
+ void setgeo(int);
63
+ void setintensity(int);
64
+ void intoBignum(void);
65
+ void outofBignum(void);
66
+ };
67
+
68
+ #endif
69
+