Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waveshare 7.8" IT8951 communication failed #93

Open
grooverkm opened this issue Nov 30, 2023 · 8 comments
Open

Waveshare 7.8" IT8951 communication failed #93

grooverkm opened this issue Nov 30, 2023 · 8 comments

Comments

@grooverkm
Copy link

Hoping this is a simple problem someone can help me resolve. Trying to set up a raspberry pi zero with 32-bit bookworm and a 7.8" Waveshare IT8951 display, in order to run SlowMovie.

Hardware passes the Waveshare self-tests and displays correctly (actually displays as 10.3inch e-Paper, which makes me believe it is supported under the same IT8951 profile in omni-epd), but when I try and run either slowmovie or omni-epd-test I get the same traceback:-

Traceback (most recent call last):
File "/home/pi/SlowMovie/slowmovie.py", line 264, in
epd = displayfactory.load_display_driver(args.epd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/SlowMovie/.SlowMovie/lib/python3.11/site-packages/omni_epd/displayfactory.py", line 113, in load_display_driver
result = classObj(deviceType[1], config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/SlowMovie/.SlowMovie/lib/python3.11/site-packages/omni_epd/displays/waveshare_display.py", line 462, in init
self._device = deviceObj.AutoEPDDisplay(vcom=self._getfloat_device_option('vcom', -1.40),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/SlowMovie/.SlowMovie/lib/python3.11/site-packages/IT8951/display.py", line 215, in init
epd = EPD(vcom=vcom, bus=bus, device=device, data_hz=spi_hz)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/SlowMovie/.SlowMovie/lib/python3.11/site-packages/IT8951/interface.py", line 35, in init
self.update_system_info()
File "/home/pi/SlowMovie/.SlowMovie/lib/python3.11/site-packages/IT8951/interface.py", line 105, in update_system_info
raise RuntimeError("communication with device failed")
RuntimeError: communication with device failed

Any ideas or help with what I may be doing wrong?

@robweber
Copy link
Owner

robweber commented Dec 2, 2023

Do you have a link to the Waveshare self-tests? I'm not familiar with them. Waveshare doesn't supply Python drivers themselves for the IT8951. One thought is did you enable SPI on your Rpi?

@grooverkm
Copy link
Author

Hi, I followed the instructions for the RPi here which I think draws on a C library (not sure, I'm a beginner), but it worked as intended and showed the hardware was working. I double checked SPI was enabled. Thanks for any help!

@robweber
Copy link
Owner

robweber commented Dec 2, 2023

The code for this is in Python so the C code isn't a big help but does prove the screen is working. One thing you could try is altering the vcom value. From the documentation you sent over this should be visible on the cable or the device somewhere. By default the library uses -2.06, your device might be different. To do this create a file in the root directory named omni-epd.ini and put in the following (replacing with your value):

[waveshare_epd.it8951]
vcom=-2.06

The error is here in the source library. It really looks like it can't get any data from the device so something in the comms is definitely wrong. Might be worth re-posting this on the IT8951 project page since that is where the driver is maintained. I did do a search on the Issues there and found one regarding a 7.8in screen.

@robweber
Copy link
Owner

robweber commented Dec 4, 2023

Just circling back to this I'm curious if you tried to reboot your Rpi since running the Waveshare demo code? A few places I've seen say that the Waveshare demo code doesn't close the SPI communications properly and after that things fail. Reboots of the OS seem to fix it.

@grooverkm
Copy link
Author

grooverkm commented Dec 4, 2023

Hi, I was just playing with it now. Not sure if I am making progress or just getting lost further. I had tried rebooting it a couple of times, as well as I have rolled back to buster, did a manual install of slowmovie, and got the same runtime error, communication with device failed. More random searching got me to here https://github.com/veebch/stonks/issues/5, which gave me some clues so I made an edit to the interface.py file with the actual screen size.

"# self.width = data[0]"
"# self.height = data[1]"
self.width = 1872
self.height = 1404

I then ran the slowmovie test file and it ran. Sort of. What I mean is, it ran without error and refreshed the screen to show the first frame, but it was a negative and there is a black horizontal line across the screen. Progress, I thought. So I checked that SPI was enabled correctly (it was) and I rebooted to run it again, but now I get this error:-

/home/pi/.local/lib/python3.9/site-packages/IT8951/interface.py:28: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
self.spi = SPI(**spi_kwargs)
Traceback (most recent call last):
File "/home/pi/SlowMovie/slowmovie.py", line 264, in
epd = displayfactory.load_display_driver(args.epd)
File "/home/pi/.local/lib/python3.9/site-packages/omni_epd/displayfactory.py", line 113, in load_display_driver
result = classObj(deviceType[1], config)
File "/home/pi/.local/lib/python3.9/site-packages/omni_epd/displays/waveshare_display.py", line 462, in init
self._device = deviceObj.AutoEPDDisplay(vcom=self._getfloat_device_option('vcom', -2.06),
File "/home/pi/.local/lib/python3.9/site-packages/IT8951/display.py", line 215, in init
epd = EPD(vcom=vcom, bus=bus, device=device, data_hz=spi_hz)
File "/home/pi/.local/lib/python3.9/site-packages/IT8951/interface.py", line 28, in init
self.spi = SPI(**spi_kwargs)
File "src/IT8951/spi.pyx", line 52, in IT8951.spi.SPI.cinit
FileNotFoundError: [Errno 2] No such file or directory: '/dev/spidev0.0'

So I must have broken something else poking around. Interestingly, over the past couple of hours since, the screen has 'faded' to a light grey - which I didn't think EPDs were supposed to do? Make me wonder if it is getting voltage/ not being released somewhere..? I have a file in the slowmovie root directory omni-epd.ini with the vcom value for the screen (-1.40) but no other changes. I do not have the waveshare demos installed since the rebuild.

Any ideas? really appreciate all the help.

@robweber
Copy link
Owner

Any luck with this? The IT8951 repo page (link above) might have more help if you're still plugging away at it. That error looks like it can't enable SPI correctly - maybe the spidev module isn't loaded properly? At this point all these errors are pretty low level OS stuff. As much as it sucks a complete reimaging of the SD card with a fresh OS might be in order.

@grooverkm
Copy link
Author

Hi, thanks for following up. I am still plugging away. I reimaged with a fresh OS and tried another project, PaperPi https://github.com/txoof/PaperPi, as a sanity check and to see if it is hardware related. That project works fine so I am reasonably sure it is on the software side - maybe something to do with the venv that SlowMovie creates. Appreciate all the help and any ideas.

@robweber
Copy link
Owner

That is weird that the other project works. PaperPi uses the exact same underlying driver for the IT8951 displays. Given that your original error was due to code from that project I wouldn't jump to any issue with SlowMovie specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants