// initilize pin modes and values in constructor TLC5940::TLC5940(void) { // set control pins to outputs and initial values // gsclk DDR_GSCLK |= (1 << GSCLK_PIN); PORT_GSCLK &= ~(1 << GSCLK_PIN); // sclk DDR_SCLK |= (1 << SCLK_PIN); PORT_SCLK &= ~(1 << SCLK_PIN); // dcprg DDR_DCPRG |= (1 << DCPRG_PIN); PORT_DCPRG &= ~(1 << DCPRG_PIN); // vprg DDR_VPRG |= (1 << VPRG_PIN); PORT_VPRG |= (1 << VPRG_PIN); // xlat DDR_XLAT |= (1 << XLAT_PIN); PORT_XLAT &= ~(1 << XLAT_PIN); // blank DDR_BLANK |= (1 << BLANK_PIN); PORT_BLANK |= (1 << BLANK_PIN); // serial data master out slave in DDR_MOSI |= (1 << MOSI_PIN); PORT_MOSI &= ~(1 << MOSI_PIN); // initialize variables at all leds off for safety for (uint8_t i=0; i<(16 * TLC5940_N); i++) { setDC(i, 0); } for (uint8_t i=0; i<(16 * TLC5940_N); i++) { setGS(i, 0); } gsFirstCycle = false; }
void tr_pid(int32_t uleft,int32_t uright, uint8_t dutyref) { int32_t mDC[4]; mDC[0] = dutyref + uleft; mDC[1] = dutyref - uright; mDC[2] = dutyref - uleft; mDC[3] = dutyref + uright; control_effort_limit(mDC); setDC(mDC); }
void rev_pid(int32_t ufwd,int32_t uback, uint8_t dutyref) { int32_t mDC[4]; mDC[0] = dutyref + ufwd; mDC[1] = dutyref - ufwd; mDC[2] = dutyref - uback; mDC[3] = dutyref + uback; control_effort_limit(mDC); setDC(mDC); }
// give the variables some default values TLC5940::TLC5940(void) { // initialize variables at all leds off for safety and dot correction to full brightness for (uint8_t i=0; i<(16 * TLC5940_N); i++) { setDC(i, 63); } for (uint8_t i=0; i<(16 * TLC5940_N); i++) { setGS(i, 0); } newData = false; }
void setWaveform(int numSamples, int mode, uint8 *currentWaveform) { switch (mode) { case SQUARE: setSquare(numSamples, currentWaveform); break; case SINE: setSine(numSamples, currentWaveform); break; case TRIANGLE: setTriangle(numSamples, currentWaveform); break; case SAWTOOTH: setSawtooth(numSamples, currentWaveform); break; case DC: setDC(numSamples, currentWaveform); break; } }