2020-05-16 00:45:51 -04:00
|
|
|
/*!
|
2020-08-23 13:29:41 -04:00
|
|
|
* @file Adafruit_GrayOLED.h
|
2020-05-16 00:45:51 -04:00
|
|
|
*
|
|
|
|
* This is part of for Adafruit's GFX library, supplying generic support
|
2020-08-23 13:29:41 -04:00
|
|
|
* for grayscale OLED displays: http://www.adafruit.com/category/63_98
|
2020-05-16 00:45:51 -04:00
|
|
|
*
|
|
|
|
* These displays use I2C or SPI to communicate. I2C requires 2 pins
|
|
|
|
* (SCL+SDA) and optionally a RESET pin. SPI requires 4 pins (MOSI, SCK,
|
|
|
|
* select, data/command) and optionally a reset pin. Hardware SPI or
|
|
|
|
* 'bitbang' software SPI are both supported.
|
|
|
|
*
|
|
|
|
* Adafruit invests time and resources providing this open source code,
|
|
|
|
* please support Adafruit and open-source hardware by purchasing
|
|
|
|
* products from Adafruit!
|
|
|
|
*
|
|
|
|
* Written by Limor Fried/Ladyada for Adafruit Industries, with
|
|
|
|
* contributions from the open source community.
|
|
|
|
*
|
|
|
|
* BSD license, all text above, and the splash screen header file,
|
|
|
|
* must be included in any redistribution.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-08-23 13:33:45 -04:00
|
|
|
#ifndef _Adafruit_GRAYOLED_H_
|
|
|
|
#define _Adafruit_GRAYOLED_H_
|
2020-05-16 00:45:51 -04:00
|
|
|
|
2020-05-16 22:38:19 -04:00
|
|
|
#if !defined(__AVR_ATtiny85__) // Not for ATtiny, at all
|
|
|
|
|
2020-05-16 00:45:51 -04:00
|
|
|
#include <Adafruit_GFX.h>
|
|
|
|
#include <Adafruit_I2CDevice.h>
|
|
|
|
#include <Adafruit_SPIDevice.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <Wire.h>
|
|
|
|
|
2020-08-23 13:29:41 -04:00
|
|
|
#define GRAYOLED_SETCONTRAST 0x81
|
|
|
|
#define GRAYOLED_NORMALDISPLAY 0xA6
|
|
|
|
#define GRAYOLED_INVERTDISPLAY 0xA7
|
2020-05-16 00:45:51 -04:00
|
|
|
|
2020-08-23 13:29:41 -04:00
|
|
|
#define MONOOLED_BLACK 0
|
|
|
|
#define MONOOLED_WHITE 1
|
|
|
|
#define MONOOLED_INVERSE 2
|
2020-05-16 00:45:51 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@brief Class that stores state and functions for interacting with
|
2020-08-23 13:29:41 -04:00
|
|
|
generic grayscale OLED displays.
|
2020-05-16 00:45:51 -04:00
|
|
|
*/
|
2020-08-23 13:29:41 -04:00
|
|
|
class Adafruit_GrayOLED : public Adafruit_GFX {
|
2020-05-16 00:45:51 -04:00
|
|
|
public:
|
2020-08-23 13:29:41 -04:00
|
|
|
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, TwoWire *twi = &Wire,
|
2020-05-16 00:45:51 -04:00
|
|
|
int8_t rst_pin = -1, uint32_t preclk = 400000,
|
|
|
|
uint32_t postclk = 100000);
|
2020-08-23 13:42:11 -04:00
|
|
|
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, int8_t mosi_pin,
|
|
|
|
int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin,
|
|
|
|
int8_t cs_pin);
|
|
|
|
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, SPIClass *spi,
|
|
|
|
int8_t dc_pin, int8_t rst_pin, int8_t cs_pin,
|
2020-05-16 00:45:51 -04:00
|
|
|
uint32_t bitrate = 8000000UL);
|
|
|
|
|
2020-08-23 13:29:41 -04:00
|
|
|
~Adafruit_GrayOLED(void);
|
2020-05-16 00:45:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The function that sub-classes define that writes out the buffer to
|
|
|
|
the display over I2C or SPI
|
|
|
|
**/
|
|
|
|
virtual void display(void) = 0;
|
|
|
|
void clearDisplay(void);
|
Change boolean to bool (#303)
* Change boolean to bool
This avoids compiler warnings such as:
In file included from /home/ed/git/dryer-arduino/ui/src/graphicstest.ino:18:
.pio/libdeps/nucleo_f446re/Adafruit GFX Library_ID13/Adafruit_GFX.h:48:39: warning: 'boolean' is deprecated [-Wdeprecated-declarations]
48 | virtual void invertDisplay(boolean i);
| ^
In file included from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:34,
from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:32,
from /tmp/tmpvslwxjr7:1:
/home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring_constants.h:110:14: note: declared here
* Fix clang format issues unrelated to this PR
Addresses the following from CI:
$ python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
--- ./Adafruit_GFX.h (original)
+++ ./Adafruit_GFX.h (reformatted)
@@ -240,8 +240,8 @@
uint8_t textsize_x; ///< Desired magnification in X-axis of text to print()
uint8_t textsize_y; ///< Desired magnification in Y-axis of text to print()
uint8_t rotation; ///< Display rotation (0 thru 3)
- bool wrap; ///< If set, 'wrap' text at right edge of display
- bool _cp437; ///< If set, use correct CP437 charset (default is off)
+ bool wrap; ///< If set, 'wrap' text at right edge of display
+ bool _cp437; ///< If set, use correct CP437 charset (default is off)
GFXfont *gfxFont; ///< Pointer to special font
};
--- ./Adafruit_GFX.cpp (original)
+++ ./Adafruit_GFX.cpp (reformatted)
@@ -1713,9 +1713,7 @@
@returns True if was pressed before, now is not.
*/
/**************************************************************************/
-bool Adafruit_GFX_Button::justReleased() {
- return (!currstate && laststate);
-}
+bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); }
// -------------------------------------------------------------------------
2020-06-15 11:20:29 -04:00
|
|
|
void invertDisplay(bool i);
|
2020-05-16 00:45:51 -04:00
|
|
|
void setContrast(uint8_t contrastlevel);
|
|
|
|
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
Change boolean to bool (#303)
* Change boolean to bool
This avoids compiler warnings such as:
In file included from /home/ed/git/dryer-arduino/ui/src/graphicstest.ino:18:
.pio/libdeps/nucleo_f446re/Adafruit GFX Library_ID13/Adafruit_GFX.h:48:39: warning: 'boolean' is deprecated [-Wdeprecated-declarations]
48 | virtual void invertDisplay(boolean i);
| ^
In file included from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:34,
from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:32,
from /tmp/tmpvslwxjr7:1:
/home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring_constants.h:110:14: note: declared here
* Fix clang format issues unrelated to this PR
Addresses the following from CI:
$ python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
--- ./Adafruit_GFX.h (original)
+++ ./Adafruit_GFX.h (reformatted)
@@ -240,8 +240,8 @@
uint8_t textsize_x; ///< Desired magnification in X-axis of text to print()
uint8_t textsize_y; ///< Desired magnification in Y-axis of text to print()
uint8_t rotation; ///< Display rotation (0 thru 3)
- bool wrap; ///< If set, 'wrap' text at right edge of display
- bool _cp437; ///< If set, use correct CP437 charset (default is off)
+ bool wrap; ///< If set, 'wrap' text at right edge of display
+ bool _cp437; ///< If set, use correct CP437 charset (default is off)
GFXfont *gfxFont; ///< Pointer to special font
};
--- ./Adafruit_GFX.cpp (original)
+++ ./Adafruit_GFX.cpp (reformatted)
@@ -1713,9 +1713,7 @@
@returns True if was pressed before, now is not.
*/
/**************************************************************************/
-bool Adafruit_GFX_Button::justReleased() {
- return (!currstate && laststate);
-}
+bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); }
// -------------------------------------------------------------------------
2020-06-15 11:20:29 -04:00
|
|
|
bool getPixel(int16_t x, int16_t y);
|
2020-05-16 00:45:51 -04:00
|
|
|
uint8_t *getBuffer(void);
|
|
|
|
|
|
|
|
void oled_command(uint8_t c);
|
|
|
|
bool oled_commandList(const uint8_t *c, uint8_t n);
|
|
|
|
|
|
|
|
protected:
|
Change boolean to bool (#303)
* Change boolean to bool
This avoids compiler warnings such as:
In file included from /home/ed/git/dryer-arduino/ui/src/graphicstest.ino:18:
.pio/libdeps/nucleo_f446re/Adafruit GFX Library_ID13/Adafruit_GFX.h:48:39: warning: 'boolean' is deprecated [-Wdeprecated-declarations]
48 | virtual void invertDisplay(boolean i);
| ^
In file included from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:34,
from /home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:32,
from /tmp/tmpvslwxjr7:1:
/home/ed/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring_constants.h:110:14: note: declared here
* Fix clang format issues unrelated to this PR
Addresses the following from CI:
$ python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
--- ./Adafruit_GFX.h (original)
+++ ./Adafruit_GFX.h (reformatted)
@@ -240,8 +240,8 @@
uint8_t textsize_x; ///< Desired magnification in X-axis of text to print()
uint8_t textsize_y; ///< Desired magnification in Y-axis of text to print()
uint8_t rotation; ///< Display rotation (0 thru 3)
- bool wrap; ///< If set, 'wrap' text at right edge of display
- bool _cp437; ///< If set, use correct CP437 charset (default is off)
+ bool wrap; ///< If set, 'wrap' text at right edge of display
+ bool _cp437; ///< If set, use correct CP437 charset (default is off)
GFXfont *gfxFont; ///< Pointer to special font
};
--- ./Adafruit_GFX.cpp (original)
+++ ./Adafruit_GFX.cpp (reformatted)
@@ -1713,9 +1713,7 @@
@returns True if was pressed before, now is not.
*/
/**************************************************************************/
-bool Adafruit_GFX_Button::justReleased() {
- return (!currstate && laststate);
-}
+bool Adafruit_GFX_Button::justReleased() { return (!currstate && laststate); }
// -------------------------------------------------------------------------
2020-06-15 11:20:29 -04:00
|
|
|
bool _init(uint8_t i2caddr = 0x3C, bool reset = true);
|
2020-05-16 00:45:51 -04:00
|
|
|
|
|
|
|
Adafruit_SPIDevice *spi_dev = NULL; ///< The SPI interface BusIO device
|
|
|
|
Adafruit_I2CDevice *i2c_dev = NULL; ///< The I2C interface BusIO device
|
|
|
|
int32_t i2c_preclk = 400000, ///< Configurable 'high speed' I2C rate
|
|
|
|
i2c_postclk = 100000; ///< Configurable 'low speed' I2C rate
|
|
|
|
uint8_t *buffer = NULL; ///< Internal 1:1 framebuffer of display mem
|
|
|
|
|
|
|
|
int16_t window_x1, ///< Dirty tracking window minimum x
|
|
|
|
window_y1, ///< Dirty tracking window minimum y
|
|
|
|
window_x2, ///< Dirty tracking window maximum x
|
|
|
|
window_y2; ///< Dirty tracking window maximum y
|
|
|
|
|
|
|
|
int dcPin, ///< The Arduino pin connected to D/C (for SPI)
|
|
|
|
csPin, ///< The Arduino pin connected to CS (for SPI)
|
|
|
|
rstPin; ///< The Arduino pin connected to reset (-1 if unused)
|
|
|
|
|
2020-08-23 13:42:11 -04:00
|
|
|
uint8_t _bpp = 1; ///< Bits per pixel color for this display
|
2020-05-16 00:45:51 -04:00
|
|
|
private:
|
|
|
|
TwoWire *_theWire = NULL; ///< The underlying hardware I2C
|
|
|
|
};
|
|
|
|
|
2020-05-16 22:38:19 -04:00
|
|
|
#endif // end __AVR_ATtiny85__
|
2020-08-23 13:29:41 -04:00
|
|
|
#endif // _Adafruit_GrayOLED_H_
|