First commit
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Geometrie der Anzeige ausmessen.
|
||||
|
||||
LINE_Y und CHARS_PER_LINE in config.py sind aus dem alten C-Programm abgeleitet,
|
||||
nicht aus einem Datenblatt. Dieses Skript hilft, die echten Werte zu finden.
|
||||
|
||||
python3 probe.py ruler Ziffernlineal 12345678901234... -> Zeichen zaehlen
|
||||
python3 probe.py lines Zeile 1 und Zeile 2 an den Positionen aus config.py
|
||||
python3 probe.py scan-y dieselbe Zeile schrittweise nach unten schieben
|
||||
python3 probe.py corners Punkte in die vier Ecken -> Pixelaufloesung pruefen
|
||||
"""
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
import config
|
||||
import migra
|
||||
from display import open_display
|
||||
|
||||
|
||||
def ruler(d):
|
||||
"""Ziffernlineal auf EINER Zeile: die Position, an der es umbricht, ist die Breite.
|
||||
|
||||
Bewusst nur eine Zeile und etwas mehr Zeichen als erwartet, damit man den
|
||||
Umbruch sieht, ohne dass sich mehrere Zeilen ueberschreiben.
|
||||
"""
|
||||
n = config.CHARS_PER_LINE + 5
|
||||
line = "".join(str((i + 1) % 10) for i in range(n))
|
||||
du = migra.DataUnit()
|
||||
du.fill(config.BACKGROUND)
|
||||
du.charset(config.CHARSET, spaced=config.CHARSET_SPACED)
|
||||
du.attributes(fg=config.COLOR, bg=config.BACKGROUND)
|
||||
du.cursor(0, config.LINE_Y[0])
|
||||
du.text(line)
|
||||
d.send(du)
|
||||
print("Bis zu welcher Ziffer laeuft die obere Zeile, bevor sie umbricht?")
|
||||
print("Das ist CHARS_PER_LINE (aktuell in config.py: %d)." % config.CHARS_PER_LINE)
|
||||
|
||||
|
||||
def lines(d):
|
||||
d.show_lines("Zeile 1", "Zeile 2")
|
||||
print("Stehen beide Zeilen sauber untereinander? Sonst LINE_Y anpassen.")
|
||||
|
||||
|
||||
def scan_y(d):
|
||||
"""Zeile schrittweise nach unten schieben, um die y-Position zu finden."""
|
||||
for y in range(0, 33, 2):
|
||||
du = migra.DataUnit()
|
||||
du.fill(config.BACKGROUND)
|
||||
du.charset(config.CHARSET, spaced=config.CHARSET_SPACED)
|
||||
du.attributes(fg=config.COLOR, bg=config.BACKGROUND)
|
||||
du.cursor(0, y)
|
||||
du.text("y=%d" % y)
|
||||
try:
|
||||
d.send(du)
|
||||
except migra.MigraError as e:
|
||||
print("y=%-3d -> %s" % (y, e))
|
||||
continue
|
||||
print("y=%-3d -> ok" % y)
|
||||
time.sleep(1.5)
|
||||
|
||||
|
||||
def corners(d):
|
||||
"""Punkte in die Ecken setzen. Ein Fehlercode '4' heisst: ausserhalb der Anzeige."""
|
||||
for x, y in ((0, 0), (63, 0), (0, 15), (63, 15), (127, 31)):
|
||||
du = migra.DataUnit().point(x, y, color=config.COLOR)
|
||||
try:
|
||||
d.send(du)
|
||||
print("Punkt %3d/%-3d -> ok" % (x, y))
|
||||
except migra.MigraError as e:
|
||||
print("Punkt %3d/%-3d -> %s" % (x, y, e))
|
||||
|
||||
|
||||
MODES = {"ruler": ruler, "lines": lines, "scan-y": scan_y, "corners": corners}
|
||||
|
||||
|
||||
def main():
|
||||
args = [a for a in sys.argv[1:] if not a.startswith("-")]
|
||||
if len(args) != 1 or args[0] not in MODES:
|
||||
print(__doc__)
|
||||
return 2
|
||||
response = config.WANT_RESPONSE and "--no-response" not in sys.argv
|
||||
d = open_display(response=response)
|
||||
try:
|
||||
MODES[args[0]](d)
|
||||
finally:
|
||||
d.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user