0

Bug in CircuitPython Display Support Using displayio lesson
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Bug in CircuitPython Display Support Using displayio lesson

by kgrove on Sat Mar 20, 2021 1:48 pm

I'm going through the CircuitPython Display Support Using displayio lesson and trying to display some text on a 32x64 LED Matrix using my Grand Central M4 Express. I noticed that when I try to run the code
Code: Select all | TOGGLE FULL SIZE
import board
import displayio
import terminalio
from adafruit_display_text import label

display = board.DISPLAY

# Set text, font, and color
text = "HELLO WORLD"
font = terminalio.FONT
color = 0x0000FF

# Create the text label
text_area = label.Label(font, text=text, color=color)

# Set the location
text_area.x = 100
text_area.y = 80

# Show it
display.show(text_area)

# Loop forever to prevent code from exiting
while True:
    pass


It throws an error
Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "code.py", line 6, in <module>
AttributeError: 'module' object has no attribute 'DISPLAY'


What is the solution?

https://learn.adafruit.com/circuitpython-display-support-using-displayio/text

kgrove
 
Posts: 41
Joined: Wed Feb 17, 2021 4:51 pm

Re: Bug in CircuitPython Display Support Using displayio les

by adafruit_support_carter on Mon Mar 22, 2021 12:57 pm

This usage:
Code: Select all | TOGGLE FULL SIZE
display = board.DISPLAY

is only for boards with "built in" displays:
https://learn.adafruit.com/circuitpytho ... 3025839-19

For the GC, you'll need to do something like this:
https://learn.adafruit.com/circuitpytho ... 3077571-21

Since you are using an LED Matrix, the setup code in the MatrixPortal library may be useful:
https://github.com/adafruit/Adafruit_Ci ... /matrix.py
It comes down to using this:
https://circuitpython.readthedocs.io/en ... index.html

This is a good general RGB matrix w/ CircuitPython guide:
https://learn.adafruit.com/rgb-led-matr ... cuitpython

adafruit_support_carter
 
Posts: 20281
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.