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

    M5Stack.h: No such file or directory with M5StickCPlus?

    Scheduled Pinned Locked Moved Arduino
    arduinoesp32c++
    2 Posts 1 Posters 7.4k Views 1 Watching
    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 Offline
      wsanders
      last edited by wsanders

      I am trying to test SPIFFS and display a jpg file using the drawJPGFile method desribed in https://docs.m5stack.com/en/api/core/lcd:

      #include <M5Stack.h>
      #include <M5StickCPlus.h>
      #include <SPIFFS.h>
      void setup() {
      M5.begin(); //Initialize M5Stack
      M5.Lcd.drawJpgFile(SPIFFS, "1.jpg",10,10);
      }
      void loop(){
      }

      When I compile the above, I get the error "M5Stack.h: No such file or directory". If I try to compile with only M5StickCPlus.h included, I get 'class M5Display' has no member named 'drawJpgFile'.

      I thought M5StickCPlus.h would include M5Stack.h? (I've never had to include M5Stack.h before in any of my sketches.)

      Are SPIFFS and drawJpgFile not yet supported on the M5StickCPlus?

      Is there another way to display images? I suppose I could always make bitmaps and write new code to load them from PROGMEM?

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

        @wsanders At least with respect to the LCD library: The only function implemented so far to manipulate whole images is drawBitmap. drawJpg and drawJpgFile are commented out in https://github.com/m5stack/M5StickC-Plus/blob/master/src/M5Display.h so I assume they aren't working yet.

        So my workflow for now is:

        1. Save the image from gimp in gimp's ".h" format. This is smaller than a xpm or bmp. You will get a static char *data structure of all the pixels in the image. The .h file includes a macro to extract the pixels:

        #define HEADER_PIXEL(data,pixel) {
        pixel[0] = (((data[0] - 33) << 2) | ((data[1] - 33) >> 4));
        pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2));
        pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33)));
        data += 4;
        }

        1. Write your own function rgb888to565 to compress the pixels into a uint16_t.

        2. Draw a bitmap of the image as fast as you can:

        #include <M5StickCPlus.h>
        #include "1.h"
        int pixel[3];
        // pointer fu to preserve the start of .h data
        char *datastart;
        uint16_t *bitmap;

        void setup() {
        M5.begin();
        M5.Lcd.setRotation(3);
        bitmap = (uint16_t *)malloc(height * width * 2);
        }

        void loop() {
        M5.Lcd.fillScreen(GREEN);
        datastart = data;
        for (int16_t y=0; y < height; y++) {
        for (int16_t x=0; x < width; x++) {
        HEADER_PIXEL(data, pixel);
        bitmap[60*y + x] = rgb888to565(pixel[0], pixel[1], pixel[2]);
        }
        }
        M5.Lcd.drawBitmap(0,0,width,height,bitmap);
        data = datastart;
        }

        Or you can use the Sprite library, which works well.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post