Revision 891
Moved comments to headers. That was painful.
lights.c | ||
---|---|---|
221 | 221 |
|
222 | 222 |
} |
223 | 223 |
|
224 |
/** |
|
225 |
* @defgroup orbs Orbs |
|
226 |
* @brief Functions for controlling the color of the orbs. |
|
227 |
* |
|
228 |
* Functions for controlling the color and lighting of the orbs. |
|
229 |
* |
|
230 |
* @{ |
|
231 |
**/ |
|
232 |
|
|
233 |
/** |
|
234 |
* Initializes the PWM for Orb control. This must be called before |
|
235 |
* the orbs are used for them to function. |
|
236 |
**/ |
|
237 | 224 |
void orb_init() |
238 | 225 |
{ |
239 | 226 |
int i; |
... | ... | |
265 | 252 |
SREG=mysreg; |
266 | 253 |
} |
267 | 254 |
|
268 |
/** |
|
269 |
* Set both orbs to the color specified. orb_init must |
|
270 |
* be called before this function may be used. |
|
271 |
* |
|
272 |
* @param red_led the red component of the color |
|
273 |
* @param green_led the green component of the color |
|
274 |
* @param blue_led the blue component of the color |
|
275 |
* |
|
276 |
* @see orb_init |
|
277 |
**/ |
|
278 | 255 |
void orb_set(unsigned char red_led, unsigned char green_led, unsigned char blue_led) { |
279 | 256 |
orb1_set(red_led,green_led,blue_led); |
280 | 257 |
orb2_set(red_led,green_led,blue_led); |
281 | 258 |
|
282 | 259 |
} |
283 | 260 |
|
284 |
/** |
|
285 |
* Set orb1 to the color specified. orb_init must |
|
286 |
* be called before this function may be used. |
|
287 |
* |
|
288 |
* @param red_led the red component of the color |
|
289 |
* @param green_led the green component of the color |
|
290 |
* @param blue_led the blue component of the color |
|
291 |
* |
|
292 |
* @see orb_init |
|
293 |
**/ |
|
294 | 261 |
void orb1_set(unsigned char red_led, unsigned char green_led, unsigned char blue_led) { |
295 | 262 |
orb_set_angle(0,red_led); |
296 | 263 |
orb_set_angle(1,green_led); |
297 | 264 |
orb_set_angle(2,blue_led); |
298 | 265 |
} |
299 | 266 |
|
300 |
/** |
|
301 |
* Set orb2 to the color specified. orb_init must |
|
302 |
* be called before this function may be used. |
|
303 |
* |
|
304 |
* @param red_led the red component of the color |
|
305 |
* @param green_led the green component of the color |
|
306 |
* @param blue_led the blue component of the color |
|
307 |
* |
|
308 |
* @see orb_init |
|
309 |
**/ |
|
310 | 267 |
void orb2_set(unsigned char red_led, unsigned char green_led, unsigned char blue_led) { |
311 | 268 |
orb_set_angle(4,red_led); |
312 | 269 |
orb_set_angle(5,green_led); |
313 | 270 |
orb_set_angle(6,blue_led); |
314 | 271 |
} |
315 | 272 |
|
316 |
/** |
|
317 |
* Set both orbs to the specified color. This function |
|
318 |
* is intended to be used with the predefined |
|
319 |
* colors. orb_init must be called before this |
|
320 |
* function may be used. |
|
321 |
* |
|
322 |
* @param col the color to set the orbs to |
|
323 |
* |
|
324 |
* @see orb_init |
|
325 |
**/ |
|
326 | 273 |
void orb_set_color(int col) |
327 | 274 |
{ |
328 | 275 |
int red, green, blue; |
... | ... | |
334 | 281 |
orb_set(red, green, blue); |
335 | 282 |
} |
336 | 283 |
|
337 |
/** |
|
338 |
* Set orb1 to the specified color. This function |
|
339 |
* is intended to be used with the predefined |
|
340 |
* colors. orb_init must be called before this |
|
341 |
* function may be used. |
|
342 |
* |
|
343 |
* @param col the color to set the orbs to |
|
344 |
* |
|
345 |
* @see orb_init |
|
346 |
**/ |
|
347 | 284 |
void orb1_set_color(int col) |
348 | 285 |
{ |
349 | 286 |
int red, green, blue; |
... | ... | |
355 | 292 |
orb1_set(red, green, blue); |
356 | 293 |
} |
357 | 294 |
|
358 |
/** |
|
359 |
* Set orb2 to the specified color. This function |
|
360 |
* is intended to be used with the predefined |
|
361 |
* colors. orb_init must be called before this |
|
362 |
* function may be used. |
|
363 |
* |
|
364 |
* @param col the color to set the orbs to |
|
365 |
* |
|
366 |
* @see orb_init |
|
367 |
**/ |
|
368 | 295 |
void orb2_set_color(int col) |
369 | 296 |
{ |
370 | 297 |
int red, green, blue; |
... | ... | |
380 | 307 |
// Disables the timer1 interrupt, disabling the Orb's color fading capabilities |
381 | 308 |
// You can still turn the red, green, and blue leds on and off with set_orb_dio |
382 | 309 |
/* If we use the PWM for anything else besides the ORB, this implementation needs to be done better */ |
383 |
/** |
|
384 |
* Disables the orb color fading capabilities |
|
385 |
* by disabling the timer1 interrupt. |
|
386 |
* |
|
387 |
* @see orb_init |
|
388 |
**/ |
|
389 | 310 |
void orb_disable() |
390 | 311 |
{ |
391 | 312 |
TCCR3B &= 0; //Turn off everything |
... | ... | |
399 | 320 |
|
400 | 321 |
//DOES THIS WORK? |
401 | 322 |
// Enables the timer1 interrupt, enabling the Orb's color fading capabilities |
402 |
/** |
|
403 |
* Enables the orb's color fading capabilities. |
|
404 |
* |
|
405 |
* @see orb_init |
|
406 |
**/ |
|
407 | 323 |
void orb_enable() |
408 | 324 |
{ |
409 | 325 |
// TCCR0 |= _BV(COM01) | _BV(COM00) | _BV(WGM00) | _BV(CS01); //Toggle OC Pin on match, FAST PWM Mode, clock/8 |
410 | 326 |
TCCR3B =_BV(CS31); |
411 | 327 |
} |
412 | 328 |
|
413 |
/** @} **/ //end group |
|
414 |
|
Also available in: Unified diff