Removing refresh trigger handler since it prevented pwnagotchi ui from displaying
This commit is contained in:
parent
d3a8dc85c3
commit
1b813f41f5
sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui
@ -207,15 +207,9 @@ class Display(View):
|
|||||||
def _waveshare_bc_render(self):
|
def _waveshare_bc_render(self):
|
||||||
buf_black = self._display.getbuffer(self.canvas)
|
buf_black = self._display.getbuffer(self.canvas)
|
||||||
emptyImage = Image.new('1', (self._display.height, self._display.width), 255)
|
emptyImage = Image.new('1', (self._display.height, self._display.width), 255)
|
||||||
buf_red = self._display.getbuffer(emptyImage)
|
buf_color = self._display.getbuffer(emptyImage)
|
||||||
if self.full_refresh_trigger >= 0 and self.full_refresh_count == self.full_refresh_trigger:
|
self._display.display(buf_black,buf_color)
|
||||||
self._display.Clear()
|
|
||||||
self._display.display(buf_black,buf_red)
|
|
||||||
self._display.sleep()
|
|
||||||
if self.full_refresh_trigger >= 0 and self.full_refresh_count == self.full_refresh_trigger:
|
|
||||||
self.full_refresh_count = 0
|
|
||||||
elif self.full_refresh_trigger >= 0:
|
|
||||||
self.full_refresh_count += 1
|
|
||||||
|
|
||||||
|
|
||||||
def _on_view_rendered(self, img):
|
def _on_view_rendered(self, img):
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from . import epdconfig
|
from . import epdconfig
|
||||||
|
from PIL import Image
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
# import numpy as np
|
||||||
|
|
||||||
# Display resolution
|
# Display resolution
|
||||||
EPD_WIDTH = 104
|
EPD_WIDTH = 104
|
||||||
@ -45,35 +48,33 @@ class EPD:
|
|||||||
|
|
||||||
# Hardware reset
|
# Hardware reset
|
||||||
def reset(self):
|
def reset(self):
|
||||||
epdconfig.digital_write(self.reset_pin, 1)
|
epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
|
||||||
epdconfig.delay_ms(200)
|
epdconfig.delay_ms(200)
|
||||||
epdconfig.digital_write(self.reset_pin, 0)
|
epdconfig.digital_write(self.reset_pin, GPIO.LOW) # module reset
|
||||||
epdconfig.delay_ms(10)
|
epdconfig.delay_ms(200)
|
||||||
epdconfig.digital_write(self.reset_pin, 1)
|
epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
|
||||||
epdconfig.delay_ms(200)
|
epdconfig.delay_ms(200)
|
||||||
|
|
||||||
def send_command(self, command):
|
def send_command(self, command):
|
||||||
epdconfig.digital_write(self.dc_pin, 0)
|
epdconfig.digital_write(self.dc_pin, GPIO.LOW)
|
||||||
epdconfig.digital_write(self.cs_pin, 0)
|
epdconfig.digital_write(self.cs_pin, GPIO.LOW)
|
||||||
epdconfig.spi_writebyte([command])
|
epdconfig.spi_writebyte([command])
|
||||||
epdconfig.digital_write(self.cs_pin, 1)
|
epdconfig.digital_write(self.cs_pin, GPIO.HIGH)
|
||||||
|
|
||||||
def send_data(self, data):
|
def send_data(self, data):
|
||||||
epdconfig.digital_write(self.dc_pin, 1)
|
epdconfig.digital_write(self.dc_pin, GPIO.HIGH)
|
||||||
epdconfig.digital_write(self.cs_pin, 0)
|
epdconfig.digital_write(self.cs_pin, GPIO.LOW)
|
||||||
epdconfig.spi_writebyte([data])
|
epdconfig.spi_writebyte([data])
|
||||||
epdconfig.digital_write(self.cs_pin, 1)
|
epdconfig.digital_write(self.cs_pin, GPIO.HIGH)
|
||||||
|
|
||||||
def ReadBusy(self):
|
def ReadBusy(self):
|
||||||
logging.debug("e-Paper busy")
|
|
||||||
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
|
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
|
||||||
epdconfig.delay_ms(100)
|
epdconfig.delay_ms(100)
|
||||||
logging.debug("e-Paper busy release")
|
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
if (epdconfig.module_init() != 0):
|
if (epdconfig.module_init() != 0):
|
||||||
return -1
|
return -1
|
||||||
|
# EPD hardware init start
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
self.send_command(0x06) # BOOSTER_SOFT_START
|
self.send_command(0x06) # BOOSTER_SOFT_START
|
||||||
@ -97,21 +98,17 @@ class EPD:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def getbuffer(self, image):
|
def getbuffer(self, image):
|
||||||
# logging.debug("bufsiz = ",int(self.width/8) * self.height)
|
|
||||||
buf = [0xFF] * (int(self.width/8) * self.height)
|
buf = [0xFF] * (int(self.width/8) * self.height)
|
||||||
image_monocolor = image.convert('1')
|
image_monocolor = image.convert('1')
|
||||||
imwidth, imheight = image_monocolor.size
|
imwidth, imheight = image_monocolor.size
|
||||||
pixels = image_monocolor.load()
|
pixels = image_monocolor.load()
|
||||||
# logging.debug("imwidth = %d, imheight = %d",imwidth,imheight)
|
|
||||||
if(imwidth == self.width and imheight == self.height):
|
if(imwidth == self.width and imheight == self.height):
|
||||||
logging.debug("Vertical")
|
|
||||||
for y in range(imheight):
|
for y in range(imheight):
|
||||||
for x in range(imwidth):
|
for x in range(imwidth):
|
||||||
# Set the bits for the column of pixels at the current position.
|
# Set the bits for the column of pixels at the current position.
|
||||||
if pixels[x, y] == 0:
|
if pixels[x, y] == 0:
|
||||||
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
|
buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
|
||||||
elif(imwidth == self.height and imheight == self.width):
|
elif(imwidth == self.height and imheight == self.width):
|
||||||
logging.debug("Horizontal")
|
|
||||||
for y in range(imheight):
|
for y in range(imheight):
|
||||||
for x in range(imwidth):
|
for x in range(imwidth):
|
||||||
newx = y
|
newx = y
|
||||||
@ -120,7 +117,7 @@ class EPD:
|
|||||||
buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8))
|
buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8))
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
def display(self, imageblack, imagered):
|
def display(self, imageblack, imagecolor):
|
||||||
self.send_command(0x10)
|
self.send_command(0x10)
|
||||||
for i in range(0, int(self.width * self.height / 8)):
|
for i in range(0, int(self.width * self.height / 8)):
|
||||||
self.send_data(imageblack[i])
|
self.send_data(imageblack[i])
|
||||||
@ -128,7 +125,7 @@ class EPD:
|
|||||||
|
|
||||||
self.send_command(0x13)
|
self.send_command(0x13)
|
||||||
for i in range(0, int(self.width * self.height / 8)):
|
for i in range(0, int(self.width * self.height / 8)):
|
||||||
self.send_data(imagered[i])
|
self.send_data(imagecolor[i])
|
||||||
self.send_command(0x92)
|
self.send_command(0x92)
|
||||||
|
|
||||||
self.send_command(0x12) # REFRESH
|
self.send_command(0x12) # REFRESH
|
||||||
|
Loading…
x
Reference in New Issue
Block a user