Replies: 5 comments 2 replies
-
There are two issues here:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi
Thanks for your prompt answer and help.
Now I'm going to check carefully my code and the links you suggested trying to find if I solve this issue.
Have a nice day
--
Inviato da Libero Mail
|
Beta Was this translation helpful? Give feedback.
2 replies
-
Hi,
thanks for your suggestion. I was able to adapt your code to my SH1107 and also to use a different from the default.
Have a nice day
… Il 22/04/2024 00:03 CEST Rick Sorensen ***@***.***> ha scritto:
I only have 128x64 SSD1306 OLED display and the driver for micropython also uses framebuf. Here is a snippet that works for me and does not use much extra memory.
The spacing assumes text is a 8x8 pixel cell, and I computed the spacing based on that. One could half-space too.
from machine import I2C
from ssd1306 import SSD1306_I2C
import framebuf
# simple 8x8 degree symbol, 1 pixel thick line, in the upper half of character cell
p0 = bytearray([0x18, 0x24, 0x24, 0x18, 0x00, 0x00, 0x00, 0x00])
# p1 drops symbol in cell by 1 pixel
p1 = bytearray([0x00, 0x18, 0x24, 0x24, 0x18, 0x00, 0x00, 0x00])
# convert to framebuf-
# 8,8 is size of blit- 8x8 pixels, 8 per row
# MONO_HLSB indicated bit 7 is left most and bits are in rows
fb0 = framebuf.FrameBuffer(p0, 8, 8, framebuf.MONO_HLSB)
fb1 = framebuf.FrameBuffer(p1, 8, 8, framebuf.MONO_HLSB)
# i am using RP2040, use default I2C
i2c = I2C(1, freq=400000)
# create display object
ol = SSD1306_I2C(128, 64, i2c, addr=60)
ol.fill(0)
ol.show() # erase
# row of symbols
ol.blit(fb0, 10, 10)
ol.blit(fb1, 20, 10)
ol.blit(fb0, 30, 10)
# number followed by symbol
ol.text("32.1", 20, 20)
ol.blit(fbuf0, 52, 20)
# another row of symbols
ol.blit(fb0, 10, 30)
ol.blit(fb1, 20, 30)
ol.blit(fb0, 30, 30)
# number followed by symbol followed by unit
ol.text("273", 20, 40)
ol.blit(fb0, 44, 40)
ol.text("K", 52, 40)
ol.show()
exampx.png (view on web) https://github.com/micropython/micropython/assets/3868608/d1d7c7f0-2e48-4bf4-a419-45cdc7929d58
—
Reply to this email directly, view it on GitHub #14338 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYK3UZU7NNJNKQEF72ILY6QZTDAVCNFSM6AAAAABGQNNI5GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCOBRHA2DM.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi,
interesting suggestion but may be too difficult for a newbie. In fact, if - for example - I open font6.py I find a very long series of hexadecimal values and I have no idea which characters these values correspond to. How can I identify the correspondence ? If I had to remove from the font the character @ that I'm not using and replace it with the symbol ° how could I do ? And for a different font ? let's say font10.py ? Thanks
… Il 22/04/2024 12:21 CEST Marcus Mendenhall ***@***.***> ha scritto:
If you want to rebuild micropython, you could just make your own fork that hacks the display module font, and replaces some other un-needed character code with a degree-sign glyph. It's not too hard to do a custom build, even if you are just getting into it.
—
Reply to this email directly, view it on GitHub #14338 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYKYCSLSJGSREGX3IMELY6TQC3AVCNFSM6AAAAABGQNNI5GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCOBXGA2TA.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
默认的ssd1306驱动字库只有chr32-127的字符,而且在mpy里面使用utf8编码,chr170,也不是单字节编码,这个显示处理还是比较麻烦的 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm an old(74) newbie of micropython and I'm trying to use an OLED SH1106 / SH1107 to display data from a BME280 sensor connected to an ESP32 working with uPY. While on the serial monitor the ° degree symbol is correctly printed I was not able to get it displayed on the SH1106. I tried both display.text("{:0.0f}°C".format(temperature), 0, 30) and display.text("{:0.0f}{}".format(temperature, chr(176)), 0, 30) but I keep on getting ValueError: unknown format code 'f' for object of type 'str'. I also tried to modify the line 335 of BME280.py by inserting the ° but it works only when printed in the shell while in the display there is a little white rectangle instead of the symbol.
Could you help me to fix this issue and apologies for the maybe silly question but I was not able to find a solution even after extensive googling. Thanks
Beta Was this translation helpful? Give feedback.
All reactions