mirror of https://github.com/arendst/Tasmota.git
Update Adafruit libraries SSD1306 and GFX
Update Adafruit libraries SSD1306 and GFX
This commit is contained in:
parent
af4dd080c5
commit
3c62507f38
|
@ -1,555 +0,0 @@
|
|||
/*!
|
||||
* @file Adafruit_SPITFT.cpp
|
||||
*
|
||||
* @mainpage Adafruit SPI TFT Displays
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
This is our library for generic SPI TFT Displays with
|
||||
address windows and 16 bit color (e.g. ILI9341, HX8357D, ST7735...)
|
||||
|
||||
Check out the links above for our tutorials and wiring diagrams
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface (RST is optional)
|
||||
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.
|
||||
MIT license, all text above must be included in any redistribution
|
||||
* @section dependencies Dependencies
|
||||
*
|
||||
* This library depends on <a href="https://github.com/adafruit/Adafruit_GFX">
|
||||
* Adafruit_GFX</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 "ladyada" Fried for Adafruit Industries.
|
||||
*
|
||||
* @section license License
|
||||
*
|
||||
* BSD license, all text here must be included in any redistribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __AVR_ATtiny85__ // NOT A CHANCE of this stuff working on ATtiny!
|
||||
|
||||
#include "Adafruit_SPITFT.h"
|
||||
#ifndef ARDUINO_STM32_FEATHER
|
||||
#include "pins_arduino.h"
|
||||
#ifndef RASPI
|
||||
#include "wiring_private.h"
|
||||
#endif
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#include "Adafruit_SPITFT_Macros.h"
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Pass 8-bit (each) R,G,B, get back 16-bit packed color
|
||||
This function converts 8-8-8 RGB data to 16-bit 5-6-5
|
||||
@param red Red 8 bit color
|
||||
@param green Green 8 bit color
|
||||
@param blue Blue 8 bit color
|
||||
@return Unsigned 16-bit down-sampled color in 5-6-5 format
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t Adafruit_SPITFT::color565(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | ((blue & 0xF8) >> 3);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Instantiate Adafruit SPI display driver with software SPI
|
||||
@param w Display width in pixels
|
||||
@param h Display height in pixels
|
||||
@param cs Chip select pin #
|
||||
@param dc Data/Command pin #
|
||||
@param mosi SPI MOSI pin #
|
||||
@param sclk SPI Clock pin #
|
||||
@param rst Reset pin # (optional, pass -1 if unused)
|
||||
@param miso SPI MISO pin # (optional, pass -1 if unused)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t mosi,
|
||||
int8_t sclk, int8_t rst, int8_t miso)
|
||||
: Adafruit_GFX(w, h) {
|
||||
_cs = cs;
|
||||
_dc = dc;
|
||||
_rst = rst;
|
||||
_sclk = sclk;
|
||||
_mosi = mosi;
|
||||
_miso = miso;
|
||||
_freq = 0;
|
||||
#ifdef USE_FAST_PINIO
|
||||
dcport = (RwReg *)portOutputRegister(digitalPinToPort(dc));
|
||||
dcpinmask = digitalPinToBitMask(dc);
|
||||
clkport = (RwReg *)portOutputRegister(digitalPinToPort(sclk));
|
||||
clkpinmask = digitalPinToBitMask(sclk);
|
||||
mosiport = (RwReg *)portOutputRegister(digitalPinToPort(mosi));
|
||||
mosipinmask = digitalPinToBitMask(mosi);
|
||||
if(miso >= 0){
|
||||
misoport = (RwReg *)portInputRegister(digitalPinToPort(miso));
|
||||
misopinmask = digitalPinToBitMask(miso);
|
||||
} else {
|
||||
misoport = 0;
|
||||
misopinmask = 0;
|
||||
}
|
||||
if(cs >= 0) {
|
||||
csport = (RwReg *)portOutputRegister(digitalPinToPort(cs));
|
||||
cspinmask = digitalPinToBitMask(cs);
|
||||
} else {
|
||||
// No chip-select line defined; might be permanently tied to GND.
|
||||
// Assign a valid GPIO register (though not used for CS), and an
|
||||
// empty pin bitmask...the nonsense bit-twiddling might be faster
|
||||
// than checking _cs and possibly branching.
|
||||
csport = dcport;
|
||||
cspinmask = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Instantiate Adafruit SPI display driver with hardware SPI
|
||||
@param w Display width in pixels
|
||||
@param h Display height in pixels
|
||||
@param cs Chip select pin #
|
||||
@param dc Data/Command pin #
|
||||
@param rst Reset pin # (optional, pass -1 if unused)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t rst)
|
||||
: Adafruit_GFX(w, h) {
|
||||
_cs = cs;
|
||||
_dc = dc;
|
||||
_rst = rst;
|
||||
_sclk = -1;
|
||||
_mosi = -1;
|
||||
_miso = -1;
|
||||
_freq = 0;
|
||||
#ifdef USE_FAST_PINIO
|
||||
clkport = 0;
|
||||
clkpinmask = 0;
|
||||
mosiport = 0;
|
||||
mosipinmask = 0;
|
||||
misoport = 0;
|
||||
misopinmask = 0;
|
||||
dcport = (RwReg *)portOutputRegister(digitalPinToPort(dc));
|
||||
dcpinmask = digitalPinToBitMask(dc);
|
||||
if(cs >= 0) {
|
||||
csport = (RwReg *)portOutputRegister(digitalPinToPort(cs));
|
||||
cspinmask = digitalPinToBitMask(cs);
|
||||
} else {
|
||||
// See notes in prior constructor.
|
||||
csport = dcport;
|
||||
cspinmask = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialiaze the SPI interface (hardware or software)
|
||||
@param freq The desired maximum SPI hardware clock frequency
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::initSPI(uint32_t freq) {
|
||||
_freq = freq;
|
||||
|
||||
// Control Pins
|
||||
if(_cs >= 0) {
|
||||
pinMode(_cs, OUTPUT);
|
||||
digitalWrite(_cs, HIGH); // Deselect
|
||||
}
|
||||
pinMode(_dc, OUTPUT);
|
||||
digitalWrite(_dc, LOW);
|
||||
|
||||
// Software SPI
|
||||
if(_sclk >= 0){
|
||||
pinMode(_mosi, OUTPUT);
|
||||
digitalWrite(_mosi, LOW);
|
||||
pinMode(_sclk, OUTPUT);
|
||||
digitalWrite(_sclk, HIGH);
|
||||
if(_miso >= 0){
|
||||
pinMode(_miso, INPUT);
|
||||
}
|
||||
}
|
||||
|
||||
// Hardware SPI
|
||||
SPI_BEGIN();
|
||||
|
||||
// toggle RST low to reset
|
||||
if (_rst >= 0) {
|
||||
pinMode(_rst, OUTPUT);
|
||||
digitalWrite(_rst, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(_rst, LOW);
|
||||
delay(100);
|
||||
digitalWrite(_rst, HIGH);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Read one byte from SPI interface (hardware or software
|
||||
@returns One byte, MSB order
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_SPITFT::spiRead() {
|
||||
if(_sclk < 0){
|
||||
return HSPI_READ();
|
||||
}
|
||||
if(_miso < 0){
|
||||
return 0;
|
||||
}
|
||||
uint8_t r = 0;
|
||||
for (uint8_t i=0; i<8; i++) {
|
||||
SSPI_SCK_LOW();
|
||||
SSPI_SCK_HIGH();
|
||||
r <<= 1;
|
||||
if (SSPI_MISO_READ()){
|
||||
r |= 0x1;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write one byte to SPI interface (hardware or software
|
||||
@param b One byte to send, MSB order
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::spiWrite(uint8_t b) {
|
||||
if(_sclk < 0){
|
||||
HSPI_WRITE(b);
|
||||
return;
|
||||
}
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1){
|
||||
if((b) & bit){
|
||||
SSPI_MOSI_HIGH();
|
||||
} else {
|
||||
SSPI_MOSI_LOW();
|
||||
}
|
||||
SSPI_SCK_LOW();
|
||||
SSPI_SCK_HIGH();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Transaction API
|
||||
* */
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Begin an SPI transaction & set CS low.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void inline Adafruit_SPITFT::startWrite(void){
|
||||
SPI_BEGIN_TRANSACTION();
|
||||
SPI_CS_LOW();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Begin an SPI transaction & set CS high.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void inline Adafruit_SPITFT::endWrite(void){
|
||||
SPI_CS_HIGH();
|
||||
SPI_END_TRANSACTION();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a command byte (must have a transaction in progress)
|
||||
@param cmd The 8-bit command to send
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::writeCommand(uint8_t cmd){
|
||||
SPI_DC_LOW();
|
||||
spiWrite(cmd);
|
||||
SPI_DC_HIGH();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Push a 2-byte color to the framebuffer RAM, will start transaction
|
||||
@param color 16-bit 5-6-5 Color to draw
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::pushColor(uint16_t color) {
|
||||
startWrite();
|
||||
SPI_WRITE16(color);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Blit multiple 2-byte colors (must have a transaction in progress)
|
||||
@param colors Array of 16-bit 5-6-5 Colors to draw
|
||||
@param len How many pixels to draw - 2 bytes per pixel!
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::writePixels(uint16_t * colors, uint32_t len){
|
||||
SPI_WRITE_PIXELS((uint8_t*)colors , len * 2);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Blit a 2-byte color many times (must have a transaction in progress)
|
||||
@param color The 16-bit 5-6-5 Color to draw
|
||||
@param len How many pixels to draw
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len){
|
||||
#ifdef SPI_HAS_WRITE_PIXELS
|
||||
if(_sclk >= 0){
|
||||
for (uint32_t t=0; t<len; t++){
|
||||
writePixel(color);
|
||||
}
|
||||
return;
|
||||
}
|
||||
static uint16_t temp[SPI_MAX_PIXELS_AT_ONCE];
|
||||
size_t blen = (len > SPI_MAX_PIXELS_AT_ONCE)?SPI_MAX_PIXELS_AT_ONCE:len;
|
||||
uint16_t tlen = 0;
|
||||
|
||||
for (uint32_t t=0; t<blen; t++){
|
||||
temp[t] = color;
|
||||
}
|
||||
|
||||
while(len){
|
||||
tlen = (len>blen)?blen:len;
|
||||
writePixels(temp, tlen);
|
||||
len -= tlen;
|
||||
}
|
||||
#else
|
||||
uint8_t hi = color >> 8, lo = color;
|
||||
if(_sclk < 0){ //AVR Optimization
|
||||
for (uint32_t t=len; t; t--){
|
||||
HSPI_WRITE(hi);
|
||||
HSPI_WRITE(lo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (uint32_t t=len; t; t--){
|
||||
spiWrite(hi);
|
||||
spiWrite(lo);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a pixel (must have a transaction in progress)
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to draw with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::writePixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return;
|
||||
setAddrWindow(x,y,1,1);
|
||||
writePixel(color);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a filled rectangle (must have a transaction in progress)
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
@param w Width in pixels
|
||||
@param h Height in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){
|
||||
if((x >= _width) || (y >= _height)) return;
|
||||
int16_t x2 = x + w - 1, y2 = y + h - 1;
|
||||
if((x2 < 0) || (y2 < 0)) return;
|
||||
|
||||
// Clip left/top
|
||||
if(x < 0) {
|
||||
x = 0;
|
||||
w = x2 + 1;
|
||||
}
|
||||
if(y < 0) {
|
||||
y = 0;
|
||||
h = y2 + 1;
|
||||
}
|
||||
|
||||
// Clip right/bottom
|
||||
if(x2 >= _width) w = _width - x;
|
||||
if(y2 >= _height) h = _height - y;
|
||||
|
||||
int32_t len = (int32_t)w * h;
|
||||
setAddrWindow(x, y, w, h);
|
||||
writeColor(color, len);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a perfectly vertical line (must have a transaction in progress)
|
||||
@param x Top-most x coordinate
|
||||
@param y Top-most y coordinate
|
||||
@param h Height in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void inline Adafruit_SPITFT::writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color){
|
||||
writeFillRect(x, y, 1, h, color);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a perfectly horizontal line (must have a transaction in progress)
|
||||
@param x Left-most x coordinate
|
||||
@param y Left-most y coordinate
|
||||
@param w Width in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void inline Adafruit_SPITFT::writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){
|
||||
writeFillRect(x, y, w, 1, color);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a pixel - sets up transaction
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to draw with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::drawPixel(int16_t x, int16_t y, uint16_t color){
|
||||
startWrite();
|
||||
writePixel(x, y, color);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a perfectly vertical line - sets up transaction
|
||||
@param x Top-most x coordinate
|
||||
@param y Top-most y coordinate
|
||||
@param h Height in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::drawFastVLine(int16_t x, int16_t y,
|
||||
int16_t h, uint16_t color) {
|
||||
startWrite();
|
||||
writeFastVLine(x, y, h, color);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Write a perfectly horizontal line - sets up transaction
|
||||
@param x Left-most x coordinate
|
||||
@param y Left-most y coordinate
|
||||
@param w Width in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::drawFastHLine(int16_t x, int16_t y,
|
||||
int16_t w, uint16_t color) {
|
||||
startWrite();
|
||||
writeFastHLine(x, y, w, color);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Fill a rectangle completely with one color.
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
@param w Width in pixels
|
||||
@param h Height in pixels
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
startWrite();
|
||||
writeFillRect(x,y,w,h,color);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Invert the display using built-in hardware command
|
||||
@param i True if you want to invert, false to make 'normal'
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::invertDisplay(boolean i) {
|
||||
startWrite();
|
||||
writeCommand(i ? invertOnCommand : invertOffCommand);
|
||||
endWrite();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a 16-bit image (RGB 5/6/5) at the specified (x,y) position.
|
||||
For 16-bit display devices; no color reduction performed.
|
||||
Adapted from https://github.com/PaulStoffregen/ILI9341_t3
|
||||
by Marc MERLIN. See examples/pictureEmbed to use this.
|
||||
5/6/2017: function name and arguments have changed for compatibility
|
||||
with current GFX library and to avoid naming problems in prior
|
||||
implementation. Formerly drawBitmap() with arguments in different order.
|
||||
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
@param pcolors 16-bit array with 16-bit color bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SPITFT::drawRGBBitmap(int16_t x, int16_t y,
|
||||
uint16_t *pcolors, int16_t w, int16_t h) {
|
||||
|
||||
int16_t x2, y2; // Lower-right coord
|
||||
if(( x >= _width ) || // Off-edge right
|
||||
( y >= _height) || // " top
|
||||
((x2 = (x+w-1)) < 0 ) || // " left
|
||||
((y2 = (y+h-1)) < 0) ) return; // " bottom
|
||||
|
||||
int16_t bx1=0, by1=0, // Clipped top-left within bitmap
|
||||
saveW=w; // Save original bitmap width value
|
||||
if(x < 0) { // Clip left
|
||||
w += x;
|
||||
bx1 = -x;
|
||||
x = 0;
|
||||
}
|
||||
if(y < 0) { // Clip top
|
||||
h += y;
|
||||
by1 = -y;
|
||||
y = 0;
|
||||
}
|
||||
if(x2 >= _width ) w = _width - x; // Clip right
|
||||
if(y2 >= _height) h = _height - y; // Clip bottom
|
||||
|
||||
pcolors += by1 * saveW + bx1; // Offset bitmap ptr to clipped top-left
|
||||
startWrite();
|
||||
setAddrWindow(x, y, w, h); // Clipped area
|
||||
while(h--) { // For each (clipped) scanline...
|
||||
writePixels(pcolors, w); // Push one (clipped) row
|
||||
pcolors += saveW; // Advance pointer by one full (unclipped) line
|
||||
}
|
||||
endWrite();
|
||||
}
|
||||
|
||||
#endif // !__AVR_ATtiny85__
|
|
@ -1,125 +0,0 @@
|
|||
#ifndef _ADAFRUIT_SPITFT_
|
||||
#define _ADAFRUIT_SPITFT_
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
|
||||
#define USE_FAST_PINIO
|
||||
|
||||
#if defined(__AVR__)
|
||||
typedef volatile uint8_t RwReg;
|
||||
#elif defined(ARDUINO_STM32_FEATHER)
|
||||
typedef volatile uint32 RwReg;
|
||||
#undef USE_FAST_PINIO
|
||||
#elif defined(__OPENCR__) || defined (__OPENCM904__)
|
||||
#undef USE_FAST_PINIO
|
||||
#elif defined(ARDUINO_FEATHER52) || defined(__arm__)
|
||||
typedef volatile uint32_t RwReg;
|
||||
#elif defined(ESP32) || defined(ESP8266)
|
||||
typedef volatile uint32_t RwReg;
|
||||
#undef USE_FAST_PINIO
|
||||
#else
|
||||
#undef USE_FAST_PINIO
|
||||
#endif
|
||||
|
||||
#include "Adafruit_SPITFT_Macros.h"
|
||||
|
||||
/// A heavily optimized SPI display subclass of GFX. Manages SPI bitbanging, transactions, DMA, etc! Despite being called SPITFT, the classic SPI data/command interface is also used by OLEDs.
|
||||
class Adafruit_SPITFT : public Adafruit_GFX {
|
||||
protected:
|
||||
|
||||
public:
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1);
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _RST = -1);
|
||||
|
||||
virtual void begin(uint32_t freq) = 0; ///< Virtual begin() function to set SPI frequency, must be overridden in subclass. @param freq Maximum SPI hardware clock speed
|
||||
|
||||
void initSPI(uint32_t freq);
|
||||
|
||||
// Required Non-Transaction
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
// Transaction API
|
||||
void startWrite(void);
|
||||
void endWrite(void);
|
||||
|
||||
void writePixel(int16_t x, int16_t y, uint16_t color);
|
||||
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
// Transaction API not used by GFX
|
||||
|
||||
/*!
|
||||
@brief SPI displays set an address window rectangle for blitting pixels
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner x coordinate
|
||||
@param w Width of window
|
||||
@param h Height of window
|
||||
*/
|
||||
virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0;
|
||||
|
||||
/*!
|
||||
@brief Write a 2-byte color (must have a transaction in progress)
|
||||
@param color 16-bit 5-6-5 Color to draw
|
||||
*/
|
||||
void inline writePixel(uint16_t color) { SPI_WRITE16(color); }
|
||||
void writePixels(uint16_t * colors, uint32_t len);
|
||||
void writeColor(uint16_t color, uint32_t len);
|
||||
void pushColor(uint16_t color);
|
||||
|
||||
// Recommended Non-Transaction
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
|
||||
|
||||
using Adafruit_GFX::drawRGBBitmap; // Check base class first
|
||||
void drawRGBBitmap(int16_t x, int16_t y,
|
||||
uint16_t *pcolors, int16_t w, int16_t h);
|
||||
void invertDisplay(boolean i);
|
||||
|
||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
protected:
|
||||
uint32_t _freq; ///< SPI clock frequency (for hardware SPI)
|
||||
#if defined (__AVR__) || defined(TEENSYDUINO) || defined (ESP8266) || defined (ESP32)
|
||||
int8_t _cs, _dc, _rst, _sclk, _mosi, _miso;
|
||||
#else
|
||||
int32_t _cs, ///< Arduino pin # for chip-select pin
|
||||
_dc, ///< Arduino pin # for data-command pin
|
||||
_rst, ///< Arduino pin # for reset pin
|
||||
_sclk, ///< Arduino pin # for SPI clock pin
|
||||
_mosi, ///< Arduino pin # for SPI MOSI pin
|
||||
_miso; ///< Arduino pin # for SPI MISO pin
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAST_PINIO
|
||||
volatile RwReg *mosiport, ///< Direct chip register for toggling MOSI with fast bitbang IO
|
||||
*misoport, ///< Direct chip register for toggling MISO with fast bitbang IO
|
||||
*clkport, ///< Direct chip register for toggling CLK with fast bitbang IO
|
||||
*dcport, ///< Direct chip register for toggling DC with fast bitbang IO
|
||||
*csport; ///< Direct chip register for toggling CS with fast bitbang IO
|
||||
RwReg mosipinmask, ///< bitmask for turning on/off MOSI with fast register bitbang IO
|
||||
misopinmask, ///< bitmask for turning on/off MISO with fast register bitbang IO
|
||||
clkpinmask, ///< bitmask for turning on/off CLK with fast register bitbang IO
|
||||
cspinmask, ///< bitmask for turning on/off CS with fast register bitbang IO
|
||||
dcpinmask; ///< bitmask for turning on/off DC with fast register bitbang IO
|
||||
#endif
|
||||
|
||||
void writeCommand(uint8_t cmd);
|
||||
void spiWrite(uint8_t v);
|
||||
uint8_t spiRead(void);
|
||||
|
||||
uint8_t invertOnCommand = 0, ///< SPI command byte to turn on invert
|
||||
invertOffCommand = 0; ///< SPI command byte to turn off invert
|
||||
int16_t _xstart = 0; ///< Many displays don't have pixels starting at (0,0) of the internal framebuffer, this is the x offset from 0 to align
|
||||
int16_t _ystart = 0; ///< Many displays don't have pixels starting at (0,0) of the internal framebuffer, this is the y offset from 0 to align
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,118 +0,0 @@
|
|||
#ifndef _ADAFRUIT_SPITFT_MACROS
|
||||
#define _ADAFRUIT_SPITFT_MACROS
|
||||
|
||||
/*
|
||||
* Control Pins
|
||||
* */
|
||||
|
||||
#ifdef USE_FAST_PINIO
|
||||
#define SPI_DC_HIGH() *dcport |= dcpinmask
|
||||
#define SPI_DC_LOW() *dcport &= ~dcpinmask
|
||||
#define SPI_CS_HIGH() *csport |= cspinmask
|
||||
#define SPI_CS_LOW() *csport &= ~cspinmask
|
||||
#else
|
||||
#define SPI_DC_HIGH() digitalWrite(_dc, HIGH)
|
||||
#define SPI_DC_LOW() digitalWrite(_dc, LOW)
|
||||
#define SPI_CS_HIGH() { if(_cs >= 0) digitalWrite(_cs, HIGH); }
|
||||
#define SPI_CS_LOW() { if(_cs >= 0) digitalWrite(_cs, LOW); }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Software SPI Macros
|
||||
* */
|
||||
|
||||
#ifdef USE_FAST_PINIO
|
||||
#define SSPI_MOSI_HIGH() *mosiport |= mosipinmask
|
||||
#define SSPI_MOSI_LOW() *mosiport &= ~mosipinmask
|
||||
#define SSPI_SCK_HIGH() *clkport |= clkpinmask
|
||||
#define SSPI_SCK_LOW() *clkport &= ~clkpinmask
|
||||
#define SSPI_MISO_READ() ((*misoport & misopinmask) != 0)
|
||||
#else
|
||||
#define SSPI_MOSI_HIGH() digitalWrite(_mosi, HIGH)
|
||||
#define SSPI_MOSI_LOW() digitalWrite(_mosi, LOW)
|
||||
#define SSPI_SCK_HIGH() digitalWrite(_sclk, HIGH)
|
||||
#define SSPI_SCK_LOW() digitalWrite(_sclk, LOW)
|
||||
#define SSPI_MISO_READ() digitalRead(_miso)
|
||||
#endif
|
||||
|
||||
#define SSPI_BEGIN_TRANSACTION()
|
||||
#define SSPI_END_TRANSACTION()
|
||||
#define SSPI_WRITE(v) spiWrite(v)
|
||||
#define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s)
|
||||
#define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l)
|
||||
#define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); }
|
||||
|
||||
/*
|
||||
* Hardware SPI Macros
|
||||
* */
|
||||
|
||||
#define SPI_OBJECT SPI
|
||||
|
||||
#if defined (__AVR__) || defined(TEENSYDUINO) || defined(ARDUINO_ARCH_STM32F1)
|
||||
#define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(SPI_CLOCK_DIV2);
|
||||
#elif defined (__arm__)
|
||||
#define HSPI_SET_CLOCK() SPI_OBJECT.setClockDivider(11);
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#define HSPI_SET_CLOCK() SPI_OBJECT.setFrequency(_freq);
|
||||
#elif defined(RASPI)
|
||||
#define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq);
|
||||
#elif defined(ARDUINO_ARCH_STM32F1)
|
||||
#define HSPI_SET_CLOCK() SPI_OBJECT.setClock(_freq);
|
||||
#else
|
||||
#define HSPI_SET_CLOCK()
|
||||
#endif
|
||||
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
#define HSPI_BEGIN_TRANSACTION() SPI_OBJECT.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0))
|
||||
#define HSPI_END_TRANSACTION() SPI_OBJECT.endTransaction()
|
||||
#else
|
||||
#define HSPI_BEGIN_TRANSACTION() HSPI_SET_CLOCK(); SPI_OBJECT.setBitOrder(MSBFIRST); SPI_OBJECT.setDataMode(SPI_MODE0)
|
||||
#define HSPI_END_TRANSACTION()
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
#define SPI_HAS_WRITE_PIXELS
|
||||
#endif
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
// Optimized SPI (ESP8266 and ESP32)
|
||||
#define HSPI_READ() SPI_OBJECT.transfer(0)
|
||||
#define HSPI_WRITE(b) SPI_OBJECT.write(b)
|
||||
#define HSPI_WRITE16(s) SPI_OBJECT.write16(s)
|
||||
#define HSPI_WRITE32(l) SPI_OBJECT.write32(l)
|
||||
#ifdef SPI_HAS_WRITE_PIXELS
|
||||
#define SPI_MAX_PIXELS_AT_ONCE 32
|
||||
#define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l)
|
||||
#else
|
||||
#define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); }
|
||||
#endif
|
||||
#else
|
||||
// Standard Byte-by-Byte SPI
|
||||
|
||||
#if defined (__AVR__) || defined(TEENSYDUINO)
|
||||
static inline uint8_t _avr_spi_read(void) __attribute__((always_inline));
|
||||
static inline uint8_t _avr_spi_read(void) {
|
||||
uint8_t r = 0;
|
||||
SPDR = r;
|
||||
while(!(SPSR & _BV(SPIF)));
|
||||
r = SPDR;
|
||||
return r;
|
||||
}
|
||||
#define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));}
|
||||
#define HSPI_READ() _avr_spi_read()
|
||||
#else
|
||||
#define HSPI_WRITE(b) SPI_OBJECT.transfer((uint8_t)(b))
|
||||
#define HSPI_READ() HSPI_WRITE(0)
|
||||
#endif
|
||||
#define HSPI_WRITE16(s) HSPI_WRITE((s) >> 8); HSPI_WRITE(s)
|
||||
#define HSPI_WRITE32(l) HSPI_WRITE((l) >> 24); HSPI_WRITE((l) >> 16); HSPI_WRITE((l) >> 8); HSPI_WRITE(l)
|
||||
#define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); }
|
||||
#endif
|
||||
|
||||
#define SPI_BEGIN() if(_sclk < 0){SPI_OBJECT.begin();}
|
||||
#define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();}
|
||||
#define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();}
|
||||
#define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}
|
||||
#define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}
|
||||
#define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);}
|
||||
|
||||
#endif // _ADAFRUIT_SPITFT_MACROS
|
|
@ -9,7 +9,6 @@ git:
|
|||
quiet: true
|
||||
env:
|
||||
global:
|
||||
- ARDUINO_IDE_VERSION="1.8.5"
|
||||
- PRETTYNAME="Adafruit GFX Library"
|
||||
|
||||
before_install:
|
||||
|
@ -24,4 +23,4 @@ script:
|
|||
# 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)
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
|
|
@ -62,6 +62,30 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr))
|
||||
#endif
|
||||
|
||||
inline GFXglyph * pgm_read_glyph_ptr(const GFXfont *gfxFont, uint8_t c)
|
||||
{
|
||||
#ifdef __AVR__
|
||||
return &(((GFXglyph *)pgm_read_pointer(&gfxFont->glyph))[c]);
|
||||
#else
|
||||
// expression in __AVR__ section may generate "dereferencing type-punned pointer will break strict-aliasing rules" warning
|
||||
// In fact, on other platforms (such as STM32) there is no need to do this pointer magic as program memory may be read in a usual way
|
||||
// So expression may be simplified
|
||||
return gfxFont->glyph + c;
|
||||
#endif //__AVR__
|
||||
}
|
||||
|
||||
inline uint8_t * pgm_read_bitmap_ptr(const GFXfont *gfxFont)
|
||||
{
|
||||
#ifdef __AVR__
|
||||
return (uint8_t *)pgm_read_pointer(&gfxFont->bitmap);
|
||||
#else
|
||||
// expression in __AVR__ section generates "dereferencing type-punned pointer will break strict-aliasing rules" warning
|
||||
// In fact, on other platforms (such as STM32) there is no need to do this pointer magic as program memory may be read in a usual way
|
||||
// So expression may be simplified
|
||||
return gfxFont->bitmap;
|
||||
#endif //__AVR__
|
||||
}
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
@ -84,7 +108,7 @@ WIDTH(w), HEIGHT(h)
|
|||
_height = HEIGHT;
|
||||
rotation = 0;
|
||||
cursor_y = cursor_x = 0;
|
||||
textsize = 1;
|
||||
textsize_x = textsize_y = 1;
|
||||
textcolor = textbgcolor = 0xFFFF;
|
||||
wrap = true;
|
||||
_cp437 = false;
|
||||
|
@ -103,6 +127,9 @@ WIDTH(w), HEIGHT(h)
|
|||
/**************************************************************************/
|
||||
void Adafruit_GFX::writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
||||
uint16_t color) {
|
||||
#if defined(ESP8266)
|
||||
yield();
|
||||
#endif
|
||||
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
if (steep) {
|
||||
_swap_int16_t(x0, y0);
|
||||
|
@ -317,6 +344,9 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
|||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
||||
uint16_t color) {
|
||||
#if defined(ESP8266)
|
||||
yield();
|
||||
#endif
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
|
@ -353,7 +383,7 @@ void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Quarter-circle drawer, used to do circles and roundrects
|
||||
@brief Quarter-circle drawer, used to do circles and roundrects
|
||||
@param x0 Center-point x coordinate
|
||||
@param y0 Center-point y coordinate
|
||||
@param r Radius of circle
|
||||
|
@ -417,25 +447,29 @@ void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Quarter-circle drawer with fill, used to do circles and roundrects
|
||||
@param x0 Center-point x coordinate
|
||||
@param y0 Center-point y coordinate
|
||||
@param r Radius of circle
|
||||
@param cornername Mask bit #1 or bit #2 to indicate which quarters of the circle we're doing
|
||||
@param delta Offset from center-point, used for round-rects
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Quarter-circle drawer with fill, used for circles and roundrects
|
||||
@param x0 Center-point x coordinate
|
||||
@param y0 Center-point y coordinate
|
||||
@param r Radius of circle
|
||||
@param corners Mask bits indicating which quarters we're doing
|
||||
@param delta Offset from center-point, used for round-rects
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
||||
uint8_t cornername, int16_t delta, uint16_t color) {
|
||||
uint8_t corners, int16_t delta, uint16_t color) {
|
||||
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
int16_t px = x;
|
||||
int16_t py = y;
|
||||
|
||||
while (x<y) {
|
||||
delta++; // Avoid some +1's in the loop
|
||||
|
||||
while(x < y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
|
@ -444,15 +478,18 @@ void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
|||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
if (cornername & 0x1) {
|
||||
writeFastVLine(x0+x, y0-y, 2*y+1+delta, color);
|
||||
writeFastVLine(x0+y, y0-x, 2*x+1+delta, color);
|
||||
// These checks avoid double-drawing certain lines, important
|
||||
// for the SSD1306 library which has an INVERT drawing mode.
|
||||
if(x < (y + 1)) {
|
||||
if(corners & 1) writeFastVLine(x0+x, y0-y, 2*y+delta, color);
|
||||
if(corners & 2) writeFastVLine(x0-x, y0-y, 2*y+delta, color);
|
||||
}
|
||||
if (cornername & 0x2) {
|
||||
writeFastVLine(x0-x, y0-y, 2*y+1+delta, color);
|
||||
writeFastVLine(x0-y, y0-x, 2*x+1+delta, color);
|
||||
if(y != py) {
|
||||
if(corners & 1) writeFastVLine(x0+py, y0-px, 2*px+delta, color);
|
||||
if(corners & 2) writeFastVLine(x0-py, y0-px, 2*px+delta, color);
|
||||
py = y;
|
||||
}
|
||||
px = x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +525,9 @@ void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
int16_t max_radius = ((w < h) ? w : h) / 2; // 1/2 minor axis
|
||||
if(r > max_radius) r = max_radius;
|
||||
// smarter version
|
||||
startWrite();
|
||||
writeFastHLine(x+r , y , w-2*r, color); // Top
|
||||
|
@ -515,11 +554,12 @@ void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
int16_t max_radius = ((w < h) ? w : h) / 2; // 1/2 minor axis
|
||||
if(r > max_radius) r = max_radius;
|
||||
// smarter version
|
||||
startWrite();
|
||||
writeFillRect(x+r, y, w-2*r, h, color);
|
||||
|
||||
// draw four corners
|
||||
fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);
|
||||
fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color);
|
||||
|
@ -620,8 +660,8 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
|||
|
||||
// For lower part of triangle, find scanline crossings for segments
|
||||
// 0-2 and 1-2. This loop is skipped if y1=y2.
|
||||
sa = dx12 * (y - y1);
|
||||
sb = dx02 * (y - y0);
|
||||
sa = (int32_t)dx12 * (y - y1);
|
||||
sb = (int32_t)dx02 * (y - y0);
|
||||
for(; y<=y2; y++) {
|
||||
a = x1 + sa / dy12;
|
||||
b = x0 + sb / dy02;
|
||||
|
@ -646,7 +686,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
|
|||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with monochrome bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
@param color 16-bit 5-6-5 Color to draw with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
@ -674,7 +714,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
|||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with monochrome bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
@param color 16-bit 5-6-5 Color to draw pixels with
|
||||
@param bg 16-bit 5-6-5 Color to draw background with
|
||||
*/
|
||||
|
@ -704,7 +744,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
|||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with monochrome bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
@param color 16-bit 5-6-5 Color to draw with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
@ -732,7 +772,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
|||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with monochrome bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
@param color 16-bit 5-6-5 Color to draw pixels with
|
||||
@param bg 16-bit 5-6-5 Color to draw background with
|
||||
*/
|
||||
|
@ -756,7 +796,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP.
|
||||
@brief Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP.
|
||||
Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
|
||||
C Array can be directly used with this function.
|
||||
There is no RAM-resident version of this function; if generating bitmaps
|
||||
|
@ -765,7 +805,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
|||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with monochrome bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
@param color 16-bit 5-6-5 Color to draw pixels with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
@ -791,13 +831,13 @@ void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos.
|
||||
@brief Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos.
|
||||
Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with grayscale bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
|
||||
|
@ -813,13 +853,13 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a RAM-resident 8-bit image (grayscale) at the specified (x,y) pos.
|
||||
@brief Draw a RAM-resident 8-bit image (grayscale) at the specified (x,y) pos.
|
||||
Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
@param bitmap byte array with grayscale bitmap
|
||||
@param w Width of bitmap in pixels
|
||||
@param h Hieght of bitmap in pixels
|
||||
@param h Height of bitmap in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
|
||||
|
@ -900,7 +940,7 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
|
||||
@brief Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
|
||||
For 16-bit display devices; no color reduction performed.
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
|
@ -922,7 +962,7 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
|
||||
@brief Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
|
||||
For 16-bit display devices; no color reduction performed.
|
||||
@param x Top left corner x coordinate
|
||||
@param y Top left corner y coordinate
|
||||
|
@ -1016,13 +1056,31 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
|
|||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
||||
uint16_t color, uint16_t bg, uint8_t size) {
|
||||
drawChar(x, y, c, color, bg, size, size);
|
||||
}
|
||||
|
||||
// Draw a character
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a single character
|
||||
@param x Bottom left corner x coordinate
|
||||
@param y Bottom left corner y coordinate
|
||||
@param c The 8-bit font-indexed character (likely ascii)
|
||||
@param color 16-bit 5-6-5 Color to draw chraracter with
|
||||
@param bg 16-bit 5-6-5 Color to fill background with (if same as color, no background)
|
||||
@param size_x Font magnification level in X-axis, 1 is 'original' size
|
||||
@param size_y Font magnification level in Y-axis, 1 is 'original' size
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
||||
uint16_t color, uint16_t bg, uint8_t size_x, uint8_t size_y) {
|
||||
|
||||
if(!gfxFont) { // 'Classic' built-in font
|
||||
|
||||
if((x >= _width) || // Clip right
|
||||
(y >= _height) || // Clip bottom
|
||||
((x + 6 * size - 1) < 0) || // Clip left
|
||||
((y + 8 * size - 1) < 0)) // Clip top
|
||||
((x + 6 * size_x - 1) < 0) || // Clip left
|
||||
((y + 8 * size_y - 1) < 0)) // Clip top
|
||||
return;
|
||||
|
||||
if(!_cp437 && (c >= 176)) c++; // Handle 'classic' charset behavior
|
||||
|
@ -1032,21 +1090,21 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
|||
uint8_t line = pgm_read_byte(&font[c * 5 + i]);
|
||||
for(int8_t j=0; j<8; j++, line >>= 1) {
|
||||
if(line & 1) {
|
||||
if(size == 1)
|
||||
if(size_x == 1 && size_y == 1)
|
||||
writePixel(x+i, y+j, color);
|
||||
else
|
||||
writeFillRect(x+i*size, y+j*size, size, size, color);
|
||||
writeFillRect(x+i*size_x, y+j*size_y, size_x, size_y, color);
|
||||
} else if(bg != color) {
|
||||
if(size == 1)
|
||||
if(size_x == 1 && size_y == 1)
|
||||
writePixel(x+i, y+j, bg);
|
||||
else
|
||||
writeFillRect(x+i*size, y+j*size, size, size, bg);
|
||||
writeFillRect(x+i*size_x, y+j*size_y, size_x, size_y, bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bg != color) { // If opaque, draw vertical line for last column
|
||||
if(size == 1) writeFastVLine(x+5, y, 8, bg);
|
||||
else writeFillRect(x+5*size, y, size, 8*size, bg);
|
||||
if(size_x == 1 && size_y == 1) writeFastVLine(x+5, y, 8, bg);
|
||||
else writeFillRect(x+5*size_x, y, size_x, 8*size_y, bg);
|
||||
}
|
||||
endWrite();
|
||||
|
||||
|
@ -1057,8 +1115,8 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
|||
// drawChar() directly with 'bad' characters of font may cause mayhem!
|
||||
|
||||
c -= (uint8_t)pgm_read_byte(&gfxFont->first);
|
||||
GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer(&gfxFont->glyph))[c]);
|
||||
uint8_t *bitmap = (uint8_t *)pgm_read_pointer(&gfxFont->bitmap);
|
||||
GFXglyph *glyph = pgm_read_glyph_ptr(gfxFont, c);
|
||||
uint8_t *bitmap = pgm_read_bitmap_ptr(gfxFont);
|
||||
|
||||
uint16_t bo = pgm_read_word(&glyph->bitmapOffset);
|
||||
uint8_t w = pgm_read_byte(&glyph->width),
|
||||
|
@ -1068,7 +1126,7 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
|||
uint8_t xx, yy, bits = 0, bit = 0;
|
||||
int16_t xo16 = 0, yo16 = 0;
|
||||
|
||||
if(size > 1) {
|
||||
if(size_x > 1 || size_y > 1) {
|
||||
xo16 = xo;
|
||||
yo16 = yo;
|
||||
}
|
||||
|
@ -1098,11 +1156,11 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
|||
bits = pgm_read_byte(&bitmap[bo++]);
|
||||
}
|
||||
if(bits & 0x80) {
|
||||
if(size == 1) {
|
||||
if(size_x == 1 && size_y == 1) {
|
||||
writePixel(x+xo+xx, y+yo+yy, color);
|
||||
} else {
|
||||
writeFillRect(x+(xo16+xx)*size, y+(yo16+yy)*size,
|
||||
size, size, color);
|
||||
writeFillRect(x+(xo16+xx)*size_x, y+(yo16+yy)*size_y,
|
||||
size_x, size_y, color);
|
||||
}
|
||||
}
|
||||
bits <<= 1;
|
||||
|
@ -1123,39 +1181,38 @@ size_t Adafruit_GFX::write(uint8_t c) {
|
|||
|
||||
if(c == '\n') { // Newline?
|
||||
cursor_x = 0; // Reset x to zero,
|
||||
cursor_y += textsize * 8; // advance y one line
|
||||
cursor_y += textsize_y * 8; // advance y one line
|
||||
} else if(c != '\r') { // Ignore carriage returns
|
||||
if(wrap && ((cursor_x + textsize * 6) > _width)) { // Off right?
|
||||
if(wrap && ((cursor_x + textsize_x * 6) > _width)) { // Off right?
|
||||
cursor_x = 0; // Reset x to zero,
|
||||
cursor_y += textsize * 8; // advance y one line
|
||||
cursor_y += textsize_y * 8; // advance y one line
|
||||
}
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
|
||||
cursor_x += textsize * 6; // Advance x one char
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize_x, textsize_y);
|
||||
cursor_x += textsize_x * 6; // Advance x one char
|
||||
}
|
||||
|
||||
} else { // Custom font
|
||||
|
||||
if(c == '\n') {
|
||||
cursor_x = 0;
|
||||
cursor_y += (int16_t)textsize *
|
||||
cursor_y += (int16_t)textsize_y *
|
||||
(uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
} else if(c != '\r') {
|
||||
uint8_t first = pgm_read_byte(&gfxFont->first);
|
||||
if((c >= first) && (c <= (uint8_t)pgm_read_byte(&gfxFont->last))) {
|
||||
GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer(
|
||||
&gfxFont->glyph))[c - first]);
|
||||
GFXglyph *glyph = pgm_read_glyph_ptr(gfxFont, c - first);
|
||||
uint8_t w = pgm_read_byte(&glyph->width),
|
||||
h = pgm_read_byte(&glyph->height);
|
||||
if((w > 0) && (h > 0)) { // Is there an associated bitmap?
|
||||
int16_t xo = (int8_t)pgm_read_byte(&glyph->xOffset); // sic
|
||||
if(wrap && ((cursor_x + textsize * (xo + w)) > _width)) {
|
||||
if(wrap && ((cursor_x + textsize_x * (xo + w)) > _width)) {
|
||||
cursor_x = 0;
|
||||
cursor_y += (int16_t)textsize *
|
||||
cursor_y += (int16_t)textsize_y *
|
||||
(uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
}
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize_x, textsize_y);
|
||||
}
|
||||
cursor_x += (uint8_t)pgm_read_byte(&glyph->xAdvance) * (int16_t)textsize;
|
||||
cursor_x += (uint8_t)pgm_read_byte(&glyph->xAdvance) * (int16_t)textsize_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1163,38 +1220,6 @@ size_t Adafruit_GFX::write(uint8_t c) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set text cursor location
|
||||
@param x X coordinate in pixels
|
||||
@param y Y coordinate in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor X location
|
||||
@returns X coordinate in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_GFX::getCursorX(void) const {
|
||||
return cursor_x;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor Y location
|
||||
@returns Y coordinate in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_GFX::getCursorY(void) const {
|
||||
return cursor_y;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
|
||||
|
@ -1202,51 +1227,19 @@ int16_t Adafruit_GFX::getCursorY(void) const {
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::setTextSize(uint8_t s) {
|
||||
textsize = (s > 0) ? s : 1;
|
||||
setTextSize(s, s);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with transparant background
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@brief Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
|
||||
@param s_x Desired text width magnification level in X-axis. 1 is default
|
||||
@param s_y Desired text width magnification level in Y-axis. 1 is default
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::setTextColor(uint16_t c) {
|
||||
// For 'transparent' background, we'll set the bg
|
||||
// to the same as fg instead of using a flag
|
||||
textcolor = textbgcolor = c;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with custom background color
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@param b 16-bit 5-6-5 Color to draw background/fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
|
||||
textcolor = c;
|
||||
textbgcolor = b;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Whether text that is too long should 'wrap' around to the next line.
|
||||
@param w Set true for wrapping, false for clipping
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::setTextWrap(boolean w) {
|
||||
wrap = w;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get rotation setting for display
|
||||
@returns 0 thru 3 corresponding to 4 cardinal rotations
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_GFX::getRotation(void) const {
|
||||
return rotation;
|
||||
void Adafruit_GFX::setTextSize(uint8_t s_x, uint8_t s_y) {
|
||||
textsize_x = (s_x > 0) ? s_x : 1;
|
||||
textsize_y = (s_y > 0) ? s_y : 1;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -1271,22 +1264,6 @@ void Adafruit_GFX::setRotation(uint8_t x) {
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Enable (or disable) Code Page 437-compatible charset.
|
||||
There was an error in glcdfont.c for the longest time -- one character
|
||||
(#176, the 'light shade' block) was missing -- this threw off the index
|
||||
of every character that followed it. But a TON of code has been written
|
||||
with the erroneous character indices. By default, the library uses the
|
||||
original 'wrong' behavior and old sketches will still work. Pass 'true'
|
||||
to this function to use correct CP437 character values in your code.
|
||||
@param x Whether to enable (True) or not (False)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX::cp437(boolean x) {
|
||||
_cp437 = x;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the font to display when print()ing, either custom or default
|
||||
|
@ -1329,32 +1306,32 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
|||
|
||||
if(c == '\n') { // Newline?
|
||||
*x = 0; // Reset x to zero, advance y by one line
|
||||
*y += textsize * (uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
*y += textsize_y * (uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
} else if(c != '\r') { // Not a carriage return; is normal char
|
||||
uint8_t first = pgm_read_byte(&gfxFont->first),
|
||||
last = pgm_read_byte(&gfxFont->last);
|
||||
if((c >= first) && (c <= last)) { // Char present in this font?
|
||||
GFXglyph *glyph = &(((GFXglyph *)pgm_read_pointer(
|
||||
&gfxFont->glyph))[c - first]);
|
||||
GFXglyph *glyph = pgm_read_glyph_ptr(gfxFont, c - first);
|
||||
uint8_t gw = pgm_read_byte(&glyph->width),
|
||||
gh = pgm_read_byte(&glyph->height),
|
||||
xa = pgm_read_byte(&glyph->xAdvance);
|
||||
int8_t xo = pgm_read_byte(&glyph->xOffset),
|
||||
yo = pgm_read_byte(&glyph->yOffset);
|
||||
if(wrap && ((*x+(((int16_t)xo+gw)*textsize)) > _width)) {
|
||||
if(wrap && ((*x+(((int16_t)xo+gw)*textsize_x)) > _width)) {
|
||||
*x = 0; // Reset x to zero, advance y by one line
|
||||
*y += textsize * (uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
*y += textsize_y * (uint8_t)pgm_read_byte(&gfxFont->yAdvance);
|
||||
}
|
||||
int16_t ts = (int16_t)textsize,
|
||||
x1 = *x + xo * ts,
|
||||
y1 = *y + yo * ts,
|
||||
x2 = x1 + gw * ts - 1,
|
||||
y2 = y1 + gh * ts - 1;
|
||||
int16_t tsx = (int16_t)textsize_x,
|
||||
tsy = (int16_t)textsize_y,
|
||||
x1 = *x + xo * tsx,
|
||||
y1 = *y + yo * tsy,
|
||||
x2 = x1 + gw * tsx - 1,
|
||||
y2 = y1 + gh * tsy - 1;
|
||||
if(x1 < *minx) *minx = x1;
|
||||
if(y1 < *miny) *miny = y1;
|
||||
if(x2 > *maxx) *maxx = x2;
|
||||
if(y2 > *maxy) *maxy = y2;
|
||||
*x += xa * ts;
|
||||
*x += xa * tsx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1362,20 +1339,20 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
|
|||
|
||||
if(c == '\n') { // Newline?
|
||||
*x = 0; // Reset x to zero,
|
||||
*y += textsize * 8; // advance y one line
|
||||
*y += textsize_y * 8; // advance y one line
|
||||
// min/max x/y unchaged -- that waits for next 'normal' character
|
||||
} else if(c != '\r') { // Normal char; ignore carriage returns
|
||||
if(wrap && ((*x + textsize * 6) > _width)) { // Off right?
|
||||
if(wrap && ((*x + textsize_x * 6) > _width)) { // Off right?
|
||||
*x = 0; // Reset x to zero,
|
||||
*y += textsize * 8; // advance y one line
|
||||
*y += textsize_y * 8; // advance y one line
|
||||
}
|
||||
int x2 = *x + textsize * 6 - 1, // Lower-right pixel of char
|
||||
y2 = *y + textsize * 8 - 1;
|
||||
int x2 = *x + textsize_x * 6 - 1, // Lower-right pixel of char
|
||||
y2 = *y + textsize_y * 8 - 1;
|
||||
if(x2 > *maxx) *maxx = x2; // Track max x, y
|
||||
if(y2 > *maxy) *maxy = y2;
|
||||
if(*x < *minx) *minx = *x; // Track min x, y
|
||||
if(*y < *miny) *miny = *y;
|
||||
*x += textsize * 6; // Advance x one char
|
||||
*x += textsize_x * 6; // Advance x one char
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1470,26 +1447,6 @@ void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get width of the display, accounting for the current rotation
|
||||
@returns Width in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_GFX::width(void) const {
|
||||
return _width;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get height of the display, accounting for the current rotation
|
||||
@returns Height in pixels
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int16_t Adafruit_GFX::height(void) const {
|
||||
return _height;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Invert the display (ideally using built-in hardware command)
|
||||
|
@ -1537,6 +1494,33 @@ void Adafruit_GFX_Button::initButton(
|
|||
textcolor, label, textsize);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialize button with our desired color/size/settings
|
||||
@param gfx Pointer to our display so we can draw to it!
|
||||
@param x The X coordinate of the center of the button
|
||||
@param y The Y coordinate of the center of the button
|
||||
@param w Width of the buttton
|
||||
@param h Height of the buttton
|
||||
@param outline Color of the outline (16-bit 5-6-5 standard)
|
||||
@param fill Color of the button fill (16-bit 5-6-5 standard)
|
||||
@param textcolor Color of the button label (16-bit 5-6-5 standard)
|
||||
@param label Ascii string of the text inside the button
|
||||
@param textsize_x The font magnification in X-axis of the label text
|
||||
@param textsize_y The font magnification in Y-axis of the label text
|
||||
*/
|
||||
/**************************************************************************/
|
||||
// Classic initButton() function: pass center & size
|
||||
void Adafruit_GFX_Button::initButton(
|
||||
Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w, uint16_t h,
|
||||
uint16_t outline, uint16_t fill, uint16_t textcolor,
|
||||
char *label, uint8_t textsize_x, uint8_t textsize_y)
|
||||
{
|
||||
// Tweak arguments and pass to the newer initButtonUL() function...
|
||||
initButtonUL(gfx, x - (w / 2), y - (h / 2), w, h, outline, fill,
|
||||
textcolor, label, textsize_x, textsize_y);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialize button with our desired color/size/settings, with upper-left coordinates
|
||||
|
@ -1556,6 +1540,30 @@ void Adafruit_GFX_Button::initButtonUL(
|
|||
Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
|
||||
uint16_t outline, uint16_t fill, uint16_t textcolor,
|
||||
char *label, uint8_t textsize)
|
||||
{
|
||||
initButtonUL(gfx, x1, y1, w, h, outline, fill, textcolor, label, textsize, textsize);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialize button with our desired color/size/settings, with upper-left coordinates
|
||||
@param gfx Pointer to our display so we can draw to it!
|
||||
@param x1 The X coordinate of the Upper-Left corner of the button
|
||||
@param y1 The Y coordinate of the Upper-Left corner of the button
|
||||
@param w Width of the buttton
|
||||
@param h Height of the buttton
|
||||
@param outline Color of the outline (16-bit 5-6-5 standard)
|
||||
@param fill Color of the button fill (16-bit 5-6-5 standard)
|
||||
@param textcolor Color of the button label (16-bit 5-6-5 standard)
|
||||
@param label Ascii string of the text inside the button
|
||||
@param textsize_x The font magnification in X-axis of the label text
|
||||
@param textsize_y The font magnification in Y-axis of the label text
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX_Button::initButtonUL(
|
||||
Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
|
||||
uint16_t outline, uint16_t fill, uint16_t textcolor,
|
||||
char *label, uint8_t textsize_x, uint8_t textsize_y)
|
||||
{
|
||||
_x1 = x1;
|
||||
_y1 = y1;
|
||||
|
@ -1564,7 +1572,8 @@ void Adafruit_GFX_Button::initButtonUL(
|
|||
_outlinecolor = outline;
|
||||
_fillcolor = fill;
|
||||
_textcolor = textcolor;
|
||||
_textsize = textsize;
|
||||
_textsize_x = textsize_x;
|
||||
_textsize_y = textsize_y;
|
||||
_gfx = gfx;
|
||||
strncpy(_label, label, 9);
|
||||
}
|
||||
|
@ -1592,19 +1601,19 @@ void Adafruit_GFX_Button::drawButton(boolean inverted) {
|
|||
_gfx->fillRoundRect(_x1, _y1, _w, _h, r, fill);
|
||||
_gfx->drawRoundRect(_x1, _y1, _w, _h, r, outline);
|
||||
|
||||
_gfx->setCursor(_x1 + (_w/2) - (strlen(_label) * 3 * _textsize),
|
||||
_y1 + (_h/2) - (4 * _textsize));
|
||||
_gfx->setCursor(_x1 + (_w/2) - (strlen(_label) * 3 * _textsize_x),
|
||||
_y1 + (_h/2) - (4 * _textsize_y));
|
||||
_gfx->setTextColor(text);
|
||||
_gfx->setTextSize(_textsize);
|
||||
_gfx->setTextSize(_textsize_x, _textsize_y);
|
||||
_gfx->print(_label);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Helper to let us know if a coordinate is within the bounds of the button
|
||||
@brief Helper to let us know if a coordinate is within the bounds of the button
|
||||
@param x The X coordinate to check
|
||||
@param y The Y coordinate to check
|
||||
@returns True if within button graphics outline
|
||||
@returns True if within button graphics outline
|
||||
*/
|
||||
/**************************************************************************/
|
||||
boolean Adafruit_GFX_Button::contains(int16_t x, int16_t y) {
|
||||
|
@ -1612,25 +1621,6 @@ boolean Adafruit_GFX_Button::contains(int16_t x, int16_t y) {
|
|||
(y >= _y1) && (y < (int16_t) (_y1 + _h)));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Sets the state of the button, should be done by some touch function
|
||||
@param p True for pressed, false for not.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_GFX_Button::press(boolean p) {
|
||||
laststate = currstate;
|
||||
currstate = p;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Query whether the button is currently pressed
|
||||
@returns True if pressed
|
||||
*/
|
||||
/**************************************************************************/
|
||||
boolean Adafruit_GFX_Button::isPressed() { return currstate; }
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Query whether the button was pressed since we last checked state
|
||||
|
@ -1691,20 +1681,10 @@ GFXcanvas1::~GFXcanvas1(void) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t* GFXcanvas1::getBuffer(void) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
|
@ -1749,8 +1729,8 @@ void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas1::fillScreen(uint16_t color) {
|
||||
|
@ -1783,23 +1763,12 @@ GFXcanvas8::~GFXcanvas8(void) {
|
|||
if(buffer) free(buffer);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t* GFXcanvas8::getBuffer(void) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
|
@ -1830,8 +1799,8 @@ void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas8::fillScreen(uint16_t color) {
|
||||
|
@ -1900,20 +1869,10 @@ GFXcanvas16::~GFXcanvas16(void) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t* GFXcanvas16::getBuffer(void) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Draw a pixel to the canvas framebuffer
|
||||
@param x x coordinate
|
||||
@param y y coordinate
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
|
@ -1944,8 +1903,8 @@ void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
@brief Fill the framebuffer completely with one color
|
||||
@param color 16-bit 5-6-5 Color to fill with
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas16::fillScreen(uint16_t color) {
|
||||
|
@ -1960,3 +1919,22 @@ void GFXcanvas16::fillScreen(uint16_t color) {
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reverses the "endian-ness" of each 16-bit pixel within the
|
||||
canvas; little-endian to big-endian, or big-endian to little.
|
||||
Most microcontrollers (such as SAMD) are little-endian, while
|
||||
most displays tend toward big-endianness. All the drawing
|
||||
functions (including RGB bitmap drawing) take care of this
|
||||
automatically, but some specialized code (usually involving
|
||||
DMA) can benefit from having pixel data already in the
|
||||
display-native order. Note that this does NOT convert to a
|
||||
SPECIFIC endian-ness, it just flips the bytes within each word.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void GFXcanvas16::byteSwap(void) {
|
||||
if(buffer) {
|
||||
uint32_t i, pixels = WIDTH * HEIGHT;
|
||||
for(i=0; i<pixels; i++) buffer[i] = __builtin_bswap16(buffer[i]);
|
||||
}
|
||||
}
|
|
@ -95,20 +95,73 @@ class Adafruit_GFX : public Print {
|
|||
uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
|
||||
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size),
|
||||
setCursor(int16_t x, int16_t y),
|
||||
setTextColor(uint16_t c),
|
||||
setTextColor(uint16_t c, uint16_t bg),
|
||||
setTextSize(uint8_t s),
|
||||
setTextWrap(boolean w),
|
||||
cp437(boolean x=true),
|
||||
setFont(const GFXfont *f = NULL),
|
||||
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size_x, uint8_t size_y),
|
||||
getTextBounds(const char *string, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
getTextBounds(const String &str, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
|
||||
setTextSize(uint8_t s),
|
||||
setTextSize(uint8_t sx, uint8_t sy),
|
||||
setFont(const GFXfont *f = NULL);
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text cursor location
|
||||
@param x X coordinate in pixels
|
||||
@param y Y coordinate in pixels
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with transparant background
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@note For 'transparent' background, background and foreground
|
||||
are set to same color rather than using a separate flag.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextColor(uint16_t c) { textcolor = textbgcolor = c; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with custom background color
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@param bg 16-bit 5-6-5 Color to draw background/fill with
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextColor(uint16_t c, uint16_t bg) {
|
||||
textcolor = c;
|
||||
textbgcolor = bg;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set whether text that is too long for the screen width should
|
||||
automatically wrap around to the next line (else clip right).
|
||||
@param w true for wrapping, false for clipping
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextWrap(boolean w) { wrap = w; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Enable (or disable) Code Page 437-compatible charset.
|
||||
There was an error in glcdfont.c for the longest time -- one
|
||||
character (#176, the 'light shade' block) was missing -- this
|
||||
threw off the index of every character that followed it.
|
||||
But a TON of code has been written with the erroneous
|
||||
character indices. By default, the library uses the original
|
||||
'wrong' behavior and old sketches will still work. Pass
|
||||
'true' to this function to use correct CP437 character values
|
||||
in your code.
|
||||
@param x true = enable (new behavior), false = disable (old behavior)
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void cp437(boolean x=true) { _cp437 = x; }
|
||||
|
||||
#if ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
|
@ -116,20 +169,53 @@ class Adafruit_GFX : public Print {
|
|||
virtual void write(uint8_t);
|
||||
#endif
|
||||
|
||||
int16_t height(void) const;
|
||||
int16_t width(void) const;
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get width of the display, accounting for current rotation
|
||||
@returns Width in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t width(void) const { return _width; };
|
||||
|
||||
uint8_t getRotation(void) const;
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get height of the display, accounting for current rotation
|
||||
@returns Height in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t height(void) const { return _height; }
|
||||
|
||||
// get current cursor position (get rotation safe maximum values, using: width() for x, height() for y)
|
||||
int16_t getCursorX(void) const;
|
||||
int16_t getCursorY(void) const;
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get rotation setting for display
|
||||
@returns 0 thru 3 corresponding to 4 cardinal rotations
|
||||
*/
|
||||
/************************************************************************/
|
||||
uint8_t getRotation(void) const { return rotation; }
|
||||
|
||||
// get current cursor position (get rotation safe maximum values,
|
||||
// using: width() for x, height() for y)
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor X location
|
||||
@returns X coordinate in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t getCursorX(void) const { return cursor_x; }
|
||||
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor Y location
|
||||
@returns Y coordinate in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t getCursorY(void) const { return cursor_y; };
|
||||
|
||||
protected:
|
||||
void
|
||||
charBounds(char c, int16_t *x, int16_t *y,
|
||||
int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy);
|
||||
const int16_t
|
||||
int16_t
|
||||
WIDTH, ///< This is the 'raw' display width - never changes
|
||||
HEIGHT; ///< This is the 'raw' display height - never changes
|
||||
int16_t
|
||||
|
@ -141,7 +227,8 @@ class Adafruit_GFX : public Print {
|
|||
textcolor, ///< 16-bit background color for print()
|
||||
textbgcolor; ///< 16-bit text color for print()
|
||||
uint8_t
|
||||
textsize, ///< Desired magnification of text to print()
|
||||
textsize_x, ///< Desired magnification in X-axis of text to print()
|
||||
textsize_y, ///< Desired magnification in Y-axis of text to print()
|
||||
rotation; ///< Display rotation (0 thru 3)
|
||||
boolean
|
||||
wrap, ///< If set, 'wrap' text at right edge of display
|
||||
|
@ -160,23 +247,44 @@ class Adafruit_GFX_Button {
|
|||
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize_x, uint8_t textsize_y);
|
||||
// New/alt initButton() uses upper-left corner & size
|
||||
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1,
|
||||
uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize_x, uint8_t textsize_y);
|
||||
void drawButton(boolean inverted = false);
|
||||
boolean contains(int16_t x, int16_t y);
|
||||
|
||||
void press(boolean p);
|
||||
boolean isPressed();
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Sets button state, should be done by some touch function
|
||||
@param p True for pressed, false for not.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void press(boolean p) { laststate = currstate; currstate = p; }
|
||||
|
||||
boolean justPressed();
|
||||
boolean justReleased();
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Query whether the button is currently pressed
|
||||
@returns True if pressed
|
||||
*/
|
||||
/**********************************************************************/
|
||||
boolean isPressed(void) { return currstate; };
|
||||
|
||||
private:
|
||||
Adafruit_GFX *_gfx;
|
||||
int16_t _x1, _y1; // Coordinates of top-left corner
|
||||
uint16_t _w, _h;
|
||||
uint8_t _textsize;
|
||||
uint8_t _textsize_x;
|
||||
uint8_t _textsize_y;
|
||||
uint16_t _outlinecolor, _fillcolor, _textcolor;
|
||||
char _label[10];
|
||||
|
||||
|
@ -191,7 +299,13 @@ class GFXcanvas1 : public Adafruit_GFX {
|
|||
~GFXcanvas1(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color),
|
||||
fillScreen(uint16_t color);
|
||||
uint8_t *getBuffer(void);
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint8_t *getBuffer(void) const { return buffer; }
|
||||
private:
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
@ -205,8 +319,13 @@ class GFXcanvas8 : public Adafruit_GFX {
|
|||
void drawPixel(int16_t x, int16_t y, uint16_t color),
|
||||
fillScreen(uint16_t color),
|
||||
writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
uint8_t *getBuffer(void);
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint8_t *getBuffer(void) const { return buffer; }
|
||||
private:
|
||||
uint8_t *buffer;
|
||||
};
|
||||
|
@ -218,8 +337,15 @@ class GFXcanvas16 : public Adafruit_GFX {
|
|||
GFXcanvas16(uint16_t w, uint16_t h);
|
||||
~GFXcanvas16(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color),
|
||||
fillScreen(uint16_t color);
|
||||
uint16_t *getBuffer(void);
|
||||
fillScreen(uint16_t color),
|
||||
byteSwap(void);
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint16_t *getBuffer(void) const { return buffer; }
|
||||
private:
|
||||
uint16_t *buffer;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,519 @@
|
|||
/*!
|
||||
* @file Adafruit_SPITFT.h
|
||||
*
|
||||
* Part of Adafruit's GFX graphics library. Originally this class was
|
||||
* written to handle a range of color TFT displays connected via SPI,
|
||||
* but over time this library and some display-specific subclasses have
|
||||
* mutated to include some color OLEDs as well as parallel-interfaced
|
||||
* displays. The name's been kept for the sake of older code.
|
||||
*
|
||||
* 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 "ladyada" Fried for Adafruit Industries,
|
||||
* with contributions from the open source community.
|
||||
*
|
||||
* BSD license, all text here must be included in any redistribution.
|
||||
*/
|
||||
|
||||
#ifndef _ADAFRUIT_SPITFT_H_
|
||||
#define _ADAFRUIT_SPITFT_H_
|
||||
|
||||
#if !defined(__AVR_ATtiny85__) // Not for ATtiny, at all
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
|
||||
// HARDWARE CONFIG ---------------------------------------------------------
|
||||
|
||||
#if defined(__AVR__)
|
||||
typedef uint8_t ADAGFX_PORT_t; ///< PORT values are 8-bit
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#elif defined(ARDUINO_STM32_FEATHER) // WICED
|
||||
typedef class HardwareSPI SPIClass; ///< SPI is a bit odd on WICED
|
||||
typedef uint32_t ADAGFX_PORT_t; ///< PORT values are 32-bit
|
||||
#elif defined(__arm__)
|
||||
#if defined(ARDUINO_ARCH_SAMD)
|
||||
// Adafruit M0, M4
|
||||
typedef uint32_t ADAGFX_PORT_t; ///< PORT values are 32-bit
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#define HAS_PORT_SET_CLR ///< PORTs have set & clear registers
|
||||
#elif defined(CORE_TEENSY)
|
||||
// PJRC Teensy 4.x
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
|
||||
typedef uint32_t ADAGFX_PORT_t; ///< PORT values are 32-bit
|
||||
// PJRC Teensy 3.x
|
||||
#else
|
||||
typedef uint8_t ADAGFX_PORT_t; ///< PORT values are 8-bit
|
||||
#endif
|
||||
#define USE_FAST_PINIO ///< Use direct PORT register access
|
||||
#define HAS_PORT_SET_CLR ///< PORTs have set & clear registers
|
||||
#else
|
||||
// Arduino Due?
|
||||
typedef uint32_t ADAGFX_PORT_t; ///< PORT values are 32-bit
|
||||
// USE_FAST_PINIO not available here (yet)...Due has a totally different
|
||||
// GPIO register set and will require some changes elsewhere (e.g. in
|
||||
// constructors especially).
|
||||
#endif
|
||||
#else // !ARM
|
||||
// Probably ESP8266 or ESP32. USE_FAST_PINIO is not available here (yet)
|
||||
// but don't worry about it too much...the digitalWrite() implementation
|
||||
// on these platforms is reasonably efficient and already RAM-resident,
|
||||
// only gotcha then is no parallel connection support for now.
|
||||
typedef uint32_t ADAGFX_PORT_t; ///< PORT values are 32-bit
|
||||
#endif // end !ARM
|
||||
typedef volatile ADAGFX_PORT_t* PORTreg_t; ///< PORT register type
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define DEFAULT_SPI_FREQ 8000000L ///< Hardware SPI default speed
|
||||
#else
|
||||
#define DEFAULT_SPI_FREQ 16000000L ///< Hardware SPI default speed
|
||||
#endif
|
||||
|
||||
#if defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
|
||||
#define USE_SPI_DMA ///< Auto DMA if using PyPortal
|
||||
#else
|
||||
//#define USE_SPI_DMA ///< If set, use DMA if available
|
||||
#endif
|
||||
// Another "oops" name -- this now also handles parallel DMA.
|
||||
// If DMA is enabled, Arduino sketch MUST #include <Adafruit_ZeroDMA.h>
|
||||
// Estimated RAM usage:
|
||||
// 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis,
|
||||
// e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes.
|
||||
|
||||
#if !defined(ARDUINO_ARCH_SAMD)
|
||||
#undef USE_SPI_DMA ///< DMA currently for SAMD chips only
|
||||
#endif
|
||||
|
||||
#if defined(USE_SPI_DMA)
|
||||
#pragma message ("GFX DMA IS ENABLED. HIGHLY EXPERIMENTAL.")
|
||||
#include <Adafruit_ZeroDMA.h>
|
||||
#endif
|
||||
|
||||
// This is kind of a kludge. Needed a way to disambiguate the software SPI
|
||||
// and parallel constructors via their argument lists. Originally tried a
|
||||
// bool as the first argument to the parallel constructor (specifying 8-bit
|
||||
// vs 16-bit interface) but the compiler regards this as equivalent to an
|
||||
// integer and thus still ambiguous. SO...the parallel constructor requires
|
||||
// an enumerated type as the first argument: tft8 (for 8-bit parallel) or
|
||||
// tft16 (for 16-bit)...even though 16-bit isn't fully implemented or tested
|
||||
// and might never be, still needed that disambiguation from soft SPI.
|
||||
enum tftBusWidth { tft8bitbus, tft16bitbus }; ///< For first arg to parallel constructor
|
||||
|
||||
// CLASS DEFINITION --------------------------------------------------------
|
||||
|
||||
/*!
|
||||
@brief Adafruit_SPITFT is an intermediary class between Adafruit_GFX
|
||||
and various hardware-specific subclasses for different displays.
|
||||
It handles certain operations that are common to a range of
|
||||
displays (address window, area fills, etc.). Originally these were
|
||||
all color TFT displays interfaced via SPI, but it's since expanded
|
||||
to include color OLEDs and parallel-interfaced TFTs. THE NAME HAS
|
||||
BEEN KEPT TO AVOID BREAKING A LOT OF SUBCLASSES AND EXAMPLE CODE.
|
||||
Many of the class member functions similarly live on with names
|
||||
that don't necessarily accurately describe what they're doing,
|
||||
again to avoid breaking a lot of other code. If in doubt, read
|
||||
the comments.
|
||||
*/
|
||||
class Adafruit_SPITFT : public Adafruit_GFX {
|
||||
|
||||
public:
|
||||
|
||||
// CONSTRUCTORS --------------------------------------------------------
|
||||
|
||||
// Software SPI constructor: expects width & height (at default rotation
|
||||
// setting 0), 4 signal pins (cs, dc, mosi, sclk), 2 optional pins
|
||||
// (reset, miso). cs argument is required but can be -1 if unused --
|
||||
// rather than moving it to the optional arguments, it was done this way
|
||||
// to avoid breaking existing code (-1 option was a later addition).
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t mosi, int8_t sck,
|
||||
int8_t rst = -1, int8_t miso = -1);
|
||||
|
||||
// Hardware SPI constructor using the default SPI port: expects width &
|
||||
// height (at default rotation setting 0), 2 signal pins (cs, dc),
|
||||
// optional reset pin. cs is required but can be -1 if unused -- rather
|
||||
// than moving it to the optional arguments, it was done this way to
|
||||
// avoid breaking existing code (-1 option was a later addition).
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h,
|
||||
int8_t cs, int8_t dc, int8_t rst = -1);
|
||||
|
||||
#if !defined(ESP8266) // See notes in .cpp
|
||||
// Hardware SPI constructor using an arbitrary SPI peripheral: expects
|
||||
// width & height (rotation 0), SPIClass pointer, 2 signal pins (cs, dc)
|
||||
// and optional reset pin. cs is required but can be -1 if unused.
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
|
||||
int8_t cs, int8_t dc, int8_t rst = -1);
|
||||
#endif // end !ESP8266
|
||||
|
||||
// Parallel constructor: expects width & height (rotation 0), flag
|
||||
// indicating whether 16-bit (true) or 8-bit (false) interface, 3 signal
|
||||
// pins (d0, wr, dc), 3 optional pins (cs, rst, rd). 16-bit parallel
|
||||
// isn't even fully implemented but the 'wide' flag was added as a
|
||||
// required argument to avoid ambiguity with other constructors.
|
||||
Adafruit_SPITFT(uint16_t w, uint16_t h, tftBusWidth busWidth,
|
||||
int8_t d0, int8_t wr, int8_t dc,
|
||||
int8_t cs = -1, int8_t rst = -1, int8_t rd = -1);
|
||||
|
||||
// CLASS MEMBER FUNCTIONS ----------------------------------------------
|
||||
|
||||
// These first two functions MUST be declared by subclasses:
|
||||
|
||||
/*!
|
||||
@brief Display-specific initialization function.
|
||||
@param freq SPI frequency, in hz (or 0 for default or unused).
|
||||
*/
|
||||
virtual void begin(uint32_t freq) = 0;
|
||||
|
||||
/*!
|
||||
@brief Set up the specific display hardware's "address window"
|
||||
for subsequent pixel-pushing operations.
|
||||
@param x Leftmost pixel of area to be drawn (MUST be within
|
||||
display bounds at current rotation setting).
|
||||
@param y Topmost pixel of area to be drawn (MUST be within
|
||||
display bounds at current rotation setting).
|
||||
@param w Width of area to be drawn, in pixels (MUST be >0 and,
|
||||
added to x, within display bounds at current rotation).
|
||||
@param h Height of area to be drawn, in pixels (MUST be >0 and,
|
||||
added to x, within display bounds at current rotation).
|
||||
*/
|
||||
virtual void setAddrWindow(
|
||||
uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0;
|
||||
|
||||
// Remaining functions do not need to be declared in subclasses
|
||||
// unless they wish to provide hardware-specific optimizations.
|
||||
// Brief comments here...documented more thoroughly in .cpp file.
|
||||
|
||||
// Subclass' begin() function invokes this to initialize hardware.
|
||||
// freq=0 to use default SPI speed. spiMode must be one of the SPI_MODEn
|
||||
// values defined in SPI.h, which are NOT the same as 0 for SPI_MODE0,
|
||||
// 1 for SPI_MODE1, etc...use ONLY the SPI_MODEn defines! Only!
|
||||
// Name is outdated (interface may be parallel) but for compatibility:
|
||||
void initSPI(uint32_t freq = 0, uint8_t spiMode = SPI_MODE0);
|
||||
// Chip select and/or hardware SPI transaction start as needed:
|
||||
void startWrite(void);
|
||||
// Chip deselect and/or hardware SPI transaction end as needed:
|
||||
void endWrite(void);
|
||||
void sendCommand(uint8_t commandByte, uint8_t *dataBytes = NULL, uint8_t numDataBytes = 0);
|
||||
void sendCommand(uint8_t commandByte, const uint8_t *dataBytes, uint8_t numDataBytes);
|
||||
uint8_t readcommand8(uint8_t commandByte, uint8_t index = 0);
|
||||
|
||||
// These functions require a chip-select and/or SPI transaction
|
||||
// around them. Higher-level graphics primitives might start a
|
||||
// single transaction and then make multiple calls to these functions
|
||||
// (e.g. circle or text rendering might make repeated lines or rects)
|
||||
// before ending the transaction. It's more efficient than starting a
|
||||
// transaction every time.
|
||||
void writePixel(int16_t x, int16_t y, uint16_t color);
|
||||
void writePixels(uint16_t *colors, uint32_t len,
|
||||
bool block=true, bool bigEndian=false);
|
||||
void writeColor(uint16_t color, uint32_t len);
|
||||
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
void writeFastHLine(int16_t x, int16_t y, int16_t w,
|
||||
uint16_t color);
|
||||
void writeFastVLine(int16_t x, int16_t y, int16_t h,
|
||||
uint16_t color);
|
||||
// This is a new function, similar to writeFillRect() except that
|
||||
// all arguments MUST be onscreen, sorted and clipped. If higher-level
|
||||
// primitives can handle their own sorting/clipping, it avoids repeating
|
||||
// such operations in the low-level code, making it potentially faster.
|
||||
// CALLING THIS WITH UNCLIPPED OR NEGATIVE VALUES COULD BE DISASTROUS.
|
||||
inline void writeFillRectPreclipped(int16_t x, int16_t y,
|
||||
int16_t w, int16_t h, uint16_t color);
|
||||
// Another new function, companion to the new non-blocking
|
||||
// writePixels() variant.
|
||||
void dmaWait(void);
|
||||
|
||||
|
||||
// These functions are similar to the 'write' functions above, but with
|
||||
// a chip-select and/or SPI transaction built-in. They're typically used
|
||||
// solo -- that is, as graphics primitives in themselves, not invoked by
|
||||
// higher-level primitives (which should use the functions above).
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w,
|
||||
uint16_t color);
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h,
|
||||
uint16_t color);
|
||||
// A single-pixel push encapsulated in a transaction. I don't think
|
||||
// this is used anymore (BMP demos might've used it?) but is provided
|
||||
// for backward compatibility, consider it deprecated:
|
||||
void pushColor(uint16_t color);
|
||||
|
||||
using Adafruit_GFX::drawRGBBitmap; // Check base class first
|
||||
void drawRGBBitmap(int16_t x, int16_t y,
|
||||
uint16_t *pcolors, int16_t w, int16_t h);
|
||||
|
||||
void invertDisplay(bool i);
|
||||
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
// Despite parallel additions, function names kept for compatibility:
|
||||
void spiWrite(uint8_t b); // Write single byte as DATA
|
||||
void writeCommand(uint8_t cmd); // Write single byte as COMMAND
|
||||
uint8_t spiRead(void); // Read single byte of data
|
||||
|
||||
// Most of these low-level functions were formerly macros in
|
||||
// Adafruit_SPITFT_Macros.h. Some have been made into inline functions
|
||||
// to avoid macro mishaps. Despite the addition of code for a parallel
|
||||
// display interface, the names have been kept for backward
|
||||
// compatibility (some subclasses may be invoking these):
|
||||
void SPI_WRITE16(uint16_t w); // Not inline
|
||||
void SPI_WRITE32(uint32_t l); // Not inline
|
||||
// Old code had both a spiWrite16() function and SPI_WRITE16 macro
|
||||
// in addition to the SPI_WRITE32 macro. The latter two have been
|
||||
// made into functions here, and spiWrite16() removed (use SPI_WRITE16()
|
||||
// instead). It looks like most subclasses had gotten comfortable with
|
||||
// SPI_WRITE16 and SPI_WRITE32 anyway so those names were kept rather
|
||||
// than the less-obnoxious camelcase variants, oh well.
|
||||
|
||||
// Placing these functions entirely in the class definition inlines
|
||||
// them implicitly them while allowing their use in other code:
|
||||
|
||||
/*!
|
||||
@brief Set the chip-select line HIGH. Does NOT check whether CS pin
|
||||
is set (>=0), that should be handled in calling function.
|
||||
Despite function name, this is used even if the display
|
||||
connection is parallel.
|
||||
*/
|
||||
void SPI_CS_HIGH(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*csPortSet = 1;
|
||||
#else // !KINETISK
|
||||
*csPortSet = csPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*csPort |= csPinMaskSet;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_cs, HIGH);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the chip-select line LOW. Does NOT check whether CS pin
|
||||
is set (>=0), that should be handled in calling function.
|
||||
Despite function name, this is used even if the display
|
||||
connection is parallel.
|
||||
*/
|
||||
void SPI_CS_LOW(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*csPortClr = 1;
|
||||
#else // !KINETISK
|
||||
*csPortClr = csPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*csPort &= csPinMaskClr;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_cs, LOW);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the data/command line HIGH (data mode).
|
||||
*/
|
||||
void SPI_DC_HIGH(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*dcPortSet = 1;
|
||||
#else // !KINETISK
|
||||
*dcPortSet = dcPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*dcPort |= dcPinMaskSet;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_dc, HIGH);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Set the data/command line LOW (command mode).
|
||||
*/
|
||||
void SPI_DC_LOW(void) {
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if defined(KINETISK)
|
||||
*dcPortClr = 1;
|
||||
#else // !KINETISK
|
||||
*dcPortClr = dcPinMask;
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
*dcPort &= dcPinMaskClr;
|
||||
#endif // end !HAS_PORT_SET_CLR
|
||||
#else // !USE_FAST_PINIO
|
||||
digitalWrite(_dc, LOW);
|
||||
#endif // end !USE_FAST_PINIO
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// A few more low-level member functions -- some may have previously
|
||||
// been macros. Shouldn't have a need to access these externally, so
|
||||
// they've been moved to the protected section. Additionally, they're
|
||||
// declared inline here and the code is in the .cpp file, since outside
|
||||
// code doesn't need to see these.
|
||||
inline void SPI_MOSI_HIGH(void);
|
||||
inline void SPI_MOSI_LOW(void);
|
||||
inline void SPI_SCK_HIGH(void);
|
||||
inline void SPI_SCK_LOW(void);
|
||||
inline bool SPI_MISO_READ(void);
|
||||
inline void SPI_BEGIN_TRANSACTION(void);
|
||||
inline void SPI_END_TRANSACTION(void);
|
||||
inline void TFT_WR_STROBE(void); // Parallel interface write strobe
|
||||
inline void TFT_RD_HIGH(void); // Parallel interface read high
|
||||
inline void TFT_RD_LOW(void); // Parallel interface read low
|
||||
|
||||
// CLASS INSTANCE VARIABLES --------------------------------------------
|
||||
|
||||
// Here be dragons! There's a big union of three structures here --
|
||||
// one each for hardware SPI, software (bitbang) SPI, and parallel
|
||||
// interfaces. This is to save some memory, since a display's connection
|
||||
// will be only one of these. The order of some things is a little weird
|
||||
// in an attempt to get values to align and pack better in RAM.
|
||||
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
PORTreg_t csPortSet; ///< PORT register for chip select SET
|
||||
PORTreg_t csPortClr; ///< PORT register for chip select CLEAR
|
||||
PORTreg_t dcPortSet; ///< PORT register for data/command SET
|
||||
PORTreg_t dcPortClr; ///< PORT register for data/command CLEAR
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
PORTreg_t csPort; ///< PORT register for chip select
|
||||
PORTreg_t dcPort; ///< PORT register for data/command
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201100)
|
||||
union {
|
||||
#endif
|
||||
struct { // Values specific to HARDWARE SPI:
|
||||
SPIClass *_spi; ///< SPI class pointer
|
||||
#if defined(SPI_HAS_TRANSACTION)
|
||||
SPISettings settings; ///< SPI transaction settings
|
||||
#else
|
||||
uint32_t _freq; ///< SPI bitrate (if no SPI transactions)
|
||||
#endif
|
||||
uint32_t _mode; ///< SPI data mode (transactions or no)
|
||||
} hwspi; ///< Hardware SPI values
|
||||
struct { // Values specific to SOFTWARE SPI:
|
||||
#if defined(USE_FAST_PINIO)
|
||||
PORTreg_t misoPort; ///< PORT (PIN) register for MISO
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
PORTreg_t mosiPortSet; ///< PORT register for MOSI SET
|
||||
PORTreg_t mosiPortClr; ///< PORT register for MOSI CLEAR
|
||||
PORTreg_t sckPortSet; ///< PORT register for SCK SET
|
||||
PORTreg_t sckPortClr; ///< PORT register for SCK CLEAR
|
||||
#if !defined(KINETISK)
|
||||
ADAGFX_PORT_t mosiPinMask; ///< Bitmask for MOSI
|
||||
ADAGFX_PORT_t sckPinMask; ///< Bitmask for SCK
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
PORTreg_t mosiPort; ///< PORT register for MOSI
|
||||
PORTreg_t sckPort; ///< PORT register for SCK
|
||||
ADAGFX_PORT_t mosiPinMaskSet; ///< Bitmask for MOSI SET (OR)
|
||||
ADAGFX_PORT_t mosiPinMaskClr; ///< Bitmask for MOSI CLEAR (AND)
|
||||
ADAGFX_PORT_t sckPinMaskSet; ///< Bitmask for SCK SET (OR bitmask)
|
||||
ADAGFX_PORT_t sckPinMaskClr; ///< Bitmask for SCK CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#if !defined(KINETISK)
|
||||
ADAGFX_PORT_t misoPinMask; ///< Bitmask for MISO
|
||||
#endif // end !KINETISK
|
||||
#endif // end USE_FAST_PINIO
|
||||
int8_t _mosi; ///< MOSI pin #
|
||||
int8_t _miso; ///< MISO pin #
|
||||
int8_t _sck; ///< SCK pin #
|
||||
} swspi; ///< Software SPI values
|
||||
struct { // Values specific to 8-bit parallel:
|
||||
#if defined(USE_FAST_PINIO)
|
||||
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
|
||||
volatile uint32_t *writePort; ///< PORT register for DATA WRITE
|
||||
volatile uint32_t *readPort; ///< PORT (PIN) register for DATA READ
|
||||
#else
|
||||
volatile uint8_t *writePort; ///< PORT register for DATA WRITE
|
||||
volatile uint8_t *readPort; ///< PORT (PIN) register for DATA READ
|
||||
#endif
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
// Port direction register pointers are always 8-bit regardless of
|
||||
// PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
|
||||
#if defined(__IMXRT1052__) || defined(__IMXRT1062__) // Teensy 4.x
|
||||
volatile uint32_t *dirSet; ///< PORT byte data direction SET
|
||||
volatile uint32_t *dirClr; ///< PORT byte data direction CLEAR
|
||||
#else
|
||||
volatile uint8_t *dirSet; ///< PORT byte data direction SET
|
||||
volatile uint8_t *dirClr; ///< PORT byte data direction CLEAR
|
||||
#endif
|
||||
PORTreg_t wrPortSet; ///< PORT register for write strobe SET
|
||||
PORTreg_t wrPortClr; ///< PORT register for write strobe CLEAR
|
||||
PORTreg_t rdPortSet; ///< PORT register for read strobe SET
|
||||
PORTreg_t rdPortClr; ///< PORT register for read strobe CLEAR
|
||||
#if !defined(KINETISK)
|
||||
ADAGFX_PORT_t wrPinMask; ///< Bitmask for write strobe
|
||||
#endif // end !KINETISK
|
||||
ADAGFX_PORT_t rdPinMask; ///< Bitmask for read strobe
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
// Port direction register pointer is always 8-bit regardless of
|
||||
// PORTreg_t -- even if 32-bit port, we modify a byte-aligned 8 bits.
|
||||
volatile uint8_t *portDir; ///< PORT direction register
|
||||
PORTreg_t wrPort; ///< PORT register for write strobe
|
||||
PORTreg_t rdPort; ///< PORT register for read strobe
|
||||
ADAGFX_PORT_t wrPinMaskSet; ///< Bitmask for write strobe SET (OR)
|
||||
ADAGFX_PORT_t wrPinMaskClr; ///< Bitmask for write strobe CLEAR (AND)
|
||||
ADAGFX_PORT_t rdPinMaskSet; ///< Bitmask for read strobe SET (OR)
|
||||
ADAGFX_PORT_t rdPinMaskClr; ///< Bitmask for read strobe CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
int8_t _d0; ///< Data pin 0 #
|
||||
int8_t _wr; ///< Write strobe pin #
|
||||
int8_t _rd; ///< Read strobe pin # (or -1)
|
||||
bool wide = 0; ///< If true, is 16-bit interface
|
||||
} tft8; ///< Parallel interface settings
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201100)
|
||||
}; ///< Only one interface is active
|
||||
#endif
|
||||
#if defined(USE_SPI_DMA) // Used by hardware SPI and tft8
|
||||
Adafruit_ZeroDMA dma; ///< DMA instance
|
||||
DmacDescriptor *dptr = NULL; ///< 1st descriptor
|
||||
DmacDescriptor *descriptor = NULL; ///< Allocated descriptor list
|
||||
uint16_t *pixelBuf[2]; ///< Working buffers
|
||||
uint16_t maxFillLen; ///< Max pixels per DMA xfer
|
||||
uint16_t lastFillColor = 0; ///< Last color used w/fill
|
||||
uint32_t lastFillLen = 0; ///< # of pixels w/last fill
|
||||
uint8_t onePixelBuf; ///< For hi==lo fill
|
||||
#endif
|
||||
#if defined(USE_FAST_PINIO)
|
||||
#if defined(HAS_PORT_SET_CLR)
|
||||
#if !defined(KINETISK)
|
||||
ADAGFX_PORT_t csPinMask; ///< Bitmask for chip select
|
||||
ADAGFX_PORT_t dcPinMask; ///< Bitmask for data/command
|
||||
#endif // end !KINETISK
|
||||
#else // !HAS_PORT_SET_CLR
|
||||
ADAGFX_PORT_t csPinMaskSet; ///< Bitmask for chip select SET (OR)
|
||||
ADAGFX_PORT_t csPinMaskClr; ///< Bitmask for chip select CLEAR (AND)
|
||||
ADAGFX_PORT_t dcPinMaskSet; ///< Bitmask for data/command SET (OR)
|
||||
ADAGFX_PORT_t dcPinMaskClr; ///< Bitmask for data/command CLEAR (AND)
|
||||
#endif // end HAS_PORT_SET_CLR
|
||||
#endif // end USE_FAST_PINIO
|
||||
uint8_t connection; ///< TFT_HARD_SPI, TFT_SOFT_SPI, etc.
|
||||
int8_t _rst; ///< Reset pin # (or -1)
|
||||
int8_t _cs; ///< Chip select pin # (or -1)
|
||||
int8_t _dc; ///< Data/command pin #
|
||||
|
||||
int16_t _xstart = 0; ///< Internal framebuffer X offset
|
||||
int16_t _ystart = 0; ///< Internal framebuffer Y offset
|
||||
uint8_t invertOnCommand = 0; ///< Command to enable invert mode
|
||||
uint8_t invertOffCommand = 0; ///< Command to disable invert mode
|
||||
|
||||
uint32_t _freq = 0; ///< Dummy var to keep subclasses happy
|
||||
};
|
||||
|
||||
#endif // end __AVR_ATtiny85__
|
||||
#endif // end _ADAFRUIT_SPITFT_H_
|
|
@ -0,0 +1,6 @@
|
|||
// THIS FILE INTENTIONALLY LEFT BLANK.
|
||||
|
||||
// Macros previously #defined here have been made into (mostly) inline
|
||||
// functions in the Adafruit_SPITFT class. Other libraries might still
|
||||
// contain code trying to #include this header file, so until everything's
|
||||
// updated this file still exists (but doing nothing) to avoid trouble.
|
|
@ -1,4 +1,4 @@
|
|||
# Adafruit GFX Library # [![Build Status](https://travis-ci.org/adafruit/Adafruit_GFX.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_GFX)
|
||||
# Adafruit GFX Library [![Build Status](https://travis-ci.com/adafruit/Adafruit-GFX-Library.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit-GFX-Library)
|
||||
|
||||
This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions).
|
||||
|
|
@ -362,4 +362,4 @@ unsigned long testFilledRoundRects() {
|
|||
}
|
||||
|
||||
return micros() - start;
|
||||
}
|
||||
}
|
|
@ -16,12 +16,14 @@ Keep 7-bit fonts around as an option in that case, more compact.
|
|||
|
||||
See notes at end for glyph nomenclature & other tidbits.
|
||||
*/
|
||||
#ifndef ARDUINO
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_GLYPH_H
|
||||
#include FT_TRUETYPE_DRIVER_H
|
||||
#include "../gfxfont.h" // Adafruit_GFX font structures
|
||||
|
||||
#define DPI 141 // Approximate res. of Adafruit 2.8" TFT
|
||||
|
@ -116,6 +118,16 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(stderr, "FreeType init error: %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
// Use TrueType engine version 35, without subpixel rendering.
|
||||
// This improves clarity of fonts since this library does not
|
||||
// support rendering multiple levels of gray in a glyph.
|
||||
// See https://github.com/adafruit/Adafruit-GFX-Library/issues/103
|
||||
FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35;
|
||||
FT_Property_Set( library, "truetype",
|
||||
"interpreter-version",
|
||||
&interpreter_version );
|
||||
|
||||
if((err = FT_New_Face(library, argv[1], 0, &face))) {
|
||||
fprintf(stderr, "Font load error: %d", err);
|
||||
FT_Done_FreeType(library);
|
||||
|
@ -282,3 +294,5 @@ the cursor on the X axis after drawing the corresponding symbol.
|
|||
There's also some changes with regard to 'background' color and new GFX
|
||||
fonts (classic fonts unchanged). See Adafruit_GFX.cpp for explanation.
|
||||
*/
|
||||
|
||||
#endif /* !ARDUINO */
|
|
@ -9,6 +9,10 @@
|
|||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||
// PROGMEM is defefind for T4 to place data in specific memory section
|
||||
#undef PROGMEM
|
||||
#define PROGMEM
|
||||
#else
|
||||
#define PROGMEM
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit GFX Library
|
||||
version=1.2.9
|
||||
version=1.5.6
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.
|
|
@ -1,729 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen below must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#include <pgmspace.h>
|
||||
#else
|
||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||
#endif
|
||||
|
||||
#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && !defined(ESP32) && !defined(__arc__)
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_SSD1306.h"
|
||||
|
||||
// the memory buffer for the LCD
|
||||
|
||||
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF,
|
||||
#if (SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH > 96*16)
|
||||
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
|
||||
0x80, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x8C, 0x8E, 0x84, 0x00, 0x00, 0x80, 0xF8,
|
||||
0xF8, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80,
|
||||
0x00, 0xE0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0x01, 0x01,
|
||||
0x01, 0x01, 0x83, 0xFF, 0xFF, 0x00, 0x00, 0x7C, 0xFE, 0xC7, 0x01, 0x01, 0x01, 0x01, 0x83, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0x38, 0xFE, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x01, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x7F, 0xFF,
|
||||
0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF,
|
||||
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x8F,
|
||||
0x8F, 0x9F, 0xBF, 0xFF, 0xFF, 0xC3, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC,
|
||||
0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x01, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00,
|
||||
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#if (SSD1306_LCDHEIGHT == 64)
|
||||
0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F,
|
||||
0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F,
|
||||
0x0F, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00,
|
||||
0x00, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xF0, 0xF8, 0x1C, 0x0E,
|
||||
0x06, 0x06, 0x06, 0x0C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFC,
|
||||
0xFE, 0xFC, 0x00, 0x18, 0x3C, 0x7E, 0x66, 0xE6, 0xCE, 0x84, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x06,
|
||||
0x06, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0xC0, 0xF8,
|
||||
0xFC, 0x4E, 0x46, 0x46, 0x46, 0x4E, 0x7C, 0x78, 0x40, 0x18, 0x3C, 0x76, 0xE6, 0xCE, 0xCC, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x0C,
|
||||
0x18, 0x18, 0x0C, 0x06, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0E, 0x0C, 0x18, 0x0C, 0x0F,
|
||||
0x07, 0x01, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x07,
|
||||
0x07, 0x0C, 0x0C, 0x18, 0x1C, 0x0C, 0x06, 0x06, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ssd1306_swap(a, b) { int16_t t = a; a = b; b = t; }
|
||||
|
||||
// the most basic function, set a single pixel
|
||||
void Adafruit_SSD1306::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
ssd1306_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
ssd1306_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// x is which column
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << (y&7)); break;
|
||||
case BLACK: buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << (y&7)); break;
|
||||
case INVERSE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] ^= (1 << (y&7)); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
cs = CS;
|
||||
rst = RST;
|
||||
dc = DC;
|
||||
sclk = SCLK;
|
||||
sid = SID;
|
||||
hwSPI = false;
|
||||
}
|
||||
|
||||
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
dc = DC;
|
||||
rst = RST;
|
||||
cs = CS;
|
||||
hwSPI = true;
|
||||
}
|
||||
|
||||
// initializer for I2C - we only indicate the reset pin!
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t reset) :
|
||||
Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
sclk = dc = cs = sid = -1;
|
||||
rst = reset;
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
|
||||
_vccstate = vccstate;
|
||||
_i2caddr = i2caddr;
|
||||
|
||||
// set pin directions
|
||||
if (sid != -1){
|
||||
pinMode(dc, OUTPUT);
|
||||
pinMode(cs, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
csport = portOutputRegister(digitalPinToPort(cs));
|
||||
cspinmask = digitalPinToBitMask(cs);
|
||||
dcport = portOutputRegister(digitalPinToPort(dc));
|
||||
dcpinmask = digitalPinToBitMask(dc);
|
||||
#endif
|
||||
if (!hwSPI){
|
||||
// set pins for software-SPI
|
||||
pinMode(sid, OUTPUT);
|
||||
pinMode(sclk, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
clkport = portOutputRegister(digitalPinToPort(sclk));
|
||||
clkpinmask = digitalPinToBitMask(sclk);
|
||||
mosiport = portOutputRegister(digitalPinToPort(sid));
|
||||
mosipinmask = digitalPinToBitMask(sid);
|
||||
#endif
|
||||
}
|
||||
if (hwSPI){
|
||||
SPI.begin();
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
|
||||
#else
|
||||
SPI.setClockDivider (4);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C Init
|
||||
Wire.begin();
|
||||
#ifdef __SAM3X8E__
|
||||
// Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL)
|
||||
TWI1->TWI_CWGR = 0;
|
||||
TWI1->TWI_CWGR = ((VARIANT_MCK / (2 * 400000)) - 4) * 0x101;
|
||||
#endif
|
||||
}
|
||||
if ((reset) && (rst >= 0)) {
|
||||
// Setup reset pin direction (used by both SPI and I2C)
|
||||
pinMode(rst, OUTPUT);
|
||||
digitalWrite(rst, HIGH);
|
||||
// VDD (3.3V) goes high at start, lets just chill for a ms
|
||||
delay(1);
|
||||
// bring reset low
|
||||
digitalWrite(rst, LOW);
|
||||
// wait 10ms
|
||||
delay(10);
|
||||
// bring out of reset
|
||||
digitalWrite(rst, HIGH);
|
||||
// turn on VCC (9V?)
|
||||
}
|
||||
|
||||
// Init sequence
|
||||
ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE
|
||||
ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5
|
||||
ssd1306_command(0x80); // the suggested ratio 0x80
|
||||
|
||||
ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8
|
||||
ssd1306_command(SSD1306_LCDHEIGHT - 1);
|
||||
|
||||
ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3
|
||||
ssd1306_command(0x0); // no offset
|
||||
ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0x14); }
|
||||
ssd1306_command(SSD1306_MEMORYMODE); // 0x20
|
||||
ssd1306_command(0x00); // 0x0 act like ks0108
|
||||
ssd1306_command(SSD1306_SEGREMAP | 0x1);
|
||||
ssd1306_command(SSD1306_COMSCANDEC);
|
||||
|
||||
#if defined SSD1306_128_32
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(0x02);
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
ssd1306_command(0x8F);
|
||||
|
||||
#elif defined SSD1306_128_64
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(0x12);
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x9F); }
|
||||
else
|
||||
{ ssd1306_command(0xCF); }
|
||||
|
||||
#elif defined SSD1306_96_16
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(0x2); //ada x12
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0xAF); }
|
||||
|
||||
#endif
|
||||
|
||||
ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x22); }
|
||||
else
|
||||
{ ssd1306_command(0xF1); }
|
||||
ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB
|
||||
ssd1306_command(0x40);
|
||||
ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6
|
||||
|
||||
ssd1306_command(SSD1306_DEACTIVATE_SCROLL);
|
||||
|
||||
ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1306::invertDisplay(uint8_t i) {
|
||||
if (i) {
|
||||
ssd1306_command(SSD1306_INVERTDISPLAY);
|
||||
} else {
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
|
||||
if (sid != -1)
|
||||
{
|
||||
// SPI
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport |= cspinmask;
|
||||
*dcport &= ~dcpinmask;
|
||||
*csport &= ~cspinmask;
|
||||
#else
|
||||
digitalWrite(cs, HIGH);
|
||||
digitalWrite(dc, LOW);
|
||||
digitalWrite(cs, LOW);
|
||||
#endif
|
||||
fastSPIwrite(c);
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport |= cspinmask;
|
||||
#else
|
||||
digitalWrite(cs, HIGH);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C
|
||||
uint8_t control = 0x00; // Co = 0, D/C = 0
|
||||
Wire.beginTransmission(_i2caddr);
|
||||
Wire.write(control);
|
||||
Wire.write(c);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
|
||||
// startscrollright
|
||||
// Activate a right handed scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_RIGHT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(0XFF);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrollleft
|
||||
// Activate a right handed scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_LEFT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(0XFF);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrolldiagright
|
||||
// Activate a diagonal scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(SSD1306_LCDHEIGHT);
|
||||
ssd1306_command(SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X01);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrolldiagleft
|
||||
// Activate a diagonal scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(SSD1306_LCDHEIGHT);
|
||||
ssd1306_command(SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X01);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::stopscroll(void){
|
||||
ssd1306_command(SSD1306_DEACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// Dim the display
|
||||
// dim = true: display is dimmed
|
||||
// dim = false: display is normal
|
||||
void Adafruit_SSD1306::dim(boolean dim) {
|
||||
uint8_t contrast;
|
||||
|
||||
if (dim) {
|
||||
contrast = 0; // Dimmed display
|
||||
} else {
|
||||
if (_vccstate == SSD1306_EXTERNALVCC) {
|
||||
contrast = 0x9F;
|
||||
} else {
|
||||
contrast = 0xCF;
|
||||
}
|
||||
}
|
||||
// the range of contrast to too small to be really useful
|
||||
// it is useful to dim the display
|
||||
ssd1306_command(SSD1306_SETCONTRAST);
|
||||
ssd1306_command(contrast);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::display(void) {
|
||||
ssd1306_command(SSD1306_COLUMNADDR);
|
||||
ssd1306_command(0); // Column start address (0 = reset)
|
||||
ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)
|
||||
|
||||
ssd1306_command(SSD1306_PAGEADDR);
|
||||
ssd1306_command(0); // Page start address (0 = reset)
|
||||
#if SSD1306_LCDHEIGHT == 64
|
||||
ssd1306_command(7); // Page end address
|
||||
#endif
|
||||
#if SSD1306_LCDHEIGHT == 32
|
||||
ssd1306_command(3); // Page end address
|
||||
#endif
|
||||
#if SSD1306_LCDHEIGHT == 16
|
||||
ssd1306_command(1); // Page end address
|
||||
#endif
|
||||
|
||||
if (sid != -1)
|
||||
{
|
||||
// SPI
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport |= cspinmask;
|
||||
*dcport |= dcpinmask;
|
||||
*csport &= ~cspinmask;
|
||||
#else
|
||||
digitalWrite(cs, HIGH);
|
||||
digitalWrite(dc, HIGH);
|
||||
digitalWrite(cs, LOW);
|
||||
#endif
|
||||
|
||||
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
|
||||
fastSPIwrite(buffer[i]);
|
||||
}
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport |= cspinmask;
|
||||
#else
|
||||
digitalWrite(cs, HIGH);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// save I2C bitrate
|
||||
#ifdef TWBR
|
||||
uint8_t twbrbackup = TWBR;
|
||||
TWBR = 12; // upgrade to 400KHz!
|
||||
#endif
|
||||
|
||||
//Serial.println(TWBR, DEC);
|
||||
//Serial.println(TWSR & 0x3, DEC);
|
||||
|
||||
// I2C
|
||||
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
|
||||
// send a bunch of data in one xmission
|
||||
Wire.beginTransmission(_i2caddr);
|
||||
WIRE_WRITE(0x40);
|
||||
for (uint8_t x=0; x<16; x++) {
|
||||
WIRE_WRITE(buffer[i]);
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
Wire.endTransmission();
|
||||
}
|
||||
#ifdef TWBR
|
||||
TWBR = twbrbackup;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// clear everything
|
||||
void Adafruit_SSD1306::clearDisplay(void) {
|
||||
memset(buffer, 0, (SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8));
|
||||
}
|
||||
|
||||
|
||||
inline void Adafruit_SSD1306::fastSPIwrite(uint8_t d) {
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(sclk, LOW);
|
||||
if(d & bit) digitalWrite(sid, HIGH);
|
||||
else digitalWrite(sid, LOW);
|
||||
digitalWrite(sclk, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
|
||||
boolean bSwap = false;
|
||||
switch(rotation) {
|
||||
case 0:
|
||||
// 0 degree rotation, do nothing
|
||||
break;
|
||||
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:
|
||||
// 180 degree rotation, invert x and y - then shift y around for height.
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
x -= (w-1);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
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) {
|
||||
// Do bounds/limit checks
|
||||
if(y < 0 || y >= HEIGHT) { return; }
|
||||
|
||||
// make sure we don't try to draw below 0
|
||||
if(x < 0) {
|
||||
w += x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
// make sure we don't go off the edge of the display
|
||||
if( (x + w) > WIDTH) {
|
||||
w = (WIDTH - x);
|
||||
}
|
||||
|
||||
// if our width is now negative, punt
|
||||
if(w <= 0) { return; }
|
||||
|
||||
// set up the pointer for movement through the buffer
|
||||
register uint8_t *pBuf = buffer;
|
||||
// adjust the buffer pointer for the current row
|
||||
pBuf += ((y/8) * SSD1306_LCDWIDTH);
|
||||
// and offset x columns in
|
||||
pBuf += x;
|
||||
|
||||
register uint8_t mask = 1 << (y&7);
|
||||
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: while(w--) { *pBuf++ |= mask; }; break;
|
||||
case BLACK: mask = ~mask; while(w--) { *pBuf++ &= mask; }; break;
|
||||
case INVERSE: while(w--) { *pBuf++ ^= mask; }; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
|
||||
bool bSwap = false;
|
||||
switch(rotation) {
|
||||
case 0:
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case 2:
|
||||
// 180 degree rotation, invert x and y - then shift y around for height.
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
y -= (h-1);
|
||||
break;
|
||||
case 3:
|
||||
// 270 degree rotation, swap x & y for rotation, then invert y
|
||||
bSwap = true;
|
||||
ssd1306_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
// do nothing if we're off the left or right side of the screen
|
||||
if(x < 0 || x >= WIDTH) { return; }
|
||||
|
||||
// make sure we don't try to draw below 0
|
||||
if(__y < 0) {
|
||||
// __y is negative, this will subtract enough from __h to account for __y being 0
|
||||
__h += __y;
|
||||
__y = 0;
|
||||
|
||||
}
|
||||
|
||||
// make sure we don't go past the height of the display
|
||||
if( (__y + __h) > HEIGHT) {
|
||||
__h = (HEIGHT - __y);
|
||||
}
|
||||
|
||||
// if our height is now negative, punt
|
||||
if(__h <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// this display doesn't need ints for coordinates, use local byte registers for faster juggling
|
||||
register uint8_t y = __y;
|
||||
register uint8_t h = __h;
|
||||
|
||||
|
||||
// set up the pointer for fast movement through the buffer
|
||||
register uint8_t *pBuf = buffer;
|
||||
// adjust the buffer pointer for the current row
|
||||
pBuf += ((y/8) * SSD1306_LCDWIDTH);
|
||||
// and offset x columns in
|
||||
pBuf += x;
|
||||
|
||||
// do the first partial byte, if necessary - this requires some masking
|
||||
register uint8_t mod = (y&7);
|
||||
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
|
||||
// register uint8_t mask = ~(0xFF >> (mod));
|
||||
static uint8_t premask[8] = {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
|
||||
register uint8_t mask = 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 WHITE: *pBuf |= mask; break;
|
||||
case BLACK: *pBuf &= ~mask; break;
|
||||
case INVERSE: *pBuf ^= mask; break;
|
||||
}
|
||||
|
||||
// fast exit if we're done here!
|
||||
if(h<mod) { return; }
|
||||
|
||||
h -= mod;
|
||||
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
}
|
||||
|
||||
|
||||
// write solid bytes while we can - effectively doing 8 rows at a time
|
||||
if(h >= 8) {
|
||||
if (color == INVERSE) { // separate copy of the code so we don't impact performance of the black/white write version with an extra comparison per loop
|
||||
do {
|
||||
*pBuf=~(*pBuf);
|
||||
|
||||
// adjust the buffer forward 8 rows worth of data
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
|
||||
// adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now)
|
||||
h -= 8;
|
||||
} while(h >= 8);
|
||||
}
|
||||
else {
|
||||
// store a local value to work with
|
||||
register uint8_t val = (color == WHITE) ? 255 : 0;
|
||||
|
||||
do {
|
||||
// write our value in
|
||||
*pBuf = val;
|
||||
|
||||
// adjust the buffer forward 8 rows worth of data
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
|
||||
// adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now)
|
||||
h -= 8;
|
||||
} while(h >= 8);
|
||||
}
|
||||
}
|
||||
|
||||
// now do the final partial byte, if necessary
|
||||
if(h) {
|
||||
mod = h & 7;
|
||||
// this time we want to mask the low bits of the byte, vs the high bits we did above
|
||||
// register uint8_t mask = (1 << mod) - 1;
|
||||
// note - lookup table results in a nearly 10% performance improvement in fill* functions
|
||||
static uint8_t postmask[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
|
||||
register uint8_t mask = postmask[mod];
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: *pBuf |= mask; break;
|
||||
case BLACK: *pBuf &= ~mask; break;
|
||||
case INVERSE: *pBuf ^= mask; break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,186 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
#ifndef _Adafruit_SSD1306_H_
|
||||
#define _Adafruit_SSD1306_H_
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#define WIRE_WRITE Wire.write
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#define WIRE_WRITE Wire.send
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
typedef volatile RwReg PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
// not supported
|
||||
#elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER) || defined(__arc__)
|
||||
typedef volatile uint32_t PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#elif defined(__AVR__)
|
||||
typedef volatile uint8_t PortReg;
|
||||
typedef uint8_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#else
|
||||
// chances are its 32 bit so assume that
|
||||
typedef volatile uint32_t PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#endif
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define INVERSE 2
|
||||
|
||||
#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
|
||||
// Address for 128x32 is 0x3C
|
||||
// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded)
|
||||
|
||||
/*=========================================================================
|
||||
SSD1306 Displays
|
||||
-----------------------------------------------------------------------
|
||||
The driver is used in multiple displays (128x64, 128x32, etc.).
|
||||
Select the appropriate display below to create an appropriately
|
||||
sized framebuffer, etc.
|
||||
|
||||
SSD1306_128_64 128x64 pixel display
|
||||
|
||||
SSD1306_128_32 128x32 pixel display
|
||||
|
||||
SSD1306_96_16
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
#define SSD1306_128_64
|
||||
// #define SSD1306_128_32
|
||||
// #define SSD1306_96_16
|
||||
/*=========================================================================*/
|
||||
|
||||
#if defined SSD1306_128_64 && defined SSD1306_128_32
|
||||
#error "Only one SSD1306 display can be specified at once in SSD1306.h"
|
||||
#endif
|
||||
#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16
|
||||
#error "At least one SSD1306 display must be specified in SSD1306.h"
|
||||
#endif
|
||||
|
||||
#if defined SSD1306_128_64
|
||||
#define SSD1306_LCDWIDTH 128
|
||||
#define SSD1306_LCDHEIGHT 64
|
||||
#endif
|
||||
#if defined SSD1306_128_32
|
||||
#define SSD1306_LCDWIDTH 128
|
||||
#define SSD1306_LCDHEIGHT 32
|
||||
#endif
|
||||
#if defined SSD1306_96_16
|
||||
#define SSD1306_LCDWIDTH 96
|
||||
#define SSD1306_LCDHEIGHT 16
|
||||
#endif
|
||||
|
||||
#define SSD1306_SETCONTRAST 0x81
|
||||
#define SSD1306_DISPLAYALLON_RESUME 0xA4
|
||||
#define SSD1306_DISPLAYALLON 0xA5
|
||||
#define SSD1306_NORMALDISPLAY 0xA6
|
||||
#define SSD1306_INVERTDISPLAY 0xA7
|
||||
#define SSD1306_DISPLAYOFF 0xAE
|
||||
#define SSD1306_DISPLAYON 0xAF
|
||||
|
||||
#define SSD1306_SETDISPLAYOFFSET 0xD3
|
||||
#define SSD1306_SETCOMPINS 0xDA
|
||||
|
||||
#define SSD1306_SETVCOMDETECT 0xDB
|
||||
|
||||
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
|
||||
#define SSD1306_SETPRECHARGE 0xD9
|
||||
|
||||
#define SSD1306_SETMULTIPLEX 0xA8
|
||||
|
||||
#define SSD1306_SETLOWCOLUMN 0x00
|
||||
#define SSD1306_SETHIGHCOLUMN 0x10
|
||||
|
||||
#define SSD1306_SETSTARTLINE 0x40
|
||||
|
||||
#define SSD1306_MEMORYMODE 0x20
|
||||
#define SSD1306_COLUMNADDR 0x21
|
||||
#define SSD1306_PAGEADDR 0x22
|
||||
|
||||
#define SSD1306_COMSCANINC 0xC0
|
||||
#define SSD1306_COMSCANDEC 0xC8
|
||||
|
||||
#define SSD1306_SEGREMAP 0xA0
|
||||
|
||||
#define SSD1306_CHARGEPUMP 0x8D
|
||||
|
||||
#define SSD1306_EXTERNALVCC 0x1
|
||||
#define SSD1306_SWITCHCAPVCC 0x2
|
||||
|
||||
// Scrolling #defines
|
||||
#define SSD1306_ACTIVATE_SCROLL 0x2F
|
||||
#define SSD1306_DEACTIVATE_SCROLL 0x2E
|
||||
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
|
||||
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
|
||||
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
|
||||
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
|
||||
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
|
||||
|
||||
class Adafruit_SSD1306 : public Adafruit_GFX {
|
||||
public:
|
||||
Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);
|
||||
Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS);
|
||||
Adafruit_SSD1306(int8_t RST = -1);
|
||||
|
||||
void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS, bool reset=true);
|
||||
void ssd1306_command(uint8_t c);
|
||||
|
||||
void clearDisplay(void);
|
||||
void invertDisplay(uint8_t i);
|
||||
void display();
|
||||
|
||||
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 dim(boolean dim);
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
private:
|
||||
int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs;
|
||||
void fastSPIwrite(uint8_t c);
|
||||
|
||||
boolean hwSPI;
|
||||
#ifdef HAVE_PORTREG
|
||||
PortReg *mosiport, *clkport, *csport, *dcport;
|
||||
PortMask mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||
#endif
|
||||
|
||||
inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
|
||||
inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
|
||||
|
||||
};
|
||||
|
||||
#endif /* _Adafruit_SSD1306_H_ */
|
|
@ -1,32 +0,0 @@
|
|||
# Adafruit_SSD1306
|
||||
<!-- START COMPATIBILITY TABLE -->
|
||||
|
||||
## Compatibility
|
||||
|
||||
MCU | Tested Works | Doesn't Work | Not Tested | Notes
|
||||
------------------ | :----------: | :----------: | :---------: | -----
|
||||
Atmega328 @ 16MHz | X | | |
|
||||
Atmega328 @ 12MHz | X | | |
|
||||
Atmega32u4 @ 16MHz | X | | |
|
||||
Atmega32u4 @ 8MHz | X | | |
|
||||
ESP8266 | X | | | change OLED_RESET to different pin if using default I2C pins D4/D5.
|
||||
Atmega2560 @ 16MHz | X | | |
|
||||
ATSAM3X8E | X | | |
|
||||
ATSAM21D | X | | |
|
||||
ATtiny85 @ 16MHz | | X | |
|
||||
ATtiny85 @ 8MHz | | X | |
|
||||
Intel Curie @ 32MHz | | | X |
|
||||
STM32F2 | | | X |
|
||||
|
||||
* ATmega328 @ 16MHz : Arduino UNO, Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini
|
||||
* ATmega328 @ 12MHz : Adafruit Pro Trinket 3V
|
||||
* ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0
|
||||
* ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro
|
||||
* ESP8266 : Adafruit Huzzah
|
||||
* ATmega2560 @ 16MHz : Arduino Mega
|
||||
* ATSAM3X8E : Arduino Due
|
||||
* ATSAM21D : Arduino Zero, M0 Pro
|
||||
* ATtiny85 @ 16MHz : Adafruit Trinket 5V
|
||||
* ATtiny85 @ 8MHz : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 3V
|
||||
|
||||
<!-- END COMPATIBILITY TABLE -->
|
|
@ -1,24 +0,0 @@
|
|||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
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.
|
||||
Scrolling code contributed by Michael Gregg
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
|
||||
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h
|
||||
|
||||
Place the Adafruit_SSD1306 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
||||
|
||||
You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from
|
||||
https://github.com/adafruit/Adafruit-GFX-Library
|
||||
and download/install that library as well
|
|
@ -1,375 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 size display using I2C to communicate
|
||||
3 pins are required to interface (2 I2C and one reset)
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 32)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// miniature bitmap display
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
delay(1);
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
delay(1);
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
delay(1);
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
|
@ -1,368 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 size display using SPI to communicate
|
||||
4 or 5 pins are required to interface
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
// If using software SPI (the default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 32)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC);
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// miniature bitmap display
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
|
@ -1,375 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x64 size display using I2C to communicate
|
||||
3 pins are required to interface (2 I2C and one reset)
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 64)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// miniature bitmap display
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
delay(1);
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
delay(1);
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
delay(1);
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
|
@ -1,368 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x64 size display using SPI to communicate
|
||||
4 or 5 pins are required to interface
|
||||
|
||||
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.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
// If using software SPI (the default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 64)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC);
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// miniature bitmap display
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
name=Adafruit SSD1306
|
||||
version=1.1.2
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
|
||||
paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
|
||||
category=Display
|
||||
url=https://github.com/adafruit/Adafruit_SSD1306
|
||||
architectures=*
|
|
@ -0,0 +1,4 @@
|
|||
# Our handy .gitignore for automation ease
|
||||
Doxyfile*
|
||||
doxygen_sqlite3.db
|
||||
html
|
|
@ -0,0 +1,29 @@
|
|||
language: c
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- ~/arduino_ide
|
||||
- ~/.arduino15/packages/
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
env:
|
||||
global:
|
||||
- ARDUINO_IDE_VERSION="1.8.5"
|
||||
- PRETTYNAME="Adafruit SSD1306"
|
||||
# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
|
||||
# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile
|
||||
|
||||
before_install:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
|
||||
|
||||
install:
|
||||
- arduino --install-library "Adafruit GFX Library"
|
||||
|
||||
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)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,179 @@
|
|||
/*!
|
||||
* @file Adafruit_SSD1306.h
|
||||
*
|
||||
* This is part of for Adafruit's SSD1306 library for monochrome
|
||||
* OLED displays: http://www.adafruit.com/category/63_98
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _Adafruit_SSD1306_H_
|
||||
#define _Adafruit_SSD1306_H_
|
||||
|
||||
// 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_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;
|
||||
#endif
|
||||
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
|
||||
#if defined(__AVR__)
|
||||
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)
|
||||
typedef volatile uint32_t PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#endif
|
||||
|
||||
#define BLACK 0 ///< Draw 'off' pixels
|
||||
#define WHITE 1 ///< Draw 'on' pixels
|
||||
#define 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_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
|
||||
|
||||
// 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
|
||||
#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
|
||||
#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
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief Class that stores state and functions for interacting with
|
||||
SSD1306 OLED displays.
|
||||
*/
|
||||
class Adafruit_SSD1306 : public Adafruit_GFX {
|
||||
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, 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);
|
||||
|
||||
// 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);
|
||||
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);
|
||||
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;
|
||||
#ifdef HAVE_PORTREG
|
||||
PortReg *mosiPort , *clkPort , *dcPort , *csPort;
|
||||
PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
|
||||
#endif
|
||||
#if defined(SPI_HAS_TRANSACTION)
|
||||
SPISettings spiSettings;
|
||||
#endif
|
||||
#if ARDUINO >= 157
|
||||
uint32_t wireClk; // Wire speed for SSD1306 transfers
|
||||
uint32_t restoreClk; // Wire speed following SSD1306 transfers
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _Adafruit_SSD1306_H_
|
|
@ -0,0 +1,54 @@
|
|||
# Adafruit_SSD1306 [![Build Status](https://travis-ci.org/adafruit/Adafruit_SSD1306.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_SSD1306)
|
||||
|
||||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use I2C or SPI to communicate, 2 to 5 pins are required to interface.
|
||||
|
||||
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. Scrolling code contributed by Michael Gregg. Dynamic buffer allocation based on work by Andrew Canaday.
|
||||
BSD license, check license.txt for more information. All text above must be included in any redistribution
|
||||
|
||||
Preferred installation method is to use the Arduino IDE Library Manager. To download the source from Github instead, click "Clone or download" above, then "Download ZIP." After uncompressing, rename the resulting folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h.
|
||||
|
||||
You will also have to install the **Adafruit GFX library** which provides graphics primitves such as lines, circles, text, etc. This also can be found in the Arduino Library Manager, or you can get the source from https://github.com/adafruit/Adafruit-GFX-Library
|
||||
|
||||
## Changes
|
||||
|
||||
Version 1.2 (November 2018) introduces some significant changes:
|
||||
|
||||
* Display dimensions are now specified in the constructor...you no longer need to edit the .h file for different screens (though old sketches can continue to work that way).
|
||||
* SPI transactions are used and SPI bitrate can be specified (both require Arduino 1.6 or later).
|
||||
* SPI and Wire (I2C) interfaces other than the defaults are supported.
|
||||
|
||||
<!-- START COMPATIBILITY TABLE -->
|
||||
|
||||
## Compatibility
|
||||
|
||||
MCU |Tested Works|Doesn't Work|Not Tested|Notes
|
||||
------------|:----------:|:----------:|:--------:|-----
|
||||
Atmega328 | X | | |
|
||||
Atmega32u4 | X | | |
|
||||
Atmega2560 | X | | |
|
||||
ESP8266 | X | | | Change OLED_RESET to different pin if using default I2C pins D4/D5.
|
||||
ESP32 | X | | |
|
||||
ATSAM3X8E | X | | |
|
||||
ATSAM21D | X | | |
|
||||
Intel Curie | X | | |
|
||||
WICED | X | | | No hardware SPI - bitbang only
|
||||
ATtiny85 | | X | |
|
||||
|
||||
* ATmega328 : Arduino UNO, Adafruit Pro Trinket, Adafruit Metro 328, Adafruit Metro Mini
|
||||
* ATmega32u4 : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0, Adafruit Flora, Bluefruit Micro
|
||||
* ATmega2560 : Arduino Mega
|
||||
* ESP8266 : Adafruit Huzzah
|
||||
* ATSAM3X8E : Arduino Due
|
||||
* ATSAM21D : Arduino Zero, M0 Pro, Adafruit Metro Express, Feather M0
|
||||
* ATtiny85 : Adafruit Gemma, Arduino Gemma, Adafruit Trinket
|
||||
|
||||
<!-- END COMPATIBILITY TABLE -->
|
|
@ -0,0 +1,79 @@
|
|||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);
|
||||
|
||||
// OLED FeatherWing buttons map to different pins depending on board:
|
||||
#if defined(ESP8266)
|
||||
#define BUTTON_A 0
|
||||
#define BUTTON_B 16
|
||||
#define BUTTON_C 2
|
||||
#elif defined(ESP32)
|
||||
#define BUTTON_A 15
|
||||
#define BUTTON_B 32
|
||||
#define BUTTON_C 14
|
||||
#elif defined(ARDUINO_STM32_FEATHER)
|
||||
#define BUTTON_A PA15
|
||||
#define BUTTON_B PC7
|
||||
#define BUTTON_C PC5
|
||||
#elif defined(TEENSYDUINO)
|
||||
#define BUTTON_A 4
|
||||
#define BUTTON_B 3
|
||||
#define BUTTON_C 8
|
||||
#elif defined(ARDUINO_FEATHER52832)
|
||||
#define BUTTON_A 31
|
||||
#define BUTTON_B 30
|
||||
#define BUTTON_C 27
|
||||
#else // 32u4, M0, M4, nrf52840 and 328p
|
||||
#define BUTTON_A 9
|
||||
#define BUTTON_B 6
|
||||
#define BUTTON_C 5
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
Serial.println("OLED FeatherWing test");
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
|
||||
|
||||
Serial.println("OLED begun");
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(1000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
|
||||
Serial.println("IO test");
|
||||
|
||||
pinMode(BUTTON_A, INPUT_PULLUP);
|
||||
pinMode(BUTTON_B, INPUT_PULLUP);
|
||||
pinMode(BUTTON_C, INPUT_PULLUP);
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.print("Connecting to SSID\n'adafruit':");
|
||||
display.print("connected!");
|
||||
display.println("IP: 10.0.1.23");
|
||||
display.println("Sending val #0");
|
||||
display.setCursor(0,0);
|
||||
display.display(); // actually display all of the above
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(!digitalRead(BUTTON_A)) display.print("A");
|
||||
if(!digitalRead(BUTTON_B)) display.print("B");
|
||||
if(!digitalRead(BUTTON_C)) display.print("C");
|
||||
delay(10);
|
||||
yield();
|
||||
display.display();
|
||||
}
|
|
@ -0,0 +1,410 @@
|
|||
/**************************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 pixel display using I2C to communicate
|
||||
3 pins are required to interface (two I2C and one reset).
|
||||
|
||||
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, check license.txt for more information
|
||||
All text above, and the splash screen below must be
|
||||
included in any redistribution.
|
||||
**************************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
|
||||
|
||||
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
|
||||
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10 // Number of snowflakes in the animation example
|
||||
|
||||
#define LOGO_HEIGHT 16
|
||||
#define LOGO_WIDTH 16
|
||||
static const unsigned char PROGMEM logo_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
delay(2000);
|
||||
// display.display() is NOT necessary after every single drawing command,
|
||||
// unless that's what you want...rather, you can batch up a bunch of
|
||||
// drawing operations and then update the screen all at once by calling
|
||||
// display.display(). These examples demonstrate both approaches...
|
||||
|
||||
testdrawline(); // Draw many lines
|
||||
|
||||
testdrawrect(); // Draw rectangles (outlines)
|
||||
|
||||
testfillrect(); // Draw rectangles (filled)
|
||||
|
||||
testdrawcircle(); // Draw circles (outlines)
|
||||
|
||||
testfillcircle(); // Draw circles (filled)
|
||||
|
||||
testdrawroundrect(); // Draw rounded rectangles (outlines)
|
||||
|
||||
testfillroundrect(); // Draw rounded rectangles (filled)
|
||||
|
||||
testdrawtriangle(); // Draw triangles (outlines)
|
||||
|
||||
testfilltriangle(); // Draw triangles (filled)
|
||||
|
||||
testdrawchar(); // Draw characters of the default font
|
||||
|
||||
testdrawstyles(); // Draw 'stylized' characters
|
||||
|
||||
testscrolltext(); // Draw scrolling text
|
||||
|
||||
testdrawbitmap(); // Draw a small bitmap image
|
||||
|
||||
// Invert and restore display, pausing in-between
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
int16_t i;
|
||||
|
||||
display.clearDisplay(); // Clear display buffer
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn line
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000); // Pause for 2 seconds
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// The INVERSE color is used so rectangles alternate white/black
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
|
||||
// The INVERSE color is used so circles alternate white/black
|
||||
display.fillCircle(display.width() / 2, display.height() / 2, i, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn circle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
// The INVERSE color is used so round-rects alternate white/black
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
|
||||
// The INVERSE color is used so triangles alternate white/black
|
||||
display.fillTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
|
||||
// Not all the characters will fit on the display. This is normal.
|
||||
// Library will draw what it can and the rest will be clipped.
|
||||
for(int16_t i=0; i<256; i++) {
|
||||
if(i == '\n') display.write(' ');
|
||||
else display.write(i);
|
||||
}
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawstyles(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello, world!"));
|
||||
|
||||
display.setTextColor(BLACK, WHITE); // Draw 'inverse' text
|
||||
display.println(3.141592);
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
delay(100);
|
||||
|
||||
// Scroll in various directions, pausing in-between:
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void testdrawbitmap(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawBitmap(
|
||||
(display.width() - LOGO_WIDTH ) / 2,
|
||||
(display.height() - LOGO_HEIGHT) / 2,
|
||||
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
display.display();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#define XPOS 0 // Indexes into the 'icons' array in function below
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
int8_t f, icons[NUMFLAKES][3];
|
||||
|
||||
// Initialize 'snowflake' positions
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
Serial.print(F("x: "));
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(F(" y: "));
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(F(" dy: "));
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
for(;;) { // Loop forever...
|
||||
display.clearDisplay(); // Clear the display buffer
|
||||
|
||||
// Draw each snowflake:
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
|
||||
display.display(); // Show the display buffer on the screen
|
||||
delay(200); // Pause for 1/10 second
|
||||
|
||||
// Then update coordinates of each flake...
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// If snowflake is off the bottom of the screen...
|
||||
if (icons[f][YPOS] >= display.height()) {
|
||||
// Reinitialize to a random position, just off the top
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,423 @@
|
|||
/**************************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 pixel display using SPI to communicate
|
||||
4 or 5 pins are required to interface.
|
||||
|
||||
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, check license.txt for more information
|
||||
All text above, and the splash screen below must be
|
||||
included in any redistribution.
|
||||
**************************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
|
||||
|
||||
// Declaration for SSD1306 display connected using software SPI (default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Comment out above, uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
&SPI, OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10 // Number of snowflakes in the animation example
|
||||
|
||||
#define LOGO_HEIGHT 16
|
||||
#define LOGO_WIDTH 16
|
||||
static const unsigned char PROGMEM logo_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
delay(2000);
|
||||
// display.display() is NOT necessary after every single drawing command,
|
||||
// unless that's what you want...rather, you can batch up a bunch of
|
||||
// drawing operations and then update the screen all at once by calling
|
||||
// display.display(). These examples demonstrate both approaches...
|
||||
|
||||
testdrawline(); // Draw many lines
|
||||
|
||||
testdrawrect(); // Draw rectangles (outlines)
|
||||
|
||||
testfillrect(); // Draw rectangles (filled)
|
||||
|
||||
testdrawcircle(); // Draw circles (outlines)
|
||||
|
||||
testfillcircle(); // Draw circles (filled)
|
||||
|
||||
testdrawroundrect(); // Draw rounded rectangles (outlines)
|
||||
|
||||
testfillroundrect(); // Draw rounded rectangles (filled)
|
||||
|
||||
testdrawtriangle(); // Draw triangles (outlines)
|
||||
|
||||
testfilltriangle(); // Draw triangles (filled)
|
||||
|
||||
testdrawchar(); // Draw characters of the default font
|
||||
|
||||
testdrawstyles(); // Draw 'stylized' characters
|
||||
|
||||
testscrolltext(); // Draw scrolling text
|
||||
|
||||
testdrawbitmap(); // Draw a small bitmap image
|
||||
|
||||
// Invert and restore display, pausing in-between
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
int16_t i;
|
||||
|
||||
display.clearDisplay(); // Clear display buffer
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn line
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000); // Pause for 2 seconds
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// The INVERSE color is used so rectangles alternate white/black
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
|
||||
// The INVERSE color is used so circles alternate white/black
|
||||
display.fillCircle(display.width() / 2, display.height() / 2, i, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn circle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
// The INVERSE color is used so round-rects alternate white/black
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
|
||||
// The INVERSE color is used so triangles alternate white/black
|
||||
display.fillTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
|
||||
// Not all the characters will fit on the display. This is normal.
|
||||
// Library will draw what it can and the rest will be clipped.
|
||||
for(int16_t i=0; i<256; i++) {
|
||||
if(i == '\n') display.write(' ');
|
||||
else display.write(i);
|
||||
}
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawstyles(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello, world!"));
|
||||
|
||||
display.setTextColor(BLACK, WHITE); // Draw 'inverse' text
|
||||
display.println(3.141592);
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
delay(100);
|
||||
|
||||
// Scroll in various directions, pausing in-between:
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void testdrawbitmap(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawBitmap(
|
||||
(display.width() - LOGO_WIDTH ) / 2,
|
||||
(display.height() - LOGO_HEIGHT) / 2,
|
||||
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
display.display();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#define XPOS 0 // Indexes into the 'icons' array in function below
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
int8_t f, icons[NUMFLAKES][3];
|
||||
|
||||
// Initialize 'snowflake' positions
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
Serial.print(F("x: "));
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(F(" y: "));
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(F(" dy: "));
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
for(;;) { // Loop forever...
|
||||
display.clearDisplay(); // Clear the display buffer
|
||||
|
||||
// Draw each snowflake:
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
|
||||
display.display(); // Show the display buffer on the screen
|
||||
delay(200); // Pause for 1/10 second
|
||||
|
||||
// Then update coordinates of each flake...
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// If snowflake is off the bottom of the screen...
|
||||
if (icons[f][YPOS] >= display.height()) {
|
||||
// Reinitialize to a random position, just off the top
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,410 @@
|
|||
/**************************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 pixel display using I2C to communicate
|
||||
3 pins are required to interface (two I2C and one reset).
|
||||
|
||||
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, check license.txt for more information
|
||||
All text above, and the splash screen below must be
|
||||
included in any redistribution.
|
||||
**************************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
|
||||
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
|
||||
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10 // Number of snowflakes in the animation example
|
||||
|
||||
#define LOGO_HEIGHT 16
|
||||
#define LOGO_WIDTH 16
|
||||
static const unsigned char PROGMEM logo_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) { // Address 0x3D for 128x64
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
delay(2000);
|
||||
// display.display() is NOT necessary after every single drawing command,
|
||||
// unless that's what you want...rather, you can batch up a bunch of
|
||||
// drawing operations and then update the screen all at once by calling
|
||||
// display.display(). These examples demonstrate both approaches...
|
||||
|
||||
testdrawline(); // Draw many lines
|
||||
|
||||
testdrawrect(); // Draw rectangles (outlines)
|
||||
|
||||
testfillrect(); // Draw rectangles (filled)
|
||||
|
||||
testdrawcircle(); // Draw circles (outlines)
|
||||
|
||||
testfillcircle(); // Draw circles (filled)
|
||||
|
||||
testdrawroundrect(); // Draw rounded rectangles (outlines)
|
||||
|
||||
testfillroundrect(); // Draw rounded rectangles (filled)
|
||||
|
||||
testdrawtriangle(); // Draw triangles (outlines)
|
||||
|
||||
testfilltriangle(); // Draw triangles (filled)
|
||||
|
||||
testdrawchar(); // Draw characters of the default font
|
||||
|
||||
testdrawstyles(); // Draw 'stylized' characters
|
||||
|
||||
testscrolltext(); // Draw scrolling text
|
||||
|
||||
testdrawbitmap(); // Draw a small bitmap image
|
||||
|
||||
// Invert and restore display, pausing in-between
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
int16_t i;
|
||||
|
||||
display.clearDisplay(); // Clear display buffer
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn line
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000); // Pause for 2 seconds
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// The INVERSE color is used so rectangles alternate white/black
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
|
||||
// The INVERSE color is used so circles alternate white/black
|
||||
display.fillCircle(display.width() / 2, display.height() / 2, i, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn circle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
// The INVERSE color is used so round-rects alternate white/black
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
|
||||
// The INVERSE color is used so triangles alternate white/black
|
||||
display.fillTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
|
||||
// Not all the characters will fit on the display. This is normal.
|
||||
// Library will draw what it can and the rest will be clipped.
|
||||
for(int16_t i=0; i<256; i++) {
|
||||
if(i == '\n') display.write(' ');
|
||||
else display.write(i);
|
||||
}
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawstyles(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello, world!"));
|
||||
|
||||
display.setTextColor(BLACK, WHITE); // Draw 'inverse' text
|
||||
display.println(3.141592);
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
delay(100);
|
||||
|
||||
// Scroll in various directions, pausing in-between:
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void testdrawbitmap(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawBitmap(
|
||||
(display.width() - LOGO_WIDTH ) / 2,
|
||||
(display.height() - LOGO_HEIGHT) / 2,
|
||||
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
display.display();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#define XPOS 0 // Indexes into the 'icons' array in function below
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
int8_t f, icons[NUMFLAKES][3];
|
||||
|
||||
// Initialize 'snowflake' positions
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
Serial.print(F("x: "));
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(F(" y: "));
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(F(" dy: "));
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
for(;;) { // Loop forever...
|
||||
display.clearDisplay(); // Clear the display buffer
|
||||
|
||||
// Draw each snowflake:
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
|
||||
display.display(); // Show the display buffer on the screen
|
||||
delay(200); // Pause for 1/10 second
|
||||
|
||||
// Then update coordinates of each flake...
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// If snowflake is off the bottom of the screen...
|
||||
if (icons[f][YPOS] >= display.height()) {
|
||||
// Reinitialize to a random position, just off the top
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,424 @@
|
|||
/**************************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x64 pixel display using SPI to communicate
|
||||
4 or 5 pins are required to interface.
|
||||
|
||||
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, check license.txt for more information
|
||||
All text above, and the splash screen below must be
|
||||
included in any redistribution.
|
||||
**************************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
|
||||
// Declaration for SSD1306 display connected using software SPI (default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Comment out above, uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
&SPI, OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10 // Number of snowflakes in the animation example
|
||||
|
||||
#define LOGO_HEIGHT 16
|
||||
#define LOGO_WIDTH 16
|
||||
static const unsigned char PROGMEM logo_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
// Draw a single pixel in white
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
|
||||
// Show the display buffer on the screen. You MUST call display() after
|
||||
// drawing commands to make them visible on screen!
|
||||
display.display();
|
||||
delay(2000);
|
||||
// display.display() is NOT necessary after every single drawing command,
|
||||
// unless that's what you want...rather, you can batch up a bunch of
|
||||
// drawing operations and then update the screen all at once by calling
|
||||
// display.display(). These examples demonstrate both approaches...
|
||||
|
||||
testdrawline(); // Draw many lines
|
||||
|
||||
testdrawrect(); // Draw rectangles (outlines)
|
||||
|
||||
testfillrect(); // Draw rectangles (filled)
|
||||
|
||||
testdrawcircle(); // Draw circles (outlines)
|
||||
|
||||
testfillcircle(); // Draw circles (filled)
|
||||
|
||||
testdrawroundrect(); // Draw rounded rectangles (outlines)
|
||||
|
||||
testfillroundrect(); // Draw rounded rectangles (filled)
|
||||
|
||||
testdrawtriangle(); // Draw triangles (outlines)
|
||||
|
||||
testfilltriangle(); // Draw triangles (filled)
|
||||
|
||||
testdrawchar(); // Draw characters of the default font
|
||||
|
||||
testdrawstyles(); // Draw 'stylized' characters
|
||||
|
||||
testscrolltext(); // Draw scrolling text
|
||||
|
||||
testdrawbitmap(); // Draw a small bitmap image
|
||||
|
||||
// Invert and restore display, pausing in-between
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
int16_t i;
|
||||
|
||||
display.clearDisplay(); // Clear display buffer
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn line
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
|
||||
for(i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000); // Pause for 2 seconds
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// The INVERSE color is used so rectangles alternate white/black
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn rectangle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillcircle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
|
||||
// The INVERSE color is used so circles alternate white/black
|
||||
display.fillCircle(display.width() / 2, display.height() / 2, i, INVERSE);
|
||||
display.display(); // Update screen with each newly-drawn circle
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
// The INVERSE color is used so round-rects alternate white/black
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
|
||||
display.height()/4, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
|
||||
// The INVERSE color is used so triangles alternate white/black
|
||||
display.fillTriangle(
|
||||
display.width()/2 , display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
|
||||
// Not all the characters will fit on the display. This is normal.
|
||||
// Library will draw what it can and the rest will be clipped.
|
||||
for(int16_t i=0; i<256; i++) {
|
||||
if(i == '\n') display.write(' ');
|
||||
else display.write(i);
|
||||
}
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawstyles(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello, world!"));
|
||||
|
||||
display.setTextColor(BLACK, WHITE); // Draw 'inverse' text
|
||||
display.println(3.141592);
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
|
||||
|
||||
display.display();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10, 0);
|
||||
display.println(F("scroll"));
|
||||
display.display(); // Show initial text
|
||||
delay(100);
|
||||
|
||||
// Scroll in various directions, pausing in-between:
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void testdrawbitmap(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.drawBitmap(
|
||||
(display.width() - LOGO_WIDTH ) / 2,
|
||||
(display.height() - LOGO_HEIGHT) / 2,
|
||||
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
display.display();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
#define XPOS 0 // Indexes into the 'icons' array in function below
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
int8_t f, icons[NUMFLAKES][3];
|
||||
|
||||
// Initialize 'snowflake' positions
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
Serial.print(F("x: "));
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(F(" y: "));
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(F(" dy: "));
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
for(;;) { // Loop forever...
|
||||
display.clearDisplay(); // Clear the display buffer
|
||||
|
||||
// Draw each snowflake:
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
|
||||
}
|
||||
|
||||
display.display(); // Show the display buffer on the screen
|
||||
delay(200); // Pause for 1/10 second
|
||||
|
||||
// Then update coordinates of each flake...
|
||||
for(f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// If snowflake is off the bottom of the screen...
|
||||
if (icons[f][YPOS] >= display.height()) {
|
||||
// Reinitialize to a random position, just off the top
|
||||
icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
|
||||
icons[f][YPOS] = -LOGO_HEIGHT;
|
||||
icons[f][DELTAY] = random(1, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
name=Adafruit SSD1306
|
||||
version=1.3.0
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays
|
||||
paragraph=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays
|
||||
category=Display
|
||||
url=https://github.com/adafruit/Adafruit_SSD1306
|
||||
architectures=*
|
|
@ -0,0 +1,108 @@
|
|||
#define splash1_width 82
|
||||
#define splash1_height 64
|
||||
|
||||
const uint8_t PROGMEM splash1_data[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
|
||||
0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x7F, 0xF0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3F, 0xFF, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1F, 0xFF, 0xFB, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x0F, 0xFF, 0xF9, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0F, 0xFF, 0xF9, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
|
||||
0xFF, 0xF1, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC,
|
||||
0x73, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x3F,
|
||||
0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1E, 0x0F,
|
||||
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x1F, 0xFC,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xF8, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xDF, 0xFF, 0xE0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x19, 0xFF, 0xC0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3F, 0x3C, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7E, 0x7C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x7F, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
||||
0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xEF,
|
||||
0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xCF, 0xFE,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x07, 0xFE, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x07, 0xFE, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x03, 0xFE, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
|
||||
0x80, 0x00, 0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80,
|
||||
0x01, 0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01,
|
||||
0xFC, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xE0,
|
||||
0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xE0, 0x00,
|
||||
0x00, 0x00, 0x1E, 0x00, 0x7F, 0xE3, 0xF7, 0x9F, 0xF9, 0xFD, 0xE7, 0x78,
|
||||
0x7B, 0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xFD, 0xFF, 0x78, 0x7B,
|
||||
0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xFD, 0xFF, 0x78, 0x7B, 0xDF,
|
||||
0xC0, 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1, 0xFF, 0x78, 0x7B, 0xDE, 0x00,
|
||||
0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1, 0xF0, 0x78, 0x7B, 0xDE, 0x00, 0x00,
|
||||
0xF7, 0x87, 0x80, 0x3D, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0x7F, 0xF7,
|
||||
0x87, 0x9F, 0xFD, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xFF, 0xF7, 0x87,
|
||||
0xBF, 0xFD, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC,
|
||||
0x3D, 0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC, 0x3D,
|
||||
0xE1, 0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xF0, 0xF7, 0x87, 0xBC, 0x3D, 0xE1,
|
||||
0xE0, 0x78, 0x7B, 0xDE, 0x00, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xE1, 0xE0,
|
||||
0x7F, 0xFB, 0xDF, 0xC0, 0xFF, 0xF7, 0xFF, 0xBF, 0xFD, 0xE1, 0xE0, 0x7F,
|
||||
0xFB, 0xDF, 0xC0, 0x7C, 0xF3, 0xF3, 0x9F, 0x3D, 0xE1, 0xE0, 0x3E, 0x7B,
|
||||
0xCF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x68, 0xDB, 0x11, 0x1A, 0x31, 0xC0, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFD, 0x2B, 0x5A, 0xFB, 0x6A, 0xEF, 0xC0, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFD, 0x4B, 0x5B, 0x3B, 0x1A, 0x33, 0xC0, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFD, 0x6B, 0x5B, 0xDB, 0x6A, 0xFD, 0xC0 };
|
||||
|
||||
#define splash2_width 115
|
||||
#define splash2_height 32
|
||||
|
||||
const uint8_t PROGMEM splash2_data[] = {
|
||||
0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF8,
|
||||
0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x7E, 0x00, 0x00, 0x01, 0xE0, 0x00,
|
||||
0x7F, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xFE, 0x00, 0x00,
|
||||
0x01, 0xE0, 0x00, 0xFF, 0xEF, 0xF8, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00,
|
||||
0xFE, 0x00, 0x00, 0x01, 0xE0, 0x00, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00,
|
||||
0x03, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x7F, 0xFE, 0x7F,
|
||||
0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x0F, 0x00,
|
||||
0x3F, 0xFE, 0x7F, 0xF8, 0x3F, 0xF1, 0xFB, 0xCF, 0xFC, 0xFE, 0xF3, 0xBC,
|
||||
0x3D, 0xEF, 0xE0, 0x1F, 0xFE, 0x7F, 0xFF, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE,
|
||||
0xFE, 0xFF, 0xBC, 0x3D, 0xEF, 0xE0, 0x1F, 0xC6, 0xFF, 0xFF, 0x7F, 0xFB,
|
||||
0xFF, 0xDF, 0xFE, 0xFE, 0xFF, 0xBC, 0x3D, 0xEF, 0xE0, 0x0F, 0xE3, 0xC7,
|
||||
0xFE, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xFF, 0xBC, 0x3D, 0xEF, 0x00,
|
||||
0x07, 0xFF, 0x87, 0xFC, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xF8, 0x3C,
|
||||
0x3D, 0xEF, 0x00, 0x01, 0xFF, 0xFF, 0xF0, 0x00, 0x7B, 0xC3, 0xC0, 0x1E,
|
||||
0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x01, 0xF3, 0x7F, 0xE0, 0x3F, 0xFB,
|
||||
0xC3, 0xCF, 0xFE, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x03, 0xE3, 0x3F,
|
||||
0x80, 0x7F, 0xFB, 0xC3, 0xDF, 0xFE, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00,
|
||||
0x07, 0xE7, 0x3C, 0x00, 0x78, 0x7B, 0xC3, 0xDE, 0x1E, 0xF0, 0xF0, 0x3C,
|
||||
0x3D, 0xEF, 0x00, 0x07, 0xFF, 0xBE, 0x00, 0x78, 0x7B, 0xC3, 0xDE, 0x1E,
|
||||
0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x07, 0xFF, 0xFE, 0x00, 0x78, 0x7B,
|
||||
0xC3, 0xDE, 0x1E, 0xF0, 0xF0, 0x3C, 0x3D, 0xEF, 0x00, 0x0F, 0xFF, 0xFE,
|
||||
0x00, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE, 0xF0, 0xF0, 0x3F, 0xFD, 0xEF, 0xE0,
|
||||
0x0F, 0xFF, 0xFF, 0x00, 0x7F, 0xFB, 0xFF, 0xDF, 0xFE, 0xF0, 0xF0, 0x3F,
|
||||
0xFD, 0xEF, 0xE0, 0x0F, 0xF9, 0xFF, 0x00, 0x3E, 0x79, 0xF9, 0xCF, 0x9E,
|
||||
0xF0, 0xF0, 0x1F, 0x3D, 0xE7, 0xE0, 0x1F, 0xF1, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0xFF,
|
||||
0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
|
||||
0x1C, 0x00, 0x7F, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0xB4, 0x6D, 0x88,
|
||||
0x8D, 0x18, 0xE0, 0x00, 0x00, 0x1F, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE,
|
||||
0x95, 0xAD, 0x7D, 0xB5, 0x77, 0xE0, 0x00, 0x00, 0x0F, 0x00, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0xFE, 0xA5, 0xAD, 0x9D, 0x8D, 0x19, 0xE0, 0x00, 0x00, 0x06,
|
||||
0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0xB5, 0xAD, 0xED, 0xB5, 0x7E, 0xE0 };
|
Loading…
Reference in New Issue