Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. grundprinzip
    3. Posts
    G
    • Continue chat with grundprinzip
    • Start new chat with grundprinzip
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by grundprinzip

    • M5Paper Canvas Rendering Artifacts

      Hey folks!

      While playing with the M5Paper, I came across the following issues. When drawing mutliple canvas on the screen sometimes the different canvases seem to be misaligned by few pixels even though the coordinates are all matching.

      Here is a very simple example:

      #include <Arduino.h>
      #include <M5EPD.h>
      
      
      // Prepare some stuff.
      void initializeSystem() {
        log_d("Prepare SysInit");
        M5.begin();
        M5.EPD.SetRotation(90);
        M5.TP.SetRotation(90);
        M5.EPD.Clear(true);
        M5.RTC.begin();
        log_d("Done SysInit");
      }
      
      void setup() {
        initializeSystem();
        M5EPD_Canvas c1(&M5.EPD);
        M5EPD_Canvas c2(&M5.EPD);
      
        log_d("Drawing first canvas");
        c1.createCanvas(200, 200);
        c1.fillRect(0,0, 200, 200, G5);
        // physical position is 300, 300
        c1.drawRect(100,100, 50, 50, G15);
        c1.pushCanvas(200, 200, UPDATE_MODE_NONE);
      
        M5.EPD.UpdateFull(UPDATE_MODE_GC16);
      
        delay(2000);
      
        log_d("Drawing second canvas");
        c2.createCanvas(50, 50);
        c2.drawRect(0,0,50,50, G15);
        c2.pushCanvas(300, 300, UPDATE_MODE_GC16);
      }
      
      void loop() {
      }
      

      In theory the two rectangles should perfectly overlap, but they do not. Please see the following picture:

      alt text

      When trying to build a nice UI this can be quite annoying. I was trying to understand where this comes from and while going through the source of the M5EPD library I found the following comment in callocSprite():

      w = (w + 3) & 0xFFFC; // width should be the multiple of 4 bits to be compatible with epdpaint
      

      Now, this made me suspicious, in the above example, the width of 50px is rounded up to 52px and this values is then used for the framebuffer. If I adjust the code above to be 52px for the rectangle and the partial canvas all the misalignment goes away. In this example the artifact just appears on the horizontal axis, but I've seen misalignment as well on the vertical axis.

      My question is, if the behavior is required or an artifact of the integration with the driver? Shouldn't the library simply forbid creating a canvas that is not a multiple of 4?

      Probably, I can just make sure that all my elements have widths that are multiples of 4 but this seems a bit weird. Any suggestions?

      posted in PRODUCTS
      G
      grundprinzip
    • RE: M5Paper UI Framework Sample Project

      @fonix232 Thanks! For me the exercise is much more exploring how the epaper display works when drawing the different components and how to optimize partial updates.

      I will have a look at the projects you mentioned and see if I can find some inspiration!

      posted in PROJECTS
      G
      grundprinzip
    • M5Paper UI Framework Sample Project

      I've been fascinated with the M5Paper ever since I received it and wanted to use it to build some home automation controller that runs for a long time on the battery.

      Now, when I started looking into the UI code of the Factory Test application, I thought I could easily extend it but unfortunately, the code is not really well documented and a weird mix of C and C++. This is where I started with my project to build a library for UI development on the M5 paper that is generic enough to be easily extended and make it easy to build nice looking and usable applications. For example the Tic Tac Toe application is about 300 lines of easy to reason about code.

      Right now it's in the beginning, but feel free to check out the source code here https://github.com/grundprinzip/M5PaperUI I'm planning to extend it with simple text fields, settings application for wifi configuration etc.

      Below are some example images from the project:

      Home Screen

      Paint App

      alt text

      posted in PROJECTS
      G
      grundprinzip
    • RE: M5Paper Shutdown() / Deep Sleep / Wakeup

      @felmue Thanks for the explanation, I have come to a similar conclusion regarding the M5.shutdown() call as well :) However, this post was stuck somewhere in an approval queue so I didn't reply earlier.

      Thanks again!

      posted in Cores
      G
      grundprinzip
    • M5Paper Shutdown() / Deep Sleep / Wakeup

      I received my M5 Paper and I'm really amazed by the product. The one thing I'm struggling with is to work efficiently with the epaper display and power. In particular, I'm not sure if the M5.shutdown() calls actually do something or how to get the device into deep sleep.

      I'm literally using the example in https://github.com/m5stack/M5EPD/blob/main/examples/Basics/RTC_BM8563/RTC_BM8563.ino to shutdown the device (and maybe try to wake it up). When shutdown() is called, the main loop seems to be still executed. When shutdown() is called without arguments it should never wake up, but if I do some serial print I can still see the device responding.

      One way that I have found to get the device actually to sleep (and to wakeup again) was to use the esp_* functions.

      If my code calls

      esp_sleep_enable_timer_wakeup(10 * 1000000);
      esp_deep_sleep_start();
      

      it will actually sleep and the main loop is not executed. Is this just a bug in the M5Paper firmware? I'm not an expert in ESP and M5Stack programming so please forgive me, if I'm doing something wrong.

      One other curious thing is that, this only works while the device is attached with the cable to my computer, but as soon as I restart it without it being attached it doesn't work anymore.

      Below is an example using the deep sleep function that works while attached:

      #include <M5EPD.h>
      #include <sstream>
      #define uS_TO_S_FACTOR 1000000
      #define TIME_TO_SLEEP 10
      
      M5EPD_Canvas canvas(&M5.EPD);
      RTC_DATA_ATTR int counter = 0;
      
      void setup() {
        M5.begin();
        M5.EPD.SetRotation(90);
        M5.EPD.Clear(true);
        M5.RTC.begin();
        canvas.createCanvas(540, 960);
        canvas.setTextSize(3);
      
        std::ostringstream buf;
        buf << "EEPRom Counter " << counter;
        canvas.drawString(buf.str().c_str(), 45, 350);
      
        uint32_t vol = M5.getBatteryVoltage();
      
        if (vol < 3300) {
          vol = 3300;
        } else if (vol > 4350) {
          vol = 4350;
        }
        float battery = (float)(vol - 3300) / (float)(4350 - 3300);
        if (battery <= 0.01) {
          battery = 0.01;
        }
        if (battery > 1) {
          battery = 1;
        }
        buf = std::ostringstream();
        buf << "Battery " << (battery * 100) << "%";
        canvas.drawString(buf.str().c_str(), 45, 550);
        canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
        ++counter;
      
        delay(5000);
        // Sleep for 5 seconds.
        esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
        esp_deep_sleep_start();
      }
      
      void loop() {}
      

      My original assumption was that I replace the last two lines with M5.shutdown(TIME_TO_SLEEP) to achieve similar results, but the devices simply does not wakeup again.

      I would be really great if someone has some more ideas :)

      Thanks!

      posted in Cores
      G
      grundprinzip
    • RE: M5Paper wakeup cause

      @dov I'm very new to the M5Paper, but I'm wondering if you couldn't use the esp_deep_sleep_start() instead of shutdown because this will keep the RTC going and shutdown everything else.

      In theory, you might be able to call esp_err_tesp_sleep_enable_timer_wakeup() with an appropriate duration and then simply continue. According to the documentation the Wifi connection data is kept as well.

      I'm currently trying to work on something like this as well.

      posted in Cores
      G
      grundprinzip