Skip to content

Commit 8dfc516

Browse files
committed
Added comments, and corrected one original comment
1 parent 527480c commit 8dfc516

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

RGBmatrixPanel.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ void RGBmatrixPanel::drawPixel(int16_t x, int16_t y, uint16_t c) {
326326
if(r & 1) ptr[32] |= B00000010; // Plane 0 R: 32 bytes ahead, bit 1
327327
else ptr[32] &= ~B00000010; // Plane 0 R unset; mask out
328328
if(g & 1) *ptr |= B00000001; // Plane 0 G: bit 0
329-
if(b & 1) *ptr |= B00000010; // Plane 0 B: bit 0
329+
if(b & 1) *ptr |= B00000010; // Plane 0 B: bit 1
330330
for(; bit < limit; bit <<= 1) {
331331
*ptr &= ~B11100000; // Mask out R,G,B in one op
332332
if(r & bit) *ptr |= B00100000; // Plane N R: bit 5
@@ -372,30 +372,30 @@ uint16_t RGBmatrixPanel::getPixel(int16_t x, int16_t y) {
372372
ptr = &matrixbuff[1-backindex][y * WIDTH * (nPlanes - 1) + x]; // Base addr
373373
// Plane 0 is a tricky case -- its data is spread about,
374374
// stored in least two bits not used by the other planes.
375-
if (ptr[64] & B00000001) r |= 1;
376-
if (ptr[64] & B00000010) g |= 1;
377-
if (ptr[32] & B00000001) b |= 1;
375+
if (ptr[64] & B00000001) r |= 1; // Plane 0 R: 64 bytes ahead, bit 0
376+
if (ptr[64] & B00000010) g |= 1; // Plane 0 G: 64 bytes ahead, bit 1
377+
if (ptr[32] & B00000001) b |= 1; // Plane 0 B: 32 bytes ahead, bit 0
378378
// The remaining three image planes are more normal-ish.
379379
// Data is stored in the high 6 bits so it can be quickly
380380
// copied to the DATAPORT register w/6 output lines.
381381
for(; bit < limit; bit <<= 1) {
382-
if (*ptr & B00000100) r |= bit;
383-
if (*ptr & B00001000) g |= bit;
384-
if (*ptr & B00010000) b |= bit;
385-
ptr += WIDTH; // Advance to next bit plane
382+
if (*ptr & B00000100) r |= bit; // Plane N R: bit 2
383+
if (*ptr & B00001000) g |= bit; // Plane N G: bit 3
384+
if (*ptr & B00010000) b |= bit; // Plane N B: bit 4
385+
ptr += WIDTH; // Advance to next bit plane
386386
}
387387
} else {
388388
// Data for the lower half of the display is stored in the upper
389389
// bits, except for the plane 0 stuff, using 2 least bits.
390390
ptr = &matrixbuff[1-backindex][(y - nRows) * WIDTH * (nPlanes - 1) + x];
391-
if (ptr[32] & B00000010) r |= 1;
392-
if (*ptr & B00000001) g |= 1;
393-
if (*ptr & B00000010) b |= 1;
391+
if (ptr[32] & B00000010) r |= 1; // Plane 0 R: 32 bytes ahead, bit 1
392+
if (*ptr & B00000001) g |= 1; // Plane 0 G: bit 0
393+
if (*ptr & B00000010) b |= 1; // Plane 0 B: bit 1
394394
for(; bit < limit; bit <<= 1) {
395-
if (*ptr & B00100000) r |= bit;
396-
if (*ptr & B01000000) g |= bit;
397-
if (*ptr & B10000000) b |= bit;
398-
ptr += WIDTH; // Advance to next bit plane
395+
if (*ptr & B00100000) r |= bit; // Plane N R: bit 5
396+
if (*ptr & B01000000) g |= bit; // Plane N G: bit 6
397+
if (*ptr & B10000000) b |= bit; // Plane N B: bit 7
398+
ptr += WIDTH; // Advance to next bit plane
399399
}
400400
}
401401

0 commit comments

Comments
 (0)