@@ -133,8 +133,8 @@ static uint32_t reverse(uint32_t x)
133
133
}
134
134
135
135
// TODO: this is dangerous, use with care
136
- #define loadSequence (x ) loadWrapper(x , sizeof (x ))
137
-
136
+ #define loadSequence (frames ) loadWrapper(frames , sizeof (frames ))
137
+ # define renderBitmap ( bitmap, rows, columns ) loadPixels(&bitmap[ 0 ][ 0 ], rows*columns)
138
138
139
139
static uint8_t __attribute__ ((aligned)) framebuffer[NUM_LEDS / 8];
140
140
@@ -186,6 +186,7 @@ class ArduinoLEDMatrix {
186
186
}};
187
187
loadSequence (tempBuffer);
188
188
next ();
189
+ _interval = 0 ;
189
190
}
190
191
void renderFrame (uint8_t frameNumber){
191
192
_currentFrame = frameNumber % _framesCount;
@@ -204,6 +205,23 @@ class ArduinoLEDMatrix {
204
205
}
205
206
return false ;
206
207
}
208
+
209
+ void loadPixels (uint8_t *arr, size_t size){
210
+ uint32_t partialBuffer = 0 ;
211
+ uint8_t pixelIndex = 0 ;
212
+ uint8_t *frameP = arr;
213
+ uint32_t *frameHolderP = _frameHolder;
214
+ while (pixelIndex < size) {
215
+ partialBuffer |= *frameP++;
216
+ if ((pixelIndex + 1 ) % 32 == 0 ) {
217
+ *(frameHolderP++) = partialBuffer;
218
+ }
219
+ partialBuffer = partialBuffer << 1 ;
220
+ pixelIndex++;
221
+ }
222
+ loadFrame (_frameHolder);
223
+ };
224
+
207
225
void loadWrapper (const uint32_t frames[][4 ], uint32_t howMany) {
208
226
_currentFrame = 0 ;
209
227
_frames = (uint32_t *)frames;
@@ -216,6 +234,7 @@ class ArduinoLEDMatrix {
216
234
217
235
private:
218
236
int _currentFrame = 0 ;
237
+ uint32_t _frameHolder[3 ];
219
238
uint32_t * _frames;
220
239
uint32_t _framesCount;
221
240
uint32_t _interval = 0 ;
0 commit comments