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(ARDUINO_ARCH_RTTHREAD) 56 #elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \ 57 !defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_RP2040) 58 typedef volatile uint32_t PortReg;
59 typedef uint32_t PortMask;
67 #ifndef NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY 68 #define BLACK SSD1306_BLACK 69 #define WHITE SSD1306_WHITE 70 #define INVERSE SSD1306_INVERSE 72 #define SSD1306_BLACK 0 74 #define SSD1306_WHITE 1 75 #define SSD1306_INVERSE 2 77 #define SSD1306_MEMORYMODE 0x20 78 #define SSD1306_COLUMNADDR 0x21 79 #define SSD1306_PAGEADDR 0x22 80 #define SSD1306_SETCONTRAST 0x81 81 #define SSD1306_CHARGEPUMP 0x8D 82 #define SSD1306_SEGREMAP 0xA0 83 #define SSD1306_DISPLAYALLON_RESUME 0xA4 84 #define SSD1306_DISPLAYALLON 0xA5 85 #define SSD1306_NORMALDISPLAY 0xA6 86 #define SSD1306_INVERTDISPLAY 0xA7 87 #define SSD1306_SETMULTIPLEX 0xA8 88 #define SSD1306_DISPLAYOFF 0xAE 89 #define SSD1306_DISPLAYON 0xAF 90 #define SSD1306_COMSCANINC 0xC0 91 #define SSD1306_COMSCANDEC 0xC8 92 #define SSD1306_SETDISPLAYOFFSET 0xD3 93 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 94 #define SSD1306_SETPRECHARGE 0xD9 95 #define SSD1306_SETCOMPINS 0xDA 96 #define SSD1306_SETVCOMDETECT 0xDB 98 #define SSD1306_SETLOWCOLUMN 0x00 99 #define SSD1306_SETHIGHCOLUMN 0x10 100 #define SSD1306_SETSTARTLINE 0x40 102 #define SSD1306_EXTERNALVCC 0x01 103 #define SSD1306_SWITCHCAPVCC 0x02 105 #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 106 #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 107 #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 108 #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A 109 #define SSD1306_DEACTIVATE_SCROLL 0x2E 110 #define SSD1306_ACTIVATE_SCROLL 0x2F 111 #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 114 #if defined SSD1306_128_64 115 #define SSD1306_LCDWIDTH 128 116 #define SSD1306_LCDHEIGHT 64 118 #if defined SSD1306_128_32 119 #define SSD1306_LCDWIDTH 128 120 #define SSD1306_LCDHEIGHT 32 122 #if defined SSD1306_96_16 123 #define SSD1306_LCDWIDTH 96 124 #define SSD1306_LCDHEIGHT 16 135 int8_t rst_pin = -1, uint32_t clkDuring = 400000UL,
136 uint32_t clkAfter = 100000UL);
138 int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
140 int8_t rst_pin, int8_t cs_pin, uint32_t bitrate = 8000000UL);
144 int8_t rst_pin, int8_t cs_pin);
151 bool reset =
true,
bool periphBegin =
true);
156 void drawPixel(int16_t x, int16_t y, uint16_t color);
157 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
158 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
165 bool getPixel(int16_t x, int16_t y);
169 inline void SPIwrite(uint8_t d) __attribute__((always_inline));
193 PortReg *mosiPort, *clkPort, *dcPort, *csPort;
194 PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
201 #if defined(SPI_HAS_TRANSACTION) 204 SPISettings spiSettings;
208 #endif // _Adafruit_SSD1306_H_ int8_t dcPin
(Data Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:187
void startscrolldiagright(uint8_t start, uint8_t stop)
Activate a diagonal scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1100
#define SSD1306_SWITCHCAPVCC
Gen. display voltage from 3.3V.
Definition: Adafruit_SSD1306.h:103
void display(void)
Push data currently in RAM to SSD1306 display.
Definition: Adafruit_SSD1306.cpp:996
~Adafruit_SSD1306(void)
Destructor for Adafruit_SSD1306 object.
Definition: Adafruit_SSD1306.cpp:342
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:645
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:420
void stopscroll(void)
Cease a previously-begun scrolling action.
Definition: Adafruit_SSD1306.cpp:1147
int8_t mosiPin
Definition: Adafruit_SSD1306.h:184
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:703
void SPIwrite(uint8_t d) __attribute__((always_inline))
Write a single byte to the SPI port.
Definition: Adafruit_SSD1306.cpp:363
int8_t csPin
(Chip Select Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:189
void clearDisplay(void)
Clear contents of display buffer (set all pixels to off).
Definition: Adafruit_SSD1306.cpp:683
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:752
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:175
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:396
TwoWire * wire
Definition: Adafruit_SSD1306.h:177
SPIClass * spi
Definition: Adafruit_SSD1306.h:175
uint8_t * getBuffer(void)
Get base address of display buffer for direct reading or writing.
Definition: Adafruit_SSD1306.cpp:985
void dim(bool dim)
Dim the display.
Definition: Adafruit_SSD1306.cpp:1182
int8_t clkPin
(Clock Pin) set when using SPI set during construction.
Definition: Adafruit_SSD1306.h:186
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:803
int8_t vccstate
VCC selection, set by begin method.
Definition: Adafruit_SSD1306.h:182
void ssd1306_command(uint8_t c)
Issue a single low-level command directly to the SSD1306 display, bypassing the library.
Definition: Adafruit_SSD1306.cpp:453
int8_t page_end
not used
Definition: Adafruit_SSD1306.h:183
bool getPixel(int16_t x, int16_t y)
Return color of a single pixel in display buffer.
Definition: Adafruit_SSD1306.cpp:958
uint8_t contrast
normal contrast setting for this device
Definition: Adafruit_SSD1306.h:200
void startscrolldiagleft(uint8_t start, uint8_t stop)
Activate alternate diagonal scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1126
int8_t rstPin
Display reset pin assignment. Set during construction.
Definition: Adafruit_SSD1306.h:190
void startscrollright(uint8_t start, uint8_t stop)
Activate a right-handed scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1054
void invertDisplay(bool i)
Enable or disable display invert mode (white-on-black vs black-on-white).
Definition: Adafruit_SSD1306.cpp:1168
int8_t i2caddr
I2C address initialized when begin method is called.
Definition: Adafruit_SSD1306.h:181
void startscrollleft(uint8_t start, uint8_t stop)
Activate a left-handed scroll for all or part of the display.
Definition: Adafruit_SSD1306.cpp:1077
uint8_t * buffer
Definition: Adafruit_SSD1306.h:179
Class that stores state and functions for interacting with SSD1306 OLED displays. ...
Definition: Adafruit_SSD1306.h:131
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:496
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:851