Skip to content

Commit af288cb

Browse files
authored
Merge pull request pixelmatix#174 from pixelmatix/easone-patch-1
Fix compiler warnings in latest version of Teensyduino
2 parents 8fac208 + 134e5b6 commit af288cb

9 files changed

+44
-36
lines changed

src/Layer_BackgroundGfx_Impl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::begin(void) {
6464
backgroundBuffers[1] = (RGB *)ESPmalloc(sizeof(RGB) * this->matrixWidth * this->matrixHeight);
6565
assert(backgroundBuffers[1] != NULL);
6666
//printf("largest free block %d: \r\n", heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
67-
memset(backgroundBuffers[0], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
68-
memset(backgroundBuffers[1], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
67+
memset((void *)backgroundBuffers[0], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
68+
memset((void *)backgroundBuffers[1], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
6969
//printf("largest free block %d: \r\n", heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
7070
}
7171
if(!backgroundColorCorrectionLUT) {
@@ -182,7 +182,7 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::fillRefreshRow(uint16_t hardwareY,
182182

183183
template <typename RGB, unsigned int optionFlags>
184184
void SMLayerBackgroundGFX<RGB, optionFlags>::copyRefreshToDrawing() {
185-
memcpy(currentDrawBufferPtr, currentRefreshBufferPtr, sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
185+
memcpy((void *)currentDrawBufferPtr, (void *)currentRefreshBufferPtr, sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
186186
}
187187

188188
// waits until previous swap is complete
@@ -198,12 +198,12 @@ void SMLayerBackgroundGFX<RGB, optionFlags>::swapBuffers(bool copy) {
198198
#if 1
199199
// workaround for bizarre (optimization) bug - currentDrawBuffer and currentRefreshBuffer are volatile and are changed by an ISR while we're waiting for swapPending here. They can't be used as parameters to memcpy directly though.
200200
if(currentDrawBuffer)
201-
memcpy(backgroundBuffers[1], backgroundBuffers[0], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
201+
memcpy((void *)backgroundBuffers[1], (void *)backgroundBuffers[0], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
202202
else
203-
memcpy(backgroundBuffers[0], backgroundBuffers[1], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
203+
memcpy((void *)backgroundBuffers[0], (void *)backgroundBuffers[1], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
204204
#else
205205
// Similar code also drawing from volatile variables doesn't work if optimization is turned on: currentDrawBuffer will be equal to currentRefreshBuffer and cause a crash from memcpy copying a buffer to itself. Why?
206-
memcpy(backgroundBuffers[currentDrawBuffer], backgroundBuffers[currentRefreshBuffer], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
206+
memcpy((void *)backgroundBuffers[currentDrawBuffer], (void *)backgroundBuffers[currentRefreshBuffer], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
207207
208208
// this also doesn't work
209209
//copyRefreshToDrawing();

src/Layer_Background_Impl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void SMLayerBackground<RGB, optionFlags>::begin(void) {
6060
backgroundBuffers[1] = (RGB *)ESPmalloc(sizeof(RGB) * this->matrixWidth * this->matrixHeight);
6161
assert(backgroundBuffers[1] != NULL);
6262
//printf("largest free block %d: \r\n", heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
63-
memset(backgroundBuffers[0], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
64-
memset(backgroundBuffers[1], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
63+
memset((void *)backgroundBuffers[0], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
64+
memset((void *)backgroundBuffers[1], 0x00, sizeof(RGB) * this->matrixWidth * this->matrixHeight);
6565
//printf("largest free block %d: \r\n", heap_caps_get_largest_free_block(MALLOC_CAP_DMA));
6666
}
6767
if(!backgroundColorCorrectionLUT) {
@@ -971,12 +971,12 @@ void SMLayerBackground<RGB, optionFlags>::swapBuffers(bool copy) {
971971
#if 1
972972
// workaround for bizarre (optimization) bug - currentDrawBuffer and currentRefreshBuffer are volatile and are changed by an ISR while we're waiting for swapPending here. They can't be used as parameters to memcpy directly though.
973973
if(currentDrawBuffer)
974-
memcpy(backgroundBuffers[1], backgroundBuffers[0], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
974+
memcpy((void *)backgroundBuffers[1], (void *)backgroundBuffers[0], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
975975
else
976-
memcpy(backgroundBuffers[0], backgroundBuffers[1], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
976+
memcpy((void *)backgroundBuffers[0], (void *)backgroundBuffers[1], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
977977
#else
978978
// Similar code also drawing from volatile variables doesn't work if optimization is turned on: currentDrawBuffer will be equal to currentRefreshBuffer and cause a crash from memcpy copying a buffer to itself. Why?
979-
memcpy(backgroundBuffers[currentDrawBuffer], backgroundBuffers[currentRefreshBuffer], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
979+
memcpy((void *)backgroundBuffers[currentDrawBuffer], (void *)backgroundBuffers[currentRefreshBuffer], sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
980980
981981
// this also doesn't work
982982
//copyRefreshToDrawing();
@@ -990,7 +990,7 @@ void SMLayerBackground<RGB, optionFlags>::swapBuffers(bool copy) {
990990

991991
template <typename RGB, unsigned int optionFlags>
992992
void SMLayerBackground<RGB, optionFlags>::copyRefreshToDrawing() {
993-
memcpy(currentDrawBufferPtr, currentRefreshBufferPtr, sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
993+
memcpy((void *)currentDrawBufferPtr, (void *)currentRefreshBufferPtr, sizeof(RGB) * (this->matrixWidth * this->matrixHeight));
994994
}
995995

996996
// return pointer to start of currentDrawBuffer, so application can do efficient loading of bitmaps

src/Layer_Scrolling_Impl.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,14 @@ void SMLayerScrolling<RGB, optionFlags>::setMinMax(void) {
226226

227227
template <typename RGB, unsigned int optionFlags>
228228
void SMLayerScrolling<RGB, optionFlags>::start(const char inputtext[], int numScrolls) {
229-
int length = strlen((const char *)inputtext);
230-
if (length > textLayerMaxStringLength)
231-
length = textLayerMaxStringLength;
229+
// int length = strlen((const char *)inputtext);
230+
// if (length > textLayerMaxStringLength)
231+
// length = textLayerMaxStringLength;
232+
int length = textLayerMaxStringLength;
233+
if ((int)strlen((const char *)inputtext) < length)
234+
length = strlen((const char *)inputtext);
232235
strncpy(text, (const char *)inputtext, length);
236+
text[textLayerMaxStringLength-1] = '\0'; // add null-termination to fix compiler warning
233237
textlen = length;
234238
scrollcounter = numScrolls;
235239

@@ -242,10 +246,14 @@ void SMLayerScrolling<RGB, optionFlags>::start(const char inputtext[], int numSc
242246
//Useful for a clock display where the time changes.
243247
template <typename RGB, unsigned int optionFlags>
244248
void SMLayerScrolling<RGB, optionFlags>::update(const char inputtext[]){
245-
int length = strlen((const char *)inputtext);
246-
if (length > textLayerMaxStringLength)
247-
length = textLayerMaxStringLength;
249+
// int length = strlen((const char *)inputtext);
250+
// if (length > textLayerMaxStringLength)
251+
// length = textLayerMaxStringLength;
252+
int length = textLayerMaxStringLength;
253+
if ((int)strlen((const char *)inputtext) < length)
254+
length = strlen((const char *)inputtext);
248255
strncpy(text, (const char *)inputtext, length);
256+
text[textLayerMaxStringLength-1] = '\0'; // add null-termination to fix compiler warning
249257
textlen = length;
250258
textWidth = (textlen * scrollFont->Width) - 1;
251259

src/MatrixCommonApa102Calc_Impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ INLINE void SmartMatrixApaCalc<refreshDepth, matrixWidth, matrixHeight, panelTyp
247247
static rgb48 tempRow0[matrixWidth];
248248

249249
// clear buffer to prevent garbage data showing through transparent layers
250-
memset(tempRow0, 0x00, sizeof(tempRow0));
250+
memset((void *)tempRow0, 0x00, sizeof(tempRow0));
251251

252252
// get pixel data from layers
253253
SM_Layer * templayer = SmartMatrixApaCalc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::baseLayer;

src/MatrixEsp32Hub75Calc_Impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
514514
// go through this process for each physical row that is contained in the refresh row
515515
do {
516516
// clear buffer to prevent garbage data showing through transparent layers
517-
memset(tempRow0, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
518-
memset(tempRow1, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
517+
memset((void *)tempRow0, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
518+
memset((void *)tempRow1, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
519519

520520
#if (REFRESH_PRINTFS >= 1)
521521
printf("multiRowRefreshRowOffset = %d\r\n", multiRowRefreshRowOffset);
@@ -841,8 +841,8 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
841841
// go through this process for each physical row that is contained in the refresh row
842842
do {
843843
// clear buffer to prevent garbage data showing through transparent layers
844-
memset(tempRow0, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
845-
memset(tempRow1, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
844+
memset((void *)tempRow0, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
845+
memset((void *)tempRow1, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
846846

847847
// get a row of physical pixel data (HUB75 paired) from the layers
848848
SM_Layer * templayer = SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::baseLayer;

src/MatrixEsp32Hub75Calc_NT_Impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ INLINE void SmartMatrixHub75Calc_NT<dummyvar>::loadMatrixBuffers48(MATRIX_DATA_S
450450
// go through this process for each physical row that is contained in the refresh row
451451
do {
452452
// clear buffer to prevent garbage data showing through transparent layers
453-
memset(tempRow0, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
454-
memset(tempRow1, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
453+
memset((void *)tempRow0, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
454+
memset((void *)tempRow1, 0x00, sizeof(rgb48) * numPixelsPerTempRow);
455455

456456
#if (REFRESH_PRINTFS >= 1)
457457
printf("multiRowRefreshRowOffset = %d\r\n", multiRowRefreshRowOffset);
@@ -778,8 +778,8 @@ INLINE void SmartMatrixHub75Calc_NT<dummyvar>::loadMatrixBuffers24(MATRIX_DATA_S
778778
// go through this process for each physical row that is contained in the refresh row
779779
do {
780780
// clear buffer to prevent garbage data showing through transparent layers
781-
memset(tempRow0, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
782-
memset(tempRow1, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
781+
memset((void *)tempRow0, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
782+
memset((void *)tempRow1, 0x00, sizeof(rgb24) * numPixelsPerTempRow);
783783

784784
// get a row of physical pixel data (HUB75 paired) from the layers
785785
SM_Layer * templayer = baseLayer;

src/MatrixTeensy3Hub75Calc_Impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelT
363363
// go through this process for each physical row that is contained in the refresh row
364364
do {
365365
// clear buffer to prevent garbage data showing through transparent layers
366-
memset(tempRow0, 0x00, sizeof(tempRow0));
367-
memset(tempRow1, 0x00, sizeof(tempRow1));
366+
memset((void *)tempRow0, 0x00, sizeof(tempRow0));
367+
memset((void *)tempRow1, 0x00, sizeof(tempRow1));
368368

369369
// get pixel data from layers
370370
SM_Layer * templayer = SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::baseLayer;

src/MatrixTeensy4Hub75Calc_Impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ FASTRUN INLINE void SmartMatrixHub75Calc<refreshDepth, matrixWidth, matrixHeight
381381
// go through this process for each physical row that is contained in the refresh row
382382
do {
383383
// clear buffer to prevent garbage data showing
384-
memset(tempRow0, 0, sizeof(tempRow0));
385-
memset(tempRow1, 0, sizeof(tempRow1));
384+
memset((void *)tempRow0, 0, sizeof(tempRow0));
385+
memset((void *)tempRow1, 0, sizeof(tempRow1));
386386

387387
// Get pixel data from layers and store in tempRow0 and tempRow1
388388
// Scan through the entire chain of panels and extract rows from each one

src/MatrixTeensy4Hub75Refresh_Impl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ FLASHMEM void SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, pane
656656

657657
unsigned int minorLoopBytes, minorLoopIterations, majorLoopBytes, majorLoopIterations;
658658
int destinationAddressOffset, destinationAddressLastOffset, sourceAddressOffset, sourceAddressLastOffset, minorLoopOffset;
659-
volatile uint32_t *destinationAddress1, *destinationAddress2, *sourceAddress;
659+
volatile void *destinationAddress1, *destinationAddress2, *sourceAddress;
660660

661661
rowBitStructBytesToShift = sizeof(SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::matrixUpdateRows[0].rowbits[0].data);
662662

@@ -677,11 +677,11 @@ FLASHMEM void SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, pane
677677
// The destination address is set to write to the OE duty cycle register, then the period register, then reset.
678678
minorLoopBytes = TIMER_REGISTERS_TO_UPDATE * sizeof(uint16_t);
679679
majorLoopIterations = 1;
680-
sourceAddress = (volatile uint32_t*) & (matrixUpdateRows[0].rowbits[0].timerValues.timer_oe);
680+
sourceAddress = & (matrixUpdateRows[0].rowbits[0].timerValues.timer_oe);
681681
sourceAddressOffset = sizeof(uint16_t); // address offset from timer_oe to timer_period
682682
sourceAddressLastOffset = -TIMER_REGISTERS_TO_UPDATE * sourceAddressOffset + sizeof(matrixUpdateRows[0].rowbits[0]);
683-
destinationAddress1 = (volatile uint32_t*) timerRegisterOE;
684-
destinationAddress2 = (volatile uint32_t*) timerRegisterPeriod;
683+
destinationAddress1 = timerRegisterOE;
684+
destinationAddress2 = timerRegisterPeriod;
685685
destinationAddressOffset = (int)destinationAddress2 - (int)destinationAddress1;
686686
destinationAddressLastOffset = -TIMER_REGISTERS_TO_UPDATE * destinationAddressOffset;
687687
dmaUpdateTimer.TCD->SADDR = sourceAddress;
@@ -717,7 +717,7 @@ FLASHMEM void SmartMatrixRefreshT4<refreshDepth, matrixWidth, matrixHeight, pane
717717
minorLoopBytes = minorLoopIterations * sizeof(uint32_t);
718718
majorLoopBytes = rowBitStructBytesToShift;
719719
majorLoopIterations = majorLoopBytes / minorLoopBytes;
720-
sourceAddress = (uint32_t*) & (matrixUpdateRows[0].rowbits[0].data[0]);
720+
sourceAddress = & (matrixUpdateRows[0].rowbits[0].data[0]);
721721
sourceAddressOffset = sizeof(uint32_t);
722722
sourceAddressLastOffset = sizeof(matrixUpdateRows[0].rowbits[0]) - majorLoopBytes; // at completion, move on to next bitplane
723723
destinationAddress1 = &(flexIO->SHIFTBUF[0]);

0 commit comments

Comments
 (0)