Adafruit SH110x Arduino Library
Public Member Functions | List of all members
Adafruit_SH1107 Class Reference

Class that stores state and functions for interacting with SH1107 OLED displays. More...

#include <Adafruit_SH110X.h>

Inheritance diagram for Adafruit_SH1107:
Adafruit_SH110X

Public Member Functions

 Adafruit_SH1107 (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 SH1107 displays. More...
 
 Adafruit_SH1107 (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 SH1107 displays, using software (bitbang) SPI. More...
 
 Adafruit_SH1107 (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 SH1107 displays, using native hardware SPI. More...
 
 ~Adafruit_SH1107 (void)
 Destructor for Adafruit_SH1107 object.
 
bool begin (uint8_t i2caddr=0x3C, bool reset=true)
 Allocate RAM for image buffer, initialize peripherals and pins. More...
 
- Public Member Functions inherited from Adafruit_SH110X
 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...
 

Additional Inherited Members

- Protected Attributes inherited from Adafruit_SH110X
uint8_t _page_start_offset = 0
 

Detailed Description

Class that stores state and functions for interacting with SH1107 OLED displays.

Constructor & Destructor Documentation

◆ Adafruit_SH1107() [1/3]

Adafruit_SH1107::Adafruit_SH1107 ( 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 SH1107 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_SH1107() [2/3]

Adafruit_SH1107::Adafruit_SH1107 ( 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 SH1107 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_SH1107() [3/3]

Adafruit_SH1107::Adafruit_SH1107 ( 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 SH1107 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

◆ begin()

bool Adafruit_SH1107::begin ( uint8_t  addr = 0x3C,
bool  reset = true 
)

Allocate RAM for image buffer, initialize peripherals and pins.

Parameters
addrI2C address of corresponding SH110X display (or pass 0 to use default of 0x3C for 128x32 display, 0x3D for all others). SPI displays (hardware or software) do not use addresses, but this argument is still required (pass 0 or any value really, it will simply be ignored). Default if unspecified is 0.
resetIf true, and if the reset pin passed to the constructor is valid, a hard reset will be performed before initializing the display. If using multiple SH110X displays on the same bus, and if they all share the same reset pin, you should only pass true on the first display being initialized, false on all others, else the already-initialized displays would be reset. Default if unspecified is true.
Returns
true on successful allocation/init, false otherwise. Well-behaved code should check the return value before proceeding.
Note
MUST call this function before any drawing or updates!

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