News:

Let's find out together what makes a PIC Tick!

Main Menu

OLED libraries for SSD1306 and SH1106

Started by Dompie, Feb 05, 2021, 11:30 AM

Previous topic - Next topic

xldaedalus

The SH1106 library is nicely written.  Unfortunately, it appears to be written for I2C only. I2C is pretty slow if you intend to use the display in a high speed environment.  I'm working on DMX, which, at top speed, receives 512 bytes of data every 25ms.  At 250kbaud, it's 4uS per bit, 11bits per data byte or UART interrupt of 44uS between bytes received. Writing display buffer the the display RAM of 132x64 bits / 8 = 1056 bytes.  Even at 1Mhz SPI, it takes 8.448mS to write.  Sending a CMD byte then a data byte can double the time required to write the screen.

This might not be a problem, but once the 512 byte DMX data buffer is full, the data needs to be handled and applied to a PWM output(s).  If the program is off writing to the the display screen for >2.5mS, a new DMX frame is already arriving. The only way the display can work is by adding interrupt vector(s) to call event handling routines in the middle or writing to display RAM, or during any function or routine that is away from the State machine for more than 50uS. It might help to have a very tight code that allows printing only the data that needs updating. Even this is relatively slow.

What if the baud rate and data flow is much faster, like the output of a 9DOF sensor controlling something like a 4 prop drone?  I am currently using interrupt vectors, direct to screen update values and a chopped down font library that is a combination of something Gabi wrote, but dramatically speeded up by some direct-to-register routines by Les.  So, I know this method would work, but it will take some time to modify the SH1106 library to work with SPI and work with an interrupt vector capability.

Interrupt vectors might not be needed if the display has its own MCU.  The idea of a "serial display" seems a good one.  MCU to MCU data rates can be > 10Mhz.  Send a cursor position and a 16bit value = 4 bytes(without start byte or checksum which might be a better idea), 32 bits could be sent in 0.32uS at 10Mhz.  With a screen update rate of 30fps, the code in the "display MCU" would have 33mS to update, with no noticeable lag in data.

Does anyone know of a serial input display like this, or am I really missing something?  Would anyone be interested in such a display if I design one?
Never, never, never give up

Alan R.

Well that was fast.   Less than 15 minutes from discovering the OLED libs exist to having the demo working on a different PIC. 

Thanks for the fantastic effort.  You've saved me weeks of work.   

I'm just coming back to working with PICs and Proton after a few years off.  I've forgotten so much, but it's coming back.

AlbertoFS

Hello all,
I am new for this display. I would like to know hoy much bytes (more or les) is it needed for code using SPI?
Is this driver use the SPI mode?
My present code is using 600 bytes.
I would like to use a PIC12F1840.
Thank you for answer.
Alberto from spain.
73's de EA3AGV

Dompie

Heeeee AlbertoFS, back on the forum!!
The SSD1306 library hold the display in memory so you need 1024 RAM at least only for the display. So a 12F1840 has too little RAM (256byte I believe).
And the SPI library is your own SPI library, I use.

Johan

trastikata

#44
Quote from: AlbertoFS on Feb 13, 2023, 09:03 PMHello all,
I am new for this display. I would like to know hoy much bytes (more or les) is it needed for code using SPI?

Hi,

what do you need to display - text only, some simple preset graphics or dynamic graphics? 

I've adapted one SSD1306 AVR library for the I2C version to display text, digits and numbers to suit my project and it takes about 60 bytes RAM. Then the font is 6 bytes per symbol, if using all the 26 capital letters and 10 digits, that's maximum 216 bytes FLASH memory for the font.  The subs are not that much code if using software SPI. 

david

Hi,
I'm using a 12F1840 chip and a SSD1315 based OLED display (I2C) which is very similar.  I can get my program and the font table stored in 2k of flash so it should be possible unless you have a lot of code.

Cheers,
David

Dompie

Ohhhh Being able to use an SSD1306 on my 12F1840 projects would be very nice. Could this library be shared???

Johan

david

#47
My effort is already in Code Examples/Led Displays/Oled Lite
I'm using 5 bytes per character but I'm a bit out of my depth so I'm sure the code can be improved upon.  It doesn't do font scaling or graphics - just upper and lower case letters, numbers and various other symbols.

Cheers,
David


Dompie

Oh I missed that one (and hadn't watched it now either). That's exactly what I need for the most part, plain text. Thank you David.

Johan

AlbertoFS

Thanks for all for this information. It is very usefull.
Probably I will use numbers only.
Alberto
73's de EA3AGV