Update SSD1306 library supporting bigger font

47 views
Skip to first unread message

rob...@hotmail.com

unread,
Sep 21, 2025, 7:38:05 AM (11 days ago) Sep 21
to jallib
Hi Bill,

It took me quite some time to figure this out. First of all, you cannot read data from the SSD1306. This means that I cannot write characters using pixels.

So I looked at the procedure ssd1306_write_char() which writes ... characters. This procedure does not require the big cache that you normally need when writing characters as pixels or when using graphics in general.

Currently the SSD1306 library worked correctly for the 6x8 font and that was only because that is a vertical font and that matches how the SSD1306 displays the data. This seems to be one of the view (or the only?) vertical font, all other - larger - fonts are horizontal fonts and that causes the problem when using them.

So I added code to this procedure that checks if the used font is a horizontal font and if so it rotates the character 90 degrees to match the SSD1306 display and splits the character up into smaller pieces since the SSD1306 works with pages (0..7) each 8 pixels high. If a font is bigger than 8 pixels, it needs to be spit up and divided over 2 pages. 

I attached the library including a picture that shows the 12x16 font working. I still need to test this for other font sizes and I need to clean the library up since currently the limit is 12x16 and if you use a smaller font I could save data space. So please give it try. You do not need any special setting for this only that you are using text mode. 

Next to cleaning the library up I am planning to move the IIC and SPI part from this library to the main program so that it is not included by this library anymore. This is in line with the JAL style guide but it results in a breaking change for anyone who is currently using the library since incuding IIC or SPI and initializing them moves to the main program. 

Kind regards,

Rob

glcd_ssd1306.jal
P1070762.JPG

Bill Beek

unread,
Sep 22, 2025, 6:26:24 AM (10 days ago) Sep 22
to jallib

Hi Rob,
I tested the lib but the same problem exist.
I added your name at the lib to be sure that the right lib was used.
You can see what's happens on the picture.
I can't understand what I have done wrong so I added my program.

Kind regards, Bill.
18F2520_1306_OLED.jal
IMG_20250922_121150.jpg

Rob CJ

unread,
Sep 22, 2025, 1:02:08 PM (10 days ago) Sep 22
to jallib
Hi Bill,

The only thing I found is that you include and initialize i2c_hardware. As you may remember this is currently also done by the ssd1306 and I am not sure if this messes things up so I commented that part out. I also commented out the include of glcd_common since that is needed by the ssd1306 library so it is included there. I also moved the selection of the font but that should not make a difference. I attached the update.

For the final version of the updated library you have to include and initialize i2c_hardware but not yet for this version.

So it should work but not sure if the I2c_hardware has messed things up (I do not think so).

Unfortunately I do not have an 18F2520  to test it. 

I see you have two devices on the IIC bus. Did you also test with without the INA3221?

And to be sure. Although the module works at +5V you should not pull-up the SDA and SCL lines to +5Volt. If you have connected both the INA3221 and the SSD1306 to +5V, the INA3221 will pull-up the lines to +5V and that can kill the module. Last but not least. As I mentioned before the SSD1306 module generates a lot of noise on the SDA and SCL lines and that is gone if you use it on 3.3 Volt.

So for this test. Only connect the SSD1306 and use it (including the PIC) at 3.3 Volt and see if that works. If that is the case and you want to use it together with the INA3221 at +5V then use a level shifter between the PIC and the SSD1306.

BTW. I do not see any power connection to the SDD1306 🙂.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Bill Beek <bill...@gmail.com>
Verzonden: maandag 22 september 2025 12:26
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Re: Update SSD1306 library supporting bigger font
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallib/5f33c130-d73d-4080-b8c4-03900fba52a9n%40googlegroups.com.
18F2520_1306_OLED.jal

Bill Beek

unread,
Sep 22, 2025, 2:15:03 PM (10 days ago) Sep 22
to jallib
Hi Rob,
Tested without the ina3221, delete the I2C code lines from the program and Vcc 3,3V but nothing changed.
So I wondered if it's possible that the lib you posted is not the same as in your test? 
The 1306 is powered by wires under the board. 
Kind regards, Bill.

Bill Beek

unread,
Sep 23, 2025, 11:25:07 AM (9 days ago) Sep 23
to jallib
Hi Rob,
Some extra information about the topic.
I tested also with a 18f1825 and sw I2C and as expected, got the same image as in the photo I posted.
If the 6x8 font is used, everything works well even with the 18f2520, which is equipped  with the tiny bootloader                                            which works handy and fast for me. 
The 16F1825 is programmed with the pickit 2. I hope that you are able to locate the problem.                                                                                                                                                                                                                                                                                                                                    Kind regards, Bill.  

Rob CJ

unread,
Sep 23, 2025, 12:34:28 PM (9 days ago) Sep 23
to jallib
Hi Bill,

I cannot explain this. I will do some more testing and also test it with the SPI interface.

Did you try it without any other connections to the IIC bus and at 3.3. Volt?

Kind regards,

Rob


Verzonden: dinsdag 23 september 2025 17:25
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] Re: Update SSD1306 library supporting bigger font
 

Bill Beek

unread,
Sep 23, 2025, 1:25:46 PM (9 days ago) Sep 23
to jallib
Hi Rob,
Only the display on IC2 and 3.3V I don't  understand it either, are you sure that the posted lib is the same as in your test?
That could explain the problem.

Bill Beek

unread,
Sep 23, 2025, 1:29:49 PM (9 days ago) Sep 23
to jallib
P.S. send me the hex file for the 18F1825 so i can see of that is okay with my setting.

Rob CJ

unread,
Sep 24, 2025, 1:01:50 PM (8 days ago) Sep 24
to jallib
Hi Bill,

Attached the JAL testprogram I used and the hex file.

Kind regards,

Rob


Verzonden: dinsdag 23 september 2025 19:29
16f1825_glcd_ssd1306_test_font.hex
16f1825_glcd_ssd1306_test_font.jal

Bill Beek

unread,
Sep 24, 2025, 1:49:50 PM (8 days ago) Sep 24
to jallib

Hi Rob,

The 12x16 font now works fine, the error was on my side, the hex file worked fine as expected.

After compilation of your program it went wrong again.

 After investigation, the glcd_font lib turned out to be corrupted, so I apologize for the inconvenience.

I have looked at the I2C lines, and also see that interference signals are

getting bigger as the voltage increases between 3 and 5 Volts.

What I also noticed was that the pulses were not very steep,

which is of course due to by the weak pullups.

After placing 2 x 4k7 resistors it looked much better and realized a more stable data transfer.

I noticed that the display regularly fails at 5V, after placing the resistors everything worked well at 5 Volts.

According to my info there is some kind of voltage regulator on the display board which would make it applicable from 3 to 5 Volt.

Many thanks for the good work,

Kind regards, Bill.


Rob CJ

unread,
Sep 25, 2025, 1:05:31 PM (7 days ago) Sep 25
to jallib
Hi Bill,

Good to hear that it works. As I mentioned before the IC on the module operates at 3.3 Volts and the pins are not 5 Volt tollerant so be careful with that.

Today I tested the library with all available JAL fonts and they - after some smalle modifications to the library - all work  now. I also moved the IIC and SPI part out of the library and moved that to the main program. The library checks which interface (I2C software, I2C hardware, I2C harware 2, SPI hardware and SPI hardware 2) is included by the main program and uses that interface automagically. The only setting that remains for the interface is the SPI software, for all others interfaces it is just including the required interface before including the ssd1306 library and it will then use that interface for the communication with SSD1306 module.

I added a text with a bigger font to the current sample programs so that users can see that that works too. It works for I2C but I still need to test it for SPI as wel. If all works then I will upload the updated library and the updated sample programs.

Good luck with the project. I think this was a nice extension of the functionality of this library.

Kind regards,

Rob


Verzonden: woensdag 24 september 2025 19:49

Rob CJ

unread,
Sep 25, 2025, 3:48:13 PM (7 days ago) Sep 25
to jallib
Hi Bill.

FYI. I finished the update of the glcd_ssd1306 library and the sample files. Tested it with all JAL Fonts using I2C and SPI and all seem to work fine.

I uploaded it to GitHub so it should be in the bee package of the upcoming weekend.

Since the version you have works for the 12x16 font it did not yet work for all available JAL fonts but that has been fixed. As said before, the IIC and SPI libraries now need to be included by the main program as to make the library compliant with the JAL style guide. It now also gives more flexibilty since you can now also use SPI 2 and I2C 2 if you needed that but it is a breaking change with the previous version of the library. Examples are given in de sample files.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Rob CJ <rob...@hotmail.com>
Verzonden: donderdag 25 september 2025 19:05
Reply all
Reply to author
Forward
0 new messages