Coder Social home page Coder Social logo

adafruit / adafruit_circuitpython_ssd1675 Goto Github PK

View Code? Open in Web Editor NEW
2.0 20.0 8.0 97 KB

CircuitPython `displayio` drivers for SSD1675-based ePaper displays

License: MIT License

Python 100.00%
circuitpython displayio ssd1675 epd epaper hacktoberfest

adafruit_circuitpython_ssd1675's Introduction

Introduction

Documentation Status

Discord

Build Status

Code Style: Black

CircuitPython displayio drivers for SSD1675-based ePaper displays

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-ssd1675

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-ssd1675

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-ssd1675

Usage Example

"""Simple test script for 2.13" 250x122 black and white featherwing.

Supported products:
  * Adafruit 2.13" Black and White FeatherWing
    * https://www.adafruit.com/product/4195
  """

import time
import board
import busio
import displayio
# Starting in CircuitPython 9.x, fourwire will be a seperate internal library
# rather than a component of the displayio library
try:
    from fourwire import FourWire
except ImportError:
    from displayio import FourWire
import adafruit_ssd1675

displayio.release_displays()

epd_cs = board.D9
epd_dc = board.D10

display_bus = FourWire(board.SPI(), command=epd_dc, chip_select=epd_cs, baudrate=1000000)
time.sleep(1)

display = adafruit_ssd1675.SSD1675(display_bus, width=250, height=122, rotation=90)

g = displayio.Group()

f = open("/display-ruler.bmp", "rb")

pic = displayio.OnDiskBitmap(f)
# CircuitPython 6 & 7 compatible
t = displayio.TileGrid(
    pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
)
# CircuitPython 7 compatible only
# t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
g.append(t)

display.root_group = g

display.refresh()

print("refreshed")

time.sleep(120)

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_ssd1675's People

Contributors

dhalbert avatar evaherrada avatar foamyguy avatar jposada202020 avatar kattni avatar ladyada avatar lesamouraipourpre avatar makermelissa avatar retiredwizard avatar sommersoft avatar tannewt avatar tcfranks avatar tekktrik avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_ssd1675's Issues

5.0.0-alpha.2 Label text doesn't update on B&W ePaper FeatherWing

Adafruit Feather M4 Express with samd51j19
5.0.0-alpha.2 on 2019-09-04
CP Lib Bundle 20190906

Maybe this belongs in circuitpython instead of here, but this issue only seems to affect the 2-color EPD.

Sorry for the code size, wanted to make sure it worked on other displays.

This code works on other FeatherWings, including TFTs, OLED, and the 3-color EPD. But text does not update after the first display on the 2-color EPD. It goes through its flashing motions, but same text appears again.

print() output shows the code is progressing through it's loops on the 2-color EPD:

Adafruit Feather M4 Express with samd51j19 5.0.0-alpha.2 on 2019-09-04 20190906
0.0
0 13144063000000
179.999
1 13324181000000
180.0
2 13504201000000

import os
import time
import board
import terminalio
import displayio
from adafruit_display_text.label import Label
from adafruit_displayio_ssd1306 import SSD1306
from adafruit_featherwing import minitft_featherwing
from adafruit_ili9341 import ILI9341
from adafruit_hx8357 import HX8357
from adafruit_ssd1675 import SSD1675
from adafruit_il0373 import IL0373


# CicruitPython 5.0.0-alpha.2 displayio EPD Test

# PyPortal
pyportal = False
# ...OR...
# Feather M4 Express + choose your own adventure:
oled = False
minitft = False
ili9341 = False
hx8357 = False
ssd1675 = True
il0373 = False

epaper = False
if ssd1675 or il0373:
    epaper = True


if pyportal:
    display = board.DISPLAY
else:
    displayio.release_displays()
    cs = board.D9
    dc = board.D10

if oled:
    # Adafruit I2C OLED FeatherWing
    i2c = board.I2C()
    display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
    display = SSD1306(display_bus, width=128, height=32)

if minitft:
    # Adafruit Mini Color TFT with Joystick FeatherWing
    display = minitft_featherwing.MiniTFTFeatherWing().display

if ili9341:
    # Adafruit 2.4" TFT FeatherWing
    display_bus = displayio.FourWire(board.SPI(), command=dc, chip_select=cs)
    display = ILI9341(display_bus, width=320, height=240)

if hx8357:
    # Adafruit 3.5" TFT FeatherWing
    display_bus = displayio.FourWire(board.SPI(), command=dc, chip_select=cs)
    display = HX8357(display_bus, width=480, height=320)

if ssd1675:
    # Adafruit 2.13" Black and White FeatherWing
    # https://github.com/adafruit/Adafruit_CircuitPython_SSD1675/blob/master/examples/ssd1675_simpletest.py
    display_bus = displayio.FourWire(board.SPI(), command=dc, chip_select=cs, baudrate=1000000)
    time.sleep(1)
    display = SSD1675(display_bus, width=250, height=122, rotation=90)

if il0373:
    # Adafruit 2.13" Tri-Color FeatherWing
    # https://github.com/adafruit/Adafruit_CircuitPython_IL0373/blob/master/examples/il0373_simpletest.py
    display_bus = displayio.FourWire(board.SPI(), command=dc, chip_select=cs, baudrate=1000000)
    time.sleep(1)
    display = IL0373(display_bus, width=212, height=104, rotation=90, highlight_color=0xff0000)


# displayio

SPLASHWIDTH = display.width
SPLASHHEIGHT = display.height
SPLASHMAX = 2
splash = displayio.Group(max_size=SPLASHMAX)

# Group 0
background_bitmap = displayio.Bitmap(SPLASHWIDTH, SPLASHHEIGHT, 1)
background_palette = displayio.Palette(1)
background_palette[0] = 0x0000
background = displayio.TileGrid(background_bitmap, pixel_shader=background_palette)
splash.append(background)

# Group 1
splash.append(displayio.Group(max_size=1, scale=1, x=0, y=0))  #dummy
font = terminalio.FONT
#                             3 80953846000000
text_area = Label(font, text="0123456789012345", color=0xFFFFFF)
text_area.x = 5
text_area.y = 25
splash[1] = text_area

display.show(splash)


with open('/VERSIONS.txt') as f:
    cp_lib_bundle = f.readline().strip()
print(os.uname()[4], os.uname()[3], cp_lib_bundle)

loop = 0
while True:
    if epaper:
        print(display.time_to_refresh)
        time.sleep(display.time_to_refresh)
    else:
        time.sleep(5)

    try:
        print(loop % 10, time.monotonic_ns())
        text_area.text = str(loop % 10) + ' ' + str(time.monotonic_ns())
        display.refresh()
    except RuntimeError as e:  # Refresh too soon
        print(e)

    loop += 1

Missing Type Annotations

There are missing type annotations for some functions in this library.

The typing module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

try:
    from typing import List, Tuple
except ImportError:
    pass

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

def wrap_text_to_pixels(
    string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:

If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs and Check your code with pre-commit contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev channel.

The following locations are reported by mypy to be missing type annotations:

  • adafruit_ssd1675.py:58

`__init__()` arguments are not Pin objects

We recently changed argument names for initializing the ESP32SPI library to use the suffix _dio rather than _pin because the arguments need to be instantiated DigitalInOut objects, not microcontroller.Pin objects.

See: adafruit/Adafruit_CircuitPython_ESP32SPI#121

This library uses the same *_pin names for it's arguments which are also expected to the DigitalInOuts rather than Pins.

I think we'll want to change the names here and any other libraries that have _pin to keep things consistent across libraries.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.