Texte mit unterschiedlichen Fonts darstellen
Offenbar gibt es vereschiedene Möglichkeiten verschiedene Fonts einzusetzen.
[[1]] [[2]] [[3]] [[4]] [[5]] [[6]] [[7]] [[8]]
Erster Versuch mit micropython-oled
example1.py
>>> from machine import Pin, I2C >>> from oled import Write, GFX, SSD1306_I2C >>> from oled.fonts import ubuntu_mono_15, ubuntu_mono_20 >>> scl = Pin(17) sda = Pin(16) >>> i2c = I2C(scl=scl, sda=sda) Pin(16, Pin.OUT, value=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'id' argument required >>> i2c = I2C(0, scl=scl, sda=sda) Pin(16, Pin.OUT, value=1) Pin(16, mode=OUT) >>> oled = SSD1306_I2C(128, 64, i2c) gfx = GFX(128, 64, oled.pixel)
Hier hängt sich die REPL auf.
Das selbe Programm jetzt aus dem Text-Editor heraus:
from machine import Pin, I2C from oled import Write, GFX, SSD1306_I2C from oled.fonts import ubuntu_mono_15, ubuntu_mono_20 scl = Pin(17) sda = Pin(16) i2c = I2C(0, scl=scl, sda=sda) Pin(16, Pin.OUT, value=1) oled = SSD1306_I2C(128, 64, i2c) gfx = GFX(128, 64, oled.pixel) write15 = Write(oled, ubuntu_mono_15) write20 = Write(oled, ubuntu_mono_20) write15.text("Espresso IDE", 0, 0) write15.text("micropython-oled", 0, 15) gfx.line(0, 32, 127, 32, 1) gfx.line(0, 33, 127, 33, 1) write20.text("1234567890", 0, 35) write15.text("Ubuntu Mono font", 0, 52) oled.show()
Auch jetzt hängt sich das Programm ohne Fehlermeldung auf!