Skip to content

x position gets shifted over time when changing the text beingdisplayed #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
FoamyGuy opened this issue Aug 14, 2020 · 0 comments · Fixed by #83
Closed

x position gets shifted over time when changing the text beingdisplayed #82

FoamyGuy opened this issue Aug 14, 2020 · 0 comments · Fixed by #83
Assignees
Labels
bug Something isn't working

Comments

@FoamyGuy
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants