Enhanced OLED plugin

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Enhanced OLED plugin

#1 Post by costo » 07 Dec 2015, 18:02

I changed the _P023_OLED.ino in such a way that it can work with 2 different OLED controllers. The SSD1306 but also the SH1106 controller.
The difference between these controllers is that the 1306 has a 128*64 bitmap and the 1106 has a 132*64 bitmap. To make the SH1106 display well there needs to be an offset of 2 pixels to the right. For the SD1306 this offset is no problem as the last 2 pixels of a row with characters are usually blanks.
Control codes used in ESPEasy for the 1306 and 1106 controllers are the same.

I also added some choices for the character character_width. The original plugin can only display 16 characters on a line with a characterwidth of 8 pixels.
The enhanced plugin gives you a choice for: 16 characters of 8 pixels, 18 characters of 7 pixels or 21 characters of 6 pixels width.

So have added 2 extra lines of declarations in top of the OLED plugin:
#define offset 0x02
byte width = 6, chars = 21; // byte width = 7, chars = 18; // byte width = 8, chars = 16;
make a choice of one of these 3 combinations to add on top.

these are the changed lines in _P023_OLED.ino (as used in release 48)

old line 164: newString.toCharArray(tmp, 17);
new line164: newString.toCharArray(tmp, chars+1);
// stringlength for display in characters on each row + 1

old line 334: for (i = 0; i < 128; i++) //clear all COL
new line 334: for (i = 0; i < (128 + 2 * offset); i++)
// offset to clear all 132 pixels in each row in the clear_display routine

old line 381: Plugin_023_sendcommand(0x00 + (8 * col & 0x0f)); //set low col address
new line 381: Plugin_023_sendcommand(offset + (width * col & 0x0f));
// offset each row 2 pixels for SH1106

old line 382: Plugin_023_sendcommand(0x10 + ((8 * col >> 4) & 0x0f)); //set high col address
new line382: Plugin_023_sendcommand(0x10 + ((width * col >> 4) & 0x0f));
// set high col address depending on number/width of characters

old line 409: for (i = 0; i < 8; i++)
new line409: for (i = 0; i < width; i++)
// sends the 8/7/6 bytes of the font

So now the display can show maximum of 8 lines of 21 characters which can be very usefull.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Enhanced OLED plugin

#2 Post by costo » 10 Dec 2015, 16:26

Image

This picture shows an 1.3 inch OLED with 21 characters/line.

The OLED used is this one: http://www.aliexpress.com/item/1-3-1-3i ... eb201560_3

It is actually a 132x64 display with an SH1106 controller (chinese sellers often do not know what they sell).
It can be configured for either SPI or I2C by 2 solderpads on the back. I2C address is 3C and D0/D1 are the SCL/SDA lines for I2C.

I changed a line in the OLED plugin to display the ° degree symbol instead of the @ symbol.

in file -P023_OLED.ino you have to edit one line.
line 228 which looks like: {0x00, 0x32, 0x49, 0x79, 0x41, 0x3E, 0x00, 0x00},
which is the symbol @

Replace this with:
{0x00,0x00,0x0C,0x12,0x12,0x0C,0x00,0x00},
which is the degrees symbol and you just have to use the '@' in the webGUI to get the degree symbol on your OLED.

timsson
Normal user
Posts: 77
Joined: 25 Mar 2016, 22:00

Re: Enhanced OLED plugin

#3 Post by timsson » 15 Aug 2016, 15:13

Hi,
how can i use this with R121 and the framedOled?
Thanks

timsson
Normal user
Posts: 77
Joined: 25 Mar 2016, 22:00

Re: Enhanced OLED plugin

#4 Post by timsson » 16 Aug 2016, 20:05


User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Enhanced OLED plugin

#5 Post by costo » 17 Aug 2016, 16:42

timsson wrote:Hi,
how can i use this with R121 and the framedOled?
Thanks
I have no idea.
You can ask the maker of the frameOLED plugin ?

It modifications I made are meant to work on the original OLED plugin as is distributed in the ESPEasy package.
I used it on R78 and a few later beta versions, I have not yet tried to make this work on the latest stable R120 or on beta versions above R120.
If I have tried it I will tell about the results.

timsson
Normal user
Posts: 77
Joined: 25 Mar 2016, 22:00

Re: Enhanced OLED plugin

#6 Post by timsson » 19 Aug 2016, 19:25

Hi,
your changes works with R121 :)
If i use this:
https://github.com/squix78/esp8266-oled-ssd1306
it also works with the "frame" version ... :)
changes are:
_P205_FrameOLED.ino
#include "SH1106.h"
SH1106 display(0x3c, SDA-Pin-D2, SCL-Pin-D1); //WemosD1mini
display.init();
and the font: display.setFont(Dialog_Plain_12);

thats all :)))
who can make the exactly coding?

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests