Extended Library Functions


Detailed Description

These functions require an include statement at the top of the sketch.

 #include "tlc_animations.h" 

 #include "tlc_fades.h" 

 #include "tlc_progmem_utils.h" 

 #include "tlc_servos.h" 

 #include "tlc_shifts.h" 


Modules

 Functions that Require VPRG_ENABLED
 Functions that require VPRG_ENABLED == 1.

Functions

void tlc_playAnimation (prog_uint8_t *animation, uint16_t frames, uint16_t periodsPerFrame)
 Plays an animation from progmem in the "background" (with interrupts).
volatile void tlc_animationXLATCallback (void)
 This is called by the XLAT interrupt every PWM period to do stuff.
uint8_t tlc_addFade (struct Tlc_Fade *fade)
 Adds a fade to the buffer.
uint8_t tlc_addFade (TLC_CHANNEL_TYPE channel, int16_t startValue, int16_t endValue, uint32_t startMillis, uint32_t endMillis)
 Adds a fade to the fade buffer.
uint8_t tlc_isFading (TLC_CHANNEL_TYPE channel)
 Checks to see if any fades are happening on channel.
uint8_t tlc_removeFades (TLC_CHANNEL_TYPE channel)
 Removes any fades from the fade buffer on this channel.
uint8_t tlc_updateFades ()
 Updates fades using millis().
uint8_t tlc_updateFades (uint32_t currentMillis)
 Updates any running fades.
void tlc_setGSfromProgmem (prog_uint8_t *gsArray)
 Sets the grayscale data from an array in progmem.
void tlc_initServos (uint8_t initAngle)
 Initializes the tlc.
void tlc_setServo (TLC_CHANNEL_TYPE channel, uint8_t angle)
 Sets a servo on channel to angle.
uint8_t tlc_getServo (TLC_CHANNEL_TYPE channel)
 Gets the current angle that channel is set to.
uint16_t tlc_angleToVal (uint8_t angle)
 Converts and angle (0 - SERVO_MAX_ANGLE) to the inverted tlc channel value (4095 - 0).
uint8_t tlc_valToAngle (uint16_t value)
 Converts an inverted tlc channel value (4095 - 0) into an angle (0 - SERVO_MAX_ANGLE).
uint16_t tlc_shiftUp (uint16_t zeroValue)
 Shifts all the channel data up (OUT0 becomes OUT1 .
uint16_t tlc_shiftDown (uint16_t topValue)
 Shifts all the channel data down (OUT 15 -> OUT 14 .


Function Documentation

uint8_t tlc_addFade ( TLC_CHANNEL_TYPE  channel,
int16_t  startValue,
int16_t  endValue,
uint32_t  startMillis,
uint32_t  endMillis 
)

Adds a fade to the fade buffer.

Parameters:
channel the ouput channel this fade is on
startValue the value at the start of the fade
endValue the value at the end of the fade
startMillis the millis() when to start the fade
endMillis the millis() when to end the fade
Returns:
0 if the fade buffer is full, fadeBufferSize if added successfully

uint8_t tlc_addFade ( struct Tlc_Fade fade  ) 

Adds a fade to the buffer.

Parameters:
fade the fade to be copied into the buffer
Returns:
0 if the fade buffer is full, fadeBufferSize if added successfully

uint16_t tlc_angleToVal ( uint8_t  angle  ) 

Converts and angle (0 - SERVO_MAX_ANGLE) to the inverted tlc channel value (4095 - 0).

volatile void tlc_animationXLATCallback ( void   ) 

This is called by the XLAT interrupt every PWM period to do stuff.

uint8_t tlc_getServo ( TLC_CHANNEL_TYPE  channel  ) 

Gets the current angle that channel is set to.

Parameters:
channel which channel to get

void tlc_initServos ( uint8_t  initAngle  ) 

Initializes the tlc.

Parameters:
initAngle the initial angle to set all servos to (0 - SERVO_MAX_ANGLE).

uint8_t tlc_isFading ( TLC_CHANNEL_TYPE  channel  ) 

Checks to see if any fades are happening on channel.

Parameters:
channel the channel to check
Returns:
1 if there is a fade in the buffer on this channel, 0 otherwise

void tlc_playAnimation ( prog_uint8_t *  animation,
uint16_t  frames,
uint16_t  periodsPerFrame 
)

Plays an animation from progmem in the "background" (with interrupts).

Parameters:
animation A progmem array of grayscale data, length NUM_TLCS * 24 * frames, in reverse order. Ensure that there is not an update waiting to happen before calling this.
frames the number of frames in animation
periodsPerFrame number of PWM periods to wait between each frame (0 means play the animation as fast as possible). The default PWM period for a 16MHz clock is 1.024ms.

uint8_t tlc_removeFades ( TLC_CHANNEL_TYPE  channel  ) 

Removes any fades from the fade buffer on this channel.

Parameters:
channel which channel the fades are on
Returns:
how many fades were removed

void tlc_setGSfromProgmem ( prog_uint8_t *  gsArray  ) 

Sets the grayscale data from an array in progmem.

This doesn't shift out any data: call Tlc.update(). An example:

#include "tlc_progmem_utils.h"
prog_uint8_t gsArray1[NUM_TLCS * 24] = {
  GS_DUO((4095 * 16)/16, (4095 * 15)/16), GS_DUO((4095 * 14)/16, (4095 * 13)/16),
  GS_DUO((4095 * 12)/16, (4095 * 11)/16), GS_DUO((4095 * 10)/16, (4095 * 9)/16),
  GS_DUO((4095 * 8)/16, (4095 * 7)/16), GS_DUO((4095 * 6)/16, (4095 * 5)/16),
  GS_DUO((4095 * 4)/16, (4095 * 3)/16), GS_DUO((4095 * 2)/16, (4095 * 1)/16),
};

// sometime after Tlc.init()
tlc_setGSfromProgmem(gsArray1);
Tlc.update();
This would set a ramp of values from OUT0 to OUT15. (Although the NUM_TLCS * 24 looks like an error, each GS_DUO is 3 bytes). The array would have to be expanded if NUM_TLCS != 1.

The format of the grayscale array is explained in tlc_GSData.

Parameters:
gsArray A progmem array of grayscale data.

void tlc_setServo ( TLC_CHANNEL_TYPE  channel,
uint8_t  angle 
)

Sets a servo on channel to angle.

Parameters:
channel which channel to set
angle (0 - SERVO_MAX_ANGLE)

uint16_t tlc_shiftDown ( uint16_t  topValue  ) 

Shifts all the channel data down (OUT 15 -> OUT 14 .

..). Needs a Tlc.update() after.

Parameters:
topValue the value of Tlc (n) channel 15.
Returns:
the value that was shifted off the bottom (OUT0)

uint16_t tlc_shiftUp ( uint16_t  zeroValue  ) 

Shifts all the channel data up (OUT0 becomes OUT1 .

..). Needs a Tlc.update() after.

Parameters:
zeroValue the value of channel 0.
Returns:
the value that was shifted off the end (OUT15)

uint8_t tlc_updateFades ( uint32_t  currentMillis  ) 

Updates any running fades.

Parameters:
currentMillis the current millis() time.
Returns:
0 if there are no fades left in the buffer.

uint8_t tlc_updateFades (  ) 

Updates fades using millis().

Returns:
0 if there are no fades left in the buffer.

uint8_t tlc_valToAngle ( uint16_t  value  ) 

Converts an inverted tlc channel value (4095 - 0) into an angle (0 - SERVO_MAX_ANGLE).


Generated on Thu Mar 5 18:09:26 2009 for Arduino Tlc5940 Library by  doxygen 1.5.6