mirror of
https://github.com/adafruit/Adafruit_SSD1306.git
synced 2026-07-28 12:25:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d94f699451 | ||
|
|
2238fef2cd | ||
|
|
bb999826b7 | ||
|
|
4d19dfb747 | ||
|
|
74cc197f48 | ||
|
|
cf89132f67 | ||
|
|
75f9703a79 | ||
|
|
03c96dba96 | ||
|
|
d64ad231f4 | ||
|
|
f3fafb60a1 | ||
|
|
fe638646c3 | ||
|
|
c488611188 | ||
|
|
6b283a1839 | ||
|
|
1efe7b8c22 | ||
|
|
dba989ad63 | ||
|
|
83ed59e8d3 | ||
|
|
7a21306b53 | ||
|
|
f34211c3d2 | ||
|
|
f25af300ab | ||
|
|
97afc0362b | ||
|
|
18c7f13ddd | ||
|
|
78d6a130b2 | ||
|
|
ea12e7df70 | ||
|
|
00fa0bdbca | ||
|
|
c95c1c47d6 | ||
|
|
16ee8a2c29 | ||
|
|
95fef51c89 | ||
|
|
14a4563e10 | ||
|
|
2196a97447 | ||
|
|
4ca34506f1 | ||
|
|
8a95baeced | ||
|
|
5fa3388757 | ||
|
|
1d52453e3b | ||
|
|
7a4d33ef04 | ||
|
|
d8acdafbdf | ||
|
|
36b0655f5c | ||
|
|
6ec47b6f1c | ||
|
|
88711efc3e | ||
|
|
1dcc8b5efa | ||
|
|
2f6eb1c8fa | ||
|
|
c9eb7d3b12 | ||
|
|
33327d02a4 | ||
|
|
46512179c6 | ||
|
|
ca3a261c95 | ||
|
|
19b6a36f3b |
@@ -7,11 +7,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
+39
-13
@@ -36,9 +36,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#if defined(__AVR__) || defined(ARDUINO_ARCH_RTTHREAD)
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
||||
#elif defined(ARDUINO_ARDUINO_NANO33BLE) || \
|
||||
defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_ARCH_RP2040)
|
||||
#include <api/deprecated-avr-comp/avr/pgmspace.h>
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#include <pgmspace.h>
|
||||
#else
|
||||
#define pgm_read_byte(addr) \
|
||||
@@ -46,7 +49,8 @@
|
||||
#endif
|
||||
|
||||
#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && \
|
||||
!defined(ESP32) && !defined(__arc__)
|
||||
!defined(ESP32) && !defined(__arc__) && !defined(__RL78__) && \
|
||||
!defined(CH32V20x) && !defined(PICO_RISCV)
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
|
||||
@@ -220,7 +224,7 @@ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin,
|
||||
Display width in pixels
|
||||
@param h
|
||||
Display height in pixels
|
||||
@param spi
|
||||
@param spi_ptr
|
||||
Pointer to an existing SPIClass instance (e.g. &SPI, the
|
||||
microcontroller's primary SPI bus).
|
||||
@param dc_pin
|
||||
@@ -240,11 +244,12 @@ Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin,
|
||||
@note Call the object's begin() function before use -- buffer
|
||||
allocation is performed there!
|
||||
*/
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi,
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi_ptr,
|
||||
int8_t dc_pin, int8_t rst_pin, int8_t cs_pin,
|
||||
uint32_t bitrate)
|
||||
: Adafruit_GFX(w, h), spi(spi ? spi : &SPI), wire(NULL), buffer(NULL),
|
||||
mosiPin(-1), clkPin(-1), dcPin(dc_pin), csPin(cs_pin), rstPin(rst_pin) {
|
||||
: Adafruit_GFX(w, h), spi(spi_ptr ? spi_ptr : &SPI), wire(NULL),
|
||||
buffer(NULL), mosiPin(-1), clkPin(-1), dcPin(dc_pin), csPin(cs_pin),
|
||||
rstPin(rst_pin) {
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
spiSettings = SPISettings(bitrate, MSBFIRST, SPI_MODE0);
|
||||
#endif
|
||||
@@ -517,8 +522,19 @@ bool Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, bool reset,
|
||||
// function if it has unusual circumstances (e.g. TWI variants that
|
||||
// can accept different SDA/SCL pins, or if two SSD1306 instances
|
||||
// with different addresses -- only a single begin() is needed).
|
||||
if (periphBegin)
|
||||
if (periphBegin) {
|
||||
wire->begin();
|
||||
#ifdef WIRE_HAS_TIMEOUT
|
||||
// Avoid indefinite hangs in the Wire library when the I2C bus stops
|
||||
// responding (e.g. SDA/SCL noise or the display disconnects). The
|
||||
// setWireTimeout() API is exposed by Arduino cores that define
|
||||
// WIRE_HAS_TIMEOUT (Arduino AVR core >= 1.8.6, see ArduinoCore-avr#42).
|
||||
// We only set the timeout when we owned the begin() call -- if the
|
||||
// caller managed Wire themselves, leave their configuration untouched.
|
||||
// See Adafruit_SSD1306 issue #288.
|
||||
wire->setWireTimeout(25000 /* us */, true /* reset on timeout */);
|
||||
#endif
|
||||
}
|
||||
} else { // Using one of the SPI modes, either soft or hardware
|
||||
pinMode(dcPin, OUTPUT); // Set data/command pin as output
|
||||
pinMode(csPin, OUTPUT); // Same for chip select
|
||||
@@ -594,6 +610,9 @@ bool Adafruit_SSD1306::begin(uint8_t vcs, uint8_t addr, bool reset,
|
||||
} else if ((WIDTH == 96) && (HEIGHT == 16)) {
|
||||
comPins = 0x2; // ada x12
|
||||
contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xAF;
|
||||
} else if ((WIDTH == 64) && (HEIGHT == 32)) {
|
||||
comPins = 0x12; // ada x12
|
||||
contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xCF;
|
||||
} else {
|
||||
// Other screen varieties -- TBD
|
||||
}
|
||||
@@ -936,7 +955,7 @@ void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y,
|
||||
}
|
||||
}
|
||||
} // endif positive height
|
||||
} // endif x in bounds
|
||||
} // endif x in bounds
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -992,11 +1011,18 @@ void Adafruit_SSD1306::display(void) {
|
||||
TRANSACTION_START
|
||||
static const uint8_t PROGMEM dlist1[] = {
|
||||
SSD1306_PAGEADDR,
|
||||
0, // Page start address
|
||||
0xFF, // Page end (not really, but works here)
|
||||
SSD1306_COLUMNADDR, 0}; // Column start address
|
||||
0, // Page start address
|
||||
0xFF, // Page end (not really, but works here)
|
||||
SSD1306_COLUMNADDR}; // Column start address
|
||||
ssd1306_commandList(dlist1, sizeof(dlist1));
|
||||
ssd1306_command1(WIDTH - 1); // Column end address
|
||||
|
||||
if (WIDTH == 64) {
|
||||
ssd1306_command1(0x20); // Column start
|
||||
ssd1306_command1(0x20 + WIDTH - 1); // Column end address
|
||||
} else {
|
||||
ssd1306_command1(0); // Column start
|
||||
ssd1306_command1((WIDTH - 1)); // Column end address
|
||||
}
|
||||
|
||||
#if defined(ESP8266)
|
||||
// ESP8266 needs a periodic yield() call to avoid watchdog reset.
|
||||
|
||||
+5
-3
@@ -25,15 +25,15 @@
|
||||
#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_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
|
||||
// #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).
|
||||
|
||||
// Uncomment to disable Adafruit splash logo
|
||||
//#define SSD1306_NO_SPLASH
|
||||
// #define SSD1306_NO_SPLASH
|
||||
|
||||
#if defined(ARDUINO_STM32_FEATHER)
|
||||
typedef class HardwareSPI SPIClass;
|
||||
@@ -51,6 +51,8 @@ typedef uint8_t PortMask;
|
||||
typedef volatile RwReg PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#elif defined(ARDUINO_ARCH_RTTHREAD)
|
||||
#undef HAVE_PORTREG
|
||||
#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \
|
||||
!defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_RP2040)
|
||||
typedef volatile uint32_t PortReg;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Adafruit Bus IO Library
|
||||
# https://github.com/adafruit/Adafruit_BusIO
|
||||
# MIT License
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
idf_component_register(SRCS "Adafruit_SSD1306.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES arduino Adafruit-GFX-Library)
|
||||
|
||||
project(Adafruit_SSD1306)
|
||||
@@ -51,6 +51,10 @@ Intel Curie | X | | |
|
||||
WICED | X | | | No hardware SPI - bitbang only
|
||||
ATtiny85 | | X | |
|
||||
Particle | X | | |
|
||||
RTduino | X | | |
|
||||
CH32 RISC-V | X | | |
|
||||
RP2040 | X | | |
|
||||
RP2350 | X | | | ARM or RISC-V architecture
|
||||
|
||||
* 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
|
||||
@@ -60,5 +64,8 @@ Particle | X | | |
|
||||
* ATSAMD21 : Arduino Zero, M0 Pro, Adafruit Metro Express, Feather M0
|
||||
* ATtiny85 : Adafruit Gemma, Arduino Gemma, Adafruit Trinket
|
||||
* Particle: Particle Argon
|
||||
* RTduino : [RTduino](https://github.com/RTduino/RTduino) is the Arduino ecosystem compatibility layer for [RT-Thread RTOS](https://github.com/RT-Thread/rt-thread) BSPs
|
||||
* CH32 RISC-V: CH32V203
|
||||
* RP2040, RP2350: Tested on Raspberry Pi Pico W/2W with [Arduino-Pico](https://github.com/earlephilhower/arduino-pico) core.
|
||||
|
||||
<!-- END COMPATIBILITY TABLE -->
|
||||
@@ -0,0 +1 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS = .
|
||||
@@ -10,6 +10,11 @@
|
||||
#define BUTTON_B 16
|
||||
#define BUTTON_C 2
|
||||
#define WIRE Wire
|
||||
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32C6)
|
||||
#define BUTTON_A 7
|
||||
#define BUTTON_B 6
|
||||
#define BUTTON_C 5
|
||||
#define WIRE Wire
|
||||
#elif defined(ESP32)
|
||||
#define BUTTON_A 15
|
||||
#define BUTTON_B 32
|
||||
@@ -34,7 +39,7 @@
|
||||
#define BUTTON_A 9
|
||||
#define BUTTON_B 8
|
||||
#define BUTTON_C 7
|
||||
#define WIRE Wire1
|
||||
#define WIRE Wire
|
||||
#else // 32u4, M0, M4, nrf52840 and 328p
|
||||
#define BUTTON_A 9
|
||||
#define BUTTON_B 6
|
||||
|
||||
@@ -60,6 +60,9 @@ static const unsigned char PROGMEM logo_bmp[] =
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// Wait for display
|
||||
delay(500);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
|
||||
@@ -60,6 +60,9 @@ static const unsigned char PROGMEM logo_bmp[] =
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// Wait for display
|
||||
delay(500);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
|
||||
@@ -0,0 +1,418 @@
|
||||
/**************************************************************************
|
||||
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 64 // 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)
|
||||
// The pins for I2C are defined by the Wire-library.
|
||||
// On an arduino UNO: A4(SDA), A5(SCL)
|
||||
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
|
||||
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
||||
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[] =
|
||||
{ 0b00000000, 0b11000000,
|
||||
0b00000001, 0b11000000,
|
||||
0b00000001, 0b11000000,
|
||||
0b00000011, 0b11100000,
|
||||
0b11110011, 0b11100000,
|
||||
0b11111110, 0b11111000,
|
||||
0b01111110, 0b11111111,
|
||||
0b00110011, 0b10011111,
|
||||
0b00011111, 0b11111100,
|
||||
0b00001101, 0b01110000,
|
||||
0b00011011, 0b10100000,
|
||||
0b00111111, 0b11100000,
|
||||
0b00111111, 0b11110000,
|
||||
0b01111100, 0b11110000,
|
||||
0b01110000, 0b01110000,
|
||||
0b00000000, 0b00110000 };
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// Wait for display
|
||||
delay(500);
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, SSD1306_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, SSD1306_WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, SSD1306_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, SSD1306_WHITE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
for(i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_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, SSD1306_INVERSE);
|
||||
display.display();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(SSD1306_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(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0,0); // Start at top-left corner
|
||||
display.println(F("Hello, world!"));
|
||||
|
||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
|
||||
display.println(3.141592);
|
||||
|
||||
display.setTextSize(2); // Draw 2X-scale text
|
||||
display.setTextColor(SSD1306_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(SSD1306_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, SSD1306_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=Adafruit SSD1306
|
||||
version=2.5.4
|
||||
version=2.5.17
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays
|
||||
|
||||
Reference in New Issue
Block a user