mirror of
https://github.com/infinition/Bjorn.git
synced 2025-12-06 06:11:46 +00:00
Update epd2in13.py
New flag & if condition to track if the display has been initialized & avoid repeated initialization and accumulation of File descriptors & system crash.
This commit is contained in:
@@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class EPD:
|
class EPD:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.is_initialized = False # New flag to track if the display has been initialized #INFINITION
|
||||||
self.reset_pin = epdconfig.RST_PIN
|
self.reset_pin = epdconfig.RST_PIN
|
||||||
self.dc_pin = epdconfig.DC_PIN
|
self.dc_pin = epdconfig.DC_PIN
|
||||||
self.busy_pin = epdconfig.BUSY_PIN
|
self.busy_pin = epdconfig.BUSY_PIN
|
||||||
@@ -66,10 +67,10 @@ class EPD:
|
|||||||
logger.debug("e-Paper busy release")
|
logger.debug("e-Paper busy release")
|
||||||
|
|
||||||
def init(self, lut):
|
def init(self, lut):
|
||||||
if (epdconfig.module_init() != 0):
|
if not self.is_initialized: # Avoid repeated initialization and accumulation of File descriptors #INFINITION
|
||||||
return -1
|
if epdconfig.module_init() != 0:
|
||||||
# EPD hardware init start
|
return -1
|
||||||
self.reset()
|
self.reset()
|
||||||
self.send_command(0x01) # DRIVER_OUTPUT_CONTROL
|
self.send_command(0x01) # DRIVER_OUTPUT_CONTROL
|
||||||
self.send_data((EPD_HEIGHT - 1) & 0xFF)
|
self.send_data((EPD_HEIGHT - 1) & 0xFF)
|
||||||
self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF)
|
self.send_data(((EPD_HEIGHT - 1) >> 8) & 0xFF)
|
||||||
|
|||||||
Reference in New Issue
Block a user