adafruit / Adafruit_CircuitPython_Display_Text

Library to display text using displayio
MIT License
56 stars 38 forks source link

button simpletest throws error on PyPortal Titano #190

Open matthewepler opened 1 year ago

matthewepler commented 1 year ago

I'm attempting to run the example file "display_button_simpletest.py" in the Adafruit Circuit Python Bundle (20230511) example directory. It throws an error "Group full." No changes were made to the original code. I did not reflash the firmware, either.

Steps taken:

  1. Move "display_button_simpletest.py" to the PyPortal Titano drive
  2. Rename file to "code.py"
  3. create lib folder and add libraries:
    • adafruit_bitmap_font/*
    • adafruit_button.py
    • adafruit_display_shapes/*
    • adafruit_display_text/*
    • adafruit_touchscreen.py
  4. Error thrown (see output below)

After some troubleshooting, I was able to get the code to run by shortening the length of the button label to just two characters. After that worked, I reset the label to "HELLO WORLD" and attempted increasing the width of the rectangle in increments of 100 up to 800 but this did not work.

As this is an example file, I would assume that it should just work.

Serial output:

code.py output:
Traceback (most recent call last):
  File "code.py", line 101, in <module>
  File "/lib/adafruit_button.py", line 174, in __init__
  File "/lib/adafruit_button.py", line 192, in label
  File "/lib/adafruit_display_text/label.py", line 100, in __init__
  File "/lib/adafruit_display_text/label.py", line 424, in _reset_text
  File "/lib/adafruit_display_text/label.py", line 375, in _update_text
RuntimeError: Group full

Code:

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
Simple button example.
"""

import board
import displayio
import terminalio
import adafruit_touchscreen
from adafruit_button import Button

# use built in display (MagTag, PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY

# --| Button Config |-------------------------------------------------
BUTTON_X = 110
BUTTON_Y = 95
BUTTON_WIDTH = 100
BUTTON_HEIGHT = 50
BUTTON_STYLE = Button.ROUNDRECT
BUTTON_FILL_COLOR = 0x00FFFF
BUTTON_OUTLINE_COLOR = 0xFF00FF
BUTTON_LABEL = "HELLO WORLD"
BUTTON_LABEL_COLOR = 0x000000

# --| Button Config |-------------------------------------------------
# Setup touchscreen (PyPortal)
ts = adafruit_touchscreen.Touchscreen(
    board.TOUCH_XL,
    board.TOUCH_XR,
    board.TOUCH_YD,
    board.TOUCH_YU,
    calibration=((5200, 59000), (5800, 57000)),
    size=(display.width, display.height),
)

# Make the display context
splash = displayio.Group()
display.show(splash)

# Make the button
button = Button(
    x=BUTTON_X,
    y=BUTTON_Y,
    width=BUTTON_WIDTH,
    height=BUTTON_HEIGHT,
    style=BUTTON_STYLE,
    fill_color=BUTTON_FILL_COLOR,
    outline_color=BUTTON_OUTLINE_COLOR,
    label=BUTTON_LABEL,
    label_font=terminalio.FONT,
    label_color=BUTTON_LABEL_COLOR,
)

# Add button to the display context
splash.append(button)

# Loop and look for touches
while True:
    p = ts.touch_point

    if p:
        if button.contains(p):
            button.selected = True
        else:
            button.selected = False  # if touch is dragged outside of button
    else:
        button.selected = False  # if touch is released
FoamyGuy commented 1 year ago

@matthewepler can you post the contents of your boot_out.txt file that should be on the CIRCUITPY drive?

I'm curious what version of circuitpython is on your device because Groups have not had a size limit for a while now, so I'm guessing the version you have may be an older one from before that change was made. It's possible you might just need to update to a newer version and then it will be working on your device.

snkYmkrct commented 2 months ago

I tested the code in display_button_simpletest.py on the Titano with circuitpython 9.0.5, and a few of the 8.x.x versions - it works correctly, I cannot reproduce this issue. And the code doesn't even seem to use the display_text library.