Comments (11)
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.
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.
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.
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. :-)
from ssd1306.
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.
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.
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.
Did you solve the problem?
from ssd1306.
I hope that you found the way to put bitmap data to the SPIFFS file
from ssd1306.
A added #55 task for enhancement
from ssd1306.
No, I did not find a solution to it.
from ssd1306.
Related Issues (20)
- Working on a IP Camera - Anyka HOT 2
- pgmspace.h issue since 1.8.3 HOT 5
- ssd1306_setRotation
- How to use this in Linux running non single board computer (laptop's i2c port) HOT 1
- Apparent hang in AVR TWI communications when display absent
- nano_gfx_types.h defines macros which pollutes the global namespace and cause compile errors
- Add support for recent series of attiny MCUs HOT 2
- Support Pi Pico / RP2040 Microcontrollers HOT 3
- I2C definition for ESP32 Espressif HOT 3
- How to port it to ESP IDF HOT 1
- Minor edits needed for Teensy HOT 4
- Potential Conflict AHTX10/AHT10 and LCDGFX HOT 2
- "Failed to Initialize: No such file or directory!" on RPI zero 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux HOT 1
- Print text at any Y-value? HOT 1
- Larger fonts possible? Turn off/on display? HOT 2
- Error compiling ssd1306_demo HOT 3
- how to convert custom fonts ? HOT 1
- How to specify i2c bus on linux? HOT 1
- None of examples load on attiny44 HOT 4
- ssd1306_demo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssd1306.