From 3b3a9e354038d8b2a78bb6b4ed69cd2005487ea1 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 30 Oct 2025 17:20:13 +0100 Subject: [PATCH] libraries: led_matrix_ add proper guards --- .../src/Arduino_LED_Matrix.h | 19 +++++++++---------- libraries/Arduino_LED_Matrix/src/gallery.h | 5 +++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h b/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h index 33d0dd813..00f6c945b 100644 --- a/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h +++ b/libraries/Arduino_LED_Matrix/src/Arduino_LED_Matrix.h @@ -130,16 +130,6 @@ static void turnLed(int idx, bool on) { } } -static uint32_t reverse(uint32_t x) -{ - x = ((x >> 1) & 0x55555555u) | ((x & 0x55555555u) << 1); - x = ((x >> 2) & 0x33333333u) | ((x & 0x33333333u) << 2); - x = ((x >> 4) & 0x0f0f0f0fu) | ((x & 0x0f0f0f0fu) << 4); - x = ((x >> 8) & 0x00ff00ffu) | ((x & 0x00ff00ffu) << 8); - x = ((x >> 16) & 0xffffu) | ((x & 0xffffu) << 16); - return x; -} - // TODO: this is dangerous, use with care #define loadSequence(frames) loadWrapper(frames, sizeof(frames)) #define renderBitmap(bitmap, rows, columns) loadPixels(&bitmap[0][0], rows*columns) @@ -343,6 +333,15 @@ class ArduinoLEDMatrix bool _sequenceDone = false; voidFuncPtr _callBack; + static uint32_t reverse(uint32_t x){ + x = ((x >> 1) & 0x55555555u) | ((x & 0x55555555u) << 1); + x = ((x >> 2) & 0x33333333u) | ((x & 0x33333333u) << 2); + x = ((x >> 4) & 0x0f0f0f0fu) | ((x & 0x0f0f0f0fu) << 4); + x = ((x >> 8) & 0x00ff00ffu) | ((x & 0x00ff00ffu) << 8); + x = ((x >> 16) & 0xffffu) | ((x & 0xffffu) << 16); + return x; + } + static void turnOnLedISR(timer_callback_args_t *arg) { static volatile int i_isr = 0; turnLed(i_isr, ((framebuffer[i_isr >> 3] & (1 << (i_isr % 8))) != 0)); diff --git a/libraries/Arduino_LED_Matrix/src/gallery.h b/libraries/Arduino_LED_Matrix/src/gallery.h index 628b640fa..fed40a443 100644 --- a/libraries/Arduino_LED_Matrix/src/gallery.h +++ b/libraries/Arduino_LED_Matrix/src/gallery.h @@ -1,3 +1,6 @@ +#ifndef _LEDMATRIX_GALLERY_H_ +#define _LEDMATRIX_GALLERY_H_ + /* Icons */ constexpr uint32_t LEDMATRIX_BLUETOOTH[] = { 0x10428, 0xa4517ff0, 0x50088104, 66 }; constexpr uint32_t LEDMATRIX_BOOTLOADER_ON[] = { 0x4015, 0x2482082, 0x81100e0, 66 }; @@ -595,3 +598,5 @@ constexpr uint32_t LEDMATRIX_ANIMATION_HOURGLASS[][4] = { { 0xe0799f87, 0xf87f87f8, 0x7f99fe07, 50 }, { 0xe0799f87, 0xf83f83f8, 0x7f99fe07, 300 } }; + +#endif // _LEDMATRIX_GALLERY_H_ \ No newline at end of file