Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcauser/deshipu-micropython-oled
https://github.com/mcauser/deshipu-micropython-oled
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mcauser/deshipu-micropython-oled
- Owner: mcauser
- License: mit
- Archived: true
- Created: 2021-05-28T03:35:43.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-05-28T03:35:58.000Z (over 3 years ago)
- Last Synced: 2024-04-22T12:34:30.896Z (7 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-micropython - micropython-oled - Collection of drivers for monochrome OLED displays, PCD8544, SH1106, SSD1306, UC1701X. (Libraries / Display)
README
Fork of the now archived https://bitbucket.org/thesheep/micropython-oled
MicroPython OLED
================This is a collection of drivers for handling monochrome OLED displays. There
are many versions of such drivers, and there is even a driver for the SSD1306
included in MicroPython's repository, but I decided to make my own, because I
needed something a little bit more optimized.To conserve memory, each version of each driver is in a separate self-contained
file that you need to copy to your board. There is no inheritance and no
multiple imports -- I'm only using the build-in `framebuf` module. Of course
that means there is some repetition between the different drivers, but that's a
price I'm willing to pay. There are also no constants that would need to be
converted to bytes before sending -- I'm using raw byte strings everywhere.To make it fast, I'm calling MicroPython's built-in functions directly, without
wrapping them into convenience functions. I'm also only allocating any memory
once, at the beginning, and then re-using those buffers for everything.Finally, I have added some convenience functions for flipping and mirroring the
display, reversing its colors, hardware scrolling, setting contrast and
switching it off and on.There are no drawing functions on the display object itself, they are available
on the frame buffer object, available as the `fb` attribute.Examples
========SH1106 I2C Example
------------------```python
import sh1106_i2c
from machine import I2C, Pini2c = I2C(-1, sda=Pin(4), scl=Pin(5), freq=400000)
d = sh1106_i2c.Display(i2c)
d.fb.fill(1)
d.fb.pixel(64, 32, 0)
d.update()
```SH1106 SPI Example
------------------```python
import sh1106_spi
from machine import SPI, Pinspi = SPI(1, baudrate=20000000)
dc = Pin(12, Pin.OUT)
cs = Pin(15, Pin.OUT)
d = sh1106_spi.Display(spi, dc, cs)
d.fb.fill(1)
d.fb.pixel(64, 32, 0)
d.update()
```