Skip to content

Commit 3b3a9e3

Browse files
committed
libraries: led_matrix_ add proper guards
1 parent b8399ed commit 3b3a9e3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ static void turnLed(int idx, bool on) {
130130
}
131131
}
132132

133-
static uint32_t reverse(uint32_t x)
134-
{
135-
x = ((x >> 1) & 0x55555555u) | ((x & 0x55555555u) << 1);
136-
x = ((x >> 2) & 0x33333333u) | ((x & 0x33333333u) << 2);
137-
x = ((x >> 4) & 0x0f0f0f0fu) | ((x & 0x0f0f0f0fu) << 4);
138-
x = ((x >> 8) & 0x00ff00ffu) | ((x & 0x00ff00ffu) << 8);
139-
x = ((x >> 16) & 0xffffu) | ((x & 0xffffu) << 16);
140-
return x;
141-
}
142-
143133
// TODO: this is dangerous, use with care
144134
#define loadSequence(frames) loadWrapper(frames, sizeof(frames))
145135
#define renderBitmap(bitmap, rows, columns) loadPixels(&bitmap[0][0], rows*columns)
@@ -343,6 +333,15 @@ class ArduinoLEDMatrix
343333
bool _sequenceDone = false;
344334
voidFuncPtr _callBack;
345335

336+
static uint32_t reverse(uint32_t x){
337+
x = ((x >> 1) & 0x55555555u) | ((x & 0x55555555u) << 1);
338+
x = ((x >> 2) & 0x33333333u) | ((x & 0x33333333u) << 2);
339+
x = ((x >> 4) & 0x0f0f0f0fu) | ((x & 0x0f0f0f0fu) << 4);
340+
x = ((x >> 8) & 0x00ff00ffu) | ((x & 0x00ff00ffu) << 8);
341+
x = ((x >> 16) & 0xffffu) | ((x & 0xffffu) << 16);
342+
return x;
343+
}
344+
346345
static void turnOnLedISR(timer_callback_args_t *arg) {
347346
static volatile int i_isr = 0;
348347
turnLed(i_isr, ((framebuffer[i_isr >> 3] & (1 << (i_isr % 8))) != 0));

libraries/Arduino_LED_Matrix/src/gallery.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef _LEDMATRIX_GALLERY_H_
2+
#define _LEDMATRIX_GALLERY_H_
3+
14
/* Icons */
25
constexpr uint32_t LEDMATRIX_BLUETOOTH[] = { 0x10428, 0xa4517ff0, 0x50088104, 66 };
36
constexpr uint32_t LEDMATRIX_BOOTLOADER_ON[] = { 0x4015, 0x2482082, 0x81100e0, 66 };
@@ -595,3 +598,5 @@ constexpr uint32_t LEDMATRIX_ANIMATION_HOURGLASS[][4] = {
595598
{ 0xe0799f87, 0xf87f87f8, 0x7f99fe07, 50 },
596599
{ 0xe0799f87, 0xf83f83f8, 0x7f99fe07, 300 }
597600
};
601+
602+
#endif // _LEDMATRIX_GALLERY_H_

0 commit comments

Comments
 (0)