Skip to content

Commit 3498f65

Browse files
authored
Add files via upload
1 parent 9593bd9 commit 3498f65

File tree

89 files changed

+32047
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+32047
-0
lines changed

libraries/Adafruit_GFX_Library/Adafruit_GFX.cpp

Lines changed: 2672 additions & 0 deletions
Large diffs are not rendered by default.

libraries/Adafruit_GFX_Library/Adafruit_GFX.h

Lines changed: 393 additions & 0 deletions
Large diffs are not rendered by default.

libraries/Adafruit_GFX_Library/Adafruit_GrayOLED.cpp

Lines changed: 421 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*!
2+
* @file Adafruit_GrayOLED.h
3+
*
4+
* This is part of for Adafruit's GFX library, supplying generic support
5+
* for grayscale OLED displays: http://www.adafruit.com/category/63_98
6+
*
7+
* These displays use I2C or SPI to communicate. I2C requires 2 pins
8+
* (SCL+SDA) and optionally a RESET pin. SPI requires 4 pins (MOSI, SCK,
9+
* select, data/command) and optionally a reset pin. Hardware SPI or
10+
* 'bitbang' software SPI are both supported.
11+
*
12+
* Adafruit invests time and resources providing this open source code,
13+
* please support Adafruit and open-source hardware by purchasing
14+
* products from Adafruit!
15+
*
16+
* Written by Limor Fried/Ladyada for Adafruit Industries, with
17+
* contributions from the open source community.
18+
*
19+
* BSD license, all text above, and the splash screen header file,
20+
* must be included in any redistribution.
21+
*
22+
*/
23+
24+
#ifndef _Adafruit_GRAYOLED_H_
25+
#define _Adafruit_GRAYOLED_H_
26+
27+
#if !defined(__AVR_ATtiny85__) // Not for ATtiny, at all
28+
29+
#include <Adafruit_GFX.h>
30+
#include <Adafruit_I2CDevice.h>
31+
#include <Adafruit_SPIDevice.h>
32+
#include <SPI.h>
33+
#include <Wire.h>
34+
35+
#define GRAYOLED_SETCONTRAST 0x81 ///< Generic contrast for almost all OLEDs
36+
#define GRAYOLED_NORMALDISPLAY 0xA6 ///< Generic non-invert for almost all OLEDs
37+
#define GRAYOLED_INVERTDISPLAY 0xA7 ///< Generic invert for almost all OLEDs
38+
39+
#define MONOOLED_BLACK 0 ///< Default black 'color' for monochrome OLEDS
40+
#define MONOOLED_WHITE 1 ///< Default white 'color' for monochrome OLEDS
41+
#define MONOOLED_INVERSE 2 ///< Default inversion command for monochrome OLEDS
42+
43+
/*!
44+
@brief Class that stores state and functions for interacting with
45+
generic grayscale OLED displays.
46+
*/
47+
class Adafruit_GrayOLED : public Adafruit_GFX {
48+
public:
49+
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, TwoWire *twi = &Wire,
50+
int8_t rst_pin = -1, uint32_t preclk = 400000,
51+
uint32_t postclk = 100000);
52+
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, int8_t mosi_pin,
53+
int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin,
54+
int8_t cs_pin);
55+
Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, SPIClass *spi,
56+
int8_t dc_pin, int8_t rst_pin, int8_t cs_pin,
57+
uint32_t bitrate = 8000000UL);
58+
59+
~Adafruit_GrayOLED(void);
60+
61+
/**
62+
@brief The function that sub-classes define that writes out the buffer to
63+
the display over I2C or SPI
64+
**/
65+
virtual void display(void) = 0;
66+
void clearDisplay(void);
67+
void invertDisplay(bool i);
68+
void setContrast(uint8_t contrastlevel);
69+
void drawPixel(int16_t x, int16_t y, uint16_t color);
70+
bool getPixel(int16_t x, int16_t y);
71+
uint8_t *getBuffer(void);
72+
73+
void oled_command(uint8_t c);
74+
bool oled_commandList(const uint8_t *c, uint8_t n);
75+
76+
protected:
77+
bool _init(uint8_t i2caddr = 0x3C, bool reset = true);
78+
79+
Adafruit_SPIDevice *spi_dev = NULL; ///< The SPI interface BusIO device
80+
Adafruit_I2CDevice *i2c_dev = NULL; ///< The I2C interface BusIO device
81+
int32_t i2c_preclk = 400000, ///< Configurable 'high speed' I2C rate
82+
i2c_postclk = 100000; ///< Configurable 'low speed' I2C rate
83+
uint8_t *buffer = NULL; ///< Internal 1:1 framebuffer of display mem
84+
85+
int16_t window_x1, ///< Dirty tracking window minimum x
86+
window_y1, ///< Dirty tracking window minimum y
87+
window_x2, ///< Dirty tracking window maximum x
88+
window_y2; ///< Dirty tracking window maximum y
89+
90+
int dcPin, ///< The Arduino pin connected to D/C (for SPI)
91+
csPin, ///< The Arduino pin connected to CS (for SPI)
92+
rstPin; ///< The Arduino pin connected to reset (-1 if unused)
93+
94+
uint8_t _bpp = 1; ///< Bits per pixel color for this display
95+
private:
96+
TwoWire *_theWire = NULL; ///< The underlying hardware I2C
97+
};
98+
99+
#endif // end __AVR_ATtiny85__
100+
#endif // _Adafruit_GrayOLED_H_

0 commit comments

Comments
 (0)