Adafruit GFX Library
Adafruit_GrayOLED.h
Go to the documentation of this file.
1 
24 #ifndef _Adafruit_GRAYOLED_H_
25 #define _Adafruit_GRAYOLED_H_
26 
27 // Not for ATtiny, at all
28 #if !defined(__AVR_ATtiny85__) && !defined(__AVR_ATtiny84__)
29 
30 #include <Adafruit_GFX.h>
31 #include <Adafruit_I2CDevice.h>
32 #include <Adafruit_SPIDevice.h>
33 #include <SPI.h>
34 #include <Wire.h>
35 
36 #define GRAYOLED_SETCONTRAST 0x81
37 #define GRAYOLED_NORMALDISPLAY 0xA6
38 #define GRAYOLED_INVERTDISPLAY 0xA7
39 
40 #define MONOOLED_BLACK 0
41 #define MONOOLED_WHITE 1
42 #define MONOOLED_INVERSE 2
43 
44 
49 public:
50  Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, TwoWire *twi = &Wire,
51  int8_t rst_pin = -1, uint32_t preclk = 400000,
52  uint32_t postclk = 100000);
53  Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, int8_t mosi_pin,
54  int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin,
55  int8_t cs_pin);
56  Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, SPIClass *spi,
57  int8_t dc_pin, int8_t rst_pin, int8_t cs_pin,
58  uint32_t bitrate = 8000000UL);
59 
60  ~Adafruit_GrayOLED(void);
61 
66  virtual void display(void) = 0;
67  void clearDisplay(void);
68  void invertDisplay(bool i);
69  void setContrast(uint8_t contrastlevel);
70  void drawPixel(int16_t x, int16_t y, uint16_t color);
71  bool getPixel(int16_t x, int16_t y);
72  uint8_t *getBuffer(void);
73 
74  void oled_command(uint8_t c);
75  bool oled_commandList(const uint8_t *c, uint8_t n);
76 
77 protected:
78  bool _init(uint8_t i2caddr = 0x3C, bool reset = true);
79 
80  Adafruit_SPIDevice *spi_dev = NULL;
81  Adafruit_I2CDevice *i2c_dev = NULL;
82  int32_t i2c_preclk = 400000,
83  i2c_postclk = 100000;
84  uint8_t *buffer = NULL;
85 
86  int16_t window_x1,
87  window_y1,
88  window_x2,
89  window_y2;
90 
91  int dcPin,
92  csPin,
93  rstPin;
94 
95  uint8_t _bpp = 1;
96 private:
97  TwoWire *_theWire = NULL;
98 };
99 
100 #endif // end __AVR_ATtiny85__ __AVR_ATtiny84__
101 #endif // _Adafruit_GrayOLED_H_
uint8_t _bpp
Bits per pixel color for this display.
Definition: Adafruit_GrayOLED.h:95
int16_t window_x2
Dirty tracking window maximum x.
Definition: Adafruit_GrayOLED.h:86
int csPin
The Arduino pin connected to CS (for SPI)
Definition: Adafruit_GrayOLED.h:91
bool _init(uint8_t i2caddr=0x3C, bool reset=true)
Allocate RAM for image buffer, initialize peripherals and pins. Note that subclasses must call this b...
Definition: Adafruit_GrayOLED.cpp:225
Definition: Adafruit_GFX.h:18
virtual void display(void)=0
The function that sub-classes define that writes out the buffer to the display over I2C or SPI...
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_GrayOLED.cpp:286
int16_t window_y1
Dirty tracking window minimum y.
Definition: Adafruit_GrayOLED.h:86
Adafruit_SPIDevice * spi_dev
The SPI interface BusIO device.
Definition: Adafruit_GrayOLED.h:80
bool oled_commandList(const uint8_t *c, uint8_t n)
Issue multiple bytes of commands OLED, using I2C or hard/soft SPI as needed.
Definition: Adafruit_GrayOLED.cpp:188
int16_t window_y2
Dirty tracking window maximum y.
Definition: Adafruit_GrayOLED.h:86
int16_t window_x1
Dirty tracking window minimum x.
Definition: Adafruit_GrayOLED.h:86
Adafruit_GrayOLED(uint8_t bpp, 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 OLED displays.
Definition: Adafruit_GrayOLED.cpp:65
void invertDisplay(bool i)
Enable or disable display invert mode (white-on-black vs black-on-white). Handy for testing! ...
Definition: Adafruit_GrayOLED.cpp:408
void setContrast(uint8_t contrastlevel)
Adjust the display contrast.
Definition: Adafruit_GrayOLED.cpp:418
uint8_t * buffer
Internal 1:1 framebuffer of display mem.
Definition: Adafruit_GrayOLED.h:84
~Adafruit_GrayOLED(void)
Destructor for Adafruit_GrayOLED object.
Definition: Adafruit_GrayOLED.cpp:151
void clearDisplay(void)
Clear contents of display buffer (set all pixels to off).
Definition: Adafruit_GrayOLED.cpp:345
uint8_t * getBuffer(void)
Get base address of display buffer for direct reading or writing.
Definition: Adafruit_GrayOLED.cpp:392
int rstPin
The Arduino pin connected to reset (-1 if unused)
Definition: Adafruit_GrayOLED.h:91
int32_t i2c_preclk
Configurable &#39;high speed&#39; I2C rate.
Definition: Adafruit_GrayOLED.h:82
bool getPixel(int16_t x, int16_t y)
Return color of a single pixel in display buffer.
Definition: Adafruit_GrayOLED.cpp:365
Class that stores state and functions for interacting with generic grayscale OLED displays...
Definition: Adafruit_GrayOLED.h:48
int32_t i2c_postclk
Configurable &#39;low speed&#39; I2C rate.
Definition: Adafruit_GrayOLED.h:83
void oled_command(uint8_t c)
Issue single command byte to OLED, using I2C or hard/soft SPI as needed.
Definition: Adafruit_GrayOLED.cpp:169
int dcPin
The Arduino pin connected to D/C (for SPI)
Definition: Adafruit_GrayOLED.h:91
Adafruit_I2CDevice * i2c_dev
The I2C interface BusIO device.
Definition: Adafruit_GrayOLED.h:81