This commit is contained in:
lady ada
2020-05-14 18:21:06 -04:00
parent a715c356a6
commit 8d271f2abe
2 changed files with 27 additions and 35 deletions
+15 -26
View File
@@ -1,10 +1,6 @@
/*!
* @file Adafruit_MonoOLED.cpp
*
* @mainpage Arduino library for generic monochrome OLEDs.
*
* @section intro_sec Introduction
*
* This is documentation for Adafruit's generic library for monochrome
* OLED displays: http://www.adafruit.com/category/63_98
*
@@ -17,24 +13,6 @@
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* @section dependencies Dependencies
*
* This library depends on <a
* href="https://github.com/adafruit/Adafruit-GFX-Library"> Adafruit_GFX</a> and
* <a href="https://github.com/adafruit/Adafruit_BusIO"> Adafruit_BusIO</a>
* being present on your system. Please make sure you have installed the latest
* version before using this library.
*
* @section author Author
*
* Written by Limor Fried/Ladyada for Adafruit Industries, with
* contributions from the open source community.
*
* @section license License
*
* BSD license, all text above, and the splash screen included below,
* must be included in any redistribution.
*
*/
#include "Adafruit_MonoOLED.h"
@@ -172,7 +150,11 @@ Adafruit_MonoOLED::~Adafruit_MonoOLED(void) {
// LOW-LEVEL UTILS ---------------------------------------------------------
// Issue single command byte to OLED, using I2C or hard/soft SPI as needed.
/*!
@brief Issue single command byte to OLED, using I2C or hard/soft SPI as
needed.
@param c The single byte command
*/
void Adafruit_MonoOLED::oled_command(uint8_t c) {
if (i2c_dev) { // I2C
uint8_t buf[2] = {0x00, c}; // Co = 0, D/C = 0
@@ -184,6 +166,14 @@ void Adafruit_MonoOLED::oled_command(uint8_t c) {
}
// Issue list of commands to MonoOLED
/*!
@brief Issue multiple bytes of commands OLED, using I2C or hard/soft SPI as
needed.
@param c Pointer to the command array
@param n The number of bytes in the command array
@returns True for success on ability to write the data in I2C.
*/
bool Adafruit_MonoOLED::oled_commandList(const uint8_t *c, uint8_t n) {
if (i2c_dev) { // I2C
uint8_t dc_byte = 0x00; // Co = 0, D/C = 0
@@ -379,9 +369,8 @@ void Adafruit_MonoOLED::invertDisplay(boolean i) {
}
/*!
@brief Dim the display.
@param dim
true to enable lower brightness mode, false for full brightness.
@brief Adjust the display contrast.
@param level The contrast level from 0 to 0x7F
@return None (void).
@note This has an immediate effect on the display, no need to call the
display() function -- buffer contents are not changed.
+12 -9
View File
@@ -57,11 +57,15 @@ public:
uint32_t bitrate = 8000000UL);
~Adafruit_MonoOLED(void);
/**
@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);
void invertDisplay(boolean i);
void setContrast(uint8_t contrastlevel);
uint8_t getContrast(void);
void drawPixel(int16_t x, int16_t y, uint16_t color);
boolean getPixel(int16_t x, int16_t y);
uint8_t *getBuffer(void);
@@ -72,15 +76,14 @@ public:
protected:
bool _init(uint8_t i2caddr = 0x3C, boolean reset = true);
Adafruit_SPIDevice *spi_dev = NULL;
Adafruit_I2CDevice *i2c_dev = NULL;
TwoWire *_theWire = NULL;
int32_t i2c_preclk = 400000, i2c_postclk = 100000;
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
private:
int dcPin, csPin, rstPin;
uint8_t *buffer = NULL;
int8_t i2caddr;
uint8_t contrast; // normal contrast setting for this device
TwoWire *_theWire = NULL; ///< The underlying hardware I2C
};
#endif // _Adafruit_MonoOLED_H_