after installing the single line installer ,and using the all-in-one-enviro-mini.py as my code. when i run it in the IDE, I get the sensor data, but no data is showing on the screen. the only thing i see is the screen slightly lighting up. Im using rasbian with desktop, and fully upgraded the os a few days ago. I also installed new fonts. Im not sure what is going on, or how to fix it. Im afraid the screen might not be functional.
Why did you start a second duplicate thread on this?
I thought I would have to start another post for a separate problem. the first post was about getting the board to register, but when the screen didnt work with the code, i thought that it was a new issue.
Ok, explained that way fair enough. My bad.
you have any ideas why the screen isnt showing anything? i literally copy pasted the file in to the ide. I looked through the code, with my limited python knowledge, and i cant seem to find the problem.
Try this bit of code. According to the Enviro+ pinout the display uses SPI0, CE1, and GPIO 12 for the backlight. I modified the breakout garden scrolling text example for that screen accordingly.
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import time
import ST7735
MESSAGE = "Hello World! How are you today?"
# Create ST7735 LCD display class.
disp = ST7735.ST7735(
port=0,
cs=1,
dc=9,
backlight=12,
rotation=270,
spi_speed_hz=10000000
)
# Initialize display.
disp.begin()
WIDTH = disp.width
HEIGHT = disp.height
img = Image.new('RGB', (WIDTH, HEIGHT), color=(0, 0, 0))
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 30)
size_x, size_y = draw.textsize(MESSAGE, font)
text_x = 160
text_y = (80 - size_y) // 2
t_start = time.time()
while True:
x = (time.time() - t_start) * 100
x %= (size_x + 160)
draw.rectangle((0, 0, 160, 80), (0, 0, 0))
draw.text((int(text_x - x), text_y), MESSAGE, font=font, fill=(255, 255, 255))
disp.display(img)
just tried the code, and i see no text. this is what it what i see in command prompt
/tmp/geany_run_script_K895R0.sh: 7: /tmp/geany_run_script_K895R0.sh: ./test: not found
(program exited with code: 127)
Press return to continue
Saved it as a python file first? LCD.py for example. Then ran it from the IDE?
i put it in the ide, saved it as a file, then executed it. first i did it in geany, then i did it in thonny. when i do it in thonny i get this message
%Run ‘screen test.py’
Traceback (most recent call last):
File “/home/pi/screen test.py”, line 18, in
spi_speed_hz=10000000
File “/usr/local/lib/python3.7/dist-packages/ST7735-0.0.4-py3.7.egg/ST7735/init.py”, line 186, in init
GPIO.setup(backlight, GPIO.OUT)
ValueError: The channel sent is invalid on a Raspberry Pi
do you think i should do a fresh install of the software for the board? how would i do that, if i should?
i changed the spi_speed_hz to 10,and i get the same message
Traceback (most recent call last):
File “/home/pi/test me.py”, line 18, in
spi_speed_hz=10
File “/usr/local/lib/python3.7/dist-packages/ST7735-0.0.4-py3.7.egg/ST7735/init.py”, line 186, in init
GPIO.setup(backlight, GPIO.OUT)
ValueError: The channel sent is invalid on a Raspberry Pi
The error is actually happening in ST7735/init.py
The display is failing to initialize? I don’t know why though?
Lately I have been using thonny.
I have three of those displays hooked up to SPI1 and running simultaneously.
If you want to start over fresh. Reimage your SD card with the latest Pi OS. Don’t use NOOBS, go with just straight PiOS. Do the update upgrade.
Leave the Envidro+ connected.
Then run the curl -sSL https://get.pimoroni.com/enviroplus | bash
Reboot and try an example, there should be an LCD.py file in the example folder that does the same thing as the one I posted above. Scrolls hello World,.