You are reading a single comment by @stephaneAG and its replies. Click here to read the full conversation.
  • Hi there !

    I had a quick take on getting that partial flip thing to work, but for a reason I can't figure out ( I'm either too dumb, tired, or both ;p ) I can't make it work for only a vertical portion of the screen ( smaller than LCD_WIDTH )

    any quick hint on this ?
    ( --> currently fixing & dev stuff on 1.44" 128x128 ;p )

    // working version
    // ..
    spi.write(0x2A,dc);
    spi.write(0,1,0,LCD_WIDTH);
    // ..
    spi.write(0x2B,dc);
    spi.write(0,y1+1,-2,(y2-y1)+1);
    // ..
    var lines = 16; // size of buffer to use for un-paletting
    var a = new Uint16Array(LCD_WIDTHlines);
    for (var y=0;y<y2-y1;y+=lines) {
      E.mapInPlace(new Uint8Array(g.buffer, y1LCD_WIDTHbits/8 + yLCD_WIDTHbits/8, a.length), a, palette, bits); //works whatever x & y !!!
    spi.write(a.buffer);
    }
    
    // not working version :frowning: ..
    // ..
    spi.write(0x2A,dc);
    spi.write(0,x1+1,0,(x2-x1));
    // ..
    spi.write(0x2B,dc);
    spi.write(0,y1+1,-2,(y2-y1)+1);
    // ..
    var lines = 16; // size of buffer to use for un-paletting
    var a = new Uint16Array((x2-x1)lines);
    for (var y=0;y<y2-y1;y+=lines) {
      E.mapInPlace(new Uint8Array(g.buffer, y1LCD_WIDTHbits/8 + yLCD_WIDTHbits/8+ x1*bits/8, a.length), a, palette, bits); // wip ... FIX THIS !! :|
    spi.write(a.buffer);
    }
    

    Also, I've been able to figure out that my screen seems to accept either RBG or BRG, not RGB, and thanks to the following link /code, here's a quick & handy remapper for those in need ;)

    // txh to http://www.barth-dev.de/online/rgb565-co­lor-picker/
    function rgb888To565(rgb888){
      //return ( (((rgb888&0xf80000)>>8) + ((rgb888&0xfc00)>>5) + ((rgb888&0xf8)>>3)) ).toString(16);
      return ( (((rgb888&0xf80000)>>8) | ((rgb888&0xfc00)>>5) | ((rgb888&0xf8)>>3)) ).toString(16);
    }
    
    // wip fix: remapping the RGB565 as
    // GGGBBBBBRRRRRGGG: ( weird 'GBRG' ?)
    // G3,G2,G1,  B5,B4,B4,B2,B1,  R5,R4,R3,R2,R1,  G6,G5,G4
    //      LSB   MSB        LSB   MSB        LSB   MSB
    function rgb888To565t2(rgb888){
      return ((rgb888 & 0x1c00) << 3)|((rgb888 & 0xf8) << 5)|((rgb888 & 0xf80000) >> 16)|((rgb888 & 0xe000) >> 13);
    }
    

    -> I hope I'll be able to draw things faster in "unicolor" that way ;p ( one of the goals is to be able to draw in 2 colors, one black & the other dynamically changing )

About

Avatar for stephaneAG @stephaneAG started