v.0.4.6 screen_text param display
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import app.utils as utils
|
||||
|
||||
# FIXME: der Import klappt nicht !!!
|
||||
# from app.display.neopixel_64x64 import NeoPixel_64x64
|
||||
# from ...display.neopixel_64x64 import NeoPixel_64x64
|
||||
|
||||
|
||||
def char_width(char_matrix) -> int:
|
||||
"""Berechnung der Bits für die Zeichenbreite
|
||||
@@ -85,7 +89,7 @@ def align_font(font, debug=False):
|
||||
return f'#keys: {len(font)}'
|
||||
|
||||
|
||||
def screen_text(text: str, font, screen_height: int, screen_width: int):
|
||||
def screen_text(text: str, display: NeoPixel_64x64):
|
||||
"""Text für einen Screen anpassen,
|
||||
Anzahl der Zeichen je Zeile begrenzen,
|
||||
ebenso wird die Höhe des Screen brücksichtigt
|
||||
@@ -102,17 +106,16 @@ def screen_text(text: str, font, screen_height: int, screen_width: int):
|
||||
pixs = 0
|
||||
visible_text = ''
|
||||
for a in txt:
|
||||
pixs += char_width(font[a]) + 1
|
||||
if pixs > screen_width:
|
||||
pixs += char_width(display.selected_font[a]) + 1
|
||||
if pixs > display.MATRIX_WIDTH:
|
||||
# Zeilenende erreicht
|
||||
break
|
||||
visible_text += a
|
||||
|
||||
return visible_text
|
||||
|
||||
f_height: int = font_height(font)
|
||||
# Ganzzahl Division
|
||||
max_visible_rows = screen_height // f_height
|
||||
max_visible_rows = display.MATRIX_HEIGHT // display.font_height
|
||||
print(f'rows_visible: {max_visible_rows}')
|
||||
|
||||
text_left = text
|
||||
|
||||
Reference in New Issue
Block a user