Guillermo Stedile / RA8875

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Sun Feb 01 18:50:57 2015 +0000
Parent:
92:ce1ab76e8614
Child:
94:203729061e48
Commit message:
Corrected a PrintScreen problem where it was extracting the image memory "off by one" and then a color conversion error that nearly corrected for it.

Changed in this revision

GraphicsDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GraphicsDisplay.cpp	Sun Feb 01 17:07:13 2015 +0000
+++ b/GraphicsDisplay.cpp	Sun Feb 01 18:50:57 2015 +0000
@@ -343,15 +343,22 @@
     return c;
 }
 
-/// RRRR RGGG GGGB BBBB
+// RGB16 little endian 
+//      GGGB BBBB RRRR RGGG
+// swap
+//      RRRR RGGG GGGB BBBB
+//                RRRR R
+// extend to BMP Color Palette is BGRx
+//      BBBB BBBB GGGG GGGG RRRR RRRR 0000 0000
 RGBQUAD GraphicsDisplay::RGB16ToRGBQuad(color_t c)
 {
     RGBQUAD q;
     
     memset(&q, 0, sizeof(q));
+    c = (c << 8) | (c >> 8);    // swap
     q.rgbBlue  = ((c & 0x001F) << 3) | (c & 0x07);          /* Blue value */
-    q.rgbGreen = ((c & 0x07E0) >> 3) | ((c >> 7) & 0x03);   /* Green value */
-    q.rgbRed   = ((c & 0xF800) >> 8) | ((c >> 11) & 0x07);  /* Red value */
+    q.rgbGreen = ((c & 0x07E0) >> 3) | ((c >> 9) & 0x03);   /* Green value */
+    q.rgbRed   = ((c & 0xF800) >> 8) | ((c >> 13) & 0x07);  /* Red value */
     q.rgbReserved = 0;
     return q;
 }
--- a/RA8875.cpp	Sun Feb 01 17:07:13 2015 +0000
+++ b/RA8875.cpp	Sun Feb 01 18:50:57 2015 +0000
@@ -1051,18 +1051,19 @@
     color_t pixel;
     RetCode_t ret = noerror;
 
-    INFO("getPixelStream(%p, %u, %d, %d)", p, count, x, y);
+    //INFO("getPixelStream(%p, %u, %d, %d)", p, count, x, y);
     PERFORMANCE_RESET;
     //WriteCommand(0x45,0x00);    // read left->right, top->bottom
     ret = WriteCommand(0x40,0x00);    // Graphics write mode
-    INFO("  r = %d", ret);
+    //INFO("  r = %d", ret);
     ret = SetGraphicsCursorRead(x, y);
-    INFO("  r = %d", ret);
+    //INFO("  r = %d", ret);
     ret = WriteCommand(0x02);
-    INFO("  r = %d", ret);
+    //INFO("  r = %d", ret);
     _select(true);
     _spiwrite(0x40);         // Cmd: read data
     _spiwrite(0x00);         // dummy read
+    _spiwrite(0x00);         // dummy read  [20150201: Required to properly align the data stream. Not yet sure why...]
     while (count--) {
         pixel  = _spiread();
         pixel |= (_spiread() << 8);
@@ -1666,10 +1667,10 @@
         }
 
         // Be optimistic - don't check for errors.
-        //HexDump("BMP_Header", (uint8_t *)&BMP_Header, sizeof(BMP_Header));
+        HexDump("BMP_Header", (uint8_t *)&BMP_Header, sizeof(BMP_Header));
         size_t r = fwrite(&BMP_Header, sizeof(char), sizeof(BMP_Header), Image);
 
-        //HexDump("BMP_Info", (uint8_t *)&BMP_Info, sizeof(BMP_Info));
+        HexDump("BMP_Info", (uint8_t *)&BMP_Info, sizeof(BMP_Info));
         r = fwrite(&BMP_Info, sizeof(char), sizeof(BMP_Info), Image);
 
         color_t transparency = GetBackgroundTransparencyColor();
@@ -1703,6 +1704,8 @@
                     ERR("getPixelStream error, and no recovery handler...");
                 }
             }
+            INFO("1st Color: %04X", pixelBuffer[0]);
+            HexDump("Raster", (uint8_t *)pixelBuffer, w);
             // Convert the local buffer to RGBQUAD format
             int lb = 0;
             for (int i=0; i<w; i++) {