From dfcc2f6bf28528bcb659c1deece7140999c9c90a Mon Sep 17 00:00:00 2001 From: Justin Richards Date: Sun, 27 Oct 2019 15:48:14 -0500 Subject: [PATCH 1/4] Adding original screen clearing LUT to help prevent burn-in Signed-off-by: Justin Richards --- .../ui/hw/libs/waveshare/v1/epd2in13bcFAST.py | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py b/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py index b770454..5804bdf 100644 --- a/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py +++ b/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py @@ -58,10 +58,10 @@ class EPD: self.height = EPD_HEIGHT lut_vcomDC = [ - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x99, 0x20, 0x20, 0x20, 0x20, 0x06, + 0x00, 0x20, 0x20, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -69,44 +69,46 @@ class EPD: ] lut_ww = [ - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x66, 0x06, 0x06, 0x06, 0x06, 0x04, + 0xAA, 0x32, 0x32, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_bw = [ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, + 0x66, 0x06, 0x06, 0x06, 0x06, 0x04, + 0xAA, 0x32, 0x32, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_wb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x99, 0x06, 0x06, 0x06, 0x06, 0x04, + 0x55, 0x42, 0x42, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_bb = [ - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x00, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x99, 0x06, 0x06, 0x06, 0x06, 0x04, + 0x55, 0x42, 0x42, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ] lut_vcom1 = [ 0xA0, 0x10, 0x10, 0x00, 0x00, 0x02, @@ -233,16 +235,32 @@ class EPD: return 0 def SetFullReg(self): - self.send_command(0x82) - self.send_data(0x00) - self.send_command(0X50) - self.send_data(0x97) -# self.send_command(0x00) # panel setting -# self.send_data(0x9f) # LUT from OTP,128x296 + self.send_command(0x00) # panel setting + self.send_data(0x9f) # LUT from OTP,128x296 + #self.send_command(0x82) + #self.send_data(0x00) + #self.send_command(0X50) + #self.send_data(0x97) + + #self.send_command(0x20) # vcom + #for count in range(0, 44): + # self.send_data(self.lut_vcomDC[count]) + #self.send_command(0x21) # ww -- + #for count in range(0, 42): + # self.send_data(self.lut_ww[count]) + #self.send_command(0x22) # bw r + #for count in range(0, 42): + # self.send_data(self.lut_bw[count]) + #self.send_command(0x23) # wb w + #for count in range(0, 42): + # self.send_data(self.lut_wb[count]) + #self.send_command(0x24) # bb b + #for count in range(0, 42): + # self.send_data(self.lut_bb[count]) def SetPartReg(self): -# self.send_command(0x00) # panel setting -# self.send_data(0xbf) # LUT from OTP,128x296 + self.send_command(0x00) # panel setting + self.send_data(0xbf) # LUT from OTP,128x296 self.send_command(0x82) self.send_data(0x03) self.send_command(0X50) @@ -336,16 +354,17 @@ class EPD: def Clear(self): self.send_command(0x10) for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) - epdconfig.delay_ms(10) - + self.send_data(0xFF) + self.send_command(0x92) + self.send_command(0x13) for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) - epdconfig.delay_ms(10) - + self.send_data(0xFF) + self.send_command(0x92) + self.SetFullReg() - self.TurnOnDisplay() + self.send_command(0x12) # REFRESH + self.ReadBusy() def sleep(self): self.send_command(0X50) From d3c6194e0fdc985748b558b76fd1734d2e35c288 Mon Sep 17 00:00:00 2001 From: Justin Richards Date: Sun, 27 Oct 2019 19:11:36 -0500 Subject: [PATCH 2/4] adding gpio plugin Signed-off-by: Justin Richards --- pwnagotchi/plugins/default/gpio_buttons.py | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pwnagotchi/plugins/default/gpio_buttons.py diff --git a/pwnagotchi/plugins/default/gpio_buttons.py b/pwnagotchi/plugins/default/gpio_buttons.py new file mode 100644 index 0000000..d9860d1 --- /dev/null +++ b/pwnagotchi/plugins/default/gpio_buttons.py @@ -0,0 +1,38 @@ +__author__ = 'ratmandu@gmail.com' +__version__ = '1.0.0' +__name__ = 'gpio_buttons' +__license__ = 'GPL3' +__description__ = 'GPIO Button support plugin' + +import logging +import RPi.GPIO as GPIO +import subprocess + +running = False +OPTIONS = dict() +GPIOs = {} +COMMANDs = None + +def runCommand(channel): + command = GPIOs[channel] + logging.info(f"Button Pressed! Running command: {command}") + process = subprocess.Popen(command, shell=True, stdin=None, stdout=open("/dev/null", "w"), stderr=None, executable="/bin/bash") + process.wait() + + +def on_loaded(): + logging.info("GPIO Button plugin loaded.") + + #get list of GPIOs + gpios = OPTIONS['gpios'] + + #set gpio numbering + GPIO.setmode(GPIO.BCM) + + for i in gpios: + gpio = list(i)[0] + command = i[gpio] + GPIOs[gpio] = command + GPIO.setup(gpio, GPIO.IN, GPIO.PUD_UP) + GPIO.add_event_detect(gpio, GPIO.FALLING, callback=runCommand, bouncetime=300) + logging.info("Added command: %s to GPIO #%d", command, gpio) From 92773a2b37331f228f0c1ef657607134ed2256b4 Mon Sep 17 00:00:00 2001 From: Justin Richards Date: Sun, 27 Oct 2019 19:20:43 -0500 Subject: [PATCH 3/4] adding to defaults.yml and shortening debounce a little bit Signed-off-by: Justin Richards --- pwnagotchi/defaults.yml | 6 ++++++ pwnagotchi/plugins/default/gpio_buttons.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/defaults.yml b/pwnagotchi/defaults.yml index 8016174..eb389ac 100644 --- a/pwnagotchi/defaults.yml +++ b/pwnagotchi/defaults.yml @@ -83,6 +83,12 @@ main: enabled: false #The IP Address of your phone with Paw Server running, default (option is empty) is 192.168.44.1 ip: '' + gpio_buttons: + enabled: false + #The following is a list of the GPIO number for your button, and the command you want to run when it is pressed + gpios: + - 20: 'sudo touch /root/.pwnagotchi-auto && sudo systemctl restart pwnagotchi' + - 21: 'shutdown -h now' # monitor interface to use iface: mon0 # command to run to bring the mon interface up in case it's not up already diff --git a/pwnagotchi/plugins/default/gpio_buttons.py b/pwnagotchi/plugins/default/gpio_buttons.py index d9860d1..c0f6ceb 100644 --- a/pwnagotchi/plugins/default/gpio_buttons.py +++ b/pwnagotchi/plugins/default/gpio_buttons.py @@ -34,5 +34,5 @@ def on_loaded(): command = i[gpio] GPIOs[gpio] = command GPIO.setup(gpio, GPIO.IN, GPIO.PUD_UP) - GPIO.add_event_detect(gpio, GPIO.FALLING, callback=runCommand, bouncetime=300) + GPIO.add_event_detect(gpio, GPIO.FALLING, callback=runCommand, bouncetime=250) logging.info("Added command: %s to GPIO #%d", command, gpio) From 7676b55b87e3a4c7d5199b8d1742920f3c573db7 Mon Sep 17 00:00:00 2001 From: Justin Richards Date: Sun, 27 Oct 2019 19:36:29 -0500 Subject: [PATCH 4/4] Revert "Adding original screen clearing LUT to help prevent burn-in" This reverts commit dfcc2f6bf28528bcb659c1deece7140999c9c90a. --- .../ui/hw/libs/waveshare/v1/epd2in13bcFAST.py | 91 ++++++++----------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py b/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py index 5804bdf..b770454 100644 --- a/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py +++ b/pwnagotchi/ui/hw/libs/waveshare/v1/epd2in13bcFAST.py @@ -58,10 +58,10 @@ class EPD: self.height = EPD_HEIGHT lut_vcomDC = [ - 0x99, 0x20, 0x20, 0x20, 0x20, 0x06, - 0x00, 0x20, 0x20, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -69,46 +69,44 @@ class EPD: ] lut_ww = [ - 0x66, 0x06, 0x06, 0x06, 0x06, 0x04, - 0xAA, 0x32, 0x32, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, + 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_bw = [ - 0x66, 0x06, 0x06, 0x06, 0x06, 0x04, - 0xAA, 0x32, 0x32, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, + 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, + 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_wb = [ - 0x99, 0x06, 0x06, 0x06, 0x06, 0x04, - 0x55, 0x42, 0x42, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ] lut_bb = [ - 0x99, 0x06, 0x06, 0x06, 0x06, 0x04, - 0x55, 0x42, 0x42, 0x00, 0x00, 0x02, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x00, + 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - ] + ] lut_vcom1 = [ 0xA0, 0x10, 0x10, 0x00, 0x00, 0x02, @@ -235,32 +233,16 @@ class EPD: return 0 def SetFullReg(self): - self.send_command(0x00) # panel setting - self.send_data(0x9f) # LUT from OTP,128x296 - #self.send_command(0x82) - #self.send_data(0x00) - #self.send_command(0X50) - #self.send_data(0x97) - - #self.send_command(0x20) # vcom - #for count in range(0, 44): - # self.send_data(self.lut_vcomDC[count]) - #self.send_command(0x21) # ww -- - #for count in range(0, 42): - # self.send_data(self.lut_ww[count]) - #self.send_command(0x22) # bw r - #for count in range(0, 42): - # self.send_data(self.lut_bw[count]) - #self.send_command(0x23) # wb w - #for count in range(0, 42): - # self.send_data(self.lut_wb[count]) - #self.send_command(0x24) # bb b - #for count in range(0, 42): - # self.send_data(self.lut_bb[count]) + self.send_command(0x82) + self.send_data(0x00) + self.send_command(0X50) + self.send_data(0x97) +# self.send_command(0x00) # panel setting +# self.send_data(0x9f) # LUT from OTP,128x296 def SetPartReg(self): - self.send_command(0x00) # panel setting - self.send_data(0xbf) # LUT from OTP,128x296 +# self.send_command(0x00) # panel setting +# self.send_data(0xbf) # LUT from OTP,128x296 self.send_command(0x82) self.send_data(0x03) self.send_command(0X50) @@ -354,17 +336,16 @@ class EPD: def Clear(self): self.send_command(0x10) for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) - self.send_command(0x92) - + self.send_data(0x00) + epdconfig.delay_ms(10) + self.send_command(0x13) for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) - self.send_command(0x92) - + self.send_data(0x00) + epdconfig.delay_ms(10) + self.SetFullReg() - self.send_command(0x12) # REFRESH - self.ReadBusy() + self.TurnOnDisplay() def sleep(self): self.send_command(0X50)