Adafruit SH110x Arduino Library
Public Member Functions | Protected Attributes | List of all members
Adafruit_SH110X Class Referenceabstract

Class that stores state and functions for interacting with SH110X OLED displays. Not instantiatable - use a subclass! More...

#include <Adafruit_SH110X.h>

Inheritance diagram for Adafruit_SH110X:
Adafruit_SH1106G Adafruit_SH1107

Public Member Functions

 Adafruit_SH110X (uint16_t w, uint16_t h, TwoWire *twi=&Wire, int8_t rst_pin=-1, uint32_t preclk=400000, uint32_t postclk=100000)
 Constructor for I2C-interfaced SH110X displays. More...
 
 Adafruit_SH110X (uint16_t w, uint16_t h, int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin, int8_t cs_pin)
 Constructor for SPI SH110X displays, using software (bitbang) SPI. More...
 
 Adafruit_SH110X (uint16_t w, uint16_t h, SPIClass *spi, int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, uint32_t bitrate=8000000UL)
 Constructor for SPI SH110X displays, using native hardware SPI. More...
 
virtual ~Adafruit_SH110X (void)=0
 Destructor for Adafruit_SH110X object.
 
void display (void)
 Push data currently in RAM to SH110X display. More...
 

Protected Attributes

uint8_t _page_start_offset = 0
 

Detailed Description

Class that stores state and functions for interacting with SH110X OLED displays. Not instantiatable - use a subclass!

Constructor & Destructor Documentation

◆ Adafruit_SH110X() [1/3]

Adafruit_SH110X::Adafruit_SH110X ( uint16_t  w,
uint16_t  h,
TwoWire *  twi = &Wire,
int8_t  rst_pin = -1,
uint32_t  clkDuring = 400000,
uint32_t  clkAfter = 100000 
)

Constructor for I2C-interfaced SH110X displays.

Parameters
wDisplay width in pixels
hDisplay height in pixels
twiPointer to an existing TwoWire instance (e.g. &Wire, the microcontroller's primary I2C bus).
rst_pinReset pin (using Arduino pin numbering), or -1 if not used (some displays might be wired to share the microcontroller's reset pin).
clkDuringSpeed (in Hz) for Wire transmissions in SH110X library calls. Defaults to 400000 (400 KHz), a known 'safe' value for most microcontrollers, and meets the SH110X datasheet spec. Some systems can operate I2C faster (800 KHz for ESP32, 1 MHz for many other 32-bit MCUs), and some (perhaps not all) SH110X's can work with this – so it's optionally be specified here and is not a default behavior. (Ignored if using pre-1.5.7 Arduino software, which operates I2C at a fixed 100 KHz.)
clkAfterSpeed (in Hz) for Wire transmissions following SH110X library calls. Defaults to 100000 (100 KHz), the default Arduino Wire speed. This is done rather than leaving it at the 'during' speed because other devices on the I2C bus might not be compatible with the faster rate. (Ignored if using pre-1.5.7 Arduino software, which operates I2C at a fixed 100 KHz.)
Note
Call the object's begin() function before use – buffer allocation is performed there!

◆ Adafruit_SH110X() [2/3]

Adafruit_SH110X::Adafruit_SH110X ( uint16_t  w,
uint16_t  h,
int8_t  mosi_pin,
int8_t  sclk_pin,
int8_t  dc_pin,
int8_t  rst_pin,
int8_t  cs_pin 
)

Constructor for SPI SH110X displays, using software (bitbang) SPI.

Parameters
wDisplay width in pixels
hDisplay height in pixels
mosi_pinMOSI (master out, slave in) pin (using Arduino pin numbering). This transfers serial data from microcontroller to display.
sclk_pinSCLK (serial clock) pin (using Arduino pin numbering). This clocks each bit from MOSI.
dc_pinData/command pin (using Arduino pin numbering), selects whether display is receiving commands (low) or data (high).
rst_pinReset pin (using Arduino pin numbering), or -1 if not used (some displays might be wired to share the microcontroller's reset pin).
cs_pinChip-select pin (using Arduino pin numbering) for sharing the bus with other devices. Active low.
Note
Call the object's begin() function before use – buffer allocation is performed there!

◆ Adafruit_SH110X() [3/3]

Adafruit_SH110X::Adafruit_SH110X ( uint16_t  w,
uint16_t  h,
SPIClass *  spi,
int8_t  dc_pin,
int8_t  rst_pin,
int8_t  cs_pin,
uint32_t  bitrate = 8000000UL 
)

Constructor for SPI SH110X displays, using native hardware SPI.

Parameters
wDisplay width in pixels
hDisplay height in pixels
spiPointer to an existing SPIClass instance (e.g. &SPI, the microcontroller's primary SPI bus).
dc_pinData/command pin (using Arduino pin numbering), selects whether display is receiving commands (low) or data (high).
rst_pinReset pin (using Arduino pin numbering), or -1 if not used (some displays might be wired to share the microcontroller's reset pin).
cs_pinChip-select pin (using Arduino pin numbering) for sharing the bus with other devices. Active low.
bitrateSPI clock rate for transfers to this display. Default if unspecified is 8000000UL (8 MHz).
Note
Call the object's begin() function before use – buffer allocation is performed there!

Member Function Documentation

◆ display()

void Adafruit_SH110X::display ( void  )

Push data currently in RAM to SH110X display.

Note
Drawing operations are not visible until this function is called. Call after each graphics command, or after a whole set of graphics commands, as best needed by one's own application.

Member Data Documentation

◆ _page_start_offset

uint8_t Adafruit_SH110X::_page_start_offset = 0
protected

some displays are 'inset' in memory, so we have to skip some memory to display


The documentation for this class was generated from the following files: