Difference between revisions of "SSD1306"
Jump to navigation
Jump to search
| Line 24: | Line 24: | ||
70: -- -- -- -- -- -- -- -- | 70: -- -- -- -- -- -- -- -- | ||
pip3 install adafruit-circuitpython-ssd1306 | pip3 install adafruit-circuitpython-ssd1306 | ||
| + | mkdir display | ||
| + | cd display | ||
| + | curl -sL https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin?raw=true -o font5x8.bin | ||
| + | </source> | ||
| + | <source lang='python'> | ||
| + | # Import all board pins. | ||
| + | from board import SCL, SDA | ||
| + | import busio | ||
| + | |||
| + | # Import the SSD1306 module. | ||
| + | import adafruit_ssd1306 | ||
| + | import time | ||
| + | |||
| + | # Create the I2C interface. | ||
| + | i2c = busio.I2C(SCL, SDA) | ||
| + | |||
| + | # Create the SSD1306 OLED class. | ||
| + | # The first two parameters are the pixel width and pixel height. Change these | ||
| + | # to the right size for your display! | ||
| + | xm=128 | ||
| + | ym=64 | ||
| + | oled= adafruit_ssd1306.SSD1306_I2C(xm, ym, i2c) | ||
| + | # Alternatively you can change the I2C address of the device with an addr parameter: | ||
| + | #display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31) | ||
| + | |||
| + | # Clear the display. Always call show after changing pixels to make the display | ||
| + | # update visible! | ||
| + | oled.fill(1) | ||
| + | oled.show() | ||
| + | time.sleep(1) | ||
| + | oled.fill(0) | ||
| + | oled.show() | ||
| + | for p in range(32,2,-2): | ||
| + | oled.fill(0) | ||
| + | for y in range(ym): | ||
| + | for x in range(xm): | ||
| + | if x%(2*p)==0 and y%p==0: | ||
| + | oled.pixel(x,y,1) | ||
| + | oled.show() | ||
| + | oled.fill(0) | ||
| + | oled.text("Good Evening",0,0,True) | ||
| + | oled.text("Dear Maria!",0,10,True) | ||
| + | oled.text("How are you?",0,20,True) | ||
| + | oled.show() | ||
| + | |||
</source> | </source> | ||