<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.sketching-with-hardware.org/wiki/index.php?action=history&amp;feed=atom&amp;title=128_x_32_OLED_Display</id>
	<title>128 x 32 OLED Display - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.sketching-with-hardware.org/wiki/index.php?action=history&amp;feed=atom&amp;title=128_x_32_OLED_Display"/>
	<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;action=history"/>
	<updated>2026-07-06T16:29:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1657&amp;oldid=prev</id>
		<title>Mayersven at 08:30, 14 June 2024</title>
		<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1657&amp;oldid=prev"/>
		<updated>2024-06-14T08:30:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:30, 14 June 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l155&quot;&gt;Line 155:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 155:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Actuator&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Actuators&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mayersven</name></author>
	</entry>
	<entry>
		<id>http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1651&amp;oldid=prev</id>
		<title>Mayersven at 08:27, 14 June 2024</title>
		<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1651&amp;oldid=prev"/>
		<updated>2024-06-14T08:27:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:27, 14 June 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l154&quot;&gt;Line 154:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 154:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         self.i2c.writevto(self.addr, self.write_list)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         self.i2c.writevto(self.addr, self.write_list)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Actuator]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mayersven</name></author>
	</entry>
	<entry>
		<id>http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1650&amp;oldid=prev</id>
		<title>Mayersven at 08:26, 14 June 2024</title>
		<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1650&amp;oldid=prev"/>
		<updated>2024-06-14T08:26:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:26, 14 June 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This is the specific tutorial for the 128 x 32 OLED Display (https://www.waveshare.com/0.91inch-oled-module.htm). For general information on OLED Displays, see the [[Tutorial Display]].&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= How to control it in MicroPython =  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= How to control it in MicroPython =  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mayersven</name></author>
	</entry>
	<entry>
		<id>http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1648&amp;oldid=prev</id>
		<title>Mayersven: Mayersven moved page SSD1306 Display to 128 x 32 OLED Display without leaving a redirect</title>
		<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1648&amp;oldid=prev"/>
		<updated>2024-06-14T08:24:17Z</updated>

		<summary type="html">&lt;p&gt;Mayersven moved page &lt;a href=&quot;/wiki/index.php?title=SSD1306_Display&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;SSD1306 Display (page does not exist)&quot;&gt;SSD1306 Display&lt;/a&gt; to &lt;a href=&quot;/wiki/128_x_32_OLED_Display&quot; title=&quot;128 x 32 OLED Display&quot;&gt;128 x 32 OLED Display&lt;/a&gt; without leaving a redirect&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:24, 14 June 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mayersven</name></author>
	</entry>
	<entry>
		<id>http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1647&amp;oldid=prev</id>
		<title>Mayersven: Created page with &quot;= How to control it in MicroPython =   The main.py shows the current time on the screen. &lt;syntaxhighlight lang=&quot;python&quot; line=&#039;line&#039;&gt; # main.py displaying the current time from...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.sketching-with-hardware.org/wiki/index.php?title=128_x_32_OLED_Display&amp;diff=1647&amp;oldid=prev"/>
		<updated>2024-06-14T08:14:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= How to control it in MicroPython =   The main.py shows the current time on the screen. &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;#039;line&amp;#039;&amp;gt; # main.py displaying the current time from...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= How to control it in MicroPython = &lt;br /&gt;
&lt;br /&gt;
The main.py shows the current time on the screen.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;#039;line&amp;#039;&amp;gt;&lt;br /&gt;
# main.py displaying the current time&lt;br /&gt;
from machine import Pin, SoftI2C&lt;br /&gt;
import ssd1306&lt;br /&gt;
from time import sleep&lt;br /&gt;
import utime&lt;br /&gt;
&lt;br /&gt;
# Initialize I2C interface with the correct pins for your setup&lt;br /&gt;
i2c = SoftI2C(scl=Pin(13), sda=Pin(12))&lt;br /&gt;
&lt;br /&gt;
# Initialize SSD1306 OLED display&lt;br /&gt;
oled_width = 128&lt;br /&gt;
oled_height = 32  # Adjusted for 128x32 OLED display&lt;br /&gt;
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    # Clear the display&lt;br /&gt;
    oled.fill(0)&lt;br /&gt;
    &lt;br /&gt;
    # Get the current time&lt;br /&gt;
    current_time = utime.localtime()&lt;br /&gt;
    time_str = &amp;#039;{:02}:{:02}:{:02}&amp;#039;.format(current_time[3], current_time[4], current_time[5])&lt;br /&gt;
    &lt;br /&gt;
    # Display the current time&lt;br /&gt;
    oled.text(&amp;#039;Current Time:&amp;#039;, 0, 0) # first line&lt;br /&gt;
    oled.text(time_str, 0, 10) # second line&lt;br /&gt;
    #oled.text(&amp;quot;EMPTY&amp;quot;, 0, 20) #third line&lt;br /&gt;
    &lt;br /&gt;
    # Update the display&lt;br /&gt;
    oled.show()&lt;br /&gt;
    &lt;br /&gt;
    # Wait for a bit before updating again&lt;br /&gt;
    sleep(1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ssd1306.py&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;#039;line&amp;#039;&amp;gt;&lt;br /&gt;
# ssd1306.py - MicroPython SSD1306 OLED driver, I2C and SPI interfaces&lt;br /&gt;
&lt;br /&gt;
from micropython import const&lt;br /&gt;
import framebuf&lt;br /&gt;
&lt;br /&gt;
# register definitions&lt;br /&gt;
SET_CONTRAST = const(0x81)&lt;br /&gt;
SET_ENTIRE_ON = const(0xa4)&lt;br /&gt;
SET_NORM_INV = const(0xa6)&lt;br /&gt;
SET_DISP = const(0xae)&lt;br /&gt;
SET_MEM_ADDR = const(0x20)&lt;br /&gt;
SET_COL_ADDR = const(0x21)&lt;br /&gt;
SET_PAGE_ADDR = const(0x22)&lt;br /&gt;
SET_DISP_START_LINE = const(0x40)&lt;br /&gt;
SET_SEG_REMAP = const(0xa0)&lt;br /&gt;
SET_MUX_RATIO = const(0xa8)&lt;br /&gt;
SET_COM_OUT_DIR = const(0xc0)&lt;br /&gt;
SET_DISP_OFFSET = const(0xd3)&lt;br /&gt;
SET_COM_PIN_CFG = const(0xda)&lt;br /&gt;
SET_DISP_CLK_DIV = const(0xd5)&lt;br /&gt;
SET_PRECHARGE = const(0xd9)&lt;br /&gt;
SET_VCOM_DESEL = const(0xdb)&lt;br /&gt;
SET_CHARGE_PUMP = const(0x8d)&lt;br /&gt;
&lt;br /&gt;
# Subclassing FrameBuffer provides support to the graphics primitives&lt;br /&gt;
class SSD1306(framebuf.FrameBuffer):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, width, height, external_vcc):&lt;br /&gt;
        self.width = width&lt;br /&gt;
        self.height = height&lt;br /&gt;
        self.external_vcc = external_vcc&lt;br /&gt;
        self.pages = self.height // 8&lt;br /&gt;
        self.buffer = bytearray(self.pages * self.width)&lt;br /&gt;
        super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB)&lt;br /&gt;
        self.init_display()&lt;br /&gt;
&lt;br /&gt;
    def init_display(self):&lt;br /&gt;
        for cmd in (&lt;br /&gt;
            SET_DISP | 0x00,  # display off&lt;br /&gt;
            # address setting&lt;br /&gt;
            SET_MEM_ADDR, 0x00,  # horizontal&lt;br /&gt;
            # resolution and layout&lt;br /&gt;
            SET_DISP_START_LINE | 0x00,&lt;br /&gt;
            SET_SEG_REMAP | 0x01,  # column addr 127 mapped to SEG0&lt;br /&gt;
            SET_MUX_RATIO, self.height - 1,&lt;br /&gt;
            SET_COM_OUT_DIR | 0x08,  # scan from COM[N] to COM0&lt;br /&gt;
            SET_DISP_OFFSET, 0x00,&lt;br /&gt;
            SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,&lt;br /&gt;
            # timing and driving scheme&lt;br /&gt;
            SET_DISP_CLK_DIV, 0x80,&lt;br /&gt;
            SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,&lt;br /&gt;
            SET_VCOM_DESEL, 0x30,  # 0.83*Vcc&lt;br /&gt;
            # display&lt;br /&gt;
            SET_CONTRAST, 0xff,  # maximum&lt;br /&gt;
            SET_ENTIRE_ON,  # output follows RAM contents&lt;br /&gt;
            SET_NORM_INV,  # not inverted&lt;br /&gt;
            # charge pump&lt;br /&gt;
            SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,&lt;br /&gt;
            SET_DISP | 0x01):  # display on&lt;br /&gt;
            self.write_cmd(cmd)&lt;br /&gt;
        self.fill(0)&lt;br /&gt;
        self.show()&lt;br /&gt;
&lt;br /&gt;
    def poweroff(self):&lt;br /&gt;
        self.write_cmd(SET_DISP | 0x00)&lt;br /&gt;
&lt;br /&gt;
    def poweron(self):&lt;br /&gt;
        self.write_cmd(SET_DISP | 0x01)&lt;br /&gt;
&lt;br /&gt;
    def contrast(self, contrast):&lt;br /&gt;
        self.write_cmd(SET_CONTRAST)&lt;br /&gt;
        self.write_cmd(contrast)&lt;br /&gt;
&lt;br /&gt;
    def invert(self, invert):&lt;br /&gt;
        self.write_cmd(SET_NORM_INV | (invert &amp;amp; 1))&lt;br /&gt;
&lt;br /&gt;
    def show(self):&lt;br /&gt;
        xpos0 = 0&lt;br /&gt;
        xpos1 = self.width - 1&lt;br /&gt;
        self.write_cmd(SET_COL_ADDR)&lt;br /&gt;
        self.write_cmd(xpos0)&lt;br /&gt;
        self.write_cmd(xpos1)&lt;br /&gt;
        self.write_cmd(SET_PAGE_ADDR)&lt;br /&gt;
        self.write_cmd(0)&lt;br /&gt;
        self.write_cmd(self.pages - 1)&lt;br /&gt;
        self.write_data(self.buffer)&lt;br /&gt;
&lt;br /&gt;
    def write_cmd(self, cmd):&lt;br /&gt;
        raise NotImplementedError&lt;br /&gt;
&lt;br /&gt;
    def write_data(self, buf):&lt;br /&gt;
        raise NotImplementedError&lt;br /&gt;
&lt;br /&gt;
class SSD1306_I2C(SSD1306):&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, width, height, i2c, addr=0x3c, external_vcc=False):&lt;br /&gt;
        self.i2c = i2c&lt;br /&gt;
        self.addr = addr&lt;br /&gt;
        self.temp = bytearray(2)&lt;br /&gt;
        self.write_list = [b&amp;#039;\x40&amp;#039;, None]  # Co=0, D/C#=1&lt;br /&gt;
        super().__init__(width, height, external_vcc)&lt;br /&gt;
&lt;br /&gt;
    def write_cmd(self, cmd):&lt;br /&gt;
        self.temp[0] = 0x80  # Co=1, D/C#=0&lt;br /&gt;
        self.temp[1] = cmd&lt;br /&gt;
        self.i2c.writeto(self.addr, self.temp)&lt;br /&gt;
&lt;br /&gt;
    def write_data(self, buf):&lt;br /&gt;
        self.write_list[1] = buf&lt;br /&gt;
        self.i2c.writevto(self.addr, self.write_list)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mayersven</name></author>
	</entry>
</feed>