Created
November 26, 2018 08:15
-
-
Save ckuethe/cd938603cdc11a5a5fc5b39f786ac752 to your computer and use it in GitHub Desktop.
Micropython Demonstration of using an ESP8266 with integrated SSD1306
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 syn=python | |
# quick demo of displaying text on an esp8266 with integrated SSD1306 | |
# OLED such as this: https://smile.amazon.com/gp/product/B076JDVRLP | |
from machine import Pin, I2C | |
from ssd1306 import SSD1306_I2C | |
from random import getrandbits | |
# The pretty wiring guide is not accurate, | |
# these values come from the schematic | |
sda=4 | |
scl=5 | |
rst=16 | |
# this doesn't seem necessary on my board, but the | |
# datasheet says that this reset may be required | |
p_rst = Pin(rst, Pin.OUT) | |
p_rst.off() | |
p_rst.on() | |
bus = I2C(sda=Pin(sda), scl=Pin(scl)) | |
print("i2c devices:", bus.scan()) | |
oled = SSD1306_I2C(128, 32, bus) | |
l = list(range(0, 31, 8)) | |
fmt="0x{:08x}" | |
while True: | |
oled.fill(0) | |
oled.text("EHLO micropython", 0, l[0]) | |
oled.text(fmt.format(getrandbits(32)), 0, l[1]) | |
oled.text(fmt.format(getrandbits(32)), 0, l[2]) | |
oled.text(fmt.format(getrandbits(32)), 0, l[3]) | |
oled.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment