Adafruit-RGB_matrix_Panel(32*16)

Dependencies:   Adafruit-GFX

Dependents:   Ardoise_magique

Revision:
12:e632883f319f
Parent:
10:db4941188812
Child:
13:0ceb1b8893e9
--- a/RGBmatrixPanel.cpp	Sun May 25 12:36:39 2014 +0000
+++ b/RGBmatrixPanel.cpp	Sun May 25 13:41:34 2014 +0000
@@ -189,7 +189,48 @@
            (g <<  7) | ((g & 0xC) << 3) |
            (b <<  1) | ( b        >> 3);
 }
-
+uint16_t RGBmatrixPanel::ColorHSV(float hue, float sat, float val, bool gflag)
+{
+    int i = floor(hue * 6);
+    float f = hue*6-i;
+    float p = val*(1-sat);
+    float q = val*(1-f*sat);
+    float t = val*(1-(1-f)*sat);
+    float r = 0,g=0,b=0;
+    switch(i % 6) {
+        case 0:
+            r = val;
+            g = t;
+            b = p;
+            break;
+        case 1:
+            r = q;
+            g = val;
+            b = p;
+            break;
+        case 2:
+            r = p;
+            g = val;
+            b = t;
+            break;
+        case 3:
+            r = p;
+            g = q;
+            b = val;
+            break;
+        case 4:
+            r = t;
+            g = p;
+            b = val;
+            break;
+        case 5:
+            r = val;
+            g = p;
+            b = q;
+            break;
+    }
+    return Color888(r*255,g*255,b*255,gflag);
+}
 void RGBmatrixPanel::drawPixel(int16_t x, int16_t y, uint16_t c)
 {
     uint8_t r, g, b, bit, limit, *ptr;
@@ -215,10 +256,8 @@
     g = (c >>  7) & 0xF; // rrrrrGGGGggbbbbb
     b = (c >>  1) & 0xF; // rrrrrggggggBBBBb
     // Loop counter stuff
-    //log_debug("(%X, %X, %X)@(%d,%d)%s",r,g,b,x,y,"\t");
     bit   = 2;
     limit = 1 << nPlanes;
-
     if(y < nRows) {
         // Data for the upper half of the display is stored in the lower bits of each byte.
         ptr = &matrixbuff[backindex][y*_rawWidth*(nPlanes-1) + x]; // Base addr
@@ -283,17 +322,13 @@
 // draw over every pixel.  (No effect if double-buffering is not enabled.)
 void RGBmatrixPanel::swapBuffers(bool copy)
 {
-    log_debug("\r\ncall swapBuffers %s","\r\n");
     if(matrixbuff[0] != matrixbuff[1]) {
         // To avoid 'tearing' display, actual swap takes place in the interrupt
         // handler, at the end of a complete screen refresh cycle.
         swapflag = true;                  // Set flag here, then...
         while(swapflag == true) wait_ms(1); // wait for interrupt to clear it
         if(copy == true) {
-            log_debug("\tmemcpy %s","\r\n");
             memcpy(matrixbuff[backindex], matrixbuff[1-backindex], 32 * nRows * 3);
-        } else {
-            log_debug("\tnot memcpy %s","\r\n");
         }
     }
 }
@@ -321,7 +356,6 @@
 void RGBmatrixPanel::updateDisplay(void)
 {
     uint8_t  *ptr;
-    log_debug("\r\ncall updateDisplay\r\n");
     _oe=1;
     _latch=1;
     if(++plane >= nPlanes) {        // Advance plane counter.  Maxed out?
@@ -330,55 +364,28 @@
             row= 0;                 // Yes, reset row counter, then...
             if(swapflag == true) {  // Swap front/back buffers if requested
                 backindex = 1 - backindex;
-                log_debug("\t\treset swapflag%s","\r\n");
                 swapflag  = false;
             }
-            log_debug("\tReset into front buffer[%d]%s",backindex,"\r\n");
             buffptr = matrixbuff[1-backindex]; // Reset into front buffer
         }
     } else if(plane == 1) {
-        log_debug("\tupdate row%s","\r\n");
         _rowBus.write(row);
     }
     _oe=0;
     _latch=0;
     ptr = (uint8_t *)buffptr;
-
-    log_debug("\t(row@plane)=(%d,%d)\r\n",row,plane);
     if(plane > 0) {
-        //ptr[i]>>2
         for(int i=0; i<32; i++) {
             _dataBus.write((*(ptr+i)>>2));
             _sclk=1;
             _sclk=0;
-#if 0
-#ifdef DEBUG
-            if(int(_dataBus)==color) {
-                log_debug(" %02x",int(_dataBus));
-            } else {
-                _dataBus=color;
-                log_debug(" (%x->%x)%s",color,int(_dataBus),"\0");
-            }
-#endif
-#endif
         }
         buffptr += _rawWidth;
     } else {
-        //((ptr[i]<<4)|((ptr[i+32]<<2)&0x0C)|((ptr[i+64])&0x03));
         for(int i=0; i<32; i++) {
             _dataBus.write(((ptr[i]<<4)|((ptr[i+32]<<2)&0x0C)|((ptr[i+64])&0x03)));
             _sclk=1;
             _sclk=0;
-#if 0
-#ifdef DEBUG
-            if(int(_dataBus)==color) {
-                log_debug(" %02x",int(_dataBus));
-            } else {
-                _dataBus=color;
-                log_debug(" (%x->%x)%s",color,int(_dataBus),"\0");
-            }
-#endif
-#endif
         }
     }