Make it optional to use the RST pin

Without RST can run without 'root' by adding the desired user
to the I2C group (e.g.: adduser pi i2c)
This commit is contained in:
Sylvan Butler
2016-08-02 21:52:18 -06:00
parent 925ca30e58
commit 42e45c8d0d
+4 -1
View File
@@ -85,7 +85,8 @@ class SSD1306Base(object):
self._gpio = GPIO.get_platform_gpio() self._gpio = GPIO.get_platform_gpio()
# Setup reset pin. # Setup reset pin.
self._rst = rst self._rst = rst
self._gpio.setup(self._rst, GPIO.OUT) if not self._rst is None:
self._gpio.setup(self._rst, GPIO.OUT)
# Handle hardware SPI # Handle hardware SPI
if spi is not None: if spi is not None:
self._log.debug('Using hardware SPI') self._log.debug('Using hardware SPI')
@@ -150,6 +151,8 @@ class SSD1306Base(object):
def reset(self): def reset(self):
"""Reset the display.""" """Reset the display."""
if self._rst is None:
return
# Set reset high for a millisecond. # Set reset high for a millisecond.
self._gpio.set_high(self._rst) self._gpio.set_high(self._rst)
time.sleep(0.001) time.sleep(0.001)