Initial commit
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
# display/epdconfig.py
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DummyGPIO:
|
||||
BCM = OUT = IN = 0
|
||||
|
||||
@staticmethod
|
||||
def setmode(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def setwarnings(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def setup(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def output(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def input(*args):
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def cleanup(*args):
|
||||
pass
|
||||
|
||||
|
||||
class DummySPI:
|
||||
max_speed_hz = 4000000
|
||||
mode = 0b00
|
||||
|
||||
@staticmethod
|
||||
def open(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def writebytes(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def writebytes2(*args):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def close():
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
import RPi.GPIO as GPIO
|
||||
import spidev
|
||||
|
||||
SPI = spidev.SpiDev()
|
||||
except ImportError:
|
||||
logger.warning(
|
||||
"RPi.GPIO or spidev not found. Using Dummy hardware drivers (Test Mode)."
|
||||
)
|
||||
GPIO = DummyGPIO()
|
||||
SPI = DummySPI()
|
||||
|
||||
RST_PIN = 17
|
||||
DC_PIN = 25
|
||||
CS_PIN = 8
|
||||
BUSY_PIN = 24
|
||||
PWR_PIN = 18
|
||||
|
||||
|
||||
def digital_write(pin, value):
|
||||
GPIO.output(pin, value)
|
||||
|
||||
|
||||
def digital_read(pin):
|
||||
return GPIO.input(pin)
|
||||
|
||||
|
||||
def delay_ms(delaytime):
|
||||
time.sleep(delaytime / 1000.0)
|
||||
|
||||
|
||||
def spi_writebyte(data):
|
||||
SPI.writebytes(data)
|
||||
|
||||
|
||||
def spi_writebyte2(data):
|
||||
SPI.writebytes2(data)
|
||||
|
||||
|
||||
def module_init():
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(RST_PIN, GPIO.OUT)
|
||||
GPIO.setup(DC_PIN, GPIO.OUT)
|
||||
GPIO.setup(CS_PIN, GPIO.OUT)
|
||||
GPIO.setup(PWR_PIN, GPIO.OUT)
|
||||
GPIO.setup(BUSY_PIN, GPIO.IN)
|
||||
GPIO.output(PWR_PIN, 1)
|
||||
|
||||
SPI.open(0, 0)
|
||||
SPI.max_speed_hz = 4000000
|
||||
SPI.mode = 0b00
|
||||
return 0
|
||||
|
||||
|
||||
def module_exit():
|
||||
SPI.close()
|
||||
GPIO.output(RST_PIN, 0)
|
||||
GPIO.output(DC_PIN, 0)
|
||||
GPIO.output(PWR_PIN, 0)
|
||||
GPIO.cleanup([RST_PIN, DC_PIN, CS_PIN, BUSY_PIN, PWR_PIN])
|
||||
Reference in New Issue
Block a user