rm-hull / luma.lcd

Python module to drive PCD8544, HT1621, ST7735, ST7567 and UC1701X-based LCDs
https://luma-lcd.readthedocs.io
MIT License
156 stars 56 forks source link

RuntimeError('This module can only be run on a Raspberry Pi!') #28

Closed thijstriemstra closed 7 years ago

thijstriemstra commented 7 years ago

A RuntimeError('This module can only be run on a Raspberry Pi!') is thrown when running the SPI examples on a non-raspberrypi. This should be a better luma.core.error.

E.g.:

$ python examples/3d_box.py -i spi
Traceback (most recent call last):
  File "examples/3d_box.py", line 129, in <module>
    device = get_device()
  File "/home/luma.examples/examples/demo_opts.py", line 142, in get_device
    device = Device(Serial(), **vars(args))
  File "/home/luma.examples/examples/demo_opts.py", line 119, in spi
    gpio=self.gpio)
  File "/home/luma.core/luma/core/serial.py", line 133, in __init__
    self._gpio = gpio or self.__rpi_gpio__()
  File "/home/luma.core/luma/core/serial.py", line 161, in __rpi_gpio__
    import RPi.GPIO
  File "/home/foo/.virtualenvs/photobooth-gui/lib/python3.5/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
rm-hull commented 7 years ago

This is RPi.GPIO telling you off for not running on a BCM2835.

You can swap the gpio module out for a noop() but this wont get you very far, ... so it would be nice to see if there were a more generic GPIO library, but when I last looked this wasn't the case, as it obviously relies on the low level chipset... although we could look at something that uses /sys/bus - that might involve writing a whole new layer, again something I had considered

thijstriemstra commented 7 years ago

simply having a generic luma.core error would be fine with me, that way we can catch it reliably (in the example).

thijstriemstra commented 7 years ago

Should be fixed in next release.