24 #ifndef _Adafruit_SSD1306_H_ 25 #define _Adafruit_SSD1306_H_ 29 #define SSD1306_128_32 30 //#define SSD1306_96_16 31 // This establishes the screen dimensions in old Adafruit_SSD1306 sketches 38 #if defined(ARDUINO_STM32_FEATHER) 39 typedef class HardwareSPI SPIClass;
42 #include <Adafruit_GFX.h> 47 typedef volatile uint8_t PortReg;
48 typedef uint8_t PortMask;
50 #elif defined(__SAM3X8E__) 51 typedef volatile RwReg PortReg;
52 typedef uint32_t PortMask;
54 #elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \ 55 !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_RP2040) 56 typedef volatile uint32_t PortReg;
57 typedef uint32_t PortMask;
65 #ifndef NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY 66 #define BLACK SSD1306_BLACK 67 #define WHITE SSD1306_WHITE 68 #define INVERSE SSD1306_INVERSE 70 #define SSD1306_BLACK 0 72 #define SSD1306_WHITE 1 73 #define SSD1306_INVERSE 2 75 #define SSD1306_MEMORYMODE 0x20 76 #define SSD1306_COLUMNADDR 0x21 77 #define SSD1306_PAGEADDR 0x22 78 #define SSD1306_SETCONTRAST 0x81 79 #define SSD1306_CHARGEPUMP 0x8D 80 #define SSD1306_SEGREMAP 0xA0 81 #define SSD1306_DISPLAYALLON_RESUME 0xA4 82 #define SSD1306_DISPLAYALLON 0xA5 83 #define SSD1306_NORMALDISPLAY 0xA6 84 #define SSD1306_INVERTDISPLAY 0xA7 85 #define SSD1306_SETMULTIPLEX 0xA8 86 #define SSD1306_DISPLAYOFF 0xAE 87 #define SSD1306_DISPLAYON 0xAF 88 #define SSD1306_COMSCANINC 0xC0 89 #define SSD1306_COMSCANDEC 0xC8 90 #define SSD1306_SETDISPLAYOFFSET 0xD3 91 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 92 #define SSD1306_SETPRECHARGE 0xD9 93 #define SSD1306_SETCOMPINS 0xDA 94 #define SSD1306_SETVCOMDETECT 0xDB 96 #define SSD1306_SETLOWCOLUMN 0x00 97 #define SSD1306_SETHIGHCOLUMN 0x10 98 #define SSD1306_SETSTARTLINE 0x40 100 #define SSD1306_EXTERNALVCC 0x01 101 #define SSD1306_SWITCHCAPVCC 0x02 103 #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 104 #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 105 #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 106 #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A 107 #define SSD1306_DEACTIVATE_SCROLL 0x2E 108 #define SSD1306_ACTIVATE_SCROLL 0x2F 109 #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 112 #if defined SSD1306_128_64 113 #define SSD1306_LCDWIDTH 128 114 #define SSD1306_LCDHEIGHT 64 116 #if defined SSD1306_128_32 117 #define SSD1306_LCDWIDTH 128 118 #define SSD1306_LCDHEIGHT 32 120 #if defined SSD1306_96_16 121 #define SSD1306_LCDWIDTH 96 122 #define SSD1306_LCDHEIGHT 16 133 int8_t rst_pin = -1, uint32_t clkDuring = 400000UL,
134 uint32_t clkAfter = 100000UL);
136 int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
138 int8_t rst_pin, int8_t cs_pin, uint32_t bitrate = 8000000UL);
142 int8_t rst_pin, int8_t cs_pin);
149 bool reset =
true,
bool periphBegin =
true);
154 void drawPixel(int16_t x, int16_t y, uint16_t color);
155 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
156 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
163 bool getPixel(int16_t x, int16_t y);
167 inline void SPIwrite(uint8_t d) __attribute__((always_inline));
191 PortReg *mosiPort, *clkPort, *dcPort, *csPort;
192 PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
199 #if defined(SPI_HAS_TRANSACTION) 202 SPISettings spiSettings;
206 #endif // _Adafruit_SSD1306_H_ int8_t dcPin
(Data Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:185
void startscrolldiagright(uint8_t start, uint8_t stop)
Activate a diagonal scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1097
#define SSD1306_SWITCHCAPVCC
Gen. display voltage from 3.3V.
Definition: Adafruit_SSD1306.h:101
void display(void)
Push data currently in RAM to SSD1306 display.
Definition: Adafruit_SSD1306.cpp:993
~Adafruit_SSD1306(void)
Destructor for Adafruit_SSD1306 object.
Definition: Adafruit_SSD1306.cpp:339
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 ...
Definition: Adafruit_SSD1306.cpp:642
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...
Definition: Adafruit_SSD1306.cpp:417
void stopscroll(void)
Cease a previously-begun scrolling action.
Definition: Adafruit_SSD1306.cpp:1144
int8_t mosiPin
Definition: Adafruit_SSD1306.h:182
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...
Definition: Adafruit_SSD1306.cpp:700
void SPIwrite(uint8_t d) __attribute__((always_inline))
Write a single byte to the SPI port.
Definition: Adafruit_SSD1306.cpp:360
int8_t csPin
(Chip Select Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:187
void clearDisplay(void)
Clear contents of display buffer (set all pixels to off).
Definition: Adafruit_SSD1306.cpp:680
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,drawFastVLine.
Definition: Adafruit_SSD1306.cpp:749
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.
Definition: Adafruit_SSD1306.cpp:172
void ssd1306_command1(uint8_t c)
Issue single command to SSD1306, using I2C or hard/soft SPI as needed. Because command calls are ofte...
Definition: Adafruit_SSD1306.cpp:393
TwoWire * wire
Definition: Adafruit_SSD1306.h:175
SPIClass * spi
Definition: Adafruit_SSD1306.h:173
uint8_t * getBuffer(void)
Get base address of display buffer for direct reading or writing.
Definition: Adafruit_SSD1306.cpp:982
void dim(bool dim)
Dim the display.
Definition: Adafruit_SSD1306.cpp:1179
int8_t clkPin
(Clock Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:184
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...
Definition: Adafruit_SSD1306.cpp:800
int8_t vccstate
VCC selection, set by begin method.
Definition: Adafruit_SSD1306.h:180
void ssd1306_command(uint8_t c)
Issue a single low-level command directly to the SSD1306 display, bypassing the library.
Definition: Adafruit_SSD1306.cpp:450
int8_t page_end
not used
Definition: Adafruit_SSD1306.h:181
bool getPixel(int16_t x, int16_t y)
Return color of a single pixel in display buffer.
Definition: Adafruit_SSD1306.cpp:955
uint8_t contrast
normal contrast setting for this device
Definition: Adafruit_SSD1306.h:198
void startscrolldiagleft(uint8_t start, uint8_t stop)
Activate alternate diagonal scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1123
int8_t rstPin
Display reset pin assignment. Set during construction.
Definition: Adafruit_SSD1306.h:188
void startscrollright(uint8_t start, uint8_t stop)
Activate a right-handed scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1051
void invertDisplay(bool i)
Enable or disable display invert mode (white-on-black vs black-on-white).
Definition: Adafruit_SSD1306.cpp:1165
int8_t i2caddr
I2C address initialized when begin method is called.
Definition: Adafruit_SSD1306.h:179
void startscrollleft(uint8_t start, uint8_t stop)
Activate a left-handed scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1074
uint8_t * buffer
Definition: Adafruit_SSD1306.h:177
Class that stores state and functions for interacting with SSD1306 OLED displays. ...
Definition: Adafruit_SSD1306.h:129
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.
Definition: Adafruit_SSD1306.cpp:493
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.
Definition: Adafruit_SSD1306.cpp:848