diff --git a/pwnagotchi/_version.py b/pwnagotchi/_version.py index 4ebf01eb..aa5e6038 100644 --- a/pwnagotchi/_version.py +++ b/pwnagotchi/_version.py @@ -1 +1 @@ -__version__ = '2.6.6' +__version__ = '2.6.7' diff --git a/pwnagotchi/ui/hw/libs/waveshare/epdconfig.py b/pwnagotchi/ui/hw/libs/waveshare/epdconfig.py index 9f317df8..72dfd076 100644 --- a/pwnagotchi/ui/hw/libs/waveshare/epdconfig.py +++ b/pwnagotchi/ui/hw/libs/waveshare/epdconfig.py @@ -31,7 +31,6 @@ import os import logging import sys import time -import subprocess logger = logging.getLogger(__name__) @@ -46,48 +45,16 @@ class RaspberryPi: def __init__(self): import spidev - import gpiozero + import RPi.GPIO + self.GPIO = RPi.GPIO self.SPI = spidev.SpiDev() - self.GPIO_RST_PIN = gpiozero.LED(self.RST_PIN) - self.GPIO_DC_PIN = gpiozero.LED(self.DC_PIN) - # self.GPIO_CS_PIN = gpiozero.LED(self.CS_PIN) - self.GPIO_PWR_PIN = gpiozero.LED(self.PWR_PIN) - self.GPIO_BUSY_PIN = gpiozero.Button(self.BUSY_PIN, pull_up=False) def digital_write(self, pin, value): - if pin == self.RST_PIN: - if value: - self.GPIO_RST_PIN.on() - else: - self.GPIO_RST_PIN.off() - elif pin == self.DC_PIN: - if value: - self.GPIO_DC_PIN.on() - else: - self.GPIO_DC_PIN.off() - # elif pin == self.CS_PIN: - # if value: - # self.GPIO_CS_PIN.on() - # else: - # self.GPIO_CS_PIN.off() - elif pin == self.PWR_PIN: - if value: - self.GPIO_PWR_PIN.on() - else: - self.GPIO_PWR_PIN.off() + self.GPIO.output(pin, value) def digital_read(self, pin): - if pin == self.BUSY_PIN: - return self.GPIO_BUSY_PIN.value - elif pin == self.RST_PIN: - return self.RST_PIN.value - elif pin == self.DC_PIN: - return self.DC_PIN.value - # elif pin == self.CS_PIN: - # return self.CS_PIN.value - elif pin == self.PWR_PIN: - return self.PWR_PIN.value + return self.GPIO.input(pin) def delay_ms(self, delaytime): time.sleep(delaytime / 1000.0) @@ -99,7 +66,15 @@ class RaspberryPi: self.SPI.writebytes2(data) def module_init(self): - self.GPIO_PWR_PIN.on() + self.GPIO.setmode(self.GPIO.BCM) + self.GPIO.setwarnings(False) + self.GPIO.setup(self.RST_PIN, self.GPIO.OUT) + self.GPIO.setup(self.DC_PIN, self.GPIO.OUT) + self.GPIO.setup(self.CS_PIN, self.GPIO.OUT) + self.GPIO.setup(self.PWR_PIN, self.GPIO.OUT) + self.GPIO.setup(self.BUSY_PIN, self.GPIO.IN) + + self.GPIO.output(self.PWR_PIN, 1) # SPI device, bus = 0, device = 0 self.SPI.open(0, 0) @@ -107,21 +82,16 @@ class RaspberryPi: self.SPI.mode = 0b00 return 0 - def module_exit(self, cleanup=False): + def module_exit(self): logger.debug("spi end") self.SPI.close() - self.GPIO_RST_PIN.off() - self.GPIO_DC_PIN.off() - self.GPIO_PWR_PIN.off() logger.debug("close 5V, Module enters 0 power consumption ...") + self.GPIO.output(self.RST_PIN, 0) + self.GPIO.output(self.DC_PIN, 0) + self.GPIO.output(self.PWR_PIN, 0) - if cleanup: - self.GPIO_RST_PIN.close() - self.GPIO_DC_PIN.close() - # self.GPIO_CS_PIN.close() - self.GPIO_PWR_PIN.close() - self.GPIO_BUSY_PIN.close() + self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN, self.PWR_PIN]) class JetsonNano: @@ -260,20 +230,12 @@ class SunriseX3: self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN], self.PWR_PIN) -if sys.version_info[0] == 2: - process = subprocess.Popen("cat /proc/cpuinfo | grep Raspberry", shell=True, stdout=subprocess.PIPE) -else: - process = subprocess.Popen("cat /proc/cpuinfo | grep Raspberry", shell=True, stdout=subprocess.PIPE, text=True) -output, _ = process.communicate() -if sys.version_info[0] == 2: - output = output.decode(sys.stdout.encoding) - -if "Raspberry" in output: +if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'): implementation = RaspberryPi() elif os.path.exists('/sys/bus/platform/drivers/gpio-x3'): implementation = SunriseX3() else: - implementation = JetsonNano() + implementation = RaspberryPi() for func in [x for x in dir(implementation) if not x.startswith('_')]: setattr(sys.modules[__name__], func, getattr(implementation, func))