Coder Social home page Coder Social logo

Bitmap from esp32 SPIFFS? about ssd1306 HOT 11 CLOSED

lexus2k avatar lexus2k commented on June 30, 2024
Bitmap from esp32 SPIFFS?

from ssd1306.

Comments (11)

lexus2k avatar lexus2k commented on June 30, 2024

Hi,

What exact options did you use on that site? I believe it should be Code Output format "Arduino code", Draw mode "vertical".
And could you please paste here your full sketch example. For color displays don't forget to call ssd1306_setMode( LCD_MODE_NORMAL ); before using 8-bit functions.

from ssd1306.

zenmanenergy avatar zenmanenergy commented on June 30, 2024

Yeah I did draw mode vertical and it displayed the image. Then I right clicked on the image and did 'save image as' (it was a .png file) storing it locally on my laptop storing it in a web accessible folder. Then I used an http GET function on the esp32 to download the .png file from my laptop (it was on a local network) to store it in SPIFFS. Then I tried to read the file from SPIFFS putting it into a uint8_t array and tried calling the ssd1306_drawMonoBitmap8() and ssd1306_drawBitmap8()

It seems like it almost works, but I'm not getting the right image. Just garbled pixels on the screen.

Oh, I'm using an st7735_128x160 screen.

This was based on the st7735 demo code. I added a few things in. I've zipped it up and attached the files.

from ssd1306.

lexus2k avatar lexus2k commented on June 30, 2024

That happens, because you read PNG-data to buffer, and those PNG-file contains not only pixels data, but also PNG-header. Maybe, PNG uses also some sort of compression after PNG-header, but ssd1306 library requires raw monochrome bitmap.

In you sketch, birds.png files takes 1534 bytes, but monochrome image needs only 128x64/8 = 1024 bytes. That means, that file contains no raw image data, suitable for the display. You need to use some PNG reader (you can search examples over Internet), or copy array data from http://javl.github.io/image2cpp/ to your sketch.

    const char * filename="/birds.png";
    fs::File imgFile = SPIFFS.open( filename, "r");
    
    uint8_t buf[1534];
    int siz = imgFile.size();
    while(siz > 0) {
      size_t len = min((int)(sizeof(buf) - 1), siz);
      imgFile.read((uint8_t *)buf, len);
      siz -= len; 
      imgFile.close();
    } 
    Serial.println(sizeof(buf));
    ssd1306_drawMonoBitmap8(0, 0, 128, 64, buf);

By the way, be careful with a passwords. I hope, you've replaced Wi-Fi password in your sketch prior to loading to github ;)

from ssd1306.

zenmanenergy avatar zenmanenergy commented on June 30, 2024

Aha! That's starting to make sense!

If I convert the png to a bmp with photoshop would this code likely work? So is ssd1306_drawBitmap8() for full color whereas ssd1306_drawMonoBitmap8() is just black/white?

Sigh... that was dumb of me with my password. I just edited those other ones, here is the same code w/o passwords. Don't come to my house and hack my wifi! If you want access, just knock on the door and I'll give you the new password. :-)

map8.zip

from ssd1306.

zenmanenergy avatar zenmanenergy commented on June 30, 2024

Btw, the reason I don't want to use http://javl.github.io/image2cpp/ and copy the array into the sketch is it means I have to hardcode the images and recompile every time I want to change an image. Using this SPIFFS method means it can download the image from a server and update the image content on the device.

from ssd1306.

zenmanenergy avatar zenmanenergy commented on June 30, 2024

Darn. I just converted it to bmp but it is now 1154 bytes. I haven't tried uploading it to the device since I have to run to work. But it seems like there is still something extra in there.

Does bmp have a header? Is there a way to skip the header and get to the raw data content? Images and binary have always confused the hell out of me!

from ssd1306.

lexus2k avatar lexus2k commented on June 30, 2024

You can try to use some hex editor (https://www.hhdsoftware.com/free-hex-editor), and convert generated array to binary file for SPIFFS file system.

from ssd1306.

lexus2k avatar lexus2k commented on June 30, 2024

Did you solve the problem?

from ssd1306.

lexus2k avatar lexus2k commented on June 30, 2024

I hope that you found the way to put bitmap data to the SPIFFS file

from ssd1306.

lexus2k avatar lexus2k commented on June 30, 2024

A added #55 task for enhancement

from ssd1306.

zenmanenergy avatar zenmanenergy commented on June 30, 2024

No, I did not find a solution to it.

from ssd1306.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.