First of all - I am a beginner.
I have some problems with special characters on ScrollPhatHD. If I use the code below, ä and ü are displayed as µô and µß. How can I solve this?
Any help would be appreciated :).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import scrollphathd as scrollphat
from scrollphathd.fonts import font5x7
import time as tm
def main():
scrollphat.write_string("Hälfte über Hälfte")
if __name__ == "__main__":
main()
while True:
try:
scrollphat.show()
scrollphat.scroll()
tm.sleep(0.05)
except KeyboardInterrupt:
scrollphat.clear()
sys.exit(-1)
Try prefixing your string with “u”, like so:
scrollphat.write_string(u"Hälfte über Hälfte")
This ensures it’s interpreted as Unicode: `u’\xe4’ and not as: ‘\xc3\xa4’
Unfortunately, peeking at the Scroll pHAT HD font shows 0xe4 is mapped as an underscore… this is because, looking back at it, the font image that Scroll pHAT HD’s 5x7 font is generated from is complete and total nonsense:
This is my fault for not taking care when generating this font! And something I’ll need to fix in the library before it will support Deutsch!
What the 0-255 range should look like, is this:
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
!"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
x¡¢£¤¥¦§¨©ª«¬®¯
°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîï
ðñòóôõö÷øùúûüýþÿ
Where the "x"s (except the actual x) represent non-printable or control characters which could be replaced with fun symbols.
Thank you very much for your detailed answer!
And - after quite some time redrawing - here’s what it should look like:
I’ll get this converted into a font file and tested.
Fixed and demonstrated here: https://github.com/pimoroni/scroll-phat-hd/commit/77d59c9870eaff468a9f2049d4b3cc11d2dd003b
You can try it out by:
git clone https://github.com/pimoroni/scroll-phat-hd
cd scroll-phat-hd/library
sudo python setup.py install