txoof / PaperPi

E-Paper display loop with plugins
97 stars 10 forks source link

Not working with 7.8inch e-Paper HAT (IT8951) #141

Closed Hoerli1337 closed 5 months ago

Hoerli1337 commented 11 months ago

Hi! I get the following error message when I try to start PaperPi:

# paperpi -d
21:55:58 paperpi :get_config_files:256 :INFO       - using configuration files to configure PaperPi: [PosixPath('/usr/local/paperpi/config/paperpi.ini'), PosixPath('/etc/default/paperpi.ini')]
21:55:58 paperpi :main      :658 :INFO       - ********** PaperPi 0.5.4.1 RGB Starting **********
21:55:58 paperpi :main      :660 :INFO       - PaperPi is running in daemon mode
Traceback (most recent call last):
  File "/usr/local/paperpi/paperpi.py", line 738, in <module>
    exit_code = main()
  File "/usr/local/paperpi/paperpi.py", line 673, in main
    screen_return = setup_display(config)
  File "/usr/local/paperpi/paperpi.py", line 435, in setup_display
    screen = Screen(epd=epd, vcom=vcom)
  File "/usr/local/paperpi/.venv/lib/python3.9/site-packages/epdlib/Screen.py", line 234, in __init__
    self.epd = epd
  File "/usr/local/paperpi/.venv/lib/python3.9/site-packages/epdlib/Screen.py", line 45, in new_f
    return f(self, *args, **kwds)
  File "/usr/local/paperpi/.venv/lib/python3.9/site-packages/epdlib/Screen.py", line 324, in epd
    myepd = self._load_hd(epd)
  File "/usr/local/paperpi/.venv/lib/python3.9/site-packages/epdlib/Screen.py", line 430, in _load_hd
    myepd = AutoEPDDisplay(vcom=self.vcom)
  File "/usr/local/paperpi/.venv/src/it8951/IT8951/display.py", line 224, in __init__
    epd = EPD(vcom=vcom, bus=bus, device=device, data_hz=spi_hz)
  File "/usr/local/paperpi/.venv/src/it8951/IT8951/interface.py", line 33, in __init__
    self.update_system_info()
  File "/usr/local/paperpi/.venv/src/it8951/IT8951/interface.py", line 103, in update_system_info
    raise RuntimeError("communication with device failed")
RuntimeError: communication with device failed
txoof commented 11 months ago

@Hoerli1337

What screen are you using? I assume it's an HD screen, but I just want to be certain.

Does the screen work with any of the demos from WaveShare?

Can you also share the ini file you're using? The `[main]' section should be enough.

Hoerli1337 commented 11 months ago

Okay that was weird. It runs now. But a reboot was not the solution, I had done several even. I had to disconnect the Pi completely from the power for a short time, then everything started cleanly automatically. Unbenannt

I have been trying to get Paperpi to run, as unfortunately I have had no success with your driver either. My goal is to display some data from my openHAB instance. For this I wanted to create a small Python script. But I am still completely at the beginning.

txoof commented 10 months ago

did you eventually get PaperPi to run? It looks like you are running on Bookworm32 with Python 11?

Hoerli1337 commented 10 months ago

Sorry for the late response, unfortunately I had other things to do. Yes PaperPi runs with Python 11 without any problems after I solved the problem with the driver.

txoof commented 10 months ago

Great news! Thanks for the update.

MehdyShinwari commented 5 months ago

Hi everyone! I have a similar issue. Rebooting or unplugging the pi from power did not solve the issue. My setup:

Error Log:

pi@raspberrypi:~ $ sudo /usr/local/bin/paperpi -d 
14:11:37 paperpi :get_config_files:235 :INFO       - using configuration files to configure PaperPi: [PosixPath('/usr/local/paperpi/config/paperpi.ini'), PosixPath('/etc/default/paperpi.ini')]
14:11:37 paperpi :main      :655 :INFO       - ********** PaperPi 0.5.6.0 RGB Starting **********
14:11:37 paperpi :main      :657 :INFO       - PaperPi is running in daemon mode
14:11:37 paperpi :main      :663 :DEBUG      - configuration:
{'main': {'display_type': 'HD', 'vcom': -1.97, 'max_refresh': 4, 'log_level': 'DEBUG', 'splash': True, 'rotation': 0, 'mirror': False, 'color': False, 'no_wipe': True, 'plugin_timeout': 30, 'daemon': True}, 'Plugin: default fallback plugin': {'layout': 'layout', 'plugin': 'default', 'refresh_rate': 30, 'min_display_time': 60, 'max_priority': 32768}, 'xPlugin: Basic Clock': {'layout': 'layout', 'plugin': 'basic_clock', 'refresh_rate': 30, 'min_display_time': 50, 'max_priority': 2}, 'xPlugin: decimal binary clock': {'layout': 'layout', 'plugin': 'dec_bin_clock', 'refresh_rate': 30, 'min_display_time': 50, 'max_priority': 2}, 'xPlugin: default fallback plugin': {'layout': 'layout', 'plugin': 'default', 'refresh_rate': 30, 'min_display_time': 60, 'max_priority': 32768}, 'xPlugin: A Demo Plugin': {'layout': 'layout', 'plugin': 'demo_plugin', 'min_display_time': 30, 'max_priority': 1, 'your_name': 'Slartybartfast', 'your_color': 'chartreuse'}, 'xPlugin: Librespot': {'layout': 'layout', 'plugin': 'librespot_client', 'refresh_rate': 10, 'max_priority': 0, 'min_display_time': 15, 'player_name': 'LibreSpot-Spotify', 'idle_timeout': 10, 'port': 24879}, 'xPlugin: LMS - Your Player Name': {'layout': 'layout', 'plugin': 'lms_client', 'player_name': 'Your Player Name', 'refresh_rate': 5, 'min_display_time': 30, 'max_priority': 0, 'idle_timeout': 15}, 'xPlugin: Weather Adis Ababa': {'layout': 'layout', 'plugin': 'met_no', 'refresh_rate': 300, 'min_display_time': 50, 'max_priority': 2, 'location_name': 'Adis Ababa', 'lat': 9.0, 'lon': 38.75, 'email': 'you@host.diamond'}, 'xPlugin: Moon Phase': {'layout': 'layout', 'plugin': 'moon_phase', 'min_display_time': 30, 'max_priority': 2, 'refresh_rate': 1200, 'email': 'you@host.diamond', 'location_name': 'Europe/Amsterdam', 'lat': 52.3, 'lon': 4.9}, 'xPlugin: New Yorker Comic': {'layout': 'layout', 'plugin': 'newyorker', 'day_range': 5, 'refresh_rate': 120, 'min_display_time': 60, 'max_priority': 2}, 'xPlugin: Reddit Quotes': {'layout': 'layout', 'plugin': 'reddit_quote', 'refresh_rate': 100, 'min_display_time': 50, 'max_priority': 2, 'max_length': 144}, 'xPlugin: Slideshow': {'layout': 'layout', 'plugin': 'slideshow', 'refresh_rate': 90, 'min_display_time': 50, 'max_priority': 2, 'image_path': '/pi/documents/images', 'order': 'random', 'frame': 'black & silver: matted'}, 'xPlugin: System Info': {'layout': 'layout', 'plugin': 'system_info', 'min_display_time': 45, 'max_priority': 2, 'storage_unit': 'GB', 'text_color': 'BLUE', 'bkground_color': 'WHITE'}, 'xPlugin: Word Clock': {'layout': 'layout', 'plugin': 'word_clock', 'refresh_rate': 125, 'min_display_time': 255, 'max_priority': 2}, 'xPlugin: XKCD Comic Plugin': {'layout': 'layout', 'plugin': 'xkcd_comic', 'refresh_rate': 1200, 'min_display_time': 120, 'max_x': 800, 'max_y': 600, 'resize': 0, 'max_retries': 10, 'max_priority': 2}, 'Plugin: Basic Clock': {'layout': 'layout', 'plugin': 'basic_clock', 'refresh_rate': 30, 'min_display_time': 50, 'max_priority': 2}, '__cmd_line': {'compatible': False, 'list_plugins': False}}

14:11:37 Screen  :_load_hd  :429 :DEBUG      - configuring IT8951 epd
Traceback (most recent call last):
  File "/usr/local/paperpi/paperpi.py", line 746, in <module>
    exit_code = main()
  File "/usr/local/paperpi/paperpi.py", line 668, in main
    screen_return = setup_display(config)
  File "/usr/local/paperpi/paperpi.py", line 407, in setup_display
    screen = Screen(epd=epd, vcom=vcom)
  File "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/epdlib/Screen.py", line 240, in __init__
    self.epd = epd
  File "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/epdlib/Screen.py", line 63, in new_f
    return f(self, *args, **kwds)
  File "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/epdlib/Screen.py", line 330, in epd
    myepd = self._load_hd(epd)
  File "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/epdlib/Screen.py", line 436, in _load_hd
    myepd = AutoEPDDisplay(vcom=self.vcom)
  File "/usr/local/paperpi/venv_paperpi/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 "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/IT8951/interface.py", line 35, in __init__
    self.update_system_info()
  File "/usr/local/paperpi/venv_paperpi/lib/python3.9/site-packages/IT8951/interface.py", line 105, in update_system_info
    raise RuntimeError("communication with device failed")
RuntimeError: communication with device failed

Any help is appreciated, thanks!

txoof commented 5 months ago

@MehdyShinwari

Sorry it's not working for you!

Can you try running the following commands and providing the output from each:

I have a couple ideas of the problem, but need more information to move forward.

hint: You can surround your output with three back tick characters "```" before and after the output. The back tick characters turns word wrapped text into a code block

MehdyShinwari commented 5 months ago

@txoof Thank you very much for the quick reply! Also thanks for the hint, first time using the comment function 😅 Here is the output of the commands:

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $ /usr/local/bin/paperpi -c /etc/default/init.d
17:50:12 paperpi :get_config_files:235 :INFO       - using configuration files to configure PaperPi: [PosixPath('/usr/local/paperpi/config/paperpi.ini'), '/etc/default/init.d']
Traceback (most recent call last):
  File "/usr/local/paperpi/paperpi.py", line 746, in <module>
    exit_code = main()
  File "/usr/local/paperpi/paperpi.py", line 682, in main
    elif config['main'].get('color', False) or config['main'].get('display_type', 'none').lower() == 'hd':
AttributeError: 'NoneType' object has no attribute 'lower'
pi@raspberrypi:~ $ ls -l /dev/spidev*
crw-rw---- 1 root spi 153, 0 Mar 19 14:34 /dev/spidev0.0
pi@raspberrypi:~ $ groups paperpi
paperpi : paperpi spi gpio
pi@raspberrypi:~ $ groups pi
pi : pi adm dialout cdrom sudo audio video plugdev games users input render netdev spi i2c gpio lpadmin
pi@raspberrypi:~ $ cat /etc/default/init.d
cat: /etc/default/init.d: No such file or directory
pi@raspberrypi:~ $ cd  /etc/default/ 
pi@raspberrypi:/etc/default $ ls
avahi-daemon   cron          locale       raspberrypi-kernel  saned
bluetooth      dbus          networking   rng-tools-debian    ssh
console-setup  fake-hwclock  nfs-common   rpcbind             triggerhappy
cpu_governor   hwclock       nss          rpi-eeprom-update   ufw
crda           keyboard      paperpi.ini  rsync               useradd
pi@raspberrypi:/etc/default $ cat paperpi.ini 
# CONFIG_VERSION=1.2
[main]
# waveshare display type use HD for IT8951 displays
display_type = HD
# required vcom value for IT8951 screens
vcom = -1.97
# maximum refresh between total screen clear for HD displays
max_refresh = 4
# logging output level
log_level = DEBUG
# display splash screen (True or False)
splash = True
# rotation of EPD display 
# (cable bottom: 0; cable left: -90; cable right: 90; cable top: 180)
rotation = 0
# mirror screen outuput - useful if output to screen appears backwards
mirror = False
# Disable RGB color support for 7-color screens (Default: True)
# This setting only affects 7 color screens and does not impact bi-color screens
color = False
# Disable screen wipe at shutdown (Default: True)
# This setting will leave the last image on the screen at shutdown
no_wipe = True
# plugin timeout - amount of time in seconds to wait for a hung plugin to complete execution
plugin_timeout = 30

##### PLUGINS #####
# Each plugin must be configured. A plugin can be
# included multiple times with different configurations
# e.g. to show the status of multiple Logitech Players, or
# weather in multiple locations or with different layouts

# find a list of available plugins:
# $ paperpi --list_plugins

# active plugins configurations must include:
# [Plugin: Your Name For This Plugin] # must start with "Plugin: "
# layout = name_of_layout # found in plugins/plugin_name/layout.py
# plugin = plugin_name # found as plugins/plugin_name
# refresh_rate = seconds # number of seconds between updates to *data*
# min_display_time = seconds # minimum time plugin should show when active
# max_priority = int # values closer to 0 are high priority, negative values are ignored

# use `paperpi --plugin_info [plugin_name]` for a sample configuration and
# available layouts

# Fallback, default plugin to display if all else fails
[Plugin: default fallback plugin]
layout = layout
plugin = default
refresh_rate = 30
min_display_time = 60
max_priority = 2**15

[Plugin: Basic Clock]
layout = layout
plugin = basic_clock
refresh_rate = 30
min_display_time = 50
max_priority = 2

pi@raspberrypi:/etc $ cd init.d
pi@raspberrypi:/etc/init.d $ ls
alsa-utils        hwclock.sh                   raspi-config
avahi-daemon      keyboard-setup.sh            rng-tools-debian
bluetooth         kmod                         rpcbind
console-setup.sh  lightdm                      rsync
cron              linux-enable-ir-emitter      rsyslog
cups              networking                   saned
cups-browsed      nfs-common                   ssh
dbus              paxctld                      sudo
dhcpcd            plymouth                     triggerhappy
dphys-swapfile    plymouth-log                 udev
fake-hwclock      procps                       ufw
fio               pulseaudio-enable-autospawn  x11-common
pi@raspberrypi:/etc/init.d $ /usr/local/bin/paperpi -c /etc/init.d
18:06:39 paperpi :get_config_files:235 :INFO       - using configuration files to configure PaperPi: [PosixPath('/usr/local/paperpi/config/paperpi.ini'), '/etc/init.d']
Traceback (most recent call last):
  File "/usr/local/paperpi/paperpi.py", line 746, in <module>
    exit_code = main()
  File "/usr/local/paperpi/paperpi.py", line 682, in main
    elif config['main'].get('color', False) or config['main'].get('display_type', 'none').lower() == 'hd':
AttributeError: 'NoneType' object has no attribute 'lower'
pi@raspberrypi:/etc/init.d $ uname -r
6.1.21-v7l+
pi@raspberrypi:/etc/init.d $ uname -m
armv7l

I cut off the plugin section (to post it here, the file is still intact) where I did not change anything. Just removed the x of the BasicClock plugin. I hope you find a clue!

txoof commented 5 months ago

The first thing to try would be to run this on Bookworm. I think there's some incompatibility in bullseye. I can't find my notes on that though.

Otherwise, your config looks good. There's a weird crash that I see when you run it from your user that I want to dig into.

I'll poke at that and get back to you in a few days. If you can try bookworm, that would be helpful.

MehdyShinwari commented 5 months ago

So I installed PaperPi on a fresh install of bookworm... and it worked without any issues! Seems that the problem was really bullseye. Thank you very much! Have a nice day!

txoof commented 5 months ago

@MehdyShinwari I'll call that out in the README explicitly. The README still claims it works with Buster which is an outright lie :)

Thanks for verifying this!

txoof commented 5 months ago

Updated documentation in in commit 4aa6912fd67265deeca859ed086ca3b637f73473