sumotoy / RA8875

A library for RAiO RA8875 display driver for Teensy3.x or LC/Arduino's/Energia/Spark
GNU General Public License v3.0
79 stars 55 forks source link

256 color mode conversion from 16 bit color to 8 bit color is wrong... #144

Closed KurtE closed 2 years ago

KurtE commented 4 years ago

I did a simple conversion for example of RED and it converted to 0...

Example of issue Red is 0xF800 which you and with 0xF800 and >> 11 bits So this converts to 0x1F or 31, which you then try to map map(31, 0, 28, 0,7) which overflows...

I fixed this in my own fork/branch: https://github.com/KurtE/RA8875/tree/RA8875_t4_multi

In the header file I updated the conversion

    uint8_t _color16To8bpp(uint16_t color) 
        __attribute__((always_inline)) {
        return ((color & 0xe000) >> 8) | ((color & 0x700) >> 6) | ((color & 0x18) >> 3);
//      return (map((color & 0xF800) >> 11, 0,28, 0,7)<<5 | map((color & 0x07E0) >> 5, 0,56, 0,7)<<2 | map(color & 0x001F, 0,24, 0,3));
    }