Raspberry Pi Pico Python SDK
7 HEIGHT =
8
9 i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=200000)
(default I2C0 pins)
10
print("I2C Address
11
print("I2C Configuration:
12
13
14 oled = SH1106_I2C(WIDTH, HEIGHT, i2c)
15
16
# Raspberry Pi logo as 32x32 bytearray
17 buffer =
@\x80\x01\x01\x80\x80\x01\x11\x88\x80\x01\x05\xa0\x80\x00\x83\xc1\x00\x00C\xe3\x00\x00
~\xfc\x00\x00L'\x00\x00\x9c\x11\x00\x00\xbf\xfd\x00\x00\xe1\x87\x00\x01\xc1\x83\x80\x02A
\x82@\x02A\x82@\x02\xc1\xc2@\x02\xf6>\xc0\x01\xfc
=\x80\x01\x18\x18\x80\x01\x88\x10\x80\x00\x8c!\x00\x00\x87\xf1\x00\x00\x7f\xf6\x00\x00
8\x1c\x00\x00\x0c
18
19
# Load the raspberry pi logo into the framebuffer (the image is 32x32)
20 fb = framebuf.FrameBuffer(buffer, 32, 32, framebuf.MONO_HLSB)
21
22
# Clear the oled display in case it has junk on it.
23 oled.fill(0)
24
25
# Blit the image from the framebuffer to the oled display
26 oled.blit(fb, 96, 0)
27
28
# Add some text
29
oled.text("Raspberry
30 oled.text("Pico",5,15)
31
32
# Finally update the oled display so the image & text is displayed
33 oled.show()
sh1106.py
SH1106 Driver Obtained from
Pico MicroPython Examples:
1
#
2
# MicroPython SH1106 OLED driver, I2C and SPI interfaces
3
#
4
# The MIT License (MIT)
5
#
6
# Copyright (c) 2016 Radomir Dopieralski (@deshipu),
7
#
8
#
9
# Permission is hereby granted, free of charge, to any person obtaining a copy
10
# of this software and associated documentation files (the "Software"), to deal
11
# in the Software without restriction, including without limitation the rights
12
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
# copies of the Software, and to permit persons to whom the Software is
14
# furnished to do so, subject to the following conditions:
15
#
16
# The above copyright notice and this permission notice shall be included in
17
# all copies or substantial portions of the Software.
18
#
19
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Using a SH1106-based OLED graphics display
32
:
"+hex(i2c.scan()[0]).upper())
"+str(i2c))
bytearray(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|?\x00\x01\x86
\x00\x00\x03\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
Pi",5,5)
https://github.com/robert-hh/SH1106
https://github.com/raspberrypi/pico-micropython-examples/tree/master/i2c/1106oled/sh1106.py
2017 Robert Hammelrath (@robert-hh)
# oled display height
# Init I2C using pins GP8 & GP9
# Display device address
# Display I2C config
# Init oled display
Lines 1 - 227
35
Need help?
Do you have a question about the Pico Python SDK and is the answer not in the manual?