54#ifndef _Adafruit_SSD1306_H_
55#define _Adafruit_SSD1306_H_
68#if defined(ARDUINO_STM32_FEATHER)
69typedef class HardwareSPI SPIClass;
77typedef volatile uint8_t PortReg;
78typedef uint8_t PortMask;
80#elif defined(__SAM3X8E__)
81typedef volatile RwReg PortReg;
82typedef uint32_t PortMask;
84#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && !defined(ARDUINO_ARCH_MBED) && \
85 !defined(ARDUINO_ARCH_RP2040)
86typedef volatile uint32_t PortReg;
87typedef uint32_t PortMask;
95#ifndef NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY
96# define BLACK SSD1306_BLACK
97# define WHITE SSD1306_WHITE
98# define INVERSE SSD1306_INVERSE
101#define SSD1306_BLACK 0
102#define SSD1306_WHITE 1
103#define SSD1306_INVERSE 2
105#define SSD1306_MEMORYMODE 0x20
106#define SSD1306_COLUMNADDR 0x21
107#define SSD1306_PAGEADDR 0x22
108#define SSD1306_SETCONTRAST 0x81
109#define SSD1306_CHARGEPUMP 0x8D
110#define SSD1306_SEGREMAP 0xA0
111#define SSD1306_DISPLAYALLON_RESUME 0xA4
112#define SSD1306_DISPLAYALLON 0xA5
113#define SSD1306_NORMALDISPLAY 0xA6
114#define SSD1306_INVERTDISPLAY 0xA7
115#define SSD1306_SETMULTIPLEX 0xA8
116#define SSD1306_DISPLAYOFF 0xAE
117#define SSD1306_DISPLAYON 0xAF
118#define SSD1306_COMSCANINC 0xC0
119#define SSD1306_COMSCANDEC 0xC8
120#define SSD1306_SETDISPLAYOFFSET 0xD3
121#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
122#define SSD1306_SETPRECHARGE 0xD9
123#define SSD1306_SETCOMPINS 0xDA
124#define SSD1306_SETVCOMDETECT 0xDB
126#define SSD1306_SETLOWCOLUMN 0x00
127#define SSD1306_SETHIGHCOLUMN 0x10
128#define SSD1306_SETSTARTLINE 0x40
130#define SSD1306_EXTERNALVCC 0x01
131#define SSD1306_SWITCHCAPVCC 0x02
133#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
134#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
135#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
136#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
137#define SSD1306_DEACTIVATE_SCROLL 0x2E
138#define SSD1306_ACTIVATE_SCROLL 0x2F
139#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
142#if defined SSD1306_128_64
143# define SSD1306_LCDWIDTH 128
144# define SSD1306_LCDHEIGHT 64
146#if defined SSD1306_128_32
147# define SSD1306_LCDWIDTH 128
148# define SSD1306_LCDHEIGHT 32
150#if defined SSD1306_96_16
151# define SSD1306_LCDWIDTH 96
152# define SSD1306_LCDHEIGHT 16
164 uint8_t w, uint8_t h, TwoWire* twi = &Wire, int8_t rst_pin = -1,
165 uint32_t clkDuring = 400000UL, uint32_t clkAfter = 100000UL);
167 uint8_t w, uint8_t h, int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin,
170 uint8_t w, uint8_t h, SPIClass*
spi, int8_t dc_pin, int8_t rst_pin, int8_t cs_pin,
171 uint32_t bitrate = 8000000UL);
175 int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
183 bool periphBegin =
true);
188 void drawPixel(int16_t
x, int16_t
y, uint16_t color);
189 virtual void drawFastHLine(int16_t
x, int16_t
y, int16_t w, uint16_t color);
190 virtual void drawFastVLine(int16_t
x, int16_t
y, int16_t h, uint16_t color);
201 inline void SPIwrite(uint8_t d) __attribute__((always_inline));
224 PortReg *mosiPort, *clkPort, *dcPort, *csPort;
225 PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
232#if defined(SPI_HAS_TRANSACTION)
235 SPISettings spiSettings;
Adafruit SSD1306 dependency code.
#define SSD1306_SWITCHCAPVCC
Gen. display voltage from 3.3V.
A generic graphics superclass that can handle all sorts of drawing. At a.
Class that stores state and functions for interacting with SSD1306 OLED displays.
int8_t i2caddr
I2C address initialized when begin method is called.
void ssd1306_command1(uint8_t c)
Issue single command to SSD1306, using I2C or hard/soft SPI as needed. Because command calls are ofte...
void display(void)
Push data currently in RAM to SSD1306 display.
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Draw a vertical line. This is also invoked by the Adafruit_GFX library in generating many higher-leve...
uint8_t * getBuffer(void)
Get base address of display buffer for direct reading or writing.
void dim(bool dim)
Dim the display.
int8_t dcPin
(Data Pin) set when using SPI set during construction.
void invertDisplay(bool i)
Enable or disable display invert mode (white-on-black vs black-on-white).
void startscrollleft(uint8_t start, uint8_t stop)
Activate a left-handed scroll for all or part of the display.
~Adafruit_SSD1306(void)
Destructor for Adafruit_SSD1306 object.
Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi=&Wire, int8_t rst_pin=-1, uint32_t clkDuring=400000UL, uint32_t clkAfter=100000UL)
Constructor for I2C-interfaced SSD1306 displays.
void startscrollright(uint8_t start, uint8_t stop)
Activate a right-handed scroll for all or part of the display.
int8_t rstPin
Display reset pin assignment. Set during construction.
int8_t csPin
(Chip Select Pin) set when using SPI set during construction.
void ssd1306_commandList(const uint8_t *c, uint8_t n)
Issue list of commands to SSD1306, same rules as above re: transactions. This is a protected function...
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Draw a horizontal line. This is also invoked by the Adafruit_GFX library in generating many higher-le...
bool getPixel(int16_t x, int16_t y)
Return color of a single pixel in display buffer.
void startscrolldiagleft(uint8_t start, uint8_t stop)
Activate alternate diagonal scroll for all or part of the display.
void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color)
Draw a vertical line with a width and color. Used by public method drawFastHLine,drawFastVLine.
void ssd1306_command(uint8_t c)
Issue a single low-level command directly to the SSD1306 display, bypassing the library.
bool begin(uint8_t switchvcc=SSD1306_SWITCHCAPVCC, uint8_t i2caddr=0, bool reset=true, bool periphBegin=true)
Allocate RAM for image buffer, initialize peripherals and pins.
void stopscroll(void)
Cease a previously-begun scrolling action.
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color)
Draw a horizontal line with a width and color. Used by public methods drawFastHLine,...
int8_t clkPin
(Clock Pin) set when using SPI set during construction.
void startscrolldiagright(uint8_t start, uint8_t stop)
Activate a diagonal scroll for all or part of the display.
int8_t vccstate
VCC selection, set by begin method.
void drawPixel(int16_t x, int16_t y, uint16_t color)
Set/clear/invert a single pixel. This is also invoked by the Adafruit_GFX library in generating many ...
uint8_t contrast
normal contrast setting for this device
void SPIwrite(uint8_t d) __attribute__((always_inline))
Write a single byte to the SPI port.
void clearDisplay(void)
Clear contents of display buffer (set all pixels to off).