HCuOLED library for SSD1307 & SH1106 based OLED displays

Useful guides, libraries, and example sketches to support our Arduino based products.
GuitarPhil
Posts: 7
Joined: Mon Jan 19, 2015 3:47 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by GuitarPhil » Fri Nov 02, 2018 1:31 pm

Thanks Andrew. I thought I was cracking up for a while LOL!

:D

Phil.

mooser
Posts: 4
Joined: Thu Mar 28, 2019 2:01 am

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by mooser » Sat May 18, 2019 2:32 am

Question about clearing multiple displays
HI have three SPL displays set up like the sample code (blinking eyes) and I'm trying to get them to start in a blank state when the system first turns on (power up) and then load some bitmaps

I've been trying to tie all of the 3 reset pins on the displays to the same arduino pin (8 in this case) as I do not need to reset them individually for any reason

Displays #2 and #3 will always flash the last known image during the reset in the setup loop, display #1 will be blank as it should be.
I've tried various sequences of clearbuffer, reset and even then displaying the empty buffer with no luck, (I thought since they are looking for pin 5 and 2 during the reset they never actually get the reset signal

Tried declaring the reset pin for each as #8 (instead of 5 and 2 as they were)

#define RST_DI1 8
#define RST_DI2 8
#define RST_DI3 8

but that only seems to reset whichever one was done last and nothing will display on the other two

Tired chaning the order of the reset to 3, 2, 1. Then display 1 and 2 flash the images and only display 1 will do anything afterwards

If I make them separate rest pins (2 5 and 8), it works fine but I'm trying to free up some wires if I can and I'm sure I read that this should be possible

Any help would be appreciated
Thanks
M

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by andrew » Sat May 18, 2019 9:38 am

The problem is that the reset function doesn't just toggle the reset pin, it also re-initialises the display. So when you reset all three displays with the reset function, although all three displays are actually getting reset, only the display your executing the reset function for is getting initialised.

I've attached an updated version (0.6) of the library to this post. This includes the addition of a separate initialisation function which can be used to re-initilise each display after they have been reset. So to reset your displays via one pin you can do this:

  1. HCuOLED1.Reset(); // Resets all 3 displays but only initialises the 1st
  2. HCuOLED2.Init() ;   // Initialise the 2nd display
  3. HCuOLED3.Init() ;   // Initialise the 3nd display

Could you let me know if it works and I'll get it added to the first post.
You do not have the required permissions to view the files attached to this post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

mooser
Posts: 4
Joined: Thu Mar 28, 2019 2:01 am

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by mooser » Sat May 18, 2019 7:28 pm

Thanks for the reply
I connected all 3 display rst pins to output 8
When I call the setup for the screens it looks like this

void setup()
{
DisplayInit(); // Clear and prepare the displays
delay (9999);

DisplayLogo(); // Display the Logo
delay (2999);
}

and the DisplayInit is this

void DisplayInit()
{
HCuOLED1.Reset();
HCuOLED2.Init() ;
HCuOLED3.Init() ;
}


Display 2 and 3 flash whatever was in them last.
If it's a fresh power up they are pretty much a full screen on, if it's a restart or re-upload of the program they show whatever bitmap they had before the restart

Also, I forgot to mention, for whatever reason they (2 and 3) are briefly backwards (mirror) then the flip forward then clear
I don't do any screen reverses or anything in the program, just display a handful of bitmaps onto the different screens.
For me, the displays are sideways with the pins on the left hand side, ribbon cable on the right. All three stacked on top of each other with display 1 on the top and 3 on the bottom.
I have bitmaps of letters being displayed so if the last thing was a letter b, during the reset / init display 2 and 3 quickly show d then b then blank
Hope that helps explain what I'm seeing
M



do I change anything on the
#define RST_DI2 5
and
#define RST_DI3 2
lines?
Since it's not calling a reset for those does it matter or should they go to output 8 as with RST_DI1?

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by andrew » Sun May 19, 2019 8:13 am

Just to be clear you're saying the displays do work after the reset, it's just that you're seeing some weirdness happen whilst the reset?

Also, I forgot to mention, for whatever reason they (2 and 3) are briefly backwards (mirror) then the flip forward then clear
Yes, both these things are done as part of the reset/init routine although I wouldn't expect you to see that so something still isn't right. I'd also not expect screen 2 & 3 to behave any differently to screen 1. I think rather than taking a guess I need to set something up on the bench but I won't get chance to do this until early next week.

Since it's not calling a reset for those does it matter or should they go to output 8 as with RST_DI1?
If you need to use those pins for something else then I would set them all to the same pin as the library will configure them as outputs.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

mooser
Posts: 4
Joined: Thu Mar 28, 2019 2:01 am

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by mooser » Sun May 19, 2019 1:13 pm

All three work correctly even during the reset if I wire them to the different reset pins (8,5,2)

The init you added allows the displays to function without reset command but doesn't blank them during the reset I guess is how I can describe it.

(I also tried clearing the buffers before the reset but I guess that doesn't actually work until after they are reset / init)

During power up or reset here's what happens when all rst are combined on pin 8, (#define RST_DI1 8, #define RST_DI2 8, #define RST_DI3 8)

screens are blank program calls for the screens to initialize (reset 1, init 2 and 3 or reset 1, 2 and 3 doesn't seem to matter)
screen 1 stays blank
screen 2 and 3 briefly flash the reversed image (either the last image on the screens if reset button is pressed or turn fully on with some black pixels scattered if its a complete power off/on cycle) and then flash briefly forward then go blank
after that they all work like normal as I turn them off and on displaying blank screens or different bitmaps

if I reset display 3 and init display 1 and 2, then 3 works fine and 1 and 2 flash the old bitmap
it only seems to blank the first screen that is reset somehow

I will not be using pin 5 and 2 but the screens are located in a different box than the controller (nano in this case) so I'd like to eliminate the two wires running between them if I can, not a huge issue or anything but I was trying to avoid it.


Thanks for looking at this

M



BTW, is there any way of dimming the displays (I'm thinking to dim them if no activity after a certain time, not power off just 1/2 brightness or something from a contrast standpoint)
Just wondering
M

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by andrew » Tue May 21, 2019 11:07 am

I've attached a new version of the library. Hopefully this should fix the issue. Can you give it a try and let me know if it works.

BTW, is there any way of dimming the displays (I'm thinking to dim them if no activity after a certain time, not power off just 1/2 brightness or something from a contrast standpoint)
Just wondering
I've also added a new function to the attached library to adjust the brightness:

  1. HCuOLED.Brightness(1) //Sets the brightness level to minimum
  2. HCuOLED.Brightness(255) //Sets the brightness level to maximum
You do not have the required permissions to view the files attached to this post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

mooser
Posts: 4
Joined: Thu Mar 28, 2019 2:01 am

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by mooser » Wed May 22, 2019 1:48 am

That worked perfectly
All three not come on blank, reset on the #1 and Init on #2 and #3

Dimming also works, using a 1 for the value drops it down a fair amount while still easily visible, I'll use that as a screen-saver type routine.

Thanks so much for fixing / adding that, especially so quickly

When I clear a screen to display a new bitmap I've been doing a clearbuffer followed by the new bitmap then the refresh

HCuOLED3.Cursor(0,10);
HCuOLED3.Bitmap(38, 6, D1ST);
HCuOLED3.Refresh();

To clear a screen and leave blank I've been doing
HCuOLED3.ClearBuffer();
HCuOLED3.Refresh();

It works but Is that correct?
Thanks again,
M

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by andrew » Wed May 22, 2019 8:19 am

Great, thanks for confirming. I'll get this new version added to the first post now.

When I clear a screen to display a new bitmap I've been doing a clearbuffer followed by the new bitmap then the refresh

HCuOLED3.Cursor(0,10);
HCuOLED3.Bitmap(38, 6, D1ST);
HCuOLED3.Refresh();

To clear a screen and leave blank I've been doing
HCuOLED3.ClearBuffer();
HCuOLED3.Refresh();

It works but Is that correct?

Yes that's correct. If your bitmap isn't the entire size of the screen you could just use the erase function to clear the area the bitmap will be drawn to. Another option, if your bitmap is small, is to use the CLEAR or INVERT draw mode option (see Things example sketch) and redraw the bitmap. Whichever is quickest or most convenient.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

ChrisSharp
Posts: 30
Joined: Thu Dec 31, 2020 1:22 pm

Re: HCuOLED library for SSD1307 & SH1106 based OLED displays

Post by ChrisSharp » Mon Feb 15, 2021 2:35 pm

Adding Fonts?

I've got the Multi-Displays example working using the HC library. I would like to use these SSD1306 as miniature Passenger Information Displays on my model railway. Although I could create bit-maps of all the displays I want, it will be more flexible to send text to the displays.

My problem is that the fonts provided in the library aren't small enough for the scale I'm working at (1:76). I've looked into font generators for these displays, but the one I've found doesn't output in the same format as the library.

Could you point me in the direction of a font converter that I could use with the Hobby Components library.

Many Thanks

Post Reply

Return to “Arduino”