Code Monkey home page Code Monkey logo

adafruit_circuitpython_displayio_ssd1306's Introduction

Introduction

Documentation Status

Discord

Build Status

Code Style: Black

DisplayIO driver for SSD1306 monochrome displays. DisplayIO drivers enable terminal output

For the framebuf based driver see Adafruit CircuitPython SSD1306.

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-displayio-ssd1306

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

sudo pip3 install adafruit-circuitpython-displayio-ssd1306

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-displayio-ssd1306

Usage Example

import board
import displayio
import adafruit_displayio_ssd1306
import busio

displayio.release_displays()

# This pinout works on a Metro and may need to be altered for other boards.
spi = busio.SPI(board.SCL, board.SDA)
tft_cs = board.D9
tft_dc = board.D8
tft_reset = board.D7

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_reset, baudrate=1000000)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)

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_displayio_ssd1306's People

Contributors

asmagill avatar dglaude avatar dhalbert avatar djdevon3 avatar evaherrada avatar foamyguy avatar gamblor21 avatar jposada202020 avatar kattni avatar ladyada avatar lesamouraipourpre avatar makermelissa avatar prcutler avatar sak917 avatar siddacious avatar sommersoft avatar spkuehl avatar tannewt avatar tcfranks avatar tekktrik avatar

Stargazers

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

Watchers

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

adafruit_circuitpython_displayio_ssd1306's Issues

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_displayio_ssd1306.py:65

Missing install in pypi

Hi,

It seems that the link to the library in pypi for installation with pip is incorrect, and I can only see the display ssd1305 library there. The installation instructions seem to imply that it should be there however?

-Jamie

Adafruit 0.96 128x64 missing every 2nd scanline

I have an Adafruit 0.96 128x64 OLED (https://www.adafruit.com/product/326) hooked up via I2C to a Adafruit RP2040 QT. I followed the instructions in the tutorial to get it working in CircuitPython (note - the code in tutorial would fail with "too many display buses" until I remembered I needed to do a displayio.release_displays() first).

While the tutorial does work - kind of - I am missing every 2nd horizontal line. See: IMG_4642

My setup code is:

displayio.release_displays()
i2c = board.STEMMA_I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)

WIDTH = 128
HEIGHT = 64  # Change to 64 if needed

display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)

I initially thought perhaps a bad board? But after a quick web search it seems missing 2nd scan line is kinda common with these 1306 boards? (saw posts on Arduino forums). so I'm wondering if this is some kind of configuration bug?

Running: Adafruit CircuitPython 8.0.0-beta.5 on 2022-12-08; Adafruit QT Py RP2040 with rp2040

FeatherWing example code: "SDA in use" error

• Feather M4 + OLED FeatherWing
• latest S3: Adafruit CircuitPython bb04fbf on 2019-07-30; Adafruit Feather M4 Express with samd51j19
• 20190729 Library Bundle
example code: displayio_ssd1306_featherwing.py

code.py output:
Traceback (most recent call last):
  File "code.py", line 7, in <module>
ValueError: SDA in use

0.49" 64 x 32 pixel module output error

Using a cheap 0.49" OLED with 64 x 32px - modified simple test.py to accommodate width and height, output shows as follows - seems not to like the tiny screen size.

Running on CP 6.2 Stable Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit Feather RP2040 with rp2040 rather than own build CP, all libraries updated from bundle automatically using the joedevivo VSCode plugins
IMG_1035

Need something to get the geometry corrected for the tiny OLEDs

Where to find status of this library and its publication?

Hi, I arrived here looking for a module to show text on a 128x32 SPI OLED that I connected to my Raspberry Pi.

I saw the note in the install section of the Readme, still tried

pip3 install adafruit-circuitpython-displayio-ssd1306

thinking that the note might have been outdated but no it doesn't exist on PyPi as far as I could see.

So I was wondering,

  • Is there a place to know the status regarding a PyPi publication?
  • Is this already usable with Blinka via a manual install or is the whole code here a Work In Progress not intended for users yet?

Many thanks

Needs further fixing to be warning-free on 9.0 while working on 8.x.

On 9.0, the current version prints warnings at import:

Adafruit CircuitPython 9.0.0-rc.1-1-g7e7b2a4154-dirty on 2024-03-17; Adafruit Macropad RP2040 with rp2040
>>> import adafruit_displayio_ssd1306
FutureWarning: FourWire moved from displayio to fourwire
FutureWarning: I2CDisplay moved from displayio to i2cdisplaybus
FutureWarning: I2CDisplay renamed I2CDisplayBus
FutureWarning: Display moved from displayio to busdisplay
FutureWarning: Display renamed BusDisplay

this is related to how an attempt was made to fix this, but it's not quite right because of how the try/import/except blocks are organized.

AttributeError: module 'displayio' has no attribute 'Fourwire`

Hello,

this is the example code

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
This test will initialize the display using displayio and draw a solid white
background, a smaller black rectangle, and some white text.
"""

import board
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306

displayio.release_displays()

oled_reset = board.D9

# Use for I2C
i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C, reset=oled_reset)

# Use for SPI
# spi = board.SPI()
# oled_cs = board.D5
# oled_dc = board.D6
# display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
#                                 reset=oled_reset, baudrate=1000000)

WIDTH = 128
HEIGHT = 32  # Change to 64 if needed
BORDER = 5

display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF  # White

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(WIDTH - BORDER * 2, HEIGHT - BORDER * 2, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000  # Black
inner_sprite = displayio.TileGrid(
    inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)

# Draw a label
text = "Hello World!"
text_area = label.Label(
    terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
)
splash.append(text_area)

while True:
    pass

but I get this error

Traceback (most recent call last):
  File "/home/pi/test.py", line 13, in <module>
    import adafruit_displayio_ssd1306
  File "/usr/local/lib/python3.9/dist-packages/adafruit_displayio_ssd1306.py", line 60, in <module>
    class SSD1306(displayio.Display):
  File "/usr/local/lib/python3.9/dist-packages/adafruit_displayio_ssd1306.py", line 71, in SSD1306
    self, bus: Union[displayio.Fourwire, displayio.I2CDisplay], **kwargs
AttributeError: module 'displayio' has no attribute 'Fourwire'

update needed for CP 9 to use busdisplay to eliminate FutureWarnings

When this library is used with CP9 some "FutureWarnings" are generated due to this line

https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306/blob/main/adafruit_displayio_ssd1306.py#L62
class SSD1306(displayio.Display):
I think it just needs to be changed to:
class SSD1306(busdisplay.BusDisplay):
as well as importing busdisplay instead of displayio

Is this already planned for update when CP9 is released?
I suppose it will need to check for the CP release for backward compatibility.

I imagine there will be many guide updates as well when CP9 is released.
https://learn.adafruit.com/adafruit-oled-featherwing/python-usage and had to make a new changes to code.py but also had to update the library as noted to eliminate all warnings.

I just wanted to open this as a warning to other users. Feel free to close it if this is being dealt with in another way.

Since the FutureWarnings are just Warnings, it works fine as is but the warnings can be annoying.

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.