Merge f0e34c2cdd into da7c017ef9
This commit is contained in:
commit
bde52015c8
1 changed files with 28 additions and 9 deletions
|
|
@ -14,6 +14,14 @@ from micropython import const
|
||||||
import adafruit_framebuf
|
import adafruit_framebuf
|
||||||
from adafruit_epd.epd import Adafruit_EPD
|
from adafruit_epd.epd import Adafruit_EPD
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import Union, Any
|
||||||
|
from busio import SPI
|
||||||
|
from digitalio import DigitalInOut
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
__version__ = "0.0.0+auto.0"
|
__version__ = "0.0.0+auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
|
||||||
|
|
||||||
|
|
@ -72,8 +80,17 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(
|
def __init__(
|
||||||
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
|
self,
|
||||||
):
|
width: int,
|
||||||
|
height: int,
|
||||||
|
spi: SPI,
|
||||||
|
*,
|
||||||
|
cs_pin: DigitalInOut,
|
||||||
|
dc_pin: DigitalInOut,
|
||||||
|
sramcs_pin: DigitalInOut,
|
||||||
|
rst_pin: DigitalInOut,
|
||||||
|
busy_pin: DigitalInOut
|
||||||
|
) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
|
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
|
||||||
)
|
)
|
||||||
|
|
@ -101,13 +118,13 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
self.set_color_buffer(1, False)
|
self.set_color_buffer(1, False)
|
||||||
# pylint: enable=too-many-arguments
|
# pylint: enable=too-many-arguments
|
||||||
|
|
||||||
def begin(self, reset=True):
|
def begin(self, reset: bool = True) -> None:
|
||||||
"""Begin communication with the display and set basic settings"""
|
"""Begin communication with the display and set basic settings"""
|
||||||
if reset:
|
if reset:
|
||||||
self.hardware_reset()
|
self.hardware_reset()
|
||||||
self.power_down()
|
self.power_down()
|
||||||
|
|
||||||
def busy_wait(self):
|
def busy_wait(self) -> None:
|
||||||
"""Wait for display to be done with current task, either by polling the
|
"""Wait for display to be done with current task, either by polling the
|
||||||
busy pin, or pausing"""
|
busy pin, or pausing"""
|
||||||
if self._busy:
|
if self._busy:
|
||||||
|
|
@ -116,7 +133,7 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
else:
|
else:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
def power_up(self):
|
def power_up(self) -> None:
|
||||||
"""Power up the display in preparation for writing RAM and updating"""
|
"""Power up the display in preparation for writing RAM and updating"""
|
||||||
self.hardware_reset()
|
self.hardware_reset()
|
||||||
self.busy_wait()
|
self.busy_wait()
|
||||||
|
|
@ -143,12 +160,12 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
|
|
||||||
self.busy_wait()
|
self.busy_wait()
|
||||||
|
|
||||||
def power_down(self):
|
def power_down(self) -> None:
|
||||||
"""Power down the display - required when not actively displaying!"""
|
"""Power down the display - required when not actively displaying!"""
|
||||||
self.command(_SSD1681_DEEP_SLEEP, bytearray([0x01]))
|
self.command(_SSD1681_DEEP_SLEEP, bytearray([0x01]))
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the display from internal memory"""
|
"""Update the display from internal memory"""
|
||||||
self.command(_SSD1681_DISP_CTRL2, bytearray([0xF7]))
|
self.command(_SSD1681_DISP_CTRL2, bytearray([0xF7]))
|
||||||
self.command(_SSD1681_MASTER_ACTIVATE)
|
self.command(_SSD1681_MASTER_ACTIVATE)
|
||||||
|
|
@ -156,7 +173,7 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
if not self._busy:
|
if not self._busy:
|
||||||
time.sleep(3) # wait 3 seconds
|
time.sleep(3) # wait 3 seconds
|
||||||
|
|
||||||
def write_ram(self, index):
|
def write_ram(self, index: Union[0, 1]) -> Any:
|
||||||
"""Send the one byte command for starting the RAM write process. Returns
|
"""Send the one byte command for starting the RAM write process. Returns
|
||||||
the byte read at the same time over SPI. index is the RAM buffer, can be
|
the byte read at the same time over SPI. index is the RAM buffer, can be
|
||||||
0 or 1 for tri-color displays."""
|
0 or 1 for tri-color displays."""
|
||||||
|
|
@ -166,7 +183,9 @@ class Adafruit_SSD1681(Adafruit_EPD):
|
||||||
return self.command(_SSD1681_WRITE_REDRAM, end=False)
|
return self.command(_SSD1681_WRITE_REDRAM, end=False)
|
||||||
raise RuntimeError("RAM index must be 0 or 1")
|
raise RuntimeError("RAM index must be 0 or 1")
|
||||||
|
|
||||||
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
|
def set_ram_address(
|
||||||
|
self, x: int, y: int
|
||||||
|
) -> None: # pylint: disable=unused-argument, no-self-use
|
||||||
"""Set the RAM address location, not used on this chipset but required by
|
"""Set the RAM address location, not used on this chipset but required by
|
||||||
the superclass"""
|
the superclass"""
|
||||||
# Set RAM X address counter
|
# Set RAM X address counter
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue