Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added getPixel().

  • Loading branch information...
commit b4cfe26d36b259d911a6baf89d5f84cfa3eba3a3 1 parent 51346d3
Fabio Pugliese Ornellas authored
38 SFRGBLEDMatrix/SFRGBLEDMatrix.cpp
@@ -13,7 +13,7 @@ extern "C" {
13 13 #define DISPLAY_PIXELS 64
14 14 #define DISPLAY_BUFFER_SIZE (DISPLAY_PIXELS*BITS_PER_COLOR*3>>3)
15 15
16   -#define swap(a, b) { int16_t t = a; a = b; b = t; }
  16 +#define SWAP(a, b) { int16_t t = a; a = b; b = t; }
17 17
18 18 #define SPECTRUM_LEN 90
19 19
@@ -189,12 +189,12 @@ void SFRGBLEDMatrix::line(const Color color, int x0, int y0, int x1, int y1){
189 189
190 190
191 191 if(steep){
192   - swap(x0, y0);
193   - swap(x1, y1);
  192 + SWAP(x0, y0);
  193 + SWAP(x1, y1);
194 194 }
195 195 if(x0>x1){
196   - swap(x0, x1);
197   - swap(y0, y1);
  196 + SWAP(x0, x1);
  197 + SWAP(y0, y1);
198 198 }
199 199
200 200 int16_t dx, dy;
@@ -304,3 +304,31 @@ void SFRGBLEDMatrix::CRT(Color bgColor, Color borderColor){
304 304 show();
305 305 }
306 306 }
  307 +
  308 +Color SFRGBLEDMatrix::getPixel(int x, int y){
  309 + uint16_t startPixel;
  310 + uint16_t startByte;
  311 + Color color=BLACK;
  312 + // Out of boundaries
  313 + if(x>=width||y>=height||y<0||y<0)
  314 + return BLACK;
  315 + // Adjust coordinates, can be disabled for single row of matrices
  316 + x+=recAdjStart - int(y>>3)*recAdjIncr;
  317 + // print pixel
  318 + startPixel=(dispCount-1-(x>>3))*DISPLAY_PIXELS + ((7-y)<<3) + (x&7);
  319 + startByte=(startPixel*12)>>3;
  320 + // odd pixels
  321 + if(startPixel&0x01) {
  322 + // XXXX RRRR
  323 + color=(frameBuff[startByte]&0x0F)<<8;
  324 + // GGGG BBBB
  325 + color=color|frameBuff[startByte+1];
  326 + // even pixels
  327 + }else{
  328 + // RRRR GGGG
  329 + color=frameBuff[startByte]<<4;
  330 + // BBBB XXXX
  331 + color=color|(frameBuff[startByte+1]>>4);
  332 + }
  333 + return color;
  334 +}
2  SFRGBLEDMatrix/SFRGBLEDMatrix.h
@@ -141,6 +141,8 @@ class SFRGBLEDMatrix {
141 141 void progressBarUpdate(Color barColor, uint16_t vaule, uint16_t max);
142 142 // CRT out animation
143 143 void CRT(Color bgColor, Color borderColor);
  144 + // Get current pixel color from buffer
  145 + Color getPixel(int x, int y);
144 146 };
145 147
146 148 #endif
1  SFRGBLEDMatrix/keywords.txt
@@ -32,6 +32,7 @@ spectrum KEYWORD2
32 32 progressBarInit KEYWORD2
33 33 progressBarUpdate KEYWORD2
34 34 CRT KEYWORD2
  35 +getPixel KEYWORD2
35 36
36 37 #######################################
37 38 # Constants (LITERAL1)

0 comments on commit b4cfe26

Please sign in to comment.
Something went wrong with that request. Please try again.