🤖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?

    Arduino
    arduino esp32 c++
    1
    2
    5.3k
    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

      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
        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
        • First post
          Last post