ropod7 / pyboard_drive

22 stars 11 forks source link

NameError: name 'LCD' is not defined #36

Closed erickcrus closed 5 years ago

erickcrus commented 5 years ago

I copied all files and folders inside the ILI9341 folder, but when running test script 01a_first_step.py, I get the second message: "NameError: name 'LCD' is not defined"

01a_first_step.p:

# In this sample we will:
# * initialize the driver
# * Set the background 
# * Load a Bitmap image at RGR565 format.
#   The image must be present in the "images" sub-directory of your pyBoard 
#
from lcd import *
l = LCD( rate=21000000 ) # step down the SPI bus speed to 21 MHz may be opportune when using 150+ mm wires                                                    
l.fillMonocolor( GREEN )                                                    
l.renderBmp( 'test.bmp' )
mchobby commented 5 years ago

This is because the file lcd.py is not available in the library path (or current path). Have a look to the /ILI9341 subfolder... the file lcd.py must be accessible to search path. Kind regards, Dominique

erickcrus commented 5 years ago

It imports the lcd.py module normally, but does not find the classes within the module. When I use the class, it says that it was not found. Here's my list of files on the board:

sh-3.2# ampy ls
/boot.py
sh-3.2# ampy put colors.py
sh-3.2# ampy put decorators.py
sh-3.2# ampy put exceptions.py
sh-3.2# ampy put lcd.py
sh-3.2# ampy put registers.py
sh-3.2# ampy put tests.py
sh-3.2# ampy mkdir images
sh-3.2# ampy mkdir fonts
sh-3.2# ampy put fonts fonts
sh-3.2# ampy put images
sh-3.2# ampy ls
/boot.py
/colors.py
/decorators.py
/exceptions.py
/fonts
/images
/lcd.py
/registers.py
/tests.py

In uPyCraft console, this is the output:

>>> from lcd import *
>>> lcd = LCD( rate=21000000 )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'LCD' isn't defined
>>> 
mchobby commented 5 years ago

The LCD class is there (ligne 294). You should be able to type from lcd import LCD

Maybe don't you have enough ressource on your MicroControler. Are you using a Genuine Pyboard?

mchobby commented 5 years ago

Oups! Line 924.

erickcrus commented 5 years ago

I am trying to use the library on a NodeMCU ESP8266, that's why it doesn't work?

mchobby commented 5 years ago

For sure! The library have been developed for the Pyboard which have quite more memory.

erickcrus commented 5 years ago

that sad :( Thank you so much friend