Page 3 of 3
Re: Larger fonts on SSD1306 OLED displays
Posted: Mon Aug 31, 2020 6:53 am
by pythoncoder
You need to use
font_to_py.py with the
-x option to create horizontally mapped fonts. This shows the options
Re: Larger fonts on SSD1306 OLED displays
Posted: Mon Aug 31, 2020 10:26 am
by IHOXOHI
PERFECT.
So good.
All my respect.
All the best.
Re: Larger fonts on SSD1306 OLED displays
Posted: Sat Oct 17, 2020 11:09 am
by IHOXOHI
Yip,
It works too with an epaper!
WONDERFULL!!!
Thanks.
Re: Larger fonts on SSD1306 OLED displays
Posted: Sun Aug 22, 2021 9:34 pm
by volkerjaenisch
Really cool software!
Re: Larger fonts on SSD1306 OLED displays
Posted: Mon Dec 09, 2024 1:01 pm
by l00p1n6
If someone is still interested in this topic, here is a solution I came up with....
NB: I am using ESP32-WROOM-32, 0.91" OLED 128x32
Code: Select all
from machine import SoftI2C, Pin
import time
import ssd1306
OLED_SCL_PIN = 22 # clock
OLED_SDA_PIN = 21 # data
OLED_WIDTH = 128 # pixels
OLED_HEIGHT = 32 # pixels
def oled_text_scaled(oled, text, x, y, scale, character_width=8, character_height=8):
# temporary buffer for the text
width = character_width * len(text)
height = character_height
temp_buf = bytearray(width * height)
temp_fb = ssd1306.framebuf.FrameBuffer(temp_buf, width, height, ssd1306.framebuf.MONO_VLSB)
# write text to the temporary framebuffer
temp_fb.text(text, 0, 0, 1)
# scale and write to the display
for i in range(width):
for j in range(height):
pixel = temp_fb.pixel(i, j)
if pixel: # If the pixel is set, draw a larger rectangle
oled.fill_rect(x + i * scale, y + j * scale, scale, scale, 1)
def main():
i2c = SoftI2C(scl=Pin(OLED_SCL_PIN), sda=Pin(OLED_SDA_PIN))
oled = ssd1306.SSD1306_I2C(OLED_WIDTH, OLED_HEIGHT, i2c)
# no scaling
oled.fill(0)
oled.text("ABCDEFGHIJKLMNOP", 0, 0)
oled.text("abcdefghijklmnop", 0, 8)
oled.text("0123456789012345", 0, 16)
oled.text("=!\"#$%&/()?-+*:;", 0, 24)
oled.show()
time.sleep(3)
# 2x
oled.fill(0)
oled_text_scaled(oled, "ABCDEFGH", 0, 0, 2)
oled_text_scaled(oled, "abcdefgh", 0, 16, 2)
oled.show()
time.sleep(3)
# 4x
oled.fill(0)
oled_text_scaled(oled, "ABCD", 0, 0, 4)
oled.show()
time.sleep(3)
if __name__ == "__main__":
main()
Re: Larger fonts on SSD1306 OLED displays
Posted: Mon Dec 09, 2024 6:57 pm
by davef
Re: Larger fonts on SSD1306 OLED displays
Posted: Tue Dec 10, 2024 12:54 pm
by l00p1n6
Done, do you want me to remove the previous post's content and just put a link to the solution on GitHub?
Re: Larger fonts on SSD1306 OLED displays
Posted: Tue Dec 10, 2024 7:36 pm
by davef
I'd leave it and then that gives two opportunities to find it. Will try your code as reading standard fonts on these OLEDs is difficult.
Re: Larger fonts on SSD1306 OLED displays
Posted: Wed Dec 11, 2024 12:49 pm
by l00p1n6
davef wrote: ↑Tue Dec 10, 2024 7:36 pm
I'd leave it and then that gives two opportunities to find it. Will try your code as reading standard fonts on these OLEDs is difficult.
Should be readable at 4x scale
Link to image (cannot embed):
https://ibb.co/XyP2fBY