SSD1306

From BITPlan Wiki
Revision as of 20:11, 3 February 2020 by Wf (talk | contribs)
Jump to navigation Jump to search
[edit]
Color  SSD1306  Raspberry Pi
yellow SCL     	GPIO 3 / SCL (Pin 5)
orange SDA 	GPIO 2 / SDA (Pin 3)
Red    VCC / V 	3,3V (pin 1)
Black  GND     	GND (Pin 6)
[edit]
sudo raspi-config
# enable i2c in Interfacing options
sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
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
# 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()