sh1106 — control of SH1106 based displays

This module provides a class to control SH1106 display drivers, which is used by the internal display on the Kookaberry. The class is derived from the framebuf.FrameBuffer class so inherits all drawing methods from that class. The display is double-buffered, meaning that any modifications to the pixels are only updated on the physical display when the show() method is called.

Example usage:

import kooka

# print some text (will display it immediately)
kooka.display.print('hello', 1234)

# turn on a pixel and show it
kooka.display.pixel(0, 0, 1)
kooka.display.show()

class SH1106_SPI

This class represents a connection to the display. It is derived from the framebuf.FrameBuffer class so inherits all drawing methods from that class.

Constructors

class sh1106.SH1106_SPI(width, height, spi, cs, dc)

Creates a new instance of this class with the following parameters:

  • width and height are the pixel dimensions of the display.

  • spi is the machine.SPI object connected to the display.

  • cs and dc are the machine.Pin objects corresponding to the chip-select and data-command lines respectively.

When the object is constructed the display is turned on and the pixels all cleared.

Methods

SH1106_SPI.init_display()

Initialises and clears the display.

SH1106_SPI.poweroff()

Turns off the display.

SH1106_SPI.poweron()

Turns on the display.

SH1106_SPI.contrast(value)

Sets the contrast of the display to the given value, between 0 and 255 inclusive.

SH1106_SPI.invert(value)

If value is true then the display colours are inverted, otherwise they are normal.

SH1106_SPI.show()

Draw the internal display buffer to the physical display.

SH1106_SPI.print(\*args, sep= ' ')

This method is intedend to be equivalent to the built-in print() method, but it prints to the display instead of the serial prompt.

The given arguments are converted to strings and then drawn to the display using the current font (defaults to 8x8 font). The display is scrolled up when text is drawn to the last line of the display.