Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. simonm
    S
    • Continue chat with simonm
    • Start new chat with simonm
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    simonm

    @simonm

    0
    Reputation
    9
    Posts
    75
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    simonm Follow

    Posts made by simonm

    • RE: M5 Paper SD image display stopped working

      I have tested with a known-good other SD card (the previous one was brand new, out of the packet) and I cannot get a true return from SD.begin(...). Please can anyone help with how to address/debug this? Has anyone else reported their SD card reading failing before?

      EDIT: I have read some other instances of people having SD card issues on this forum. Having looked at their issues, I have ensured I have a 16GB (not larger) FAT32 formatted SD card. I have also tried SD.begin(4, SPI, 1000000); and 10 MHz too in M5EPD.cpp but it still returns false. I have also remembered to remove and reinsert the SD card between boot cycles where power has not been removed, so each SD.begin() should be the first that the SD card controller sees. Any other ideas?

      posted in PRODUCTS
      S
      simonm
    • RE: Sleep / low power on Paper V1.1 without clearing the display on Wake?

      @ajb2k3 thanks so much for that insight. Do you have an implementation of HV write mode for the Paper display in a different platform (UIflow etc)? Don't worry if not, because it seems that existing shutdown() is able to retain images according to @felmue's example.

      posted in Cores
      S
      simonm
    • RE: M5 Paper SD image display stopped working

      Aha, I forgot to initialise SPIFFS, which is why it didn't work with that file system. This now displays a smiley face on the EPD, from SPIFFS.

      #include <M5EPD.h>
      #include "SPIFFS.h"
      
      
      M5EPD_Canvas canvas(&M5.EPD);
      
      void setup()
      {
        M5.begin();
        M5.EPD.SetRotation(0);
        M5.EPD.Clear(true);
        if (!SPIFFS.begin(true)) {
          Serial.println("An Error has occurred while mounting SPIFFS");
          return;
        }
        if (testSpiffs())
        {
      
          canvas.createCanvas(540, 960);
          canvas.setTextSize(3);
          //canvas.drawPngFile(SD, "/smiley.png", 0, 0);
          canvas.drawPngFile(SPIFFS, "/smiley.png", 0, 0);
          canvas.pushCanvas(0, 0, UPDATE_MODE_GC16);
        }
        else
        {
          Serial.println("Error opening file from SPIFFS");
        }
      
      }
      
      void loop()
      {
      
      }
      
      bool testSpiffs(void)
      {
         /*static*/ uint16_t rowCounter = 0;
      
        File file = SPIFFS.open("/smiley.png");
      
        if (!file) {
          Serial.println("Failed to open file for reading");
          return false;
        }
      
        Serial.println("File Content:");
      
        while (file.available()) {
          Serial.print("0x");
          Serial.print((byte)file.read(), HEX);
          Serial.print(", ");
          rowCounter++;
          if (rowCounter == 12)
          {
            rowCounter = 0;
            Serial.println();
          }
        }
      
        file.close();
        return true;
      }
      

      Which strongly suggests my issue is with Paper reading from SD cards.

      posted in PRODUCTS
      S
      simonm
    • RE: M5 Paper SD image display stopped working

      Thanks for the suggestion @felmue . That example is pretty much what I based my initially-working-now-not working test with the drawPngFile(). I have just downloaded and tested with the flower image on the SD card and it fails to render on the EPD:

      #include <M5EPD.h>
      //#include <WiFi.h>
      
      M5EPD_Canvas canvas(&M5.EPD);
      
      void setup() {
          M5.begin();
          M5.EPD.SetRotation(90);
          M5.EPD.Clear(true);
          /*
          WiFi.begin("WIFI-SSID", "WIFI-PASSWORD");
      
          while (WiFi.status() != WL_CONNECTED) {
              delay(500);
              Serial.print(".");
          }
      */
          canvas.createCanvas(540, 960);
          canvas.setTextSize(3);
          /*
          canvas.drawJpgUrl(
              "https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/example_pic/"
              "flower.jpg");
              */
          canvas.drawJpgFile(SD, "/flower.jpg", 0, 0);
          canvas.pushCanvas(0, 0, UPDATE_MODE_GC16);
      }
      

      I added to the M5EPD::begin(...) function in M5EPD.cpp:

        if (SDEnable == true) {
              SPI.begin(14, 13, 12, 4);
      	bool sdSuccess = SD.begin(4, SPI, 20000000);
      	if(!sdSuccess && SerialEnable) Serial.println("SD.begin() failed");
          }
      

      and when the sketch calls M5.begin() I get "SD.begin() failed" on the serial monitor. So I think this is more of an SD card issue than EPD at this point. I have tried various sequences of reset/power-down and insert/remove/insert the SD card in order to make sure both the SD card and the ESP32 start from known reset points. But no success so far. So strange that it would work a few times on the Paper and then stop working, especially as the SD card remains responsive to my Windows PC.

      I will start trying other SD cards but if anything else occurs please shout.

      posted in PRODUCTS
      S
      simonm
    • RE: M5 Paper SD image display stopped working

      I tried using an SD file test example and SD.begin() returned false (I used SPI.begin(14, 13, 12, 4) ).

      So to try and get around the issue of the SD card, I placed smiley.png in a data folder in the Arduino sketch folder and used the ESP32 Sketch Data Upload tool in Arduino/Tools menu to copy the png to SPIFFS.

      Then I ran the code above with canvas.drawPngFile(SPIFFS, "/smiley.png", 0, 0); and got the same blank display.

      Then I tried to test SPIFFS to detect the file, with

       File file = SPIFFS.open("/smiley.png");
      
        if (!file) {
          Serial.println("Failed to open file for reading");
          return false;
        }
      

      and this returned false/ printed the failure message. Very confused now about where the issue could be! Sorry to ping but @felmue is there anything obvious I'm doing wrong or a known issue with SD cards and the Paper? Or another diagnostic check I should try? Being able to use the SD card or SPIFFS to store images would be extremely helpful for my project plans.

      The only other symptom I can report which may be of use is that when I used the scale factor in the overloaded drawPngFile(), I now get a square of that size flash white when the Paper runs setup(), as opposed to the full canvas size or the size of the original png. I find that strange and thought I'd add it in case it gives a clue as to the issue.

      posted in PRODUCTS
      S
      simonm
    • RE: Sleep / low power on Paper V1.1 without clearing the display on Wake?

      @felmue thanks for pointing out where that note lives! I'm still getting used to M5 stuff.

      posted in Cores
      S
      simonm
    • M5 Paper SD image display stopped working

      I managed to get a small black and white png file of a smiley face stored on a micro SD card to display on the M5 Paper V1.1 but now when I flash the device, the screen refreshes white and no image is displayed. I removed the SD card to verify that the png file was not corrupted, and it looked fine on my PC. I have tinkered with the code, to scale the image up, which is when it stopped working (initially correctly scaled it) so I tried to go back to the basic drawPngFile() function but it did not recover.

      What could have gone wrong?

      #include <M5EPD.h>
      
      M5EPD_Canvas canvas(&M5.EPD);
      
      void setup()
      {
        M5.begin();
        M5.EPD.SetRotation(0);
        M5.EPD.Clear(true);
      
        canvas.createCanvas(540, 960);
        canvas.setTextSize(3);
        canvas.drawPngFile(SD, "/smiley.png", 0, 0);
        canvas.pushCanvas(0, 0, UPDATE_MODE_GC16);
      }
      
      posted in PRODUCTS
      S
      simonm
    • RE: Sleep / low power on Paper V1.1 without clearing the display on Wake?

      @felmue thanks great explanation and example. In your example, is there any issue restructuring it:

      void setup()
      {
      ...
          // First draw old count
          myCount = readEEPROM(EEPROM_ADDR, 0);
          snprintf(myBuf, 10,  "%04d ", myCount);
          CountPageSprite.drawString(myBuf, 20, 20);
          CountPageSprite.pushCanvas(0, 0, UPDATE_MODE_DU4);
      }
      
      void loop()
      {
          // Then draw new count
          myCount++;
          writeEEPROM(EEPROM_ADDR, 0, myCount);
          snprintf(myBuf, 10, "%04d ", myCount);
          CountPageSprite.drawString(myBuf, 20, 20);
          CountPageSprite.pushCanvas(0, 0, UPDATE_MODE_DU4);
          delay(250); // required, else no update
      
          Serial.printf("Shutdown...\n");
          Serial.flush();
      
          M5.shutdown(10);
      
          // This part is only executed if running from USB power
          delay(1000);
          // Undo what shutdown did
          M5.RTC.clearIRQ();
          M5.enableMainPower();
          // Kill some time
          Serial.println("Should not be reached when battery powered 1");
          delay(10000);
          Serial.println("Should not be reached when battery powered 2");
      }
      

      to avoid needing to use the GOTO? I realise it will work perfectly well as-is. I think I would like to try and use the shutdown mode, as I can be asleep for most of the time, with updates once per minute at most.

      I find it very unusual that the API docs don't seem to mention that USB power vs battery power makes a difference to whether shutdown() will result in any change to the power state.

      @ajb2k3 thanks for your reply. Please could you elaborate on what HV mode is? I had a look at the Paper API for canvas and power/system but couldn't see anything relating to 'HV'. Do any of the existing API functions already take care of this?

      posted in Cores
      S
      simonm
    • Sleep / low power on Paper V1.1 without clearing the display on Wake?

      Sorry if this is the wrong category, please feel free to move. I have the M5 Paper V1.1 and would like to use it as a graphical clock. The battery doesn't need to last months between charges but the longer the better. I need RTC and not much else. I'm looking for a way to put the device into the lowest possible power mode and update the display once per minute, or so.

      I tried code kindly provided by @felmue in a thread about sleeping (and thoroughly confused myself that shutdown() behaviour appears to be very different when USB power is connected). However, that shutdown() function appears to place the processor into a reset state when it returns/wakes, which in turn clears the display during setup().

      Are there any different ways of managing sleep/low power modes that will retain RAM and resume running in loop() where it left off? If not, are there any tips about how to structure setup() so as to provide the visually smoothest display update regime, while still benefitting from low power shutdown()?

      posted in Cores
      S
      simonm