Skip to content

Commit d259e86

Browse files
committed
Version 2.6.7
1 parent 5844e51 commit d259e86

File tree

2 files changed

+21
-59
lines changed

2 files changed

+21
-59
lines changed

pwnagotchi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.6.6'
1+
__version__ = '2.6.7'

pwnagotchi/ui/hw/libs/waveshare/epdconfig.py

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import logging
3232
import sys
3333
import time
34-
import subprocess
3534

3635
logger = logging.getLogger(__name__)
3736

@@ -46,48 +45,16 @@ class RaspberryPi:
4645

4746
def __init__(self):
4847
import spidev
49-
import gpiozero
48+
import RPi.GPIO
5049

50+
self.GPIO = RPi.GPIO
5151
self.SPI = spidev.SpiDev()
52-
self.GPIO_RST_PIN = gpiozero.LED(self.RST_PIN)
53-
self.GPIO_DC_PIN = gpiozero.LED(self.DC_PIN)
54-
# self.GPIO_CS_PIN = gpiozero.LED(self.CS_PIN)
55-
self.GPIO_PWR_PIN = gpiozero.LED(self.PWR_PIN)
56-
self.GPIO_BUSY_PIN = gpiozero.Button(self.BUSY_PIN, pull_up=False)
5752

5853
def digital_write(self, pin, value):
59-
if pin == self.RST_PIN:
60-
if value:
61-
self.GPIO_RST_PIN.on()
62-
else:
63-
self.GPIO_RST_PIN.off()
64-
elif pin == self.DC_PIN:
65-
if value:
66-
self.GPIO_DC_PIN.on()
67-
else:
68-
self.GPIO_DC_PIN.off()
69-
# elif pin == self.CS_PIN:
70-
# if value:
71-
# self.GPIO_CS_PIN.on()
72-
# else:
73-
# self.GPIO_CS_PIN.off()
74-
elif pin == self.PWR_PIN:
75-
if value:
76-
self.GPIO_PWR_PIN.on()
77-
else:
78-
self.GPIO_PWR_PIN.off()
54+
self.GPIO.output(pin, value)
7955

8056
def digital_read(self, pin):
81-
if pin == self.BUSY_PIN:
82-
return self.GPIO_BUSY_PIN.value
83-
elif pin == self.RST_PIN:
84-
return self.RST_PIN.value
85-
elif pin == self.DC_PIN:
86-
return self.DC_PIN.value
87-
# elif pin == self.CS_PIN:
88-
# return self.CS_PIN.value
89-
elif pin == self.PWR_PIN:
90-
return self.PWR_PIN.value
57+
return self.GPIO.input(pin)
9158

9259
def delay_ms(self, delaytime):
9360
time.sleep(delaytime / 1000.0)
@@ -99,29 +66,32 @@ def spi_writebyte2(self, data):
9966
self.SPI.writebytes2(data)
10067

10168
def module_init(self):
102-
self.GPIO_PWR_PIN.on()
69+
self.GPIO.setmode(self.GPIO.BCM)
70+
self.GPIO.setwarnings(False)
71+
self.GPIO.setup(self.RST_PIN, self.GPIO.OUT)
72+
self.GPIO.setup(self.DC_PIN, self.GPIO.OUT)
73+
self.GPIO.setup(self.CS_PIN, self.GPIO.OUT)
74+
self.GPIO.setup(self.PWR_PIN, self.GPIO.OUT)
75+
self.GPIO.setup(self.BUSY_PIN, self.GPIO.IN)
76+
77+
self.GPIO.output(self.PWR_PIN, 1)
10378

10479
# SPI device, bus = 0, device = 0
10580
self.SPI.open(0, 0)
10681
self.SPI.max_speed_hz = 4000000
10782
self.SPI.mode = 0b00
10883
return 0
10984

110-
def module_exit(self, cleanup=False):
85+
def module_exit(self):
11186
logger.debug("spi end")
11287
self.SPI.close()
11388

114-
self.GPIO_RST_PIN.off()
115-
self.GPIO_DC_PIN.off()
116-
self.GPIO_PWR_PIN.off()
11789
logger.debug("close 5V, Module enters 0 power consumption ...")
90+
self.GPIO.output(self.RST_PIN, 0)
91+
self.GPIO.output(self.DC_PIN, 0)
92+
self.GPIO.output(self.PWR_PIN, 0)
11893

119-
if cleanup:
120-
self.GPIO_RST_PIN.close()
121-
self.GPIO_DC_PIN.close()
122-
# self.GPIO_CS_PIN.close()
123-
self.GPIO_PWR_PIN.close()
124-
self.GPIO_BUSY_PIN.close()
94+
self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN, self.PWR_PIN])
12595

12696

12797
class JetsonNano:
@@ -260,20 +230,12 @@ def module_exit(self):
260230
self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN], self.PWR_PIN)
261231

262232

263-
if sys.version_info[0] == 2:
264-
process = subprocess.Popen("cat /proc/cpuinfo | grep Raspberry", shell=True, stdout=subprocess.PIPE)
265-
else:
266-
process = subprocess.Popen("cat /proc/cpuinfo | grep Raspberry", shell=True, stdout=subprocess.PIPE, text=True)
267-
output, _ = process.communicate()
268-
if sys.version_info[0] == 2:
269-
output = output.decode(sys.stdout.encoding)
270-
271-
if "Raspberry" in output:
233+
if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'):
272234
implementation = RaspberryPi()
273235
elif os.path.exists('/sys/bus/platform/drivers/gpio-x3'):
274236
implementation = SunriseX3()
275237
else:
276-
implementation = JetsonNano()
238+
implementation = RaspberryPi()
277239

278240
for func in [x for x in dir(implementation) if not x.startswith('_')]:
279241
setattr(sys.modules[__name__], func, getattr(implementation, func))

0 commit comments

Comments
 (0)