-
MAX7219 LED Matrix
06/28/2016 at 12:17 • 0 commentsA driver for the 8x8 LED matrix. This one doesn't support chaining of multiple modules yet.
The code: https://bitbucket.org/thesheep/micropython-max7219/src/tip/max7219.py
-
PCA9685 PWM Driver
06/27/2016 at 21:05 • 0 commentsThis 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
-
ST7735 Display
06/27/2016 at 14:54 • 0 commentsSimilar 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 ADC
06/10/2016 at 21:28 • 0 commentsADS1015 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
-
ILI9340/ILI9341 TFT Display
06/05/2016 at 14:11 • 0 commentsThose displays are quite popular and common, so I made a driver for them. Right now the driver is very basic, only gives the ability to draw individual pixels or filled rectangles. It's also pretty slow, at least with the bit-banged SPI on the ESP8266. The code is at https://bitbucket.org/thesheep/micropython-ili9341/src/
Update: now also added text and vertical scrolling.
Update: implemented HSPI on the ESP8266 and it's now blazing fast.
-
RC Hobby Servos
05/16/2016 at 10:55 • 0 commentsThis is a very simple library for controlling up to eight hobby servos with Micropython on ESP8266. The limitation of eight servos comes from the fact that only 8 pins have PWM supported currently, and this is just a simple wrapper over the PWM functionality. The code is at https://bitbucket.org/thesheep/micropython-servo/src/tip/servo.py
Note that to use pins gpio0, gpio2 and gpio15, you need to add appropriate pull-up or pull-down resistors, to make the board boot into the correct mode despite having the servos connected.
-
VL6180 Optical Time-o-Flight Distance Sensor
05/15/2016 at 15:11 • 0 commentsThe VL6180 is a very small, pretty accurate, I²C-based distance sensor. And it can also measure ambient light. I wrote a simple library for Micropython for talking with it, mostly based on the Sparkfun's Arduino library. The code is at: https://bitbucket.org/thesheep/micropython-vl6180/src/tip/vl6180.py
Note that this library uses the new I2C interface, which is currently available on Micropython for the ESP8266. It should eventually be available on all Micropython ports, though.
Example:
import time from machine import I2C, Pin from vl6180 import Sensor i2c = I2C(sda=Pin(4), scl=Pin(5)) sensor = Sensor(i2c) print(sensor.range())
-
HT16K33 7-seg And 14-seg Displays
05/15/2016 at 15:06 • 0 commentsNot just the Adafruit matrices use the HT16K33 chip. Their 7- and 14-segment displays use it as well, and here's a library that supports those: https://bitbucket.org/thesheep/micropython-ht16k33/tip/ht16k33_seg.py
It requires the matrix library to work, as it reuses some of the code. I decided to put it in a separate file, because it comes with some data defining all the letters and digits, and that would waste memory if you only wanted to use the matrix part of the code.
Some example code:
import time from machine import I2C, Pin from ht16k33_seg import Seg14x4 i2c = I2C(sda=Pin(4), scl=Pin(5)) display = Seg14x4(i2c) display.brightness(8) for c in "Hello world!": display.push(c) display.show() time.sleep(0.25)
-
HT16K33 LED Matrix Backpack
05/15/2016 at 14:59 • 0 commentsThe Adafruit LED matrix backpacks use the HT16K33 chip for I²C communication and driving the LEDs. I wrote a simple library for Micropython for handling those. The source code is at https://bitbucket.org/thesheep/micropython-ht16k33/src/tip/ht16k33_matrix.py
The library is very basic, it lets you fill the whole matrix, clear it, or set individual pixels on it. It should run on any platform that runs MicroPython and has I²C communication. Both 8x8 and 16x8 matrices are supported.
Example code:
from machine import I2C, Pin from ht16k33_matrix import Matrix8x8 i2c = I2C(sda=Pin(4), scl=Pin(5)) display = Matrix8x8(i2c) display.brightness(8) display.blink_rate(2) display.fill(True) display.pixel(0, 0, False) display.pixel(7, 0, False) display.pixel(0, 7, False) display.pixel(7, 7, False) display.show()
Update: thanks to Adafruit's support I now added the bi-color matrix to the library.