x position gets shifted over time when changing the text beingdisplayed
FoamyGuy opened this issue · 0 comments
FoamyGuy commented
This sample code illustrates the issue:
import board
import time
import terminalio
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
text = "Helloworld"
font = bitmap_font.load_font("fonts/Helvetica-Bold-16.bdf")
text_area = label.Label(font, text=text*5)
text_area.anchor_point = (0.75,0)
text_area.anchored_position = (190, 10)
board.DISPLAY.show(text_area)
i = 0
while True:
time.sleep(0.01)
if i % 2 == 0:
text_area.text = "Hello world1".format(i)
else:
text_area.text = "Hello\nworld {}".format(i)
i += 1
The label will move itself left until it reaches the edge of the screen.
This appears to be a rounding issue with floating point math in the anchored_position getter and setter which get called when the text is updated.