Updates for current Arduino IDE

Fixes bugs with AVR PROGMEM changes in Arduino IDE 1.6 or later.  Tested
with Arduino 1.8.2 and Sparkfun TLC5940 breakout.  Details at
https://github.com/arduino/Arduino/wiki/1.6-Frequently-Asked-Questions#errors-related-to-avr-progmem-changes
This commit is contained in:
Jeff-Haas 2017-04-13 23:01:06 -07:00
parent 87051f1118
commit 89d8a53ddf
3 changed files with 17 additions and 17 deletions

View File

@ -1,5 +1,5 @@
#define ANI_ARDUINO_FRAMES 80 #define ANI_ARDUINO_FRAMES 80
uint8_t ani_arduino[NUM_TLCS * 24 * ANI_ARDUINO_FRAMES] PROGMEM = { const uint8_t ani_arduino[NUM_TLCS * 24 * ANI_ARDUINO_FRAMES] PROGMEM = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,6,176,206, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,6,176,206,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,65,10,64,247,15,240,255, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,65,10,64,247,15,240,255,
0,0,0,0,0,0,0,0,0,0,0,0,1,160,122,13,192,255,15,240,254,11,192,89, 0,0,0,0,0,0,0,0,0,0,0,0,1,160,122,13,192,255,15,240,254,11,192,89,

View File

@ -30,7 +30,7 @@
#include "tlc_progmem_utils.h" #include "tlc_progmem_utils.h"
/** The currently playing animation */ /** The currently playing animation */
prog_uint8_t *tlc_currentAnimation; const uint8_t *tlc_currentAnimation;
/** The number of frames in the current animation */ /** The number of frames in the current animation */
volatile uint16_t tlc_animationFrames; volatile uint16_t tlc_animationFrames;
/** The number of PWM periods to display each frame - 1 */ /** The number of PWM periods to display each frame - 1 */
@ -39,11 +39,11 @@ volatile uint16_t tlc_animationPeriodsPerFrame;
volatile uint16_t tlc_animationPeriodsWait; volatile uint16_t tlc_animationPeriodsWait;
volatile void tlc_animationXLATCallback(void); volatile void tlc_animationXLATCallback(void);
void tlc_playAnimation(prog_uint8_t *animation, uint16_t frames, uint16_t periodsPerFrame); void tlc_playAnimation(const uint8_t PROGMEM *animation, uint16_t frames, uint16_t periodsPerFrame);
/** \addtogroup ExtendedFunctions /** \addtogroup ExtendedFunctions
\code #include "tlc_animations.h" \endcode \code #include "tlc_animations.h" \endcode
- void tlc_playAnimation(prog_uint8_t *animation, uint16_t frames, - void tlc_playAnimation(const uint8_t PROGMEM *animation, uint16_t frames,
uint16_t periodsPerFrame) - plays an animation from progmem. */ uint16_t periodsPerFrame) - plays an animation from progmem. */
/* @{ */ /* @{ */
@ -55,7 +55,7 @@ void tlc_playAnimation(prog_uint8_t *animation, uint16_t frames, uint16_t period
\param periodsPerFrame number of PWM periods to wait between each frame \param periodsPerFrame number of PWM periods to wait between each frame
(0 means play the animation as fast as possible). (0 means play the animation as fast as possible).
The default PWM period for a 16MHz clock is 1.024ms. */ The default PWM period for a 16MHz clock is 1.024ms. */
void tlc_playAnimation(prog_uint8_t *animation, uint16_t frames, uint16_t periodsPerFrame) void tlc_playAnimation(const uint8_t PROGMEM *animation, uint16_t frames, uint16_t periodsPerFrame)
{ {
tlc_currentAnimation = animation; tlc_currentAnimation = animation;
tlc_animationFrames = frames; tlc_animationFrames = frames;

View File

@ -26,17 +26,17 @@
#include "Tlc5940.h" #include "Tlc5940.h"
#include "pinouts/pin_functions.h" #include "pinouts/pin_functions.h"
void tlc_setGSfromProgmem(prog_uint8_t *gsArray); void tlc_setGSfromProgmem(const uint8_t PROGMEM *gsArray);
#if VPRG_ENABLED #if VPRG_ENABLED
void tlc_setDCfromProgmem(prog_uint8_t *dcArray); void tlc_setDCfromProgmem(const uint8_t PROGMEM *dcArray);
#endif #endif
/** \addtogroup ExtendedFunctions /** \addtogroup ExtendedFunctions
\code #include "tlc_progmem_utils.h" \endcode \code #include "tlc_progmem_utils.h" \endcode
- void tlc_setGSfromProgmem(prog_uint8_t *gsArray) - copies the progmem - void tlc_setGSfromProgmem(const uint8_t PROGMEM *gsArray) - copies the progmem
grayscale to current grayscale array. Requires a grayscale to current grayscale array. Requires a
\link Tlc5940::update Tlc.update() \endlink. \link Tlc5940::update Tlc.update() \endlink.
- void tlc_setDCfromProgmem(prog_uint8_t *dcArray) - shifts the data from a - void tlc_setDCfromProgmem(const uint8_t PROGMEM *dcArray) - shifts the data from a
progmem dot correction array (doesn't need an update). */ progmem dot correction array (doesn't need an update). */
/* @{ */ /* @{ */
@ -44,7 +44,7 @@ void tlc_setDCfromProgmem(prog_uint8_t *dcArray);
any data: call Tlc.update(). An example: any data: call Tlc.update(). An example:
\code \code
#include "tlc_progmem_utils.h" #include "tlc_progmem_utils.h"
prog_uint8_t gsArray1[NUM_TLCS * 24] = { const uint8_t PROGMEM gsArray1[NUM_TLCS * 24] = {
GS_DUO((4095 * 16)/16, (4095 * 15)/16), GS_DUO((4095 * 14)/16, (4095 * 13)/16), 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 * 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 * 8)/16, (4095 * 7)/16), GS_DUO((4095 * 6)/16, (4095 * 5)/16),
@ -62,9 +62,9 @@ Tlc.update();
The format of the grayscale array is explained in #tlc_GSData. The format of the grayscale array is explained in #tlc_GSData.
\param gsArray A progmem array of grayscale data. */ \param gsArray A progmem array of grayscale data. */
void tlc_setGSfromProgmem(prog_uint8_t *gsArray) void tlc_setGSfromProgmem(const uint8_t PROGMEM *gsArray)
{ {
prog_uint8_t *gsArrayp = gsArray; const uint8_t PROGMEM *gsArrayp = gsArray;
uint8_t *gsDatap = tlc_GSData; uint8_t *gsDatap = tlc_GSData;
while (gsDatap < tlc_GSData + NUM_TLCS * 24) { while (gsDatap < tlc_GSData + NUM_TLCS * 24) {
*gsDatap++ = pgm_read_byte(gsArrayp++); *gsDatap++ = pgm_read_byte(gsArrayp++);
@ -78,14 +78,14 @@ void tlc_setGSfromProgmem(prog_uint8_t *gsArray)
/** \addtogroup ReqVPRG_ENABLED /** \addtogroup ReqVPRG_ENABLED
From tlc_progmem_utils.h: From tlc_progmem_utils.h:
- tlc_setDCfromProgmem(prog_uint8_t *dcArray) - shifts the data from a - tlc_setDCfromProgmem(const uint8_t PROGMEM *dcArray) - shifts the data from a
progmem dot correction array (doesn't need an update). */ progmem dot correction array (doesn't need an update). */
/* @{ */ /* @{ */
/** Sets the dot correction data from an array in progmem. An example: /** Sets the dot correction data from an array in progmem. An example:
\code \code
#include "tlc_progmem_utils.h" #include "tlc_progmem_utils.h"
prog_uint8_t dcArray1[NUM_TLCS * 12] = { const uint8_t PROGMEM dcArray1[NUM_TLCS * 12] = {
DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63),
DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63), DC_QUARTET(32, 63, 32, 63),
}; };
@ -103,12 +103,12 @@ tlc_setDCfromProgmem(dcArray1);
\param dcArray A progmem array of dot correction data to be shifted out. \param dcArray A progmem array of dot correction data to be shifted out.
\see \link Tlc5940::setAllDC Tlc.setAllDC \endlink */ \see \link Tlc5940::setAllDC Tlc.setAllDC \endlink */
void tlc_setDCfromProgmem(prog_uint8_t *dcArray) void tlc_setDCfromProgmem(const uint8_t PROGMEM *dcArray)
{ {
tlc_dcModeStart(); tlc_dcModeStart();
prog_uint8_t *p = dcArray; const uint8_t PROGMEM *p = dcArray;
prog_uint8_t *dcArrayEnd = dcArray + NUM_TLCS * 12; const uint8_t PROGMEM *dcArrayEnd = dcArray + NUM_TLCS * 12;
while (p < dcArrayEnd) { while (p < dcArrayEnd) {
tlc_shift8(pgm_read_byte(p++)); tlc_shift8(pgm_read_byte(p++));
} }