0

So i was testing my TFT but when i uploaded the code

import board
import displayio
import terminalio
from adafruit_ili9341 import ILI9341

# Initialize ILI9341 display
spi = board.SPI()
tft_cs = board.D9
tft_dc = board.D10
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D6)
display = ILI9341(display_bus, width=320, height=240)

# Create a display group
group = displayio.Group(max_size=10)
display.show(group)

# Function to display text
def display_text(text, x, y, color):
    text_area = label.Label(terminalio.FONT, text=text, color=color, x=x, y=y)
    group.append(text_area)
    
# Clear the screen
display.fill(0)
display.show()

# Display text
display_text("Hello, CircuitPython!", 50, 100, 0xFFFF00)  # Yellow color

I got this error

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/lib/adafruit_ili9341/__init__.py", line 21, in <module>
  File "/lib/adafruit_ili9341/ILI9341.py", line 21, in <module>
ImportError: no module named 'numbers'

Can anyone tell me how to fix this? Bcuz the "numbers" module is supposed to be installed since you flash the circuitpython firmware. I removed the lib folder because i needed more space.

I tried searching it in the library manager but it wasnt there. I also tried reflashing but it just stayed as it was.

1 Answers1

0

The layout in the filesystem of your library does not match the current CircuitPython library. I can see https://github.com/adafruit/Adafruit_Python_ILI9341 which looks like what you have but that's not intended for use with CircuitPython and has a note about deprecation. I'm not familiar with it but I think it's an old library for the Raspberry Pi (not Pico).

The CircuitPython libraries can be downloaded from https://circuitpython.org/libraries - these tend to be small libraries designed to run on relatively low memory microcontrollers. If there's a Python 3 equivalent then they are likely to be cut-down versions. It looks like there are two libraries currently in the bundle that support this display type (note: CircuitPython is in the repository name):

You mentioned a "library manager" - what's that refer to?

As a general tip, you can check the builtin modules by running help("modules") on CircuitPython REPL and the rest by looking in the library path, /lib is recommended place to put them but sys.path tells me ['', '/', '.frozen', '/lib'].

KevinJWalters
  • 193
  • 1
  • 7