rad 0.2.2 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/History.txt +34 -0
  2. data/Manifest.txt +113 -7
  3. data/{README.txt → README.rdoc} +17 -5
  4. data/Rakefile +3 -0
  5. data/bin/rad +106 -1
  6. data/lib/examples/add_hysteresis.rb +13 -0
  7. data/lib/examples/basic_blink.rb +10 -0
  8. data/lib/examples/blink_m_address_assignment.rb +104 -0
  9. data/lib/examples/blink_m_hello.rb +14 -0
  10. data/lib/examples/blink_m_multi.rb +61 -0
  11. data/lib/examples/blink_with_serial.rb +16 -0
  12. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  13. data/lib/examples/debounce_methods.rb +49 -0
  14. data/lib/examples/external_variable_fu.rb +26 -0
  15. data/lib/examples/external_variables.rb +32 -0
  16. data/lib/examples/first_sound.rb +23 -0
  17. data/lib/examples/frequency_generator.rb +30 -0
  18. data/lib/examples/hello_array.rb +48 -0
  19. data/lib/examples/hello_array2.rb +79 -0
  20. data/lib/examples/hello_array_eeprom.rb +59 -0
  21. data/lib/examples/hello_clock.rb +84 -0
  22. data/lib/examples/hello_eeprom.rb +51 -0
  23. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  24. data/lib/examples/hello_format_print.rb +94 -0
  25. data/lib/examples/hello_lcd_charset.rb +75 -0
  26. data/lib/examples/hello_pa_lcd.rb +59 -0
  27. data/lib/examples/hello_servos.rb +88 -0
  28. data/lib/examples/hello_spectra_sound.rb +38 -0
  29. data/lib/examples/hello_world.rb +11 -0
  30. data/lib/examples/hello_xbee.rb +12 -0
  31. data/lib/examples/hysteresis_duel.rb +39 -0
  32. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  33. data/lib/examples/midi_beat_box.rb +86 -0
  34. data/lib/examples/midi_scales.rb +94 -0
  35. data/lib/examples/motor_knob.rb +30 -0
  36. data/lib/examples/servo_buttons.rb +23 -0
  37. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  38. data/lib/examples/servo_throttle.rb +40 -0
  39. data/lib/examples/sparkfun_lcd.rb +48 -0
  40. data/lib/examples/spectra_soft_pot.rb +34 -0
  41. data/lib/examples/times_method.rb +8 -0
  42. data/lib/examples/toggle.rb +10 -0
  43. data/lib/examples/twitter.rb +57 -0
  44. data/lib/examples/two_wire.rb +14 -0
  45. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  46. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  47. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  48. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  49. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  50. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  51. data/lib/libraries/DS1307/DS1307.h +66 -0
  52. data/lib/libraries/{SWSerLCDpa → DS1307}/keywords.txt +1 -1
  53. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  54. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  55. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  56. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  57. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  58. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  59. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  60. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  61. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  62. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  63. data/lib/libraries/OneWire/OneWire.h +63 -0
  64. data/lib/libraries/OneWire/keywords.txt +35 -0
  65. data/lib/libraries/OneWire/readme.txt +13 -0
  66. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +93 -47
  67. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +16 -9
  68. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  69. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  70. data/lib/libraries/Servo/Servo.cpp +192 -0
  71. data/lib/libraries/Servo/Servo.h +61 -0
  72. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  73. data/lib/libraries/Stepper/Stepper.h +86 -0
  74. data/lib/libraries/Stepper/keywords.txt +28 -0
  75. data/lib/libraries/Wire/Wire.cpp +262 -0
  76. data/lib/libraries/Wire/Wire.h +67 -0
  77. data/lib/libraries/Wire/keywords.txt +31 -0
  78. data/lib/libraries/Wire/twi.h +57 -0
  79. data/lib/libraries/Wire/utility/twi.c +449 -0
  80. data/lib/libraries/Wire/utility/twi.h +57 -0
  81. data/lib/plugins/bitwise_ops.rb +54 -0
  82. data/lib/plugins/blink.rb +25 -0
  83. data/lib/plugins/blink_m.rb +356 -0
  84. data/lib/plugins/debounce.rb +138 -0
  85. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  86. data/lib/plugins/hysteresis.rb +52 -0
  87. data/lib/plugins/input_output_state.rb +84 -0
  88. data/lib/plugins/lcd_padding.rb +58 -0
  89. data/lib/plugins/mem_test.rb +37 -0
  90. data/lib/plugins/midi.rb +60 -0
  91. data/lib/plugins/parallax_ping.rb +50 -0
  92. data/lib/plugins/servo_pulse.rb +31 -0
  93. data/lib/plugins/servo_setup.rb +86 -0
  94. data/lib/plugins/smoother.rb +54 -0
  95. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  96. data/lib/plugins/spectra_symbol.rb +79 -0
  97. data/lib/plugins/twitter_connect.rb +145 -0
  98. data/lib/rad/README.rdoc +5 -0
  99. data/lib/rad/arduino_plugin.rb +246 -0
  100. data/lib/rad/arduino_sketch.rb +351 -257
  101. data/lib/rad/generators/makefile/makefile.erb +1 -1
  102. data/lib/rad/generators/makefile/makefile.rb +9 -10
  103. data/lib/rad/hardware_library.rb +813 -0
  104. data/lib/rad/init.rb +3 -1
  105. data/lib/rad/rad_processor.rb +128 -0
  106. data/lib/rad/rad_rewriter.rb +94 -0
  107. data/lib/rad/rad_type_checker.rb +26 -0
  108. data/lib/rad/sim/arduino_sketch.rb +57 -0
  109. data/lib/rad/sketch_compiler.rb +47 -0
  110. data/lib/rad/tasks/build_and_make.rake +146 -24
  111. data/lib/rad/variable_processing.rb +153 -0
  112. data/lib/rad/version.rb +1 -1
  113. data/spec/examples/hello_world.rb +11 -0
  114. data/spec/examples/serial_motor.rb +12 -0
  115. data/spec/models/sketch_compiler_spec.rb +96 -0
  116. data/spec/sim/hello_world_spec.rb +42 -0
  117. data/test/test_array_processing.rb +179 -0
  118. data/test/test_plugin_loading.rb +151 -0
  119. data/test/test_translation_post_processing.rb +185 -0
  120. data/test/test_variable_processing.rb +238 -0
  121. data/website/index.html +22 -7
  122. data/website/stylesheets/screen.css +32 -1
  123. metadata +130 -13
@@ -0,0 +1,57 @@
1
+ /*
2
+ twi.h - TWI/I2C library for Wiring & Arduino
3
+ Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+ #ifndef twi_h
21
+ #define twi_h
22
+
23
+ #include <inttypes.h>
24
+
25
+ //#define ATMEGA8
26
+
27
+ #ifndef CPU_FREQ
28
+ #define CPU_FREQ 16000000L
29
+ #endif
30
+
31
+ #ifndef TWI_FREQ
32
+ #define TWI_FREQ 100000L
33
+ #endif
34
+
35
+ #ifndef TWI_BUFFER_LENGTH
36
+ #define TWI_BUFFER_LENGTH 32
37
+ #endif
38
+
39
+ #define TWI_READY 0
40
+ #define TWI_MRX 1
41
+ #define TWI_MTX 2
42
+ #define TWI_SRX 3
43
+ #define TWI_STX 4
44
+
45
+ void twi_init(void);
46
+ void twi_setAddress(uint8_t);
47
+ uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t);
48
+ uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t);
49
+ uint8_t twi_transmit(uint8_t*, uint8_t);
50
+ void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
51
+ void twi_attachSlaveTxEvent( void (*)(void) );
52
+ void twi_reply(uint8_t);
53
+ void twi_stop(void);
54
+ void twi_releaseBus(void);
55
+
56
+ #endif
57
+
@@ -0,0 +1,54 @@
1
+ class BitwiseOps < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+
10
+ # add to directives
11
+
12
+ # add to external variables
13
+
14
+ # add the following to the setup method
15
+ # add_to_setup
16
+
17
+
18
+ int build_int(int hibyte, int lobyte) {
19
+ return((hibyte << 8) + lobyte);
20
+ }
21
+
22
+ int i_shiftleft(int val, int shift) {
23
+ return(val << shift);
24
+ }
25
+
26
+ int i_shiftright(int val, int shift) {
27
+ return(val >> shift);
28
+ }
29
+
30
+ byte b_shiftleft(byte val, byte shift) {
31
+ return(val << shift);
32
+ }
33
+
34
+ byte b_shiftright(byte val, byte shift) {
35
+ return(val >> shift);
36
+ }
37
+
38
+ int bit_and(int val, int mask) {
39
+ return(val & mask);
40
+ }
41
+
42
+ int bit_or(int val, int mask) {
43
+ return(val | mask);
44
+ }
45
+
46
+ int bit_xor(int val, int mask) {
47
+ return(val ^ mask);
48
+ }
49
+
50
+ int twos_comp(int val) {
51
+ return((val ^ 0xffff) + 1);
52
+ }
53
+
54
+ end
@@ -0,0 +1,25 @@
1
+ class Blink < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+
10
+ # add to directives
11
+
12
+ # add to external variables
13
+
14
+ # add the following to the setup method
15
+ # add_to_setup
16
+
17
+
18
+ void blink(int pin, int ms) {
19
+ digitalWrite( pin, HIGH );
20
+ delay( ms );
21
+ digitalWrite( pin, LOW );
22
+ delay( ms );
23
+ }
24
+
25
+ end
@@ -0,0 +1,356 @@
1
+ class BlinkM < ArduinoPlugin
2
+
3
+ #
4
+ #
5
+ # BlinkM_funcs.h -- Arduino library to control BlinkM
6
+ # --------------
7
+ #
8
+ #
9
+ # Note: original version of this file lives with the BlinkMTester sketch
10
+ #
11
+ # 2007, Tod E. Kurt, ThingM, http://thingm.com/
12
+ #
13
+ # version: 20080203
14
+ #
15
+ # history:
16
+ # 20080101 - initial release
17
+ # 20080203 - added setStartupParam(), bugfix receiveBytes() from Dan Julio
18
+ # 20080727 - ported to rad jd barnhart
19
+ #
20
+ # first step, declare output pin 19 as i2c
21
+ ## output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
22
+
23
+
24
+ include_wire
25
+
26
+ add_blink_m_struct
27
+
28
+
29
+
30
+ # Not needed when pin is declared with :enable => :true
31
+ # In fact, declaring it twice causes nothing but problems
32
+
33
+ static void BlinkM_begin()
34
+ {
35
+ Wire.begin(); // join i2c bus (address optional for master)
36
+ }
37
+
38
+
39
+ // General version of BlinkM_beginWithPower().
40
+
41
+ static void BlinkM_beginWithPowerPins(byte pwrpin, byte gndpin)
42
+ {
43
+ DDRC |= _BV(pwrpin) | _BV(gndpin); // make outputs
44
+ PORTC &=~ _BV(gndpin);
45
+ PORTC |= _BV(pwrpin);
46
+ delay(100); // wait for things to stabilize
47
+
48
+ Wire.begin();
49
+ }
50
+
51
+ // Call this first when BlinkM is plugged directly into Arduino
52
+ // The BlinkMs PWR (power) pins should line up with pins 2 and 3 of the connector,
53
+ // while the I2C (communications) pins should line up with pins 4 and 5.
54
+
55
+ static void BlinkM_beginWithPower()
56
+ {
57
+ BlinkM_beginWithPowerPins( PC3, PC2 );
58
+ }
59
+
60
+ // sends a generic command
61
+
62
+ static void BlinkM_sendCmd(byte addr, byte* cmd, int cmdlen)
63
+ {
64
+ Wire.beginTransmission(addr);
65
+ for( byte i=0; i<cmdlen; i++)
66
+ Wire.send(cmd[i]);
67
+ Wire.endTransmission();
68
+ }
69
+
70
+ // receives generic data
71
+ // returns 0 on success, and -1 if no data available
72
+ // note: responsiblity of caller to know how many bytes to expect
73
+
74
+ static int BlinkM_receiveBytes(byte addr, byte* resp, byte len)
75
+ {
76
+ Wire.requestFrom(addr, len);
77
+ if( Wire.available() ) {
78
+ for( int i=0; i<len; i++)
79
+ resp[i] = Wire.receive();
80
+ return 0;
81
+ }
82
+ return -1;
83
+ }
84
+
85
+ // Sets the I2C address of the BlinkM(s)
86
+ // Typically used to setup BlinkM addresses
87
+ // Connect one and call this with an address like 10,
88
+ // then 11 for the next and so on and so forth
89
+ // Uses "general call" broadcast address
90
+
91
+ static void BlinkM_setAddress(byte newaddress)
92
+ {
93
+ Wire.beginTransmission(0x00); // general call (broadcast address)
94
+ Wire.send('A');
95
+ Wire.send(newaddress);
96
+ Wire.send(0xD0);
97
+ Wire.send(0x0D); // dood!
98
+ Wire.send(newaddress);
99
+ Wire.endTransmission();
100
+ delay(50); // just in case
101
+ }
102
+
103
+
104
+ // Gets the I2C addrss of the BlinkM
105
+ // Kind of redundant when sent to a specific address
106
+ // but uses to verify BlinkM communication
107
+
108
+ static int BlinkM_getAddress(byte addr)
109
+ {
110
+ Wire.beginTransmission(addr);
111
+ Wire.send('a');
112
+ Wire.endTransmission();
113
+ Wire.requestFrom(addr, (byte)1);
114
+ if( Wire.available() ) {
115
+ byte b = Wire.receive();
116
+ return b;
117
+ }
118
+ return -1;
119
+ }
120
+
121
+ // Gets the BlinkM firmware version
122
+
123
+ static int BlinkM_getVersion(byte addr)
124
+ {
125
+ Wire.beginTransmission(addr);
126
+ Wire.send('Z');
127
+ Wire.endTransmission();
128
+ Wire.requestFrom(addr, (byte)2);
129
+ if( Wire.available() ) {
130
+ byte major_ver = Wire.receive();
131
+ byte minor_ver = Wire.receive();
132
+ return (major_ver<<8) + minor_ver;
133
+ }
134
+ return -1;
135
+ }
136
+
137
+ // Demonstrates how to verify you-re talking to a BlinkM
138
+ // and that you know its address -- message version
139
+
140
+ static char* blink_m_check_address_message(byte addr) // :as => :optional
141
+ {
142
+ char message[50];
143
+ char status[5];
144
+ strcpy(message, "received 0x");
145
+ //Serial.print("Checking BlinkM address...");
146
+ int b = BlinkM_getAddress(addr);
147
+ if( b==-1 ) {
148
+ //Serial.println("No response, that's not good");
149
+ return "No response, that's not good"; // no response
150
+ }
151
+ itoa(b, status ,16);
152
+
153
+ //Serial.print("received addr: 0x");
154
+ //Serial.print(b,HEX);
155
+ if( b != addr )
156
+ return "error, mismatch"; // error, addr mismatch
157
+ else
158
+ return strcat(message, status); // match, everything okay
159
+ }
160
+
161
+ // Demonstrates how to verify you-re talking to a BlinkM
162
+ // and that you know its address -- digital version
163
+
164
+ static int BlinkM_checkAddress(byte addr)
165
+ {
166
+ //Serial.print("Checking BlinkM address...");
167
+ int b = BlinkM_getAddress(addr);
168
+ if( b==-1 ) {
169
+ //Serial.println("No response, that's not good");
170
+ return -1; // no response
171
+ }
172
+
173
+ //Serial.print("received addr: 0x");
174
+ //Serial.print(b,HEX);
175
+ if( b != addr )
176
+ return 1; // error, addr mismatch
177
+ else
178
+ return 0; // match, everything okay
179
+ }
180
+
181
+ // Sets the speed of fading between colors.
182
+ // Higher numbers means faster fading, 255 == instantaneous fading
183
+
184
+ static void BlinkM_setFadeSpeed(byte addr, byte fadespeed)
185
+ {
186
+ Wire.beginTransmission(addr);
187
+ Wire.send('f');
188
+ Wire.send(fadespeed);
189
+ Wire.endTransmission();
190
+ }
191
+
192
+ // Sets the light script playback time adjust
193
+ // The timeadj argument is signed, and is an additive value to all
194
+ // durations in a light script. Set to zero to turn off time adjust.
195
+
196
+ static void BlinkM_setTimeAdj(byte addr, byte timeadj)
197
+ {
198
+ Wire.beginTransmission(addr);
199
+ Wire.send('t');
200
+ Wire.send(timeadj);
201
+ Wire.endTransmission();
202
+ }
203
+
204
+ // Fades to an RGB color
205
+
206
+ static void BlinkM_fadeToRGB(byte addr, byte red, byte grn, byte blu)
207
+ {
208
+ Wire.beginTransmission(addr);
209
+ Wire.send('c');
210
+ Wire.send(red);
211
+ Wire.send(grn);
212
+ Wire.send(blu);
213
+ Wire.endTransmission();
214
+ }
215
+
216
+ // Fades to an HSB color
217
+
218
+ static void BlinkM_fadeToHSB(byte addr, byte hue, byte saturation, byte brightness)
219
+ {
220
+ Wire.beginTransmission(addr);
221
+ Wire.send('h');
222
+ Wire.send(hue);
223
+ Wire.send(saturation);
224
+ Wire.send(brightness);
225
+ Wire.endTransmission();
226
+ }
227
+
228
+ // Sets an RGB color immediately
229
+
230
+ static void BlinkM_setRGB(byte addr, byte red, byte grn, byte blu)
231
+ {
232
+ Wire.beginTransmission(addr);
233
+ Wire.send('n');
234
+ Wire.send(red);
235
+ Wire.send(grn);
236
+ Wire.send(blu);
237
+ Wire.endTransmission();
238
+ }
239
+
240
+ // Fades to a random RGB color
241
+
242
+ static void BlinkM_fadeToRandomRGB(byte addr, byte rrnd, byte grnd, byte brnd)
243
+ {
244
+ Wire.beginTransmission(addr);
245
+ Wire.send('C');
246
+ Wire.send(rrnd);
247
+ Wire.send(grnd);
248
+ Wire.send(brnd);
249
+ Wire.endTransmission();
250
+ }
251
+ // Fades to a random HSB color
252
+
253
+ static void BlinkM_fadeToRandomHSB(byte addr, byte hrnd, byte srnd, byte brnd)
254
+ {
255
+ Wire.beginTransmission(addr);
256
+ Wire.send('H');
257
+ Wire.send(hrnd);
258
+ Wire.send(srnd);
259
+ Wire.send(brnd);
260
+ Wire.endTransmission();
261
+ }
262
+
263
+ static void BlinkM_getRGBColor(byte addr, byte* r, byte* g, byte* b)
264
+ {
265
+ Wire.beginTransmission(addr);
266
+ Wire.send('g');
267
+ Wire.endTransmission();
268
+ Wire.requestFrom(addr, (byte)3);
269
+ if( Wire.available() ) {
270
+ *r = Wire.receive();
271
+ *g = Wire.receive();
272
+ *b = Wire.receive();
273
+ }
274
+ }
275
+
276
+ static void BlinkM_playScript(byte addr, byte script_id, byte reps, byte pos)
277
+ {
278
+ Wire.beginTransmission(addr);
279
+ Wire.send('p');
280
+ Wire.send(script_id);
281
+ Wire.send(reps);
282
+ Wire.send(pos);
283
+ Wire.endTransmission();
284
+ }
285
+
286
+ static void BlinkM_stopScript(byte addr)
287
+ {
288
+ Wire.beginTransmission(addr);
289
+ Wire.send('o');
290
+ Wire.endTransmission();
291
+ }
292
+
293
+ static void BlinkM_setScriptLengthReps(byte addr, byte script_id,
294
+ byte len, byte reps)
295
+ {
296
+ Wire.beginTransmission(addr);
297
+ Wire.send('L');
298
+ Wire.send(script_id);
299
+ Wire.send(len);
300
+ Wire.send(reps);
301
+ Wire.endTransmission();
302
+ }
303
+
304
+ static void BlinkM_writeScriptLine(byte addr, byte script_id,
305
+ byte pos, byte dur,
306
+ byte cmd, byte arg1, byte arg2, byte arg3)
307
+ {
308
+ #ifdef BLINKM_FUNCS_DEBUG
309
+ Serial.print("writing line:"); Serial.print(pos,DEC);
310
+ Serial.print(" with cmd:"); Serial.print(cmd);
311
+ Serial.print(" arg1:"); Serial.println(arg1,HEX);
312
+ #endif
313
+ Wire.beginTransmission(addr);
314
+ Wire.send('W');
315
+ Wire.send(script_id);
316
+ Wire.send(pos);
317
+ Wire.send(dur);
318
+ Wire.send(cmd);
319
+ Wire.send(arg1);
320
+ Wire.send(arg2);
321
+ Wire.send(arg3);
322
+ Wire.endTransmission();
323
+ }
324
+
325
+ static void BlinkM_writeScript(byte addr, byte script_id,
326
+ byte len, byte reps,
327
+ blinkm_script_line* lines)
328
+ {
329
+ #ifdef BLINKM_FUNCS_DEBUG
330
+ Serial.print("writing script to addr:"); Serial.print(addr,DEC);
331
+ Serial.print(", script_id:"); Serial.println(script_id,DEC);
332
+ #endif
333
+ for(byte i=0; i < len; i++) {
334
+ blinkm_script_line l = lines[i];
335
+ BlinkM_writeScriptLine( addr, script_id, i, l.dur,
336
+ l.cmd[0], l.cmd[1], l.cmd[2], l.cmd[3]);
337
+ }
338
+ BlinkM_setScriptLengthReps(addr, script_id, len, reps);
339
+ }
340
+
341
+
342
+ static void BlinkM_setStartupParams(byte addr, byte mode, byte script_id,
343
+ byte reps, byte fadespeed, byte timeadj)
344
+ {
345
+ Wire.beginTransmission(addr);
346
+ Wire.send('B');
347
+ Wire.send(mode);
348
+ Wire.send(script_id);
349
+ Wire.send(reps);
350
+ Wire.send(fadespeed);
351
+ Wire.send(timeadj);
352
+ Wire.endTransmission();
353
+ }
354
+
355
+
356
+ end