Skip to content

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

Closed
@FoamyGuy

Description

@FoamyGuy

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.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions