thingpulse / esp8266-oled-ssd1306 Goto Github PK
View Code? Open in Web Editor NEWDriver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
Home Page: https://thingpulse.com
License: Other
Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
Home Page: https://thingpulse.com
License: Other
The new naming conventions in Ver 3.0 in combination with the Arduino automatic Library Manager will cause all sketches using esp8266-oled-ssd1306 Ver 2.0 to crash.
You should rename your library, call the new one Ver 1.0 and restore esp8266-oled-ssd1306 to Ver 2.0.2
Don't close this issue without doing something to warn users of this problem.
Roger
Installed in PlatformIO and trying to use SSD1306Brzo.
I get an error message indicating that <brzo_i2c.h> cannot be included (from SSD1306Brzo.h).
Brzo i2c is not a separate library for PlatformIO. How do I best install that? Or should it be included in the ESP8266_SSD1306 library?
Hi! I though to be smart and connect two 0.96" oled displays to my EPS8266, each with the same address but each with different SDA and SDC ports (as I still have sufficient of them in the flight tracker..)
So this is part of the code:
.......
const int I2C_display_ADDRESS = 0x3c;
const int SDA_PIN = 4;
const int SDC_PIN = 2;
const int SDA_PIN2= 12;
const int SDC_PIN2= 13;
SSD1306Wire display1(I2C_display_ADDRESS, SDA_PIN, SDC_PIN);
SSD1306Wire display2(I2C_display_ADDRESS, SDA_PIN2, SDC_PIN2);**
......
Compiling the program however gave the following error:
.....
sketch\flightscan_test3.ino.cpp.o: In function __static_initialization_and_destruction_0': C:\Users\Hans\AppData\Local\Temp\arduino_modified_sketch_472887/flightscan_test3.ino:195: undefined reference to
vtable for OLEDDisplay'
collect2.exe: error: ld returned 1 exit status
exit status 1
.....
My question: is it possible to have dual displays without changing the I2C addresses in this way?
Hi,
I have just downloaded all the libraries and added them to the libraries folder.
When I try to compile the example "WeatherStationDemo", the compilation fails with due to the following:
WeatherStationDemo.ino:29:21: fatal error: SSD1306.h: No such file or directory
compilation terminated.
Error compiling.
If I click on adding the library to the project, these headers are included:
#include <SSD1306Fonts.h>
#include <ssd1306_i2c.h>
Still, no success with compilation, even after removing these:
//#include "SSD1306.h"
//#include "SSD1306Ui.h"
I noticed the sentence on the home page: "SSD1306.h Renaming ssd1306_i2c to SSD1306 "
Could it be a mistake related to this, or I am doing something wrong? Thanks.
Hello. I really like you project WeatherClock, but i cannot use cyrillic fonts. and i don't know to do this. Thanks.
hello,
i don't understand how use to setContrast,
thx
Is it possible to remove or add frames during runtime?
When trying to use multiple OLEDs I get the following error:
Linking .pioenvs\nodemcuv2\firmware.elf
.pioenvs\nodemcuv2\src\main.o:(.text._ZN11OLEDDisplayC2Ev[_ZN11OLEDDisplayC5Ev]+0x0): undefined reference to `vtable for OLEDDisplay'
Code:
SH1106 display(0x3c, D1, D2);
SH1106 display2(0x3c, D3, D4);
The same happens when using different i2c addresses:
SH1106 display(0x3c, D1, D2);
SH1106 display2(0x3d, D1, D2);
I made the following font - Dialog, Bold, 10pts, >=3.0
The first problem is that the array name comes out as:
const char Dialog.bold_Bold_10[] PROGMEM = {
(The dot after "Dialog" causes a compile error.)
Changing the line to "Dialog_Bold_10" allows it to compile.
Second problem:
This font worked fine when I made it for v2.0 of the SSD1306 lib.
However when made for the 3.0 lib, it fails to display an uppercase 'M'.
(Widest letter?)
Thanks for a great lib!
FWIW the lib seems to work with ATmega chips if you make the following change in the init()
Wire.begin(mySda, mySdc);
Wire.begin();
Hi Guys,
I spent some time to test my request to be able to switch to a specific frame (thanks for coding this part by the way).
I'm trying to use switchToFrame without success but may by I'm doing wrong, here below the code (only part of)
void loop() {
// bla bla check RF packet received
if (packet_received) {
// display immediately data received
ui.switchToFrame(RF_FRAME_INDEX);
ui.update();
// Here I'm doing approx 2 second long stuff blocking
Post_Data();
}
ui.update();
// Handle Web server
web_server.handleClient();
// Handle OTA
ArduinoOTA.handle();
}
Frame are scrolling OK but it never switch to the correct one (it does nothing) when I call switchToFrame()
If there any example on how do use it ?
Thanks
Hi,
hi i tried to send some Non Latin Characters (Arabic letters) and nothing was displayed on the screen.
is this a limitation of Added font , or a library limitation.
thanks
Hi,
Any chance of supporting the SH1106 as well?
The only difference seems to be the size of the memory buffer, like described here
https://forum.arduino.cc/index.php?topic=256374.0
There is only one small difference between SSD1306 and SH1106: The SH1106 controller has an internal RAM of 132x64 pixel. The SSD1306 only has 128x64 pixel.
First problem for standard 128x64 OLEDs with SH1106 controller is: How is the 128x64 window mapped into the 132x64 RAM?
It seems, that the 128x64 OLED is centered in most cases within the 132x64 area, that means pixel (2,0) in ram is pixel (0,0) on the display.
For u8glib, the update for the SH1106 was very small. I just had to shift the display by 2 pixel. This is more complicated with the Adafruit lib.
Cheers
/edit ebay 1.3" oled's seem to use this chip. i don t actually know if it displays all pixels or it s just cropped to the center 128 px.
I have been trying to add new font with The Dot Factory Tool, but rendering is not proper,
How do you add fonts?
Hi,
I am trying to minimize lost space around a text by trying to put it a few pixels off screen on the vertical.
At the bottom, it works fine, at the top, o big chunk of the text seems to be missing with 10px font and -2 y position.
In screenshot, middle and right hand text on overlay had -2 as y.
A useful addition would be allowing 'NONE' to be included in the following setting which would prevent display of the any indicators. This would leave more space for other screen content in frames, if needed.
// TOP, LEFT, BOTTOM, RIGHT, NONE
ui.setIndicatorPosition(NONE);
As an extension of the above, allow a list of frame numbers which should include indicators, as in:
// TOP, LEFT, BOTTOM, RIGHT, NONE. [int frame1, int frame2, ... int framen]
ui.setIndicatorPosition(BOTTOM, 1, 3, 4);
The above example would show the frame indicators at the bottom for frames 1, 3, and 4 only.
if only TOP, LEFT, BOTTOM or RIGHT were included, the frame indicators would be shown on all frames. if NONE were included, there would be no frame indicators.
Changing the names of files from SSD1306xxxxx to OLEDDisplayxxxxx without changing the name of the library itself is a terrible thing to do.
Arduino has a pop-up that opens whenever you open the program. It urges you to update libraries and boards. Anyone in the world who has used your "esp8266-oled-ssd1306" and has clicked on update will have their sketches blown up.
This caused me two hours of grief.
Luckily i had Ver 2.0.2 in a backup.
Please fix this quickly.
Roger
Oldmicroguy
Hi, Trying to compile the example. Ubuntu 14.04 VM, generic esp-12.
Arduino: 1.6.6 (Linux), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 4M (1M SPIFFS), ck"
SSD1306Demo:55: error: 'drawFrame1' was not declared in this scope
void (_frameCallbacks[])(int x, int y) = {drawFrame1, drawFrame2, drawFrame3, drawFrame4};
^
SSD1306Demo:55: error: 'drawFrame2' was not declared in this scope
void (_frameCallbacks[])(int x, int y) = {drawFrame1, drawFrame2, drawFrame3, drawFrame4};
^
SSD1306Demo:55: error: 'drawFrame3' was not declared in this scope
void (_frameCallbacks[])(int x, int y) = {drawFrame1, drawFrame2, drawFrame3, drawFrame4};
^
SSD1306Demo:55: error: 'drawFrame4' was not declared in this scope
void (_frameCallbacks[])(int x, int y) = {drawFrame1, drawFrame2, drawFrame3, drawFrame4};
^
exit status 1
'drawFrame1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Hi,
what a great, fast Library! I Just have fun with some random graphics.
I just wonder what the drawFastImage() is about.
Where can I find a converter for this datatype:
Draw a bitmap in the internal image format
void drawFastImage(int16_t x, int16_t y, int16_t width, int16_t height, const char *image);
Thank you!
Felix
Hello,
It will be very helpful if you add support for 64x48 OLED like the official display for Wemos 👍 http://www.wemos.cc/Products/oled_shield.html
Here they did almost the same :
https://github.com/mcauser/Adafruit_SSD1306/tree/esp8266-64x48
Regards!
I am an experienced C++ programmer (embedded). I love the work you have done and would like to participate. However, I noticed that the naming conventions are not ideal. Would you allow me to update the naming of the variables? I also have a few other updates in mind after this.
Hi, i'm using esp8266-oled-ssd1306 library for may project.
But while loading the sketch to the Arduino, I got the following error?
error: '_min' was not declared in this scope
minBoundY = _min(minBoundY, y);
The same happens to _max?
Could you explain to me how to get around this problem, please?
Thank you!
I am experimenting with improving the rendering performance of text. To archive better performance I had to change the font definition to include a direct jump table, so there is no need to calculate the address each time you need to jump to the correct char. I also added a flag to the jump table (eg. 0xFF, 0xFF) to signal that the char is not printable, removing it completely from the font table.
This jump table consist of 3 bytes. The first two are used for the jump (giving us 2^16 addressable bytes) and the last byte is used to define the width of the char. You can see the usage in the new drawString function.
After doing all that I investigated a bit in how the display buffer is structured and noticed that it has a curious layout in which each byte corresponds to 8 pixel in height. To get the best performance I designed an image format which is basically a flipped XBM to have a better 1:1 mapping to each pixel in height. I added an internal function called drawInternal which takes such an image an draws it in as little buffer modifications as possible.
Due to the optimisation the new font definitions are a little smaller too. (approx. 2kb)
If you are interested in investigating further in this direction I would create a pull request to discuss how we can further improve text render performance (I think there are some opportunity to cache some calculations).
These improvements could also be made for drawing calls like drawRect and fillRect.
This is caused by the multiple inclusion of SSD1306Fonts.h. If I choose Sketch->Include Library->ESP8266 Oled Driver... in the Arduino IDE, this is included in my sketch:
#include <SSD1306.h>
#include <SSD1306Fonts.h>
#include <SSD1306Ui.h>
But SSD1306Fonts.h is also included in SSD1306Ui.h. So either the include of SSD1306Fonts.h in the sketch is unnecessary, or a #pragma once
should be added to SSD1306Fonts.h.
But really, the file should be split into a .h and a .cpp file. The definitions should go in the .h file, the implementation should go in the .cpp file.
I am using version 3, but have problems with the internal format. Please could you help me with an example of such a file and the way to do the call, so I can start playing around with it?
Is it possible to add \n for breaking text into a new line for method drawString or drawStringMaxWidth?
please remove unnecessary #include <ArduinoJson.h> from example
This:
// You can change the transition that is used
// SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN
should be (TOP should be UP):
// You can change the transition that is used
// SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN
This:
display->setFont(ArialMT_Plain_16);
display->drawString(0 + x, 20, "Arial 16");
should be (missing '+ Y'):
display->setFont(ArialMT_Plain_16);
display->drawString(0 + x, 20 + y, "Arial 16");
This:
display->setFont(ArialMT_Plain_24);
display->drawString(0 + x, 34, "Arial 24");
should be (missing '+ Y'):
display->setFont(ArialMT_Plain_24);
display->drawString(0 + x, 34 + y, "Arial 24");
Also, the images here: https://github.com/squix78/esp8266-oled-ssd1306
do not match what the current version of SSD1306Demo.ino displays.
(Thanks for a fantastic SSD1306 driver, BTW.)
While using the SSD1306UiDemo, I've modified this one in order to have:
`void msOverlay1(OLEDDisplay display, OLEDDisplayUiState state) {
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_10);
display->drawString(128, 0, String(millis()));
}
void msOverlay2(OLEDDisplay display, OLEDDisplayUiState state) {
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_10);
display->drawString(128, 0, String("TESTTESTTEST"));
}`
Then:
// Overlays are statically drawn on top of a frame eg. a clock OverlayCallback overlays[] = { msOverlay1,msOverlay2 }; int overlaysCount = 2;
Running the example with these modifications, and you can see that "TESTTESTTEST" is written on top of the current milliseconds.
Hi,
Just created a program based on your example for WeMos D1 and noticed that part of loop()
inside if (remainingTimeBudget > 0)
doesn't run.
Is it safe to run some code outside this condition?
One more thing: changing fps to 25 or lesser makes insane frames switching, like 3-5 frames in one second.
Feature request or example.. would be good to run multiple displays, ie. weather on one and the time on the other.
Hi there,
Sorry, it's more a question then an issue. If there is other channel for this type of request, just let me know.
I'm using UI with automatic transition (4 callbacks) with great success, but in some case (external event) I need to go immediately to a specific transition whatever where I am (for example I'm in # 1 and I want to go immediately to # 3)
Then let the others continue as usual -> # 4, # 1, # 2, # 3 ...
I do not need to go back the one "interrupted" just continue.
What's the best practice to achieve this ?
Thanks for your help
We should have a section where we link to more advanced examples. And add some more examples covering all the functions of this library.
Hi, I have a 128x32 display, got it to work, but noticed that there were issues. I fixed them (on the main branch code), and was wondering if you would like me to commit those changes to the main branch.
It's a quick fix, not a cleanup like the 3.0 branch. So I'd recommend to put these quick fixes in the main branch. And then I could test and (if necessary) fix the 3.0 branch as well.
What do you think?
Add a function that simply lets the user draw a progress bar.
I have recently upgraded from V2.0.2 to the latest code and have issues when rendering black text on a white background. This used to work as expected in version 2 but now the rendering results in garbage. Is this a bug or am I missing something in the changes?
First, thanks for an awesome library!
In some cases the drawStringMaxWidth call can cut off words at the right edge of the screen. In this case 'diam' is cut off, and 'tempor' could have wrapped to the next line as well.
Here is Roboto 12 with this code:
display.setFont(Roboto_12);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawStringMaxWidth(0, 0, 128,
"Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
Hi, great work on this library, thanks much for your efforts. I tried converting existing code that worked for an SPI SSD1306 .96" display to use an SH1106 1.3" (SPI) one. Though I do get some recognizable display elements, the overall result is quite mangled. Some random overwrites, some reverse display elements. I know the code is new for the SH1106...has this been tested on the SPI version?
I'm trying to configure a ESP 201 as a DHT sensor and I want it to show values on an OLED.
I'm having troubles with it: I can't make the ssd1306 work with the simplest example code provided with the library.
First, is this library compatible with the 201 version?
What are the most suitable pins for I2C interface?
Thank you
Following sequence the indicators are still displayed:
ui.setTargetFPS(30);
ui.disableIndicator(); <- no effect
ui.setFrameAnimation(SLIDE_LEFT);
ui.setFrames(frames, numberOfFrames);
ui.setOverlays(overlays, numberOfOverlays);
ui.init();
hi,
how would you got about using this great lib for just a single frame without indicators and no switchover animations?
cheers
Hi there,
I think I discovered a bug with drawProgressBar when using UI to scroll frames containing a bargraph. The problem occurs only during scroll, once frame is fixed all is fine!
When scrolling coming frame containing bargraph there are some line draw on display during scroll, I circled them in red on screenshot below
Did some of you noticed this ?
here the frame code just in case
void drawFrameRF(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
char buff[32];
int16_t percent;
volatile uint8_t * p;
int16_t yidx = 0;
byte n;
n = data.size;
p = data.buffer;
display->clear();
display->setFont(Roboto_Condensed_Bold_Bold_16);
if (!got_first) {
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(x + 64, 14, "No radio data");
display->drawString(x + 64, 34, "received yet");
} else {
display->setTextAlignment(TEXT_ALIGN_LEFT);
if (data.type == RF_MOD_RFM69) {
sprintf_P(buff, PSTR("NODE %d"), data.nodeid );
display->drawString(x + 0, 0, buff);
// rssi for RFM69B is -115 (0%) to 0 (100%)
percent = (int16_t) data.rssi;
// rssi range now 0 (0%) to 115 (100%)
percent += 115;
// now calc percentage
percent = (percent * 100) / 115;
if (percent > 100) percent = 100;
if (percent < 0 ) percent = 0;
// display bargraph on lcd
display->drawProgressBar( x + 60, 4, 64 , 12, 50 /*percent*/);
display->setFont(Roboto_Condensed_12);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(x + 64, 48, timeAgo(g_second-packet_last_seen));
}
}
ui.disableIndicator();
}
Please provide a simple/minimalist example.
You may want to do something with keywords or something, to help make this library easier to find.
Hi Daniel,
I must say firstly awesome work you have done, great examples.
I am trying to get the full digits of a clock to display, initial values are int's using sprintf to format so that leading zero is not truncated and displayed. for example 07:01 and not 7 : 1
Any ideas on where I may be going wrong?
char bufHR[3] = "";
sprintf(bufHR, "%2d", RTC_Hour); // format to 2 decimal places for display output
display.drawString(15, 20, bufHR);
Display works but still only displays single digit and not leading zero.
Thanks
Dans
PS: I will try different formats such as: "%02d" any other suggestions please let me know.
I'm trying to draw a bitmap using the drawBitmap() function, but I can't show the image correctly.
I created the array using LCD Assistant (http://en.radzio.dxp.pl/bitmap_converter) and replaced the one in the demo project but the image is messed up. I also tried drawXbm() without results. How did you prepared the array for the WiFi logo in the demo?
Currently the code in OLEDDisplay::drawRect is as follows:
drawHorizontalLine(x, y, width);
drawVerticalLine(x, y, height);
drawVerticalLine(x + width, y, height);
drawHorizontalLine(x, y + height, width);
Compared to fillRect
function, this draws a rectangle which is 1 pixel wider and 1 pixel higher. Also it lacks a pixel at the lower-right corner.
If I change that to x + width - 1
and y + height - 1
, i get same size as for fillRect
.
I'm not sure if such a "fix" qualifies as a change in API though :)
And by the way, why is fillRect
using drawHorizontalLine
? Isn't drawVerticalLine
faster because it can set up to 8 pixels at a time?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.