Forked para SNOCC
Fork of RA8875 by
Diff: RA8875.cpp
- Revision:
- 106:c80828f5dea4
- Parent:
- 105:4f116006ba1f
- Child:
- 107:f9ccffcb84f1
diff -r 4f116006ba1f -r c80828f5dea4 RA8875.cpp --- a/RA8875.cpp Sat Feb 27 18:40:35 2016 +0000 +++ b/RA8875.cpp Sat Feb 27 22:27:49 2016 +0000 @@ -216,7 +216,7 @@ { unsigned char mwcr1 = ReadCommand(0x41) & ~0x01; // retain all but the currently selected layer - if (screenwidth >= 800 && screenheight >= 480 && screenbpp == 8) { + if (screenwidth >= 800 && screenheight >= 480 && screenbpp > 8) { return bad_parameter; } else if (layer > 1) { return bad_parameter; @@ -568,6 +568,10 @@ return false; } +// RRRR RGGG GGGB BBBB +// 4321 0543 2104 3210 +// RRRG GGBB +// 2102 1010 uint8_t RA8875::_cvt16to8(color_t c16) { return ((c16 >> 8) & 0xE0) @@ -575,15 +579,23 @@ | ((c16 >> 3) & 0x03); } +// RRRG GGBB +// 2102 1010 +// RRRR RGGG GGGB BBBB +// 2101 0543 2104 3210 color_t RA8875::_cvt8to16(uint8_t c8) { - color_t c16 = ((c8 & 0xE0) << 8) - | ((c8 & 0xC0) << 5) - | ((c8 & 0x1C) << 6) - | ((c8 & 0x1C) << 3) - | ((c8 & 0x03) << 3) - | ((c8 & 0x03) << 1) - | ((c8 & 0x03) >> 1); + color_t c16; + color_t temp = (color_t)c8; + + c16 = ((temp & 0xE0) << 8) + | ((temp & 0xC0) << 5) + | ((temp & 0x1C) << 6) + | ((temp & 0x1C) << 3) + | ((temp & 0x03) << 3) + | ((temp & 0x03) << 1) + | ((temp & 0x03) >> 1); + c16 = (c16 << 8) | (c16 >> 8); return c16; } @@ -1115,7 +1127,8 @@ _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...] + if (screenbpp == 16) + _spiwrite(0x00); // dummy read is only necessary when in 16-bit mode while (count--) { if (screenbpp == 16) { pixel = _spiread(); @@ -2866,4 +2879,3 @@ } #endif // TESTENABLE -