From 210095f2e237092c211c6aaf90c39345e05b0575 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 13 Aug 2025 16:36:00 -0500 Subject: [PATCH] cleanup, pre-commit, docs. --- README.rst | 61 ++++++++++++++++--- adafruit_uc8253.py | 10 +-- docs/index.rst | 7 +-- .../uc8253_ThinkInk_370_Tricolor_BABMFGNR.py | 7 +-- examples/uc8253_simpletest.py | 7 +-- 5 files changed, 61 insertions(+), 31 deletions(-) diff --git a/README.rst b/README.rst index f53362a..80cb23a 100644 --- a/README.rst +++ b/README.rst @@ -37,18 +37,13 @@ or individual libraries can be installed using `circup `_. - -.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the -image from the assets folder in the PCB's GitHub repo. +* `3.7" 416x240 Monochrome Black/White eInk / ePaper - Bare Display - UC8253 Chipset `_ +* `3.7" 416x240 Tri-Color Red / Black / White eInk - Bare Display - UC8253 Chipset `_ `Purchase one from the Adafruit shop `_ Installing from PyPI ===================== -.. note:: This library is not available on PyPI yet. Install documentation is included - as a standard element. Stay tuned for PyPI availability! - -.. todo:: Remove the above note if PyPI version is/will be available at time of release. On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from PyPI `_. @@ -99,8 +94,56 @@ Or the following command to update an existing version: Usage Example ============= -.. todo:: Add a quick, simple example. It and other examples should live in the -examples folder and be included in docs/examples.rst. +.. code-block:: python + + import time + + import board + import busio + import displayio + from fourwire import FourWire + + import adafruit_uc8253 + + displayio.release_displays() + + # This pinout works on a MagTag with the newer screen and may need to be altered for other boards. + spi = busio.SPI(board.EPD_SCK, board.EPD_MOSI) # Uses SCK and MOSI + epd_cs = board.EPD_CS + epd_dc = board.EPD_DC + epd_reset = board.EPD_RESET + epd_busy = board.EPD_BUSY + + display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000) + time.sleep(1) + + display = adafruit_uc8253.UC8253( + display_bus, width=240, height=416, busy_pin=epd_busy, rotation=0, vcom_cdi=0x97 + ) + + g = displayio.Group() + + pic = displayio.OnDiskBitmap("/display-ruler-1280x720.bmp") + t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) + g.append(t) + + display.root_group = g + + display.refresh() + + print("refreshed") + + time.sleep(display.time_to_refresh + 5) + # Always refresh a little longer. It's not a problem to refresh + # a few seconds more, but it's terrible to refresh too early + # (the display will throw an exception when if the refresh + # is too soon) + print("waited correct time") + + # Keep the display the same + while True: + time.sleep(10) + Documentation ============= diff --git a/adafruit_uc8253.py b/adafruit_uc8253.py index 2c414a6..139d5c5 100644 --- a/adafruit_uc8253.py +++ b/adafruit_uc8253.py @@ -15,8 +15,8 @@ Implementation Notes **Hardware:** -.. todo:: Add links to any specific hardware product page(s), or category page(s). - Use unordered list & hyperlink rST inline format: "* `Link Text `_" +* `3.7" 416x240 Monochrome Black/White eInk / ePaper - Bare Display - UC8253 Chipset `_ +* `3.7" 416x240 Tri-Color Red / Black / White eInk - Bare Display - UC8253 Chipset `_ **Software and Dependencies:** @@ -35,7 +35,7 @@ except ImportError: _START_SEQUENCE = ( b"\x04\x00" # POWERON - b"\x50\x01\xd7" # VCOM/CDI + b"\x50\x01\xd7" # VCOM/CDI b"\x00\x02\xcf\x8d" # PANELSETTING: 0b11001111, 0x8D ) @@ -48,7 +48,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_UC8253.git" class UC8253(EPaperDisplay): """UC8253 ePaper display driver""" - def __init__(self, bus, vcom_cdi=0xd7, **kwargs): + def __init__(self, bus, vcom_cdi=0xD7, **kwargs): start_sequence = bytearray(_START_SEQUENCE) if "highlight_color" in kwargs: @@ -75,5 +75,5 @@ class UC8253(EPaperDisplay): write_color_ram_command=color_ram_command, refresh_display_command=0x12, refresh_time=16, - always_toggle_chip_select=True + always_toggle_chip_select=True, ) diff --git a/docs/index.rst b/docs/index.rst index da4c77f..6390bb7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,14 +24,11 @@ Table of Contents .. toctree:: :caption: Tutorials -.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave - the toctree above for use later. - .. toctree:: :caption: Related Products -.. todo:: Add any product links here. If there are none, then simply delete this todo and leave - the toctree above for use later. + 3.7" 416x240 Monochrome Black/White eInk / ePaper - Bare Display - UC8253 Chipset + 3.7" 416x240 Tri-Color Red / Black / White eInk - Bare Display - UC8253 Chipset .. toctree:: :caption: Other Links diff --git a/examples/uc8253_ThinkInk_370_Tricolor_BABMFGNR.py b/examples/uc8253_ThinkInk_370_Tricolor_BABMFGNR.py index f5b4119..0c75f77 100644 --- a/examples/uc8253_ThinkInk_370_Tricolor_BABMFGNR.py +++ b/examples/uc8253_ThinkInk_370_Tricolor_BABMFGNR.py @@ -27,12 +27,7 @@ display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, time.sleep(1) display = adafruit_uc8253.UC8253( - display_bus, - width=240, - height=416, - busy_pin=epd_busy, - rotation=0, - highlight_color=0xff0000 + display_bus, width=240, height=416, busy_pin=epd_busy, rotation=0, highlight_color=0xFF0000 ) g = displayio.Group() diff --git a/examples/uc8253_simpletest.py b/examples/uc8253_simpletest.py index e9d6d64..6757b44 100644 --- a/examples/uc8253_simpletest.py +++ b/examples/uc8253_simpletest.py @@ -27,12 +27,7 @@ display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, time.sleep(1) display = adafruit_uc8253.UC8253( - display_bus, - width=240, - height=416, - busy_pin=epd_busy, - rotation=0, - vcom_cdi=0x97 + display_bus, width=240, height=416, busy_pin=epd_busy, rotation=0, vcom_cdi=0x97 ) g = displayio.Group()