M5Paper partial Update Canvas



  • Found in the documentation the command
    Function: flushes the data in the buffer to the specified area of the screen in the specified mode.

    m5epd_err_t UpdateArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, m5epd_update_mode_t mode);

    Can I use it for partial updating the canvas, if yes how to use this command?

    Cheers,
    Jan



  • m5epd_err_t UpdateArea(100,100,100,100)
    would update an area of 100 px X 100px with the top left corner starting at position X=100, Y=100.



  • @ajb2k3
    Thanks, I wont to update (redraw) every time a new character, without updating the whole screen. But the command is not do that what I expect.
    Her my short test program. What is wrong ont it?

    #include <M5EPD.h>
    M5EPD_Canvas canvas1(&M5.EPD);

    String testString[]={"A","B","C","D","E","F","G"};

    void setup() {
    M5.begin();
    M5.TP.SetRotation(180);
    M5.EPD.SetRotation(180);
    M5.EPD.Clear(true);
    canvas1.createCanvas(960, 540);
    canvas1.loadFont("/fonts/GenSenRounded-R.ttf", SD);
    canvas1.createRender(60);
    canvas1.setTextSize(60);
    canvas1.drawString("A",20,20);
    canvas1.pushCanvas(0, 0, UPDATE_MODE_GL16);
    }

    void loop() {
    for (int i=1; i<7; i++)
    {
    canvas1.drawString(testString[i],20,20);
    /* m5epd_err_t UpdateArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, m5epd_update_mode_t mode); */
    M5.EPD.UpdateArea(0,0,100,100,UPDATE_MODE_GL16);
    delay(1000);
    }
    }

    Cheers
    Jan.



  • You need to also include the M5stack libraries.
    What do you mean "not what you expect"
    any error message?
    Can you post a picture of the screen?



  • @ajb2k3 said in M5Paper partial Update Canvas:

    You need to also include the M5stack libraries.

    Wat do you mean with that? This simple program is complete or not?



  • @ajb2k3
    I espect to see the characters be changed at the fix place. Do you have try to run my simple program?



  • As mentioned in the other thread, the missing step is transferring the canvas framebuffer to the EPD.
    If your loop function is changed as below, it works as you expect.

    void loop() {
      for (int i=1; i<7; i++)
      {
        canvas1.drawString(testString[i],20,20);
        /* m5epd_err_t UpdateArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, m5epd_update_mode_t mode); */
        M5.EPD.WriteFullGram4bpp((uint8_t*)canvas1.frameBuffer());
        M5.EPD.UpdateArea(0,0,100,100,UPDATE_MODE_GL16);
        delay(1000);
      }
    }