mirror of
https://github.com/PaulStoffregen/Tlc5940
synced 2025-09-27 10:02:20 +02:00
1. SCLK additional pulse fix
2. Minor bugs
This commit is contained in:
27
Tlc5940.cpp
27
Tlc5940.cpp
@@ -22,6 +22,7 @@
|
||||
#include "Tlc5940.h"
|
||||
#include "pinouts/pin_functions.h"
|
||||
|
||||
|
||||
int sin_pin;
|
||||
int sout_pin;
|
||||
int sclk_pin;
|
||||
@@ -57,6 +58,9 @@ volatile void (*tlc_onUpdateFinished)(void);
|
||||
the array is the same as the format of the TLC's serial interface. */
|
||||
uint8_t tlc_GSData[NUM_TLCS * 24];
|
||||
|
||||
/** Packed DOT Correction data, 12 bytes (16 * 6 bits) per TLC. */
|
||||
uint8_t tlc_DCData[NUM_TLCS * 12];
|
||||
|
||||
/** Don't add an extra SCLK pulse after switching from dot-correction mode. */
|
||||
static uint8_t firstGSInput;
|
||||
|
||||
@@ -120,6 +124,12 @@ void IRAM_ATTR TLC5940_onTimer()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ARDUINO_ARCH_ESP32)
|
||||
// SPI to send gray-scale data
|
||||
const uint32_t TLC5940_SPI_CLK = 8000000; // 8MHz
|
||||
SPIClass* TLC5940_vspi = NULL;
|
||||
#endif
|
||||
|
||||
/** \defgroup ReqVPRG_ENABLED Functions that Require VPRG_ENABLED
|
||||
Functions that require VPRG_ENABLED == 1.
|
||||
You can enable VPRG by changing
|
||||
@@ -341,7 +351,10 @@ uint8_t Tlc5940::update(void)
|
||||
firstGSInput = 0;
|
||||
} else {
|
||||
#if defined (ARDUINO_ARCH_ESP32)
|
||||
TLC5940_vspi->end(); // Release SCLK pin
|
||||
output_pin(sclk_pin);
|
||||
pulse_pin(sclk_pin);
|
||||
TLC5940_vspi->begin(sclk_pin, sout_pin, sin_pin, -1);
|
||||
#elif
|
||||
pulse_pin(SCLK_PORT, SCLK_PIN);
|
||||
#endif
|
||||
@@ -447,6 +460,14 @@ void Tlc5940::updateDC(void)
|
||||
tlc_shift8(*p++);
|
||||
tlc_shift8(*p++);
|
||||
}
|
||||
|
||||
// dot correction data latch
|
||||
#if defined (ARDUINO_ARCH_ESP32)
|
||||
pulse_pin(xlat_pin);
|
||||
#elif
|
||||
pulse_pin(XLAT_PORT, XLAT_PIN);
|
||||
#endif
|
||||
|
||||
tlc_dcModeStop();
|
||||
}
|
||||
|
||||
@@ -498,7 +519,7 @@ void Tlc5940::setAllDC(uint8_t value)
|
||||
uint8_t firstByte = value << 2 | value >> 4;
|
||||
uint8_t secondByte = value << 4 | value >> 2;
|
||||
uint8_t thirdByte = value << 6 | value;
|
||||
|
||||
uint8_t *p = tlc_DCData;
|
||||
while (p < tlc_DCData + NUM_TLCS * 12) {
|
||||
*p++ = firstByte;
|
||||
*p++ = secondByte;
|
||||
@@ -567,10 +588,6 @@ void tlc_shift8(uint8_t byte)
|
||||
|
||||
/** Initializes the SPI module */
|
||||
|
||||
// SPI to send gray-scale data
|
||||
const uint32_t TLC5940_SPI_CLK = 8000000; // 8MHz
|
||||
SPIClass* TLC5940_vspi = NULL;
|
||||
|
||||
void tlc_shift8_init(void)
|
||||
{
|
||||
TLC5940_vspi = new SPIClass(VSPI);
|
||||
|
@@ -108,7 +108,7 @@
|
||||
- 1 VPRG is connected
|
||||
\note VPRG to GND inputs grayscale data, VPRG to Vcc inputs dot-correction
|
||||
data */
|
||||
#define VPRG_ENABLED 0
|
||||
#define VPRG_ENABLED 1
|
||||
|
||||
/** Enables/disables XERR (TLC pin 16) functionality to check for shorted/broken
|
||||
LEDs
|
||||
|
@@ -103,18 +103,15 @@ tlc_setDCfromProgmem(dcArray1);
|
||||
|
||||
\param dcArray A progmem array of dot correction data to be shifted out.
|
||||
\see \link Tlc5940::setAllDC Tlc.setAllDC \endlink */
|
||||
void tlc_setDCfromProgmem(const uint8_t PROGMEM *dcArray)
|
||||
void tlc_setDCfromProgmem(const uint8_t /*PROGMEM*/ *dcArray)
|
||||
{
|
||||
tlc_dcModeStart();
|
||||
|
||||
const uint8_t PROGMEM *p = dcArray;
|
||||
const uint8_t PROGMEM *dcArrayEnd = dcArray + NUM_TLCS * 12;
|
||||
while (p < dcArrayEnd) {
|
||||
tlc_shift8(pgm_read_byte(p++));
|
||||
const uint8_t /*PROGMEM*/ *dcArrayp = dcArray;
|
||||
uint8_t *dcDatap = tlc_DCData;
|
||||
while (dcDatap < tlc_DCData + NUM_TLCS * 12) {
|
||||
*dcDatap++ = pgm_read_byte(dcArrayp++);
|
||||
*dcDatap++ = pgm_read_byte(dcArrayp++);
|
||||
*dcDatap++ = pgm_read_byte(dcArrayp++);
|
||||
}
|
||||
pulse_pin(XLAT_PORT, XLAT_PIN);
|
||||
|
||||
tlc_dcModeStop();
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
Reference in New Issue
Block a user