A collection of miscellaneous libraries and drivers for Micropython
This is a small infra-red distance sensor with I²C interface. It can measure distances from 4 to 127cm. The source code is available here: https://bitbucket.org/thesheep/micropython-gp2y0e03/src
from machine import I2C, Pin import gp2y0e03 i2c = I2C(Pin(5), Pin(4), freq=100000) s = gp2y0e03.GP2Y0E03(i2c) s.read()
This is a collection of 6 different displays drivers for TFT and OLED RGB displays. I finally took the time to refactor all my drivers, pull out the common parts, and put them all in a single library. Don't worry, each driver is in a separate file, so you can copy only the parts that you are actually using onto your board.
The source is at https://bitbucket.org/thesheep/micropython-display
Here's a library for handling a bunch of popular I2C-based real-time clock chips: https://github.com/adafruit/Adafruit-uRTC
And here is the documentation for it: http://micropython-urtc.readthedocs.io/en/latest/
As you can guess from the naming, I was supported by Adafruit Industries to write this one (but of course it will work with any breakout boards for those chips, not just theirs). I will most likely create more libraries for them.
Another basic display driver. This one uses the framebuf module, as does the SSD1306 driver in Micropython's source tree.
The use is pretty much the same.
This driver is for a monochromatic matrix of up to 144 LEDs, with hardware PWM and blinking. It also has 8 frames of memory, and can fade between them, or play animations with them -- optionally synchronized to music! The code is at https://bitbucket.org/thesheep/micropython-is31fl3731/src/tip/is31fl3731.py
import is31fl3731 from machine import I2C, Pin i2c = I2C(Pin(5), Pin(4)) display = is31fl3731.CharlieWing(i2c) display.fill(127) display.pixel(0, 0, 2, True) display.blink(540)
This is a relatively cheap SPI E-ink display that you can find on tindie. It has 4 shades of grey per pixel, and 172x72 resolution.
from machine import Pin, SPI import ssd1606 spi = SPI(miso=Pin(12), mosi=Pin(13, Pin.OUT), sck=Pin(14, Pin.OUT)) display = ssd1606.SSD1606(172, 72, spi, Pin(4), Pin(5), Pin(2), Pin(15)) display.fill(3) display.pixel(10, 10, 0) display.show()
And the display:
A driver for the 8x8 LED matrix. This one doesn't support chaining of multiple modules yet.
This chip is actually used in two different modules. First it's used in the 16-channel I²C servo (and LED) drivers. Second, it's also used in Adafruit's motor shield. That's why apart from the main module, which lets you control the chip directly, there are also two others, specifically for the servos and the DC motors.
The source code is at https://bitbucket.org/thesheep/micropython-pca9685/src
Similar to the ILI9341 driver. In fact, they are so similar, that I see some refactoring in their future to bring some common parts together. But for now, the code is here: https://bitbucket.org/thesheep/micropython-ili9341/src/tip/st7735.py
An example program:
from machine import Pin, SPI import st7735 spi = SPI(miso=Pin(12), mosi=Pin(13, Pin.OUT), sck=Pin(14, Pin.OUT)) display = st7735.ST7735(128, 128, spi, Pin(2), Pin(4), Pin(5)) display.fill(0x7521) display.pixel(64, 64, 0)And a photo of the display:
ADS1015 is a nice I2C-based analog-to-digital converter chip, with four 12-bit channels and configurable gain. Here's a driver for it: https://bitbucket.org/thesheep/micropython-ads1015/src