18 #ifndef _Adafruit_SSD1306_H_ 19 #define _Adafruit_SSD1306_H_ 23 #define WIRE_WRITE Wire.write 26 #define WIRE_WRITE Wire.send 29 #if defined(__SAM3X8E__) 30 typedef volatile RwReg PortReg;
31 typedef uint32_t PortMask;
33 #elif defined(ARDUINO_ARCH_SAMD) 35 #elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER) || defined(__arc__) 36 typedef volatile uint32_t PortReg;
37 typedef uint32_t PortMask;
38 #elif defined(__AVR__) 39 typedef volatile uint8_t PortReg;
40 typedef uint8_t PortMask;
44 typedef volatile uint32_t PortReg;
45 typedef uint32_t PortMask;
49 #include <Adafruit_GFX.h> 55 #define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D 76 #define SSD1306_128_64 82 #if defined SSD1306_128_64 && defined SH1106_128_64 83 #error "Select either SH1106 or SSD1306 display type in SSD1306.h" 87 #if defined SSD1306_128_64 && defined SSD1306_128_32 88 #error "Only one SSD1306 display can be specified at once in SSD1306.h" 90 #if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 && !defined SSD1306_64_48 && !defined SH1106_128_64 91 #error "At least one SSD1306 display must be specified in SSD1306.h" 94 #if defined SSD1306_128_64 || defined SH1106_128_64 95 #define SSD1306_LCDWIDTH 128 96 #define SSD1306_LCDHEIGHT 64 98 #if defined SSD1306_128_32 99 #define SSD1306_LCDWIDTH 128 100 #define SSD1306_LCDHEIGHT 32 102 #if defined SSD1306_96_16 103 #define SSD1306_LCDWIDTH 96 104 #define SSD1306_LCDHEIGHT 16 105 #elif defined SSD1306_64_48 106 #define SSD1306_LCDWIDTH 64 107 #define SSD1306_LCDHEIGHT 48 110 #define SSD1306_SETCONTRAST 0x81 111 #define SSD1306_DISPLAYALLON_RESUME 0xA4 112 #define SSD1306_DISPLAYALLON 0xA5 113 #define SSD1306_NORMALDISPLAY 0xA6 114 #define SSD1306_INVERTDISPLAY 0xA7 115 #define SSD1306_DISPLAYOFF 0xAE 116 #define SSD1306_DISPLAYON 0xAF 118 #define SSD1306_SETDISPLAYOFFSET 0xD3 119 #define SSD1306_SETCOMPINS 0xDA 121 #define SSD1306_SETVCOMDETECT 0xDB 123 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 124 #define SSD1306_SETPRECHARGE 0xD9 126 #define SSD1306_SETMULTIPLEX 0xA8 128 #define SSD1306_SETLOWCOLUMN 0x00 129 #define SSD1306_SETHIGHCOLUMN 0x10 131 #define SSD1306_SETSTARTLINE 0x40 133 #define SSD1306_MEMORYMODE 0x20 134 #define SSD1306_COLUMNADDR 0x21 135 #define SSD1306_PAGEADDR 0x22 137 #define SSD1306_COMSCANINC 0xC0 138 #define SSD1306_COMSCANDEC 0xC8 140 #define SSD1306_SEGREMAP 0xA0 142 #define SSD1306_CHARGEPUMP 0x8D 144 #define SSD1306_EXTERNALVCC 0x1 145 #define SSD1306_SWITCHCAPVCC 0x2 147 #define SH1106_SETSTARTPAGE 0xB0 150 #define SSD1306_ACTIVATE_SCROLL 0x2F 151 #define SSD1306_DEACTIVATE_SCROLL 0x2E 152 #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 153 #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 154 #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 155 #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 156 #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A 160 Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);
164 void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS,
bool reset=
true);
165 void ssd1306_command(uint8_t c);
167 void clearDisplay(
void);
168 void invertDisplay(uint8_t i);
171 void startscrollright(uint8_t start, uint8_t stop);
172 void startscrollleft(uint8_t start, uint8_t stop);
174 void startscrolldiagright(uint8_t start, uint8_t stop);
175 void startscrolldiagleft(uint8_t start, uint8_t stop);
176 void stopscroll(
void);
178 void dim(
boolean dim);
180 void drawPixel(int16_t x, int16_t y, uint16_t color);
182 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
183 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
186 int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs;
187 void fastSPIwrite(uint8_t c);
191 PortReg *mosiport, *clkport, *csport, *dcport;
192 PortMask mosipinmask, clkpinmask, cspinmask, dcpinmask;
195 inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
196 inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
Definition: Adafruit_GFX.h:13
Definition: Adafruit_SSD1306.h:158