🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Anybody get drawJpgFile to work with M5 PaperS3?

    PRODUCTS
    1
    3
    406
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wsanders
      last edited by wsanders

      Anybody get drawJpgFile and SPIFFS to work with M5 PaperS3? The following program finds the file "badge.jpg" but the jpeg is not displayed. I have turned jpg optimization and progressive off since that has been a source of problems in the past:

      #include <epdiy.h>
      #include <SPIFFS.h>
      #include <M5GFX.h>
      
      M5GFX display;
      
      void setup(void)
      { 
        display.init();
        display.startWrite();
        display.fillScreen(TFT_WHITE);
        display.setTextSize(5.0);
        if (display.isEPD())
        { 
          display.setEpdMode(epd_mode_t::epd_fastest);
        }
        // eyelet at top
        display.setRotation(display.getRotation() ^ 2);
        
        display.println("I RUN");
        if(!SPIFFS.begin(true)){
          display.println("An Error has occurred while mounting SPIFFS");
        }
        display.println("SPIFFS OK");
        File file = SPIFFS.open("/badge.jpg");
        if(!file){
          display.println("Failed to open file");
        }
        file.close();
        display.println("Open OK");
        
        display.drawJpgFile(SPIFFS, "/badge.jpg" , 0, 0);
        display.display();
      }
      

      If I cant get drawJpgFile to work, has someone written a script to put the result in a const array such as in the example file at https://github.com/m5stack/M5GFX/blob/2c12f148d6e3df64ead33b04c7989fe6d90a7a83/examples/Basic/drawImageData/drawImageData.ino?

      1 Reply Last reply Reply Quote 0
      • W
        wsanders
        last edited by wsanders

        This is probably a problem with SPIFFs. If I change the file open to

          File file = SPIFFS.open("/NONEXISTENT");
        

        the open still succeeds even though the file doesn't exist.So I have no way to know if drawJpgFile even works or not.

        W 1 Reply Last reply Reply Quote 0
        • W
          wsanders @wsanders
          last edited by

          Now that I think of it, I could not get drawJpgFile to work in a previous project (a fake Nixie watch), and I see from the PaperS3 demo program sample code that the Jpg is stored as a static array.

          I got my simple badge display program to work by storing the image as a C array (exported from GIMP) and walking through the pixels, which is how I did it in my previous project. Suprisingly it's not incredibly slow but of course data in this format is incredibly bulky.

          This github code is an example of how to convert a file into a statoc C array: https://github.com/notisrac/FileToCArray

          In the next few days, maybe I'll figure out if SPIFFS works on the PaperS3 and report back.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post