diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml new file mode 100644 index 0000000..55c09a6 --- /dev/null +++ b/.github/workflows/githubci.yml @@ -0,0 +1,32 @@ +name: Arduino Library CI + +on: [pull_request, push, repository_dispatch] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: adafruit/ci-arduino + path: ci + + - name: pre-install + run: bash ci/actions_install.sh + + - name: test platforms + run: python3 ci/build_platform.py main_platforms + + - name: clang + run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . + + - name: doxygen + env: + GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} + PRETTYNAME : "Adafruit SSD1306" + run: bash ci/doxy_gen_and_deploy.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0df5c4d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: c -sudo: false -cache: - directories: - - ~/arduino_ide - - ~/.arduino15/packages/ -git: - depth: false - quiet: true -env: - global: - - PRETTYNAME="Adafruit SSD1306" - -before_install: - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) - -script: - - build_main_platforms - -# Generate and deploy documentation -after_success: - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) - - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) diff --git a/Adafruit_SSD1306.cpp b/Adafruit_SSD1306.cpp index 9b5bc51..6eae34a 100644 --- a/Adafruit_SSD1306.cpp +++ b/Adafruit_SSD1306.cpp @@ -19,9 +19,10 @@ * * @section dependencies Dependencies * - * This library depends on - * Adafruit_GFX being present on your system. Please make sure you have - * installed the latest version before using this library. + * This library depends on Adafruit_GFX + * being present on your system. Please make sure you have installed the latest + * version before using this library. * * @section author Author * @@ -36,67 +37,68 @@ */ #ifdef __AVR__ - #include +#include #elif defined(ESP8266) || defined(ESP32) - #include +#include #else - #define pgm_read_byte(addr) \ +#define pgm_read_byte(addr) \ (*(const unsigned char *)(addr)) ///< PROGMEM workaround for non-AVR #endif -#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && !defined(ESP32) && !defined(__arc__) - #include +#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && \ + !defined(ESP32) && !defined(__arc__) +#include #endif -#include #include "Adafruit_SSD1306.h" #include "splash.h" +#include // SOME DEFINES AND STATIC VARIABLES USED INTERNALLY ----------------------- #if defined(BUFFER_LENGTH) - #define WIRE_MAX BUFFER_LENGTH ///< AVR or similar Wire lib +#define WIRE_MAX BUFFER_LENGTH ///< AVR or similar Wire lib #elif defined(SERIAL_BUFFER_SIZE) - #define WIRE_MAX (SERIAL_BUFFER_SIZE-1) ///< Newer Wire uses RingBuffer +#define WIRE_MAX (SERIAL_BUFFER_SIZE - 1) ///< Newer Wire uses RingBuffer #else - #define WIRE_MAX 32 ///< Use common Arduino core default +#define WIRE_MAX 32 ///< Use common Arduino core default #endif -#define ssd1306_swap(a, b) \ +#define ssd1306_swap(a, b) \ (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) ///< No-temp-var swap operation #if ARDUINO >= 100 - #define WIRE_WRITE wire->write ///< Wire write function in recent Arduino lib +#define WIRE_WRITE wire->write ///< Wire write function in recent Arduino lib #else - #define WIRE_WRITE wire->send ///< Wire write function in older Arduino lib +#define WIRE_WRITE wire->send ///< Wire write function in older Arduino lib #endif #ifdef HAVE_PORTREG - #define SSD1306_SELECT *csPort &= ~csPinMask; ///< Device select - #define SSD1306_DESELECT *csPort |= csPinMask; ///< Device deselect - #define SSD1306_MODE_COMMAND *dcPort &= ~dcPinMask; ///< Command mode - #define SSD1306_MODE_DATA *dcPort |= dcPinMask; ///< Data mode +#define SSD1306_SELECT *csPort &= ~csPinMask; ///< Device select +#define SSD1306_DESELECT *csPort |= csPinMask; ///< Device deselect +#define SSD1306_MODE_COMMAND *dcPort &= ~dcPinMask; ///< Command mode +#define SSD1306_MODE_DATA *dcPort |= dcPinMask; ///< Data mode #else - #define SSD1306_SELECT digitalWrite(csPin, LOW); ///< Device select - #define SSD1306_DESELECT digitalWrite(csPin, HIGH); ///< Device deselect - #define SSD1306_MODE_COMMAND digitalWrite(dcPin, LOW); ///< Command mode - #define SSD1306_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode +#define SSD1306_SELECT digitalWrite(csPin, LOW); ///< Device select +#define SSD1306_DESELECT digitalWrite(csPin, HIGH); ///< Device deselect +#define SSD1306_MODE_COMMAND digitalWrite(dcPin, LOW); ///< Command mode +#define SSD1306_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode #endif #if (ARDUINO >= 157) && !defined(ARDUINO_STM32_FEATHER) - #define SETWIRECLOCK wire->setClock(wireClk) ///< Set before I2C transfer - #define RESWIRECLOCK wire->setClock(restoreClk) ///< Restore after I2C xfer +#define SETWIRECLOCK wire->setClock(wireClk) ///< Set before I2C transfer +#define RESWIRECLOCK wire->setClock(restoreClk) ///< Restore after I2C xfer #else // setClock() is not present in older Arduino Wire lib (or WICED) - #define SETWIRECLOCK ///< Dummy stand-in define - #define RESWIRECLOCK ///< keeps compiler happy +#define SETWIRECLOCK ///< Dummy stand-in define +#define RESWIRECLOCK ///< keeps compiler happy #endif #if defined(SPI_HAS_TRANSACTION) - #define SPI_TRANSACTION_START spi->beginTransaction(spiSettings) ///< Pre-SPI - #define SPI_TRANSACTION_END spi->endTransaction() ///< Post-SPI +#define SPI_TRANSACTION_START spi->beginTransaction(spiSettings) ///< Pre-SPI +#define SPI_TRANSACTION_END spi->endTransaction() ///< Post-SPI #else // SPI transactions likewise not present in older Arduino SPI lib - #define SPI_TRANSACTION_START ///< Dummy stand-in define - #define SPI_TRANSACTION_END ///< keeps compiler happy +#define SPI_TRANSACTION_START ///< Dummy stand-in define +#define SPI_TRANSACTION_END ///< keeps compiler happy #endif // The definition of 'transaction' is broadened a bit in the context of @@ -109,24 +111,24 @@ // in the TRANSACTION_* macros. // Check first if Wire, then hardware SPI, then soft SPI: -#define TRANSACTION_START \ - if(wire) { \ - SETWIRECLOCK; \ - } else { \ - if(spi) { \ - SPI_TRANSACTION_START; \ - } \ - SSD1306_SELECT; \ - } ///< Wire, SPI or bitbang transfer setup -#define TRANSACTION_END \ - if(wire) { \ - RESWIRECLOCK; \ - } else { \ - SSD1306_DESELECT; \ - if(spi) { \ - SPI_TRANSACTION_END; \ - } \ - } ///< Wire, SPI or bitbang transfer end +#define TRANSACTION_START \ + if (wire) { \ + SETWIRECLOCK; \ + } else { \ + if (spi) { \ + SPI_TRANSACTION_START; \ + } \ + SSD1306_SELECT; \ + } ///< Wire, SPI or bitbang transfer setup +#define TRANSACTION_END \ + if (wire) { \ + RESWIRECLOCK; \ + } else { \ + SSD1306_DESELECT; \ + if (spi) { \ + SPI_TRANSACTION_END; \ + } \ + } ///< Wire, SPI or bitbang transfer end // CONSTRUCTORS, DESTRUCTOR ------------------------------------------------ @@ -164,11 +166,13 @@ allocation is performed there! */ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi, - int8_t rst_pin, uint32_t clkDuring, uint32_t clkAfter) : - Adafruit_GFX(w, h), spi(NULL), wire(twi ? twi : &Wire), buffer(NULL), - mosiPin(-1), clkPin(-1), dcPin(-1), csPin(-1), rstPin(rst_pin) + int8_t rst_pin, uint32_t clkDuring, + uint32_t clkAfter) + : Adafruit_GFX(w, h), spi(NULL), wire(twi ? twi : &Wire), buffer(NULL), + mosiPin(-1), clkPin(-1), dcPin(-1), csPin(-1), rstPin(rst_pin) #if ARDUINO >= 157 - , wireClk(clkDuring), restoreClk(clkAfter) + , + wireClk(clkDuring), restoreClk(clkAfter) #endif { } @@ -200,12 +204,12 @@ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi, @note Call the object's begin() function before use -- buffer allocation is performed there! */ -Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, - int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin, - int8_t cs_pin) : Adafruit_GFX(w, h), spi(NULL), wire(NULL), buffer(NULL), - mosiPin(mosi_pin), clkPin(sclk_pin), dcPin(dc_pin), csPin(cs_pin), - rstPin(rst_pin) { -} +Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin, + int8_t sclk_pin, int8_t dc_pin, + int8_t rst_pin, int8_t cs_pin) + : Adafruit_GFX(w, h), spi(NULL), wire(NULL), buffer(NULL), + mosiPin(mosi_pin), clkPin(sclk_pin), dcPin(dc_pin), csPin(cs_pin), + rstPin(rst_pin) {} /*! @brief Constructor for SPI SSD1306 displays, using native hardware SPI. @@ -234,9 +238,10 @@ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, allocation is performed there! */ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, - int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, uint32_t bitrate) : - Adafruit_GFX(w, h), spi(spi ? spi : &SPI), wire(NULL), buffer(NULL), - mosiPin(-1), clkPin(-1), dcPin(dc_pin), csPin(cs_pin), rstPin(rst_pin) { + int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, + uint32_t bitrate) + : Adafruit_GFX(w, h), spi(spi ? spi : &SPI), wire(NULL), buffer(NULL), + mosiPin(-1), clkPin(-1), dcPin(dc_pin), csPin(cs_pin), rstPin(rst_pin) { #ifdef SPI_HAS_TRANSACTION spiSettings = SPISettings(bitrate, MSBFIRST, SPI_MODE0); #endif @@ -269,11 +274,10 @@ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, allocation is performed there! */ Adafruit_SSD1306::Adafruit_SSD1306(int8_t mosi_pin, int8_t sclk_pin, - int8_t dc_pin, int8_t rst_pin, int8_t cs_pin) : - Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), spi(NULL), wire(NULL), - buffer(NULL), mosiPin(mosi_pin), clkPin(sclk_pin), dcPin(dc_pin), - csPin(cs_pin), rstPin(rst_pin) { -} + int8_t dc_pin, int8_t rst_pin, int8_t cs_pin) + : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), spi(NULL), wire(NULL), + buffer(NULL), mosiPin(mosi_pin), clkPin(sclk_pin), dcPin(dc_pin), + csPin(cs_pin), rstPin(rst_pin) {} /*! @brief DEPRECATED constructor for SPI SSD1306 displays, using native @@ -296,10 +300,10 @@ Adafruit_SSD1306::Adafruit_SSD1306(int8_t mosi_pin, int8_t sclk_pin, @note Call the object's begin() function before use -- buffer allocation is performed there! */ -Adafruit_SSD1306::Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, - int8_t cs_pin) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), - spi(&SPI), wire(NULL), buffer(NULL), mosiPin(-1), clkPin(-1), - dcPin(dc_pin), csPin(cs_pin), rstPin(rst_pin) { +Adafruit_SSD1306::Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, int8_t cs_pin) + : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), spi(&SPI), wire(NULL), + buffer(NULL), mosiPin(-1), clkPin(-1), dcPin(dc_pin), csPin(cs_pin), + rstPin(rst_pin) { #ifdef SPI_HAS_TRANSACTION spiSettings = SPISettings(8000000, MSBFIRST, SPI_MODE0); #endif @@ -319,17 +323,16 @@ Adafruit_SSD1306::Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, @note Call the object's begin() function before use -- buffer allocation is performed there! */ -Adafruit_SSD1306::Adafruit_SSD1306(int8_t rst_pin) : - Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), spi(NULL), wire(&Wire), - buffer(NULL), mosiPin(-1), clkPin(-1), dcPin(-1), csPin(-1), - rstPin(rst_pin) { -} +Adafruit_SSD1306::Adafruit_SSD1306(int8_t rst_pin) + : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT), spi(NULL), wire(&Wire), + buffer(NULL), mosiPin(-1), clkPin(-1), dcPin(-1), csPin(-1), + rstPin(rst_pin) {} /*! @brief Destructor for Adafruit_SSD1306 object. */ Adafruit_SSD1306::~Adafruit_SSD1306(void) { - if(buffer) { + if (buffer) { free(buffer); buffer = NULL; } @@ -340,19 +343,21 @@ Adafruit_SSD1306::~Adafruit_SSD1306(void) { // Issue single byte out SPI, either soft or hardware as appropriate. // SPI transaction/selection must be performed in calling function. inline void Adafruit_SSD1306::SPIwrite(uint8_t d) { - if(spi) { + if (spi) { (void)spi->transfer(d); } else { - for(uint8_t bit = 0x80; bit; bit >>= 1) { + for (uint8_t bit = 0x80; bit; bit >>= 1) { #ifdef HAVE_PORTREG - if(d & bit) *mosiPort |= mosiPinMask; - else *mosiPort &= ~mosiPinMask; - *clkPort |= clkPinMask; // Clock high + if (d & bit) + *mosiPort |= mosiPinMask; + else + *mosiPort &= ~mosiPinMask; + *clkPort |= clkPinMask; // Clock high *clkPort &= ~clkPinMask; // Clock low #else digitalWrite(mosiPin, d & bit); - digitalWrite(clkPin , HIGH); - digitalWrite(clkPin , LOW); + digitalWrite(clkPin, HIGH); + digitalWrite(clkPin, LOW); #endif } } @@ -363,7 +368,7 @@ inline void Adafruit_SSD1306::SPIwrite(uint8_t d) { // must be started/ended in calling function for efficiency. // This is a private function, not exposed (see ssd1306_command() instead). void Adafruit_SSD1306::ssd1306_command1(uint8_t c) { - if(wire) { // I2C + if (wire) { // I2C wire->beginTransmission(i2caddr); WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 WIRE_WRITE(c); @@ -377,12 +382,12 @@ void Adafruit_SSD1306::ssd1306_command1(uint8_t c) { // Issue list of commands to SSD1306, same rules as above re: transactions. // This is a private function, not exposed. void Adafruit_SSD1306::ssd1306_commandList(const uint8_t *c, uint8_t n) { - if(wire) { // I2C + if (wire) { // I2C wire->beginTransmission(i2caddr); WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 uint8_t bytesOut = 1; - while(n--) { - if(bytesOut >= WIRE_MAX) { + while (n--) { + if (bytesOut >= WIRE_MAX) { wire->endTransmission(); wire->beginTransmission(i2caddr); WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 @@ -394,7 +399,8 @@ void Adafruit_SSD1306::ssd1306_commandList(const uint8_t *c, uint8_t n) { wire->endTransmission(); } else { // SPI -- transaction started in calling function SSD1306_MODE_COMMAND - while(n--) SPIwrite(pgm_read_byte(c++)); + while (n--) + SPIwrite(pgm_read_byte(c++)); } } @@ -452,24 +458,24 @@ void Adafruit_SSD1306::ssd1306_command(uint8_t c) { @note MUST call this function before any drawing or updates! */ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, - boolean periphBegin) { + boolean periphBegin) { - if((!buffer) && !(buffer = (uint8_t *)malloc(WIDTH * ((HEIGHT + 7) / 8)))) + if ((!buffer) && !(buffer = (uint8_t *)malloc(WIDTH * ((HEIGHT + 7) / 8)))) return false; clearDisplay(); - if(HEIGHT > 32) { + if (HEIGHT > 32) { drawBitmap((WIDTH - splash1_width) / 2, (HEIGHT - splash1_height) / 2, - splash1_data, splash1_width, splash1_height, 1); + splash1_data, splash1_width, splash1_height, 1); } else { drawBitmap((WIDTH - splash2_width) / 2, (HEIGHT - splash2_height) / 2, - splash2_data, splash2_width, splash2_height, 1); + splash2_data, splash2_width, splash2_height, 1); } vccstate = vcs; // Setup pin directions - if(wire) { // Using I2C + if (wire) { // Using I2C // If I2C address is unspecified, use default // (0x3C for 32-pixel-tall displays, 0x3D for all others). i2caddr = addr ? addr : ((HEIGHT == 32) ? 0x3C : 0x3D); @@ -477,29 +483,31 @@ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, // function if it has unusual circumstances (e.g. TWI variants that // can accept different SDA/SCL pins, or if two SSD1306 instances // with different addresses -- only a single begin() is needed). - if(periphBegin) wire->begin(); + if (periphBegin) + wire->begin(); } else { // Using one of the SPI modes, either soft or hardware pinMode(dcPin, OUTPUT); // Set data/command pin as output pinMode(csPin, OUTPUT); // Same for chip select #ifdef HAVE_PORTREG - dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin)); + dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin)); dcPinMask = digitalPinToBitMask(dcPin); - csPort = (PortReg *)portOutputRegister(digitalPinToPort(csPin)); + csPort = (PortReg *)portOutputRegister(digitalPinToPort(csPin)); csPinMask = digitalPinToBitMask(csPin); #endif SSD1306_DESELECT - if(spi) { // Hardware SPI + if (spi) { // Hardware SPI // SPI peripheral begin same as wire check above. - if(periphBegin) spi->begin(); - } else { // Soft SPI + if (periphBegin) + spi->begin(); + } else { // Soft SPI pinMode(mosiPin, OUTPUT); // MOSI and SCLK outputs - pinMode(clkPin , OUTPUT); + pinMode(clkPin, OUTPUT); #ifdef HAVE_PORTREG - mosiPort = (PortReg *)portOutputRegister(digitalPinToPort(mosiPin)); + mosiPort = (PortReg *)portOutputRegister(digitalPinToPort(mosiPin)); mosiPinMask = digitalPinToBitMask(mosiPin); - clkPort = (PortReg *)portOutputRegister(digitalPinToPort(clkPin)); - clkPinMask = digitalPinToBitMask(clkPin); - *clkPort &= ~clkPinMask; // Clock low + clkPort = (PortReg *)portOutputRegister(digitalPinToPort(clkPin)); + clkPinMask = digitalPinToBitMask(clkPin); + *clkPort &= ~clkPinMask; // Clock low #else digitalWrite(clkPin, LOW); // Clock low #endif @@ -507,8 +515,8 @@ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, } // Reset SSD1306 if requested and reset pin specified in constructor - if(reset && (rstPin >= 0)) { - pinMode( rstPin, OUTPUT); + if (reset && (rstPin >= 0)) { + pinMode(rstPin, OUTPUT); digitalWrite(rstPin, HIGH); delay(1); // VDD goes high at start, pause for 1 ms digitalWrite(rstPin, LOW); // Bring reset low @@ -519,41 +527,38 @@ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, TRANSACTION_START // Init sequence - static const uint8_t PROGMEM init1[] = { - SSD1306_DISPLAYOFF, // 0xAE - SSD1306_SETDISPLAYCLOCKDIV, // 0xD5 - 0x80, // the suggested ratio 0x80 - SSD1306_SETMULTIPLEX }; // 0xA8 + static const uint8_t PROGMEM init1[] = {SSD1306_DISPLAYOFF, // 0xAE + SSD1306_SETDISPLAYCLOCKDIV, // 0xD5 + 0x80, // the suggested ratio 0x80 + SSD1306_SETMULTIPLEX}; // 0xA8 ssd1306_commandList(init1, sizeof(init1)); ssd1306_command1(HEIGHT - 1); - static const uint8_t PROGMEM init2[] = { - SSD1306_SETDISPLAYOFFSET, // 0xD3 - 0x0, // no offset - SSD1306_SETSTARTLINE | 0x0, // line #0 - SSD1306_CHARGEPUMP }; // 0x8D + static const uint8_t PROGMEM init2[] = {SSD1306_SETDISPLAYOFFSET, // 0xD3 + 0x0, // no offset + SSD1306_SETSTARTLINE | 0x0, // line #0 + SSD1306_CHARGEPUMP}; // 0x8D ssd1306_commandList(init2, sizeof(init2)); ssd1306_command1((vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0x14); - static const uint8_t PROGMEM init3[] = { - SSD1306_MEMORYMODE, // 0x20 - 0x00, // 0x0 act like ks0108 - SSD1306_SEGREMAP | 0x1, - SSD1306_COMSCANDEC }; + static const uint8_t PROGMEM init3[] = {SSD1306_MEMORYMODE, // 0x20 + 0x00, // 0x0 act like ks0108 + SSD1306_SEGREMAP | 0x1, + SSD1306_COMSCANDEC}; ssd1306_commandList(init3, sizeof(init3)); uint8_t comPins = 0x02; contrast = 0x8F; - if((WIDTH == 128) && (HEIGHT == 32)) { + if ((WIDTH == 128) && (HEIGHT == 32)) { comPins = 0x02; contrast = 0x8F; - } else if((WIDTH == 128) && (HEIGHT == 64)) { + } else if ((WIDTH == 128) && (HEIGHT == 64)) { comPins = 0x12; contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF; - } else if((WIDTH == 96) && (HEIGHT == 16)) { - comPins = 0x2; // ada x12 + } else if ((WIDTH == 96) && (HEIGHT == 16)) { + comPins = 0x2; // ada x12 contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xAF; } else { // Other screen varieties -- TBD @@ -567,12 +572,12 @@ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, ssd1306_command1(SSD1306_SETPRECHARGE); // 0xd9 ssd1306_command1((vccstate == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1); static const uint8_t PROGMEM init5[] = { - SSD1306_SETVCOMDETECT, // 0xDB - 0x40, - SSD1306_DISPLAYALLON_RESUME, // 0xA4 - SSD1306_NORMALDISPLAY, // 0xA6 - SSD1306_DEACTIVATE_SCROLL, - SSD1306_DISPLAYON }; // Main screen turn on + SSD1306_SETVCOMDETECT, // 0xDB + 0x40, + SSD1306_DISPLAYALLON_RESUME, // 0xA4 + SSD1306_NORMALDISPLAY, // 0xA6 + SSD1306_DEACTIVATE_SCROLL, + SSD1306_DISPLAYON}; // Main screen turn on ssd1306_commandList(init5, sizeof(init5)); TRANSACTION_END @@ -598,26 +603,32 @@ boolean Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, boolean reset, commands as needed by one's own application. */ void Adafruit_SSD1306::drawPixel(int16_t x, int16_t y, uint16_t color) { - if((x >= 0) && (x < width()) && (y >= 0) && (y < height())) { + if ((x >= 0) && (x < width()) && (y >= 0) && (y < height())) { // Pixel is in-bounds. Rotate coordinates if needed. - switch(getRotation()) { - case 1: + switch (getRotation()) { + case 1: ssd1306_swap(x, y); x = WIDTH - x - 1; break; - case 2: - x = WIDTH - x - 1; + case 2: + x = WIDTH - x - 1; y = HEIGHT - y - 1; break; - case 3: + case 3: ssd1306_swap(x, y); y = HEIGHT - y - 1; break; } - switch(color) { - case SSD1306_WHITE: buffer[x + (y/8)*WIDTH] |= (1 << (y&7)); break; - case SSD1306_BLACK: buffer[x + (y/8)*WIDTH] &= ~(1 << (y&7)); break; - case SSD1306_INVERSE: buffer[x + (y/8)*WIDTH] ^= (1 << (y&7)); break; + switch (color) { + case SSD1306_WHITE: + buffer[x + (y / 8) * WIDTH] |= (1 << (y & 7)); + break; + case SSD1306_BLACK: + buffer[x + (y / 8) * WIDTH] &= ~(1 << (y & 7)); + break; + case SSD1306_INVERSE: + buffer[x + (y / 8) * WIDTH] ^= (1 << (y & 7)); + break; } } } @@ -649,54 +660,68 @@ void Adafruit_SSD1306::clearDisplay(void) { Follow up with a call to display(), or with other graphics commands as needed by one's own application. */ -void Adafruit_SSD1306::drawFastHLine( - int16_t x, int16_t y, int16_t w, uint16_t color) { +void Adafruit_SSD1306::drawFastHLine(int16_t x, int16_t y, int16_t w, + uint16_t color) { boolean bSwap = false; - switch(rotation) { - case 1: + switch (rotation) { + case 1: // 90 degree rotation, swap x & y for rotation, then invert x bSwap = true; ssd1306_swap(x, y); x = WIDTH - x - 1; break; - case 2: + case 2: // 180 degree rotation, invert x and y, then shift y around for height. - x = WIDTH - x - 1; - y = HEIGHT - y - 1; - x -= (w-1); + x = WIDTH - x - 1; + y = HEIGHT - y - 1; + x -= (w - 1); break; - case 3: + case 3: // 270 degree rotation, swap x & y for rotation, // then invert y and adjust y for w (not to become h) bSwap = true; ssd1306_swap(x, y); - y = HEIGHT - y - 1; - y -= (w-1); + y = HEIGHT - y - 1; + y -= (w - 1); break; } - if(bSwap) drawFastVLineInternal(x, y, w, color); - else drawFastHLineInternal(x, y, w, color); + if (bSwap) + drawFastVLineInternal(x, y, w, color); + else + drawFastHLineInternal(x, y, w, color); } -void Adafruit_SSD1306::drawFastHLineInternal( - int16_t x, int16_t y, int16_t w, uint16_t color) { +void Adafruit_SSD1306::drawFastHLineInternal(int16_t x, int16_t y, int16_t w, + uint16_t color) { - if((y >= 0) && (y < HEIGHT)) { // Y coord in bounds? - if(x < 0) { // Clip left + if ((y >= 0) && (y < HEIGHT)) { // Y coord in bounds? + if (x < 0) { // Clip left w += x; - x = 0; + x = 0; } - if((x + w) > WIDTH) { // Clip right + if ((x + w) > WIDTH) { // Clip right w = (WIDTH - x); } - if(w > 0) { // Proceed only if width is positive - uint8_t *pBuf = &buffer[(y / 8) * WIDTH + x], - mask = 1 << (y & 7); - switch(color) { - case SSD1306_WHITE: while(w--) { *pBuf++ |= mask; }; break; - case SSD1306_BLACK: mask = ~mask; while(w--) { *pBuf++ &= mask; }; break; - case SSD1306_INVERSE: while(w--) { *pBuf++ ^= mask; }; break; + if (w > 0) { // Proceed only if width is positive + uint8_t *pBuf = &buffer[(y / 8) * WIDTH + x], mask = 1 << (y & 7); + switch (color) { + case SSD1306_WHITE: + while (w--) { + *pBuf++ |= mask; + }; + break; + case SSD1306_BLACK: + mask = ~mask; + while (w--) { + *pBuf++ &= mask; + }; + break; + case SSD1306_INVERSE: + while (w--) { + *pBuf++ ^= mask; + }; + break; } } } @@ -718,25 +743,25 @@ void Adafruit_SSD1306::drawFastHLineInternal( Follow up with a call to display(), or with other graphics commands as needed by one's own application. */ -void Adafruit_SSD1306::drawFastVLine( - int16_t x, int16_t y, int16_t h, uint16_t color) { +void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h, + uint16_t color) { boolean bSwap = false; - switch(rotation) { - case 1: + switch (rotation) { + case 1: // 90 degree rotation, swap x & y for rotation, // then invert x and adjust x for h (now to become w) bSwap = true; ssd1306_swap(x, y); - x = WIDTH - x - 1; - x -= (h-1); + x = WIDTH - x - 1; + x -= (h - 1); break; - case 2: + case 2: // 180 degree rotation, invert x and y, then shift y around for height. - x = WIDTH - x - 1; + x = WIDTH - x - 1; y = HEIGHT - y - 1; - y -= (h-1); + y -= (h - 1); break; - case 3: + case 3: // 270 degree rotation, swap x & y for rotation, then invert y bSwap = true; ssd1306_swap(x, y); @@ -744,91 +769,106 @@ void Adafruit_SSD1306::drawFastVLine( break; } - if(bSwap) drawFastHLineInternal(x, y, h, color); - else drawFastVLineInternal(x, y, h, color); + if (bSwap) + drawFastHLineInternal(x, y, h, color); + else + drawFastVLineInternal(x, y, h, color); } -void Adafruit_SSD1306::drawFastVLineInternal( - int16_t x, int16_t __y, int16_t __h, uint16_t color) { +void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, + int16_t __h, uint16_t color) { - if((x >= 0) && (x < WIDTH)) { // X coord in bounds? - if(__y < 0) { // Clip top + if ((x >= 0) && (x < WIDTH)) { // X coord in bounds? + if (__y < 0) { // Clip top __h += __y; __y = 0; } - if((__y + __h) > HEIGHT) { // Clip bottom + if ((__y + __h) > HEIGHT) { // Clip bottom __h = (HEIGHT - __y); } - if(__h > 0) { // Proceed only if height is now positive + if (__h > 0) { // Proceed only if height is now positive // this display doesn't need ints for coordinates, // use local byte registers for faster juggling - uint8_t y = __y, h = __h; + uint8_t y = __y, h = __h; uint8_t *pBuf = &buffer[(y / 8) * WIDTH + x]; // do the first partial byte, if necessary - this requires some masking uint8_t mod = (y & 7); - if(mod) { + if (mod) { // mask off the high n bits we want to set mod = 8 - mod; // note - lookup table results in a nearly 10% performance // improvement in fill* functions // uint8_t mask = ~(0xFF >> mod); - static const uint8_t PROGMEM premask[8] = - { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; + static const uint8_t PROGMEM premask[8] = {0x00, 0x80, 0xC0, 0xE0, + 0xF0, 0xF8, 0xFC, 0xFE}; uint8_t mask = pgm_read_byte(&premask[mod]); // adjust the mask if we're not going to reach the end of this byte - if(h < mod) mask &= (0XFF >> (mod - h)); - - switch(color) { - case SSD1306_WHITE: *pBuf |= mask; break; - case SSD1306_BLACK: *pBuf &= ~mask; break; - case SSD1306_INVERSE: *pBuf ^= mask; break; + if (h < mod) + mask &= (0XFF >> (mod - h)); + + switch (color) { + case SSD1306_WHITE: + *pBuf |= mask; + break; + case SSD1306_BLACK: + *pBuf &= ~mask; + break; + case SSD1306_INVERSE: + *pBuf ^= mask; + break; } pBuf += WIDTH; } - if(h >= mod) { // More to go? + if (h >= mod) { // More to go? h -= mod; // Write solid bytes while we can - effectively 8 rows at a time - if(h >= 8) { - if(color == SSD1306_INVERSE) { + if (h >= 8) { + if (color == SSD1306_INVERSE) { // separate copy of the code so we don't impact performance of // black/white write version with an extra comparison per loop do { - *pBuf ^= 0xFF; // Invert byte - pBuf += WIDTH; // Advance pointer 8 rows - h -= 8; // Subtract 8 rows from height - } while(h >= 8); + *pBuf ^= 0xFF; // Invert byte + pBuf += WIDTH; // Advance pointer 8 rows + h -= 8; // Subtract 8 rows from height + } while (h >= 8); } else { // store a local value to work with uint8_t val = (color != SSD1306_BLACK) ? 255 : 0; do { - *pBuf = val; // Set byte - pBuf += WIDTH; // Advance pointer 8 rows - h -= 8; // Subtract 8 rows from height - } while(h >= 8); + *pBuf = val; // Set byte + pBuf += WIDTH; // Advance pointer 8 rows + h -= 8; // Subtract 8 rows from height + } while (h >= 8); } } - if(h) { // Do the final partial byte, if necessary + if (h) { // Do the final partial byte, if necessary mod = h & 7; // this time we want to mask the low bits of the byte, // vs the high bits we did above // uint8_t mask = (1 << mod) - 1; // note - lookup table results in a nearly 10% performance // improvement in fill* functions - static const uint8_t PROGMEM postmask[8] = - { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F }; + static const uint8_t PROGMEM postmask[8] = {0x00, 0x01, 0x03, 0x07, + 0x0F, 0x1F, 0x3F, 0x7F}; uint8_t mask = pgm_read_byte(&postmask[mod]); - switch(color) { - case SSD1306_WHITE: *pBuf |= mask; break; - case SSD1306_BLACK: *pBuf &= ~mask; break; - case SSD1306_INVERSE: *pBuf ^= mask; break; + switch (color) { + case SSD1306_WHITE: + *pBuf |= mask; + break; + case SSD1306_BLACK: + *pBuf &= ~mask; + break; + case SSD1306_INVERSE: + *pBuf ^= mask; + break; } } } } // endif positive height - } // endif x in bounds + } // endif x in bounds } /*! @@ -837,24 +877,24 @@ void Adafruit_SSD1306::drawFastVLineInternal( Column of display -- 0 at left to (screen width - 1) at right. @param y Row of display -- 0 at top to (screen height -1) at bottom. - @return true if pixel is set (usually SSD1306_WHITE, unless display invert mode - is enabled), false if clear (SSD1306_BLACK). + @return true if pixel is set (usually SSD1306_WHITE, unless display invert + mode is enabled), false if clear (SSD1306_BLACK). @note Reads from buffer contents; may not reflect current contents of screen if display() has not been called. */ boolean Adafruit_SSD1306::getPixel(int16_t x, int16_t y) { - if((x >= 0) && (x < width()) && (y >= 0) && (y < height())) { + if ((x >= 0) && (x < width()) && (y >= 0) && (y < height())) { // Pixel is in-bounds. Rotate coordinates if needed. - switch(getRotation()) { - case 1: + switch (getRotation()) { + case 1: ssd1306_swap(x, y); x = WIDTH - x - 1; break; - case 2: - x = WIDTH - x - 1; + case 2: + x = WIDTH - x - 1; y = HEIGHT - y - 1; break; - case 3: + case 3: ssd1306_swap(x, y); y = HEIGHT - y - 1; break; @@ -869,9 +909,7 @@ boolean Adafruit_SSD1306::getPixel(int16_t x, int16_t y) { @return Pointer to an unsigned 8-bit array, column-major, columns padded to full byte boundary if needed. */ -uint8_t *Adafruit_SSD1306::getBuffer(void) { - return buffer; -} +uint8_t *Adafruit_SSD1306::getBuffer(void) { return buffer; } // REFRESH DISPLAY --------------------------------------------------------- @@ -885,11 +923,10 @@ uint8_t *Adafruit_SSD1306::getBuffer(void) { void Adafruit_SSD1306::display(void) { TRANSACTION_START static const uint8_t PROGMEM dlist1[] = { - SSD1306_PAGEADDR, - 0, // Page start address - 0xFF, // Page end (not really, but works here) - SSD1306_COLUMNADDR, - 0 }; // Column start address + SSD1306_PAGEADDR, + 0, // Page start address + 0xFF, // Page end (not really, but works here) + SSD1306_COLUMNADDR, 0}; // Column start address ssd1306_commandList(dlist1, sizeof(dlist1)); ssd1306_command1(WIDTH - 1); // Column end address @@ -903,13 +940,13 @@ void Adafruit_SSD1306::display(void) { yield(); #endif uint16_t count = WIDTH * ((HEIGHT + 7) / 8); - uint8_t *ptr = buffer; - if(wire) { // I2C + uint8_t *ptr = buffer; + if (wire) { // I2C wire->beginTransmission(i2caddr); WIRE_WRITE((uint8_t)0x40); uint8_t bytesOut = 1; - while(count--) { - if(bytesOut >= WIRE_MAX) { + while (count--) { + if (bytesOut >= WIRE_MAX) { wire->endTransmission(); wire->beginTransmission(i2caddr); WIRE_WRITE((uint8_t)0x40); @@ -921,7 +958,8 @@ void Adafruit_SSD1306::display(void) { wire->endTransmission(); } else { // SPI SSD1306_MODE_DATA - while(count--) SPIwrite(*ptr++); + while (count--) + SPIwrite(*ptr++); } TRANSACTION_END #if defined(ESP8266) @@ -943,16 +981,13 @@ void Adafruit_SSD1306::display(void) { void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop) { TRANSACTION_START static const uint8_t PROGMEM scrollList1a[] = { - SSD1306_RIGHT_HORIZONTAL_SCROLL, - 0X00 }; + SSD1306_RIGHT_HORIZONTAL_SCROLL, 0X00}; ssd1306_commandList(scrollList1a, sizeof(scrollList1a)); ssd1306_command1(start); ssd1306_command1(0X00); ssd1306_command1(stop); - static const uint8_t PROGMEM scrollList1b[] = { - 0X00, - 0XFF, - SSD1306_ACTIVATE_SCROLL }; + static const uint8_t PROGMEM scrollList1b[] = {0X00, 0XFF, + SSD1306_ACTIVATE_SCROLL}; ssd1306_commandList(scrollList1b, sizeof(scrollList1b)); TRANSACTION_END } @@ -968,17 +1003,14 @@ void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop) { // To scroll the whole display, run: display.startscrollleft(0x00, 0x0F) void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop) { TRANSACTION_START - static const uint8_t PROGMEM scrollList2a[] = { - SSD1306_LEFT_HORIZONTAL_SCROLL, - 0X00 }; + static const uint8_t PROGMEM scrollList2a[] = {SSD1306_LEFT_HORIZONTAL_SCROLL, + 0X00}; ssd1306_commandList(scrollList2a, sizeof(scrollList2a)); ssd1306_command1(start); ssd1306_command1(0X00); ssd1306_command1(stop); - static const uint8_t PROGMEM scrollList2b[] = { - 0X00, - 0XFF, - SSD1306_ACTIVATE_SCROLL }; + static const uint8_t PROGMEM scrollList2b[] = {0X00, 0XFF, + SSD1306_ACTIVATE_SCROLL}; ssd1306_commandList(scrollList2b, sizeof(scrollList2b)); TRANSACTION_END } @@ -995,20 +1027,16 @@ void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop) { void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop) { TRANSACTION_START static const uint8_t PROGMEM scrollList3a[] = { - SSD1306_SET_VERTICAL_SCROLL_AREA, - 0X00 }; + SSD1306_SET_VERTICAL_SCROLL_AREA, 0X00}; ssd1306_commandList(scrollList3a, sizeof(scrollList3a)); ssd1306_command1(HEIGHT); static const uint8_t PROGMEM scrollList3b[] = { - SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL, - 0X00 }; + SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL, 0X00}; ssd1306_commandList(scrollList3b, sizeof(scrollList3b)); ssd1306_command1(start); ssd1306_command1(0X00); ssd1306_command1(stop); - static const uint8_t PROGMEM scrollList3c[] = { - 0X01, - SSD1306_ACTIVATE_SCROLL }; + static const uint8_t PROGMEM scrollList3c[] = {0X01, SSD1306_ACTIVATE_SCROLL}; ssd1306_commandList(scrollList3c, sizeof(scrollList3c)); TRANSACTION_END } @@ -1025,20 +1053,16 @@ void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop) { void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop) { TRANSACTION_START static const uint8_t PROGMEM scrollList4a[] = { - SSD1306_SET_VERTICAL_SCROLL_AREA, - 0X00 }; + SSD1306_SET_VERTICAL_SCROLL_AREA, 0X00}; ssd1306_commandList(scrollList4a, sizeof(scrollList4a)); ssd1306_command1(HEIGHT); static const uint8_t PROGMEM scrollList4b[] = { - SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL, - 0X00 }; + SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL, 0X00}; ssd1306_commandList(scrollList4b, sizeof(scrollList4b)); ssd1306_command1(start); ssd1306_command1(0X00); ssd1306_command1(stop); - static const uint8_t PROGMEM scrollList4c[] = { - 0X01, - SSD1306_ACTIVATE_SCROLL }; + static const uint8_t PROGMEM scrollList4c[] = {0X01, SSD1306_ACTIVATE_SCROLL}; ssd1306_commandList(scrollList4c, sizeof(scrollList4c)); TRANSACTION_END } @@ -1065,8 +1089,8 @@ void Adafruit_SSD1306::stopscroll(void) { @note This has an immediate effect on the display, no need to call the display() function -- buffer contents are not changed, rather a different pixel mode of the display hardware is used. When - enabled, drawing SSD1306_BLACK (value 0) pixels will actually draw white, - SSD1306_WHITE (value 1) will draw black. + enabled, drawing SSD1306_BLACK (value 0) pixels will actually draw + white, SSD1306_WHITE (value 1) will draw black. */ void Adafruit_SSD1306::invertDisplay(boolean i) { TRANSACTION_START diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h index a8d6c87..75236bb 100644 --- a/Adafruit_SSD1306.h +++ b/Adafruit_SSD1306.h @@ -26,95 +26,97 @@ // ONE of the following three lines must be #defined: //#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen -#define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen +#define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen //#define SSD1306_96_16 ///< DEPRECATED: old way to specify 96x16 screen // This establishes the screen dimensions in old Adafruit_SSD1306 sketches // (NEW CODE SHOULD IGNORE THIS, USE THE CONSTRUCTORS THAT ACCEPT WIDTH // AND HEIGHT ARGUMENTS). #if defined(ARDUINO_STM32_FEATHER) - typedef class HardwareSPI SPIClass; +typedef class HardwareSPI SPIClass; #endif -#include -#include #include +#include +#include #if defined(__AVR__) - typedef volatile uint8_t PortReg; - typedef uint8_t PortMask; - #define HAVE_PORTREG +typedef volatile uint8_t PortReg; +typedef uint8_t PortMask; +#define HAVE_PORTREG #elif defined(__SAM3X8E__) - typedef volatile RwReg PortReg; - typedef uint32_t PortMask; - #define HAVE_PORTREG -#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && !defined(ARDUINO_ARCH_MBED) - typedef volatile uint32_t PortReg; - typedef uint32_t PortMask; - #define HAVE_PORTREG +typedef volatile RwReg PortReg; +typedef uint32_t PortMask; +#define HAVE_PORTREG +#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \ + !defined(ARDUINO_ARCH_MBED) +typedef volatile uint32_t PortReg; +typedef uint32_t PortMask; +#define HAVE_PORTREG #endif /// The following "raw" color names are kept for backwards client compatability -/// They can be disabled by predefining this macro before including the Adafruit header -/// client code will then need to be modified to use the scoped enum values directly +/// They can be disabled by predefining this macro before including the Adafruit +/// header client code will then need to be modified to use the scoped enum +/// values directly #ifndef NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY -#define BLACK SSD1306_BLACK ///< Draw 'off' pixels -#define WHITE SSD1306_WHITE ///< Draw 'on' pixels -#define INVERSE SSD1306_INVERSE ///< Invert pixels +#define BLACK SSD1306_BLACK ///< Draw 'off' pixels +#define WHITE SSD1306_WHITE ///< Draw 'on' pixels +#define INVERSE SSD1306_INVERSE ///< Invert pixels #endif - /// fit into the SSD1306_ naming scheme -#define SSD1306_BLACK 0 ///< Draw 'off' pixels -#define SSD1306_WHITE 1 ///< Draw 'on' pixels -#define SSD1306_INVERSE 2 ///< Invert pixels - -#define SSD1306_MEMORYMODE 0x20 ///< See datasheet -#define SSD1306_COLUMNADDR 0x21 ///< See datasheet -#define SSD1306_PAGEADDR 0x22 ///< See datasheet -#define SSD1306_SETCONTRAST 0x81 ///< See datasheet -#define SSD1306_CHARGEPUMP 0x8D ///< See datasheet -#define SSD1306_SEGREMAP 0xA0 ///< See datasheet +/// fit into the SSD1306_ naming scheme +#define SSD1306_BLACK 0 ///< Draw 'off' pixels +#define SSD1306_WHITE 1 ///< Draw 'on' pixels +#define SSD1306_INVERSE 2 ///< Invert pixels + +#define SSD1306_MEMORYMODE 0x20 ///< See datasheet +#define SSD1306_COLUMNADDR 0x21 ///< See datasheet +#define SSD1306_PAGEADDR 0x22 ///< See datasheet +#define SSD1306_SETCONTRAST 0x81 ///< See datasheet +#define SSD1306_CHARGEPUMP 0x8D ///< See datasheet +#define SSD1306_SEGREMAP 0xA0 ///< See datasheet #define SSD1306_DISPLAYALLON_RESUME 0xA4 ///< See datasheet -#define SSD1306_DISPLAYALLON 0xA5 ///< Not currently used -#define SSD1306_NORMALDISPLAY 0xA6 ///< See datasheet -#define SSD1306_INVERTDISPLAY 0xA7 ///< See datasheet -#define SSD1306_SETMULTIPLEX 0xA8 ///< See datasheet -#define SSD1306_DISPLAYOFF 0xAE ///< See datasheet -#define SSD1306_DISPLAYON 0xAF ///< See datasheet -#define SSD1306_COMSCANINC 0xC0 ///< Not currently used -#define SSD1306_COMSCANDEC 0xC8 ///< See datasheet -#define SSD1306_SETDISPLAYOFFSET 0xD3 ///< See datasheet -#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 ///< See datasheet -#define SSD1306_SETPRECHARGE 0xD9 ///< See datasheet -#define SSD1306_SETCOMPINS 0xDA ///< See datasheet -#define SSD1306_SETVCOMDETECT 0xDB ///< See datasheet - -#define SSD1306_SETLOWCOLUMN 0x00 ///< Not currently used -#define SSD1306_SETHIGHCOLUMN 0x10 ///< Not currently used -#define SSD1306_SETSTARTLINE 0x40 ///< See datasheet - -#define SSD1306_EXTERNALVCC 0x01 ///< External display voltage source -#define SSD1306_SWITCHCAPVCC 0x02 ///< Gen. display voltage from 3.3V - -#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll -#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 ///< Init left scroll +#define SSD1306_DISPLAYALLON 0xA5 ///< Not currently used +#define SSD1306_NORMALDISPLAY 0xA6 ///< See datasheet +#define SSD1306_INVERTDISPLAY 0xA7 ///< See datasheet +#define SSD1306_SETMULTIPLEX 0xA8 ///< See datasheet +#define SSD1306_DISPLAYOFF 0xAE ///< See datasheet +#define SSD1306_DISPLAYON 0xAF ///< See datasheet +#define SSD1306_COMSCANINC 0xC0 ///< Not currently used +#define SSD1306_COMSCANDEC 0xC8 ///< See datasheet +#define SSD1306_SETDISPLAYOFFSET 0xD3 ///< See datasheet +#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 ///< See datasheet +#define SSD1306_SETPRECHARGE 0xD9 ///< See datasheet +#define SSD1306_SETCOMPINS 0xDA ///< See datasheet +#define SSD1306_SETVCOMDETECT 0xDB ///< See datasheet + +#define SSD1306_SETLOWCOLUMN 0x00 ///< Not currently used +#define SSD1306_SETHIGHCOLUMN 0x10 ///< Not currently used +#define SSD1306_SETSTARTLINE 0x40 ///< See datasheet + +#define SSD1306_EXTERNALVCC 0x01 ///< External display voltage source +#define SSD1306_SWITCHCAPVCC 0x02 ///< Gen. display voltage from 3.3V + +#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll +#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 ///< Init left scroll #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 ///< Init diag scroll -#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A ///< Init diag scroll -#define SSD1306_DEACTIVATE_SCROLL 0x2E ///< Stop scroll -#define SSD1306_ACTIVATE_SCROLL 0x2F ///< Start scroll -#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 ///< Set scroll range +#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A ///< Init diag scroll +#define SSD1306_DEACTIVATE_SCROLL 0x2E ///< Stop scroll +#define SSD1306_ACTIVATE_SCROLL 0x2F ///< Start scroll +#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 ///< Set scroll range // Deprecated size stuff for backwards compatibility with old sketches #if defined SSD1306_128_64 - #define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_64 defined - #define SSD1306_LCDHEIGHT 64 ///< DEPRECATED: height w/SSD1306_128_64 defined +#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_64 defined +#define SSD1306_LCDHEIGHT 64 ///< DEPRECATED: height w/SSD1306_128_64 defined #endif #if defined SSD1306_128_32 - #define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_32 defined - #define SSD1306_LCDHEIGHT 32 ///< DEPRECATED: height w/SSD1306_128_32 defined +#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_32 defined +#define SSD1306_LCDHEIGHT 32 ///< DEPRECATED: height w/SSD1306_128_32 defined #endif #if defined SSD1306_96_16 - #define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined - #define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined +#define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined +#define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined #endif /*! @@ -122,69 +124,67 @@ SSD1306 OLED displays. */ class Adafruit_SSD1306 : public Adafruit_GFX { - public: +public: // NEW CONSTRUCTORS -- recommended for new projects - Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi=&Wire, int8_t rst_pin=-1, - uint32_t clkDuring=400000UL, uint32_t clkAfter=100000UL); + Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi = &Wire, + int8_t rst_pin = -1, uint32_t clkDuring = 400000UL, + uint32_t clkAfter = 100000UL); Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin, int8_t sclk_pin, - int8_t dc_pin, int8_t rst_pin, int8_t cs_pin); - Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, - int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, uint32_t bitrate=8000000UL); + int8_t dc_pin, int8_t rst_pin, int8_t cs_pin); + Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, int8_t dc_pin, + int8_t rst_pin, int8_t cs_pin, uint32_t bitrate = 8000000UL); // DEPRECATED CONSTRUCTORS - for back compatibility, avoid in new projects Adafruit_SSD1306(int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, - int8_t rst_pin, int8_t cs_pin); + int8_t rst_pin, int8_t cs_pin); Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, int8_t cs_pin); Adafruit_SSD1306(int8_t rst_pin = -1); ~Adafruit_SSD1306(void); - boolean begin(uint8_t switchvcc=SSD1306_SWITCHCAPVCC, - uint8_t i2caddr=0, boolean reset=true, - boolean periphBegin=true); - void display(void); - void clearDisplay(void); - void invertDisplay(boolean i); - void dim(boolean dim); - void drawPixel(int16_t x, int16_t y, uint16_t color); + boolean begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = 0, + boolean reset = true, boolean periphBegin = true); + void display(void); + void clearDisplay(void); + void invertDisplay(boolean i); + void dim(boolean dim); + void drawPixel(int16_t x, int16_t y, uint16_t color); virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - void startscrollright(uint8_t start, uint8_t stop); - void startscrollleft(uint8_t start, uint8_t stop); - void startscrolldiagright(uint8_t start, uint8_t stop); - void startscrolldiagleft(uint8_t start, uint8_t stop); - void stopscroll(void); - void ssd1306_command(uint8_t c); - boolean getPixel(int16_t x, int16_t y); - uint8_t *getBuffer(void); - - private: - inline void SPIwrite(uint8_t d) __attribute__((always_inline)); - void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, - uint16_t color); - void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, - uint16_t color); - void ssd1306_command1(uint8_t c); - void ssd1306_commandList(const uint8_t *c, uint8_t n); - - SPIClass *spi; - TwoWire *wire; - uint8_t *buffer; - int8_t i2caddr, vccstate, page_end; - int8_t mosiPin , clkPin , dcPin , csPin, rstPin; + void startscrollright(uint8_t start, uint8_t stop); + void startscrollleft(uint8_t start, uint8_t stop); + void startscrolldiagright(uint8_t start, uint8_t stop); + void startscrolldiagleft(uint8_t start, uint8_t stop); + void stopscroll(void); + void ssd1306_command(uint8_t c); + boolean getPixel(int16_t x, int16_t y); + uint8_t *getBuffer(void); + +private: + inline void SPIwrite(uint8_t d) __attribute__((always_inline)); + void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color); + void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color); + void ssd1306_command1(uint8_t c); + void ssd1306_commandList(const uint8_t *c, uint8_t n); + + SPIClass *spi; + TwoWire *wire; + uint8_t *buffer; + int8_t i2caddr, vccstate, page_end; + int8_t mosiPin, clkPin, dcPin, csPin, rstPin; #ifdef HAVE_PORTREG - PortReg *mosiPort , *clkPort , *dcPort , *csPort; - PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask; + PortReg *mosiPort, *clkPort, *dcPort, *csPort; + PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask; #endif #if ARDUINO >= 157 - uint32_t wireClk; // Wire speed for SSD1306 transfers - uint32_t restoreClk; // Wire speed following SSD1306 transfers + uint32_t wireClk; // Wire speed for SSD1306 transfers + uint32_t restoreClk; // Wire speed following SSD1306 transfers #endif - uint8_t contrast; // normal contrast setting for this device + uint8_t contrast; // normal contrast setting for this device #if defined(SPI_HAS_TRANSACTION) protected: // Allow sub-class to change - SPISettings spiSettings; + SPISettings spiSettings; #endif }; diff --git a/README.md b/README.md index 4d71f95..ab1b45a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Adafruit_SSD1306 [![Build Status](https://travis-ci.org/adafruit/Adafruit_SSD1306.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_SSD1306) +# Adafruit_SSD1306 [![Build Status](https://github.com/adafruit/Adafruit_SSD1306/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_SSD1306/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_SSD1306/html/index.html) This is a library for our Monochrome OLEDs based on SSD1306 drivers diff --git a/library.properties b/library.properties index bc4843d..34a56dc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit SSD1306 -version=2.2.1 +version=2.3.0 author=Adafruit maintainer=Adafruit sentence=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays diff --git a/splash.h b/splash.h index 813fa53..1520e32 100644 --- a/splash.h +++ b/splash.h @@ -1,108 +1,182 @@ -#define splash1_width 82 +#define splash1_width 82 #define splash1_height 64 const uint8_t PROGMEM splash1_data[] = { - B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B10000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000011,B10000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000111,B11000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000111,B11000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00001111,B11000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,B11100000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,B11100000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11100000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11110000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B01111111,B11110000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00011111,B11111000,B01111111,B11110000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00111111,B11111110,B01111111,B11110000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00111111,B11111111,B01111111,B11110000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00011111,B11111111,B11111011,B11100000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00001111,B11111111,B11111001,B11111111,B11000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00001111,B11111111,B11111001,B11111111,B11111000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000111,B11111111,B11110001,B11111111,B11111111,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000011,B11111100,B01110011,B11111111,B11111111,B10000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000001,B11111110,B00111111,B11111111,B11111111,B10000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B11111111,B00011110,B00001111,B11111111,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B01111111,B11111110,B00011111,B11111100,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00001111,B11011111,B11111111,B11100000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00011111,B00011001,B11111111,B11000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00111111,B00111100,B11111111,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B01111110,B01111100,B11111000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B01111111,B11111110,B01111100,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B11111111,B11111111,B11111100,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000001,B11111111,B11101111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000001,B11111111,B11001111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000011,B11111111,B00000111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000011,B11111100,B00000111,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000011,B11110000,B00000011,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000001,B10000000,B00000000,B11111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00111110,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001100,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B00000111,B10000000,B00000000,B11111100,B00000000,B00000000,B00000011,B11000000,B00000000, - B00000000,B00000000,B00000111,B10000000,B00000001,B11111100,B00000000,B00000000,B00000011,B11000000,B00000000, - B00000000,B00000000,B00000111,B10000000,B00000001,B11111100,B00000000,B00000000,B00000011,B11000000,B00000000, - B00000000,B00000000,B00000111,B10000000,B00000001,B11100000,B00000000,B00000000,B00000000,B00011110,B00000000, - B00000000,B00000000,B00000111,B10000000,B00000001,B11100000,B00000000,B00000000,B00000000,B00011110,B00000000, - B01111111,B11100011,B11110111,B10011111,B11111001,B11111101,B11100111,B01111000,B01111011,B11011111,B11000000, - B11111111,B11110111,B11111111,B10111111,B11111101,B11111101,B11111111,B01111000,B01111011,B11011111,B11000000, - B11111111,B11110111,B11111111,B10111111,B11111101,B11111101,B11111111,B01111000,B01111011,B11011111,B11000000, - B11110000,B11110111,B10000111,B10111100,B00111101,B11100001,B11111111,B01111000,B01111011,B11011110,B00000000, - B11110000,B11110111,B10000111,B10111100,B00111101,B11100001,B11110000,B01111000,B01111011,B11011110,B00000000, - B00000000,B11110111,B10000111,B10000000,B00111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B01111111,B11110111,B10000111,B10011111,B11111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B11111111,B11110111,B10000111,B10111111,B11111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B11110000,B11110111,B10000111,B10111100,B00111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B11110000,B11110111,B10000111,B10111100,B00111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B11110000,B11110111,B10000111,B10111100,B00111101,B11100001,B11100000,B01111000,B01111011,B11011110,B00000000, - B11111111,B11110111,B11111111,B10111111,B11111101,B11100001,B11100000,B01111111,B11111011,B11011111,B11000000, - B11111111,B11110111,B11111111,B10111111,B11111101,B11100001,B11100000,B01111111,B11111011,B11011111,B11000000, - B01111100,B11110011,B11110011,B10011111,B00111101,B11100001,B11100000,B00111110,B01111011,B11001111,B11000000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11000000, - B11111111,B11111111,B11111111,B11111111,B11111101,B01101000,B11011011,B00010001,B00011010,B00110001,B11000000, - B11111111,B11111111,B11111111,B11111111,B11111101,B00101011,B01011010,B11111011,B01101010,B11101111,B11000000, - B11111111,B11111111,B11111111,B11111111,B11111101,B01001011,B01011011,B00111011,B00011010,B00110011,B11000000, - B11111111,B11111111,B11111111,B11111111,B11111101,B01101011,B01011011,B11011011,B01101010,B11111101,B11000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B10000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000011, B10000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000111, + B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000111, B11000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00001111, B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00011111, B11100000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00011111, B11100000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00111111, B11100000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00111111, B11110000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B01111111, + B11110000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00011111, B11111000, B01111111, B11110000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00111111, B11111110, + B01111111, B11110000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00111111, B11111111, B01111111, B11110000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00011111, + B11111111, B11111011, B11100000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00001111, B11111111, B11111001, B11111111, + B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00001111, B11111111, B11111001, B11111111, B11111000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000111, B11111111, B11110001, + B11111111, B11111111, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000011, B11111100, B01110011, B11111111, B11111111, B10000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B11111110, + B00111111, B11111111, B11111111, B10000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B11111111, B00011110, B00001111, B11111111, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B01111111, B11111110, B00011111, B11111100, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00111111, B11111111, B11111111, + B11111000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00001111, B11011111, B11111111, B11100000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00011111, B00011001, + B11111111, B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00111111, B00111100, B11111111, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B01111110, + B01111100, B11111000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B01111111, B11111110, B01111100, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B11111111, B11111111, B11111100, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B11111111, B11111111, B11111110, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B11111111, B11111111, B11111110, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000001, B11111111, B11101111, + B11111110, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000001, B11111111, B11001111, B11111110, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B11111111, + B00000111, B11111110, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000011, B11111100, B00000111, B11111110, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, + B11110000, B00000011, B11111110, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000001, B10000000, B00000000, B11111110, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B01111110, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00111110, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00001100, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000111, B10000000, B00000000, + B11111100, B00000000, B00000000, B00000011, B11000000, B00000000, B00000000, + B00000000, B00000111, B10000000, B00000001, B11111100, B00000000, B00000000, + B00000011, B11000000, B00000000, B00000000, B00000000, B00000111, B10000000, + B00000001, B11111100, B00000000, B00000000, B00000011, B11000000, B00000000, + B00000000, B00000000, B00000111, B10000000, B00000001, B11100000, B00000000, + B00000000, B00000000, B00011110, B00000000, B00000000, B00000000, B00000111, + B10000000, B00000001, B11100000, B00000000, B00000000, B00000000, B00011110, + B00000000, B01111111, B11100011, B11110111, B10011111, B11111001, B11111101, + B11100111, B01111000, B01111011, B11011111, B11000000, B11111111, B11110111, + B11111111, B10111111, B11111101, B11111101, B11111111, B01111000, B01111011, + B11011111, B11000000, B11111111, B11110111, B11111111, B10111111, B11111101, + B11111101, B11111111, B01111000, B01111011, B11011111, B11000000, B11110000, + B11110111, B10000111, B10111100, B00111101, B11100001, B11111111, B01111000, + B01111011, B11011110, B00000000, B11110000, B11110111, B10000111, B10111100, + B00111101, B11100001, B11110000, B01111000, B01111011, B11011110, B00000000, + B00000000, B11110111, B10000111, B10000000, B00111101, B11100001, B11100000, + B01111000, B01111011, B11011110, B00000000, B01111111, B11110111, B10000111, + B10011111, B11111101, B11100001, B11100000, B01111000, B01111011, B11011110, + B00000000, B11111111, B11110111, B10000111, B10111111, B11111101, B11100001, + B11100000, B01111000, B01111011, B11011110, B00000000, B11110000, B11110111, + B10000111, B10111100, B00111101, B11100001, B11100000, B01111000, B01111011, + B11011110, B00000000, B11110000, B11110111, B10000111, B10111100, B00111101, + B11100001, B11100000, B01111000, B01111011, B11011110, B00000000, B11110000, + B11110111, B10000111, B10111100, B00111101, B11100001, B11100000, B01111000, + B01111011, B11011110, B00000000, B11111111, B11110111, B11111111, B10111111, + B11111101, B11100001, B11100000, B01111111, B11111011, B11011111, B11000000, + B11111111, B11110111, B11111111, B10111111, B11111101, B11100001, B11100000, + B01111111, B11111011, B11011111, B11000000, B01111100, B11110011, B11110011, + B10011111, B00111101, B11100001, B11100000, B00111110, B01111011, B11001111, + B11000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B11111111, B11111111, + B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, + B11111111, B11000000, B11111111, B11111111, B11111111, B11111111, B11111101, + B01101000, B11011011, B00010001, B00011010, B00110001, B11000000, B11111111, + B11111111, B11111111, B11111111, B11111101, B00101011, B01011010, B11111011, + B01101010, B11101111, B11000000, B11111111, B11111111, B11111111, B11111111, + B11111101, B01001011, B01011011, B00111011, B00011010, B00110011, B11000000, + B11111111, B11111111, B11111111, B11111111, B11111101, B01101011, B01011011, + B11011011, B01101010, B11111101, B11000000, }; -#define splash2_width 115 +#define splash2_width 115 #define splash2_height 32 const uint8_t PROGMEM splash2_data[] = { - B00000000,B00000000,B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000000,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000001,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000001,B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000011,B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000111,B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00000111,B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000000,B00001111,B11111000,B00000000,B00000000,B00000000,B00000011,B11000000,B00000000,B01111110,B00000000,B00000000,B00000001,B11100000,B00000000, - B01111111,B00001111,B11111000,B00000000,B00000000,B00000000,B00000011,B11000000,B00000000,B11111110,B00000000,B00000000,B00000001,B11100000,B00000000, - B11111111,B11101111,B11111000,B00000000,B00000000,B00000000,B00000011,B11000000,B00000000,B11111110,B00000000,B00000000,B00000001,B11100000,B00000000, - B11111111,B11111111,B11111000,B00000000,B00000000,B00000000,B00000011,B11000000,B00000000,B11110000,B00000000,B00000000,B00000000,B00001111,B00000000, - B01111111,B11111110,B01111111,B11000000,B00000000,B00000000,B00000011,B11000000,B00000000,B11110000,B00000000,B00000000,B00000000,B00001111,B00000000, - B00111111,B11111110,B01111111,B11111000,B00111111,B11110001,B11111011,B11001111,B11111100,B11111110,B11110011,B10111100,B00111101,B11101111,B11100000, - B00011111,B11111110,B01111111,B11111111,B01111111,B11111011,B11111111,B11011111,B11111110,B11111110,B11111111,B10111100,B00111101,B11101111,B11100000, - B00011111,B11000110,B11111111,B11111111,B01111111,B11111011,B11111111,B11011111,B11111110,B11111110,B11111111,B10111100,B00111101,B11101111,B11100000, - B00001111,B11100011,B11000111,B11111110,B01111000,B01111011,B11000011,B11011110,B00011110,B11110000,B11111111,B10111100,B00111101,B11101111,B00000000, - B00000111,B11111111,B10000111,B11111100,B01111000,B01111011,B11000011,B11011110,B00011110,B11110000,B11111000,B00111100,B00111101,B11101111,B00000000, - B00000001,B11111111,B11111111,B11110000,B00000000,B01111011,B11000011,B11000000,B00011110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00000001,B11110011,B01111111,B11100000,B00111111,B11111011,B11000011,B11001111,B11111110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00000011,B11100011,B00111111,B10000000,B01111111,B11111011,B11000011,B11011111,B11111110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00000111,B11100111,B00111100,B00000000,B01111000,B01111011,B11000011,B11011110,B00011110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00000111,B11111111,B10111110,B00000000,B01111000,B01111011,B11000011,B11011110,B00011110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00000111,B11111111,B11111110,B00000000,B01111000,B01111011,B11000011,B11011110,B00011110,B11110000,B11110000,B00111100,B00111101,B11101111,B00000000, - B00001111,B11111111,B11111110,B00000000,B01111111,B11111011,B11111111,B11011111,B11111110,B11110000,B11110000,B00111111,B11111101,B11101111,B11100000, - B00001111,B11111111,B11111111,B00000000,B01111111,B11111011,B11111111,B11011111,B11111110,B11110000,B11110000,B00111111,B11111101,B11101111,B11100000, - B00001111,B11111001,B11111111,B00000000,B00111110,B01111001,B11111001,B11001111,B10011110,B11110000,B11110000,B00011111,B00111101,B11100111,B11100000, - B00011111,B11110001,B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00011111,B10000000,B11111111,B00000000,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11100000, - B00011100,B00000000,B01111111,B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B10110100,B01101101,B10001000,B10001101,B00011000,B11100000, - B00000000,B00000000,B00011111,B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B10010101,B10101101,B01111101,B10110101,B01110111,B11100000, - B00000000,B00000000,B00001111,B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B10100101,B10101101,B10011101,B10001101,B00011001,B11100000, - B00000000,B00000000,B00000110,B00000000,B01111111,B11111111,B11111111,B11111111,B11111110,B10110101,B10101101,B11101101,B10110101,B01111110,B11100000, + B00000000, B00000000, B01100000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B11100000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000001, B11100000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000001, B11110000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000011, B11110000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000111, + B11110000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000111, B11111000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00001111, B11111000, B00000000, B00000000, B00000000, B00000011, + B11000000, B00000000, B01111110, B00000000, B00000000, B00000001, B11100000, + B00000000, B01111111, B00001111, B11111000, B00000000, B00000000, B00000000, + B00000011, B11000000, B00000000, B11111110, B00000000, B00000000, B00000001, + B11100000, B00000000, B11111111, B11101111, B11111000, B00000000, B00000000, + B00000000, B00000011, B11000000, B00000000, B11111110, B00000000, B00000000, + B00000001, B11100000, B00000000, B11111111, B11111111, B11111000, B00000000, + B00000000, B00000000, B00000011, B11000000, B00000000, B11110000, B00000000, + B00000000, B00000000, B00001111, B00000000, B01111111, B11111110, B01111111, + B11000000, B00000000, B00000000, B00000011, B11000000, B00000000, B11110000, + B00000000, B00000000, B00000000, B00001111, B00000000, B00111111, B11111110, + B01111111, B11111000, B00111111, B11110001, B11111011, B11001111, B11111100, + B11111110, B11110011, B10111100, B00111101, B11101111, B11100000, B00011111, + B11111110, B01111111, B11111111, B01111111, B11111011, B11111111, B11011111, + B11111110, B11111110, B11111111, B10111100, B00111101, B11101111, B11100000, + B00011111, B11000110, B11111111, B11111111, B01111111, B11111011, B11111111, + B11011111, B11111110, B11111110, B11111111, B10111100, B00111101, B11101111, + B11100000, B00001111, B11100011, B11000111, B11111110, B01111000, B01111011, + B11000011, B11011110, B00011110, B11110000, B11111111, B10111100, B00111101, + B11101111, B00000000, B00000111, B11111111, B10000111, B11111100, B01111000, + B01111011, B11000011, B11011110, B00011110, B11110000, B11111000, B00111100, + B00111101, B11101111, B00000000, B00000001, B11111111, B11111111, B11110000, + B00000000, B01111011, B11000011, B11000000, B00011110, B11110000, B11110000, + B00111100, B00111101, B11101111, B00000000, B00000001, B11110011, B01111111, + B11100000, B00111111, B11111011, B11000011, B11001111, B11111110, B11110000, + B11110000, B00111100, B00111101, B11101111, B00000000, B00000011, B11100011, + B00111111, B10000000, B01111111, B11111011, B11000011, B11011111, B11111110, + B11110000, B11110000, B00111100, B00111101, B11101111, B00000000, B00000111, + B11100111, B00111100, B00000000, B01111000, B01111011, B11000011, B11011110, + B00011110, B11110000, B11110000, B00111100, B00111101, B11101111, B00000000, + B00000111, B11111111, B10111110, B00000000, B01111000, B01111011, B11000011, + B11011110, B00011110, B11110000, B11110000, B00111100, B00111101, B11101111, + B00000000, B00000111, B11111111, B11111110, B00000000, B01111000, B01111011, + B11000011, B11011110, B00011110, B11110000, B11110000, B00111100, B00111101, + B11101111, B00000000, B00001111, B11111111, B11111110, B00000000, B01111111, + B11111011, B11111111, B11011111, B11111110, B11110000, B11110000, B00111111, + B11111101, B11101111, B11100000, B00001111, B11111111, B11111111, B00000000, + B01111111, B11111011, B11111111, B11011111, B11111110, B11110000, B11110000, + B00111111, B11111101, B11101111, B11100000, B00001111, B11111001, B11111111, + B00000000, B00111110, B01111001, B11111001, B11001111, B10011110, B11110000, + B11110000, B00011111, B00111101, B11100111, B11100000, B00011111, B11110001, + B11111111, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, + B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00011111, + B10000000, B11111111, B00000000, B01111111, B11111111, B11111111, B11111111, + B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11100000, + B00011100, B00000000, B01111111, B00000000, B01111111, B11111111, B11111111, + B11111111, B11111110, B10110100, B01101101, B10001000, B10001101, B00011000, + B11100000, B00000000, B00000000, B00011111, B00000000, B01111111, B11111111, + B11111111, B11111111, B11111110, B10010101, B10101101, B01111101, B10110101, + B01110111, B11100000, B00000000, B00000000, B00001111, B00000000, B01111111, + B11111111, B11111111, B11111111, B11111110, B10100101, B10101101, B10011101, + B10001101, B00011001, B11100000, B00000000, B00000000, B00000110, B00000000, + B01111111, B11111111, B11111111, B11111111, B11111110, B10110101, B10101101, + B11101101, B10110101, B01111110, B11100000, };