You are reading a single comment by @stephaneAG and its replies. Click here to read the full conversation.
  • Hi there !
    -> it's always a pleasure sharing findings ;)

    A whole module seems a little overkill for stuff that could be set via options ( or it seems to me, at least ? ), also I have a little 64x48 old screen for which I can't fix the display ( I didn't mod the SSD1306 module right during my tests, reason for the horizontal white lines I'm getting :/ .. )

    I totally agree on putting the rows/cols offsets in the init cmds & I tired to do so, but I still don't have enough hints on the params of column & page address ( I could successfully fiddle with those to fix the "italic" text, but couldn't get the same fix working with tweaks on init .. ) -> if you have any docs on those, I'll be very glad to read about it :)

    cmd(0x2A,[0,0,0,LCD_WIDTH]); 
    cmd(0x2B,[0,0,0,LCD_HEIGHT]);
    

    Understood for the DMA stuff ( I 'll have to continue my beginner tries on how to use DMA before jumping to Espruino code that would relate to the subject .. but not skilled enough to help you there :/ )

    For the "other mode", I was thinking of something that would actually work on the official Espruino boards as well & use some "partial clear & flip()" to minimize the ram & memory needed :)

    Thanks for the link on ".getModified()", it'd be pretty nice to clear the last stuff drawn :)

    For your proposal on 'flip()' you'd wish something that clears only the last area drawn or every areas drawn ? (in other words, if I do the following, do I get a "cumulative" modified area ? )

    g.setPixel(10,20); // 1st thing draw
    g.getModified(); //> {x1:10, y1:20, x2:10, y2:20}
    g.setPixel(20,30); // 2nd thing draw
    g.getModified(); //> {x1:10, y1:20, x2:20, y2:30} --> I get the src correct ? 
    

    If the above is actually what's returned, I'll be happy modding the flip() fcn in order to only send the modified rows ( shall we include a bool to "force" re-sending unmodified stuff as well ? ) :)

    For the "italic" text, it was actually a glitch from setting the 1st or 3rd params in the 0x2A/0x2B calls, but thanks for the hint on the font doubling ;)
    -> it reminds me I "extracted" the font that was used by Autodesk for their 123DCircuit tool before it went offline, and being pretty nice for pcbs it'd be pretty cool to also have it on displays ;)

    For the "alternative behavior" of the "paletted mode", I was getting weird colors mainly because of having a not big enough palette I guess ( it seemed to went away when having a palette of 16 items, clearer after reading the source again .. ;) )

    For the "instant logo drawing", I studied your platform game code ( & tested it -> it seemed I had some fixes to do be done with the player "flying" and going down otherwise, but this may have come from the way I set my btns ;) )
    -> I'll have to try the flappy example & the neat clock one :)

    The goal being to save memory & get a colored logo drawn at once in whatever paletted/normal mode, I guess a possible solution would be to 1st save it to .boot0 & cie & then have the code that draws it on power up & reboot ?

    -> I'll try the said stuff in few mins & give an update that as well ( .. )

    Last but not least, I digged within jswrap_graphics.h/.c & graphics.h.c to better understand stuff .. and there's a lot to grasp :) !
    I think aside from the 'flip()' update, a version accepting args 'd be still relevant, as well as 'clear(area(s))' ( & maybe 'clip(area(s))' to only draw stuff that's within the said area(s) - for interesting & retro text effects ;p ? )

    For the "partial clear" part, what about the following ?

    // jswrap_graphics.h
    void jswrap_graphics_clearP(JsVar *parent, int x1, int y1, int x2, int y2);
    
    // jswrap_graphics.c
    /*JSON{
      "type" : "method",
      "class" : "Graphics",
      "name" : "clearP",
      "generate" : "jswrap_graphics_clearP"
    }
    Clear the LCD partially with the Background Color
    */
    void jswrap_graphics_clearP(JsVar *parent, int x1, int y1, int x2, int y2) {
      JsGraphics gfx; if (!graphicsGetFromVar(&gfx, parent)) return;
      graphicsClear(&gfx);
      graphicsSetVar(&gfx); // gfx data changed because modified area
    }
    
    // graphics.h
    void graphicsClearP(JsGraphics *gfx, short x1, short y1, short x2, short y2);
    
    // graphics.c
    void graphicsClearP(JsGraphics *gfx, int x1, int y1, int x2, int y2) {
    unsigned int c = gfx->data.fgColor;
      gfx->data.fgColor = gfx->data.bgColor;
    graphicsFillRectDevice(gfx,x1,y1,x2,y2);­
      gfx->data.fgColor = c;
    }
    

    For the 'flip()' update, maybe something like the following to be able to either try a flip or a partial flip if something was modified, and "force" it for whatever reason if needed - but I guess the "force" bool wouldn't be used .. ?

    // R: untested yet ! ;)
    /*
    options = {
      force: false, // to force a refresh even if g.buffer is unmodified ( some debug mess happened ? )
      y1: 0, // for specific rows handle ( partial )
      y2: LCD_HEIGHT, // for specific rows handle ( partial )
      x1: 0,  // 'll surely be too slow for usage ..
      x2: LCD_WIDTH // 'll surely be too slow for usage ..
    }
    */
    g.flip = function(options) {
       // check if modified
      var tmp = g.getModified();
      if(typeof tmp === "undefined"){
        // nothing to update: force ?
      } else {
        var y1 = options.y1 || 0;
        var y2 = options.y2 || LCD_HEIGHT;
        var y1 = options.x1 || 0;
        var y1 = options.x2 || LCD_WIDTH;
        ce.reset();
        spi.write(0x2A,dc);
        //spi.write(0,1,0,LCD_WIDTH); // WORKS: made the trick for non-italic text drawn at once ! :D
        spi.write(0,1+ x1,0,x2);
        spi.write(0x2B,dc);
        //spi.write(0,0,0,LCD_HEIGHT); // otherwise, we had spi.write(0,y+rowStart,0,y+rowStart+1);
        spi.write(0,y1,0,y2);
        spi.write(0x2C,dc);
        var lines = 16; // size of buffer to use for un-paletting
        //var a = new Uint16Array(LCD_WIDTH*lines); // default
        var a = new Uint16Array((x2-x1)*lines); // default
        //for (var y=0;y<LCD_HEIGHT;y+=lines) { // default
        for (var y=0;y<y2-y1;y+=lines) { // default
          //E.mapInPlace(new Uint8Array(g.buffer, y*LCD_WIDTH*bits/8, a.length), a, palette, bits);
          E.mapInPlace(new Uint8Array(g.buffer, y*(x2-x1)*bits/8, a.length), a, palette, bits);
          spi.write(a.buffer);
        }
        ce.set();
      }
      };
    

    This being said, I'm onto some fun with g.buffer ;)

    I hope the above 'll work as is ( I still have to make my 1st own Espruino build before trying further modding the src ;)

About

Avatar for stephaneAG @stephaneAG started