Copy area of 1st buffer to 2nd buffer

Posted on
  • Hello Everyone,
    is there a way to copy the contents of buffer a to buffer b while in "doublebuffered" LCDMode?

    -Maxi

  • Thr 2021.07.15

    re: 'is there a way to copy the contents of buffer a to buffer b while in "doublebuffered" LCDMode?'

    Without a code snippet of how those buffers are created and (scope) used, unable to provide a
    definitive response. Would the slice() method work?

    https://www.w3schools.com/jsref/jsref_sl­ice_array.asp

    https://banglejs.com/reference#l_Array_s­lice



    Other ideas at:
    Set each pixels color individually on Bangle.js screen

  • There is no example code^^ The question boils down to this: If I use the doublebuffered mode, can I get a reference to the buffer that is currenty visible (a.k.a. the buffer that got drawn after calling g.flip() in order to access it's contents (and then copy it to the other buffer to avoid redrawing identical parts).

  • I understand now from your original inquiry that there doesn't appear to be a function available
    from the current reference:

    https://banglejs.com/reference#l_Bangle_­setLCDMode

    Has an attempt been made to take a peek under the covers to see if one may garner any insight
    until others may respond?

    Just to the right of the function declaration, there is a right facing arrow,
    Bangle.setLCDMode →

    which when clicked takes one to the source:

    https://github.com/espruino/Espruino/blo­b/master/libs/banglejs/jswrap_bangle.c#L­1585

    (while that link reference in the docs needs to be updated)

    Jump to line 1585 for the 'doublebuffered' section. Traversing the calls to certain functions may require the use of other tools such as VSCode.

  • If I use the doublebuffered mode, can I get a reference to the buffer that is currenty visible

    I'm afraid not - the doublebuffered mode stores two buffers on the LCD itself, but the LCD is write-only, and doesn't allow copies within itself - so it's just not something that can be done.

    I'm not quite sure what you're planning, but for stuff like this I'd recommend trying to create an offscreen buffer with Graphics.createArrayBuffer. You'd have to use a lower bit depth and/or resolution to get it in memory, but once you have that you can then read data from it. In the most recent firmwares there's even a blit function to allow you to copy between areas in the same buffer

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Copy area of 1st buffer to 2nd buffer

Posted by Avatar for sauerman @sauerman

Actions