Font size increase for OLED Display Module SSD1306

turns out I know nothing about libraries either. Google found the following link

Can any aspect of the adafruit arduino ssd1306 library approach be adopted?

1 Like

Adafruit use the same idea discussed above - scaling the font in integer multiples. The library linked is compiled for Arduino which means it doesn’t have the same challenges we face for unifying functionality for Pico, RPi, micro:bit (and others in the future!)

You could definitely achieve this, it would require dropping the MicroPython framebuf class used in PiicoDev_SSD1306.py and making your own. Not exactly for the faint-hearted but it’s what’s outlined in my previous reply.

3 Likes

Michael,
thank you very much for going to the trouble of detailing than explanation above. I’m currently looking at “PiicoDev_SSD1306.py” (… “Ported by Peter Johnston at Core Electronics October 2021…”) from James46717 via Simple Relay Timer - Tutorial Australia.

I didn’t realise the inner workings of the frame buffer was such a pain.

I think the key though is your last statement “challenges we face for unifying functionality…”. That’s the really hard bit. All I can say is, keep up the good work!

As for my specific use case - I might put that challenge on hold for the moment.

Cheers,
Allan H

3 Likes

I’m very keen to see what could be achieved by manipulating bitmaps programatically. Of course, the challenge would be to maintain cross-platform compatibility.

An alternative is the Adafruit PiOLED HAT for RPi which allows custom fonts and text sizes out of the box. Not sure if it could be made to work alongside my Piicodev setup as the Piicodev adapter occupies my GPIO.

3 Likes

Stephen,
I had a look at the enormous amount of coding required as per Usage | Adafruit PiOLED - 128x32 Mini OLED for Raspberry Pi | Adafruit Learning System and put it in the too hard basket for the moment.

That’s the really nice thing about the Core Piicodev system - most of that complexity is hidden. It just works.

ALH

That’s the really nice thing about the Core Piicodev system - most of that complexity is hidden. It just works.

Completely agree. You can get your code done super-quick.

To prove that it is possible there is:

which is a working example. Which recommends:

ALH

2 Likes

The limitation of small font size was raised last January and it seems has not been solved. At the time the only solution I could see was to load graphic images. These are 128 x 64 pixel Portable Bitmap Image (PBM) files. If you only wanted say the numbers 0 - 9 it would be feasible to load one of ten PBM files created in Photoshop. But if you wanted a signed temperature in deg celsius this method obviously fails. To illustrate I have a test.pbm file but it will not upload. To create a PBM file on demand you would need the netpbmfile python library

but this is hardly an efficient or elegant solution.
I am presently using the OLED display in a weather station. It is also useful for displaying results when prototyping. It would be really nice to have a display which was not such a strain on the eyes. Is there any other hardware available?

1 Like

Hey Allan,

What kind of characters were you looking to display? Some rudimentary numbers should be easy to put together using lines and arcs.
@James46717 has some really interesting code in this topic: Pi Pico Smart Watering System Controller - #4 by James46717

While the excellent team at Core look at getting fonts larger it might be a good place to start!

1 Like

Liam,
Michael has flagged the work that @James46717 work in this area. It’s taken me two days to do some reading and get my head around all the information in the posts above.

Summing up where we are so far (refer to posts above for Michael’s technical descriptions):

  1. The problem (as Michael pointed out earlier) is that in the micropython SSD1306 display implementation, text is limited to 8 x 8 pixels. (framebuf — frame buffer manipulation — MicroPython 1.18 documentation)

  2. Use case: Require temperature and humidity display in a larger font. Say -10.0 °C to +50.0 °C and 10% to 90% RH. Just need numbers (0-9) and some symbols (+,-,.,°C, %RH) . A total of 15 characters distinct required.

  3. Jim’s code displays a larger font by parsing the required string into individual characters. It then manually constructs each character using the requisite number of lines (micropython primitives).

Key element of Jim’s code (paraphrased) (Broad description which omits the offsets required to correctly position the character on the display). Which is something I can work with.

image

  1. What I had in mind was a process of fiddling with the pixels in the frame buffer. Is it possible to could convert a letter in a particular font to a (say) 16 x 16 bit-map / set of pixels. And then “place/overlay” the pixels/bits In the appropriate locations in the frame buffer (/memory locations),?

Or to borrow and reinterpret Michael’s description “hand make the frame buffer” ?

image

rinse and repeat until entire string has the appropriate pixels fiddled. And then display the frame buffer.

It’s got a very simplistic appeal. But forget any ideas of making this approach general or suitable for a wide range of platforms or displays. Strictly a one-off for a SSD1306 controller and a 128 x 64 display.

Any ideas anyone? Is this vaguely possible? Or am I just being cheerfully optimistic out of ignorance? Happy to accept advice from someone who knows what they’re doing. Although I suspect I know what the answer is…

  1. At this stage, the most practical approach is to follow that in item # 3. I’ll let everyone know how it goes . Nothing happens quickly around here.

ALH

1 Like

Hi Allan,

With a combo of James’s work, a bit of your time and the arc and circle functions (linked below), you should be able to collapse the functions used and add some of the basic characters. (having it scale nicely might be a bit harder)

Definitely - the FrameBuffer.pixel(x, y[, c]) command lets you set a single pixels value to on or off. A tool like this should speed things up!

Code for arcs and circles:

Documentation: GitHub - CoreElectronics/CE-PiicoDev-SSD1306-MicroPython-Module: CE-PiicoDev-SSD1306-MicroPython-Module

1 Like

A few years back I used this OLED: https://www.waveshare.com/wiki/0.96inch_OLED_(A)
It is based on SSD1306. I installed the necessary arduino library from the wiki page.

I used the following function to make the text size smaller or bigger:
static void SSD1331_char(unsigned char x, unsigned char y, char acsii, char size, char mode, unsigned short hwColor)
My tutorial is in my native language but the photos and code may help you understand how I did it.
https://blog.techshopbd.com/tds-মিটার/

2 Likes

Hey everyone! We featured this forum topic in this week’s episode of The Factory - our fortnightly engineering catchup.

There’s some great ideas being thrown around for case-specific solutions. I’ve seen projects where people define numbers out of drawn lines, or use the .blit() method to overlay bitmap images.
I think the most accessible solution for the most people is the Pull Request that we discuss in the video. It should be pretty trivial to support font scaling within the framebuf class natively. If you’d like to see this feature get implemented into MicroPython then perhaps add your support to the PR - its a pretty simple one and perhaps just hasn’t garnered enough attention.


With all that being said, this is still an open source project - your ideas and code contributions are welcome! If you think you’ve come up with something that makes PiicoDev even just a little :pinching_hand: bit better then open an issue or PR on the GitHub repo!

4 Likes

Looks like I’m going to be busy for the next few weekends…

1 Like

Hey Allan,

Just wanted to touch base really quickly - where were you up to with this?(the thought of doing this work twice would be painful)
I’ve got a project where I would also like to use some larger numbers and thought of spinning up a could of small functions to draw specific characters like you requested:

I’ll keep you posted :smiley:

Bumping the topic: while the excellent team at Core works on a cleaner implementation I’ve botched together something that allows for scaling much like parametric CAD.

2 Likes

Thanks very much putting that code together. After a bit of thought, I’m more inclined to work with…

I have no idea how font files work, but I can easily generate text files like the following (for example) “5.DAT”
image

If I have a temperature (say) “+12.34C” I can:

FOR each line
FOR each characters in the string,
call up the appropriate character “.DAT” file and
FOR each line/column in the DAT file, with the appropriate character offset, set the relevant pixels in the frame buffer.
RINSE and REPEAT

[incidentally, How do you indent text in this forum?]

The key element is:

Not too fussed about the speed because it’s a temperature reading which should be varying only slowly (in my case anyway), and we do a screen update only when the entire process is finished. Not particularly elegant either, but it’s simple. Fault finding is relatively straightforward. And updates/correction/alternatives to the font/DAT files can be done with a text editor. Or in my case an Excel spreadsheet using conditional formatting to manually construct DAT file source data for each character.

The hold-up is that I have no idea how to open a file and read the data in micro-python. And zero experience using a Pi . I’m working on it.

In the meantime, if someone wants to put some code together, I’m quite happy to generate the DAT files…

Cheers,
ALH

1 Like

Hi Allan,

The blit method (mentioned in the Factory) more or less does the overlaying method, though is only included in framebuf.

In Micropython the font is stored as a long hex array: https://github.com/micropython/micropython/blob/master/extmod/font_petme128_8x8.h
This tool lets you build, visualise and text hex strings: LED Matrix Tool

Though the underlying code isn’t there to scale and load the fonts.

Id definitely check out a guide on using file readers, the Makerverse micro SD adapter. Makerverse Micro SD Adapter - MicroPython Guide and Data Logging - Tutorial Australia

I’m not entirely certain that its possible, the forum’s text input uses markdown so you can bullet items with - or * but screenshots are probably easier (or comment them like code with ``` at the start and end

Thanks of those links. This may take a while. Now might be a good time to learn some basic linux skills.
ALH

An interesting discussion.
The bitmap and line drawing methods I used are very limited, but they resulted in a quick solution and low memory usage. When I first started I wanted to develop a font driver, the ability to use existing font files to display characters. I soon found it was beyond my programming skills.

The RPi Pico has a limited memory which is already half used by Micro Python. Adafruits version takes up even more memory space. The RP2040 can support up to 16MB of off chip memory, the Pico has only 2MB. Price, space consideration ??? If version 2 of the Pico is ever produced I would like to see it with the full 16MB.

The PiicoDev OLED module is a great product, I have yet to use it on anything other than the Pico. I am pretty sure a RPi Zero 2 would be able to run scalable fonts. I have done this with an Adafruit OLED and their drivers.

An alternative using the Pico would be to throwaway Micropython and use the Arduino IDE to develop C++ code. I soon gave up this idea because Thonny and Micropython are just too easy to use.

Some thoughts.
Cheers
Jim

1 Like