Compare commits

...
45 Commits
Author SHA1 Message Date
Tyeth GundryandGitHub d94f699451 Bump version to 2.5.17
Update version to 2.5.17
2026-05-29 13:29:22 +01:00
Adabot 2238fef2cd Bump version to 2.5.17 2026-05-29 13:07:28 +01:00
Limor "Ladyada" FriedandGitHub bb999826b7 Merge pull request #303 from adityachilka1/fix/wire-timeout
Add Wire.setWireTimeout to avoid I2C bus hangs (closes #288)
2026-05-22 10:49:20 -04:00
aditya 4d19dfb747 Add Wire.setWireTimeout to avoid I2C bus hangs (closes #288)
If the I2C bus stops responding mid-transaction (noise, the display
becomes disconnected, etc.), the underlying Wire library spins in
an indefinite loop and the host MCU effectively hangs. The Arduino
AVR core fixed this in ArduinoCore-avr@deea929 by exposing
setWireTimeout(); cores that implement it define WIRE_HAS_TIMEOUT
so callers can detect the feature at compile time.

Use that detection: when periphBegin owns the wire->begin() call,
follow it with a 25 ms timeout + reset on timeout. We only touch
Wire's configuration when we performed the begin() ourselves; if
the caller managed Wire externally, leave their configuration
untouched.

No behavioural change on cores without WIRE_HAS_TIMEOUT (the entire
block is compiled out).
2026-05-22 17:34:40 +05:30
Tyeth GundryandGitHub 74cc197f48 Bump version to 2.5.16 2025-12-05 14:38:14 +00:00
Tyeth GundryandGitHub cf89132f67 Merge pull request #299 from mikeysklar/wait-for-display
wait for display
2025-12-05 14:37:54 +00:00
Mikey Sklar 75f9703a79 wait for display
500ms delay on startup for i2c displays. The Feather ESP32-C6 required this and I suspect a few other boards.
2025-11-18 15:00:48 -08:00
Tyeth GundryandGitHub 03c96dba96 Merge pull request #291 from JChristensen/dev
Compatibility with RP2350 when using RISC-V cores.
2025-06-24 17:34:02 +01:00
Tyeth GundryandGitHub d64ad231f4 Merge pull request #292 from tyeth/add-64x32-support-2025
Add 64x32 support 2025
2025-06-24 17:22:27 +01:00
Tyeth GundryandGitHub f3fafb60a1 Merge branch 'master' into add-64x32-support-2025 2025-06-24 17:22:08 +01:00
Tyeth Gundry fe638646c3 Bump library.properties to version 2.5.15 2025-06-24 16:09:27 +00:00
Tyeth Gundry c488611188 formatting 2025-06-24 15:59:13 +00:00
Tyeth Gundry 6b283a1839 drop unnecessary comment 2025-06-24 15:58:33 +00:00
JChristensen 1efe7b8c22 Compatibility with RP2350 when using RISC-V cores. 2025-06-19 16:49:49 -04:00
Tyeth GundryandGitHub dba989ad63 Update library.properties - bump version to 2.5.14 2025-05-09 12:27:04 +01:00
Limor "Ladyada" FriedandGitHub 83ed59e8d3 Merge pull request #289 from NickIOT72/master
Add compatibilty with CH32V203 devices
2025-05-03 10:52:34 -04:00
NickIOT72 7a21306b53 verified clang format on header file 2025-05-02 19:08:05 -04:00
NickIOT72 f34211c3d2 verified clang format 2025-05-02 18:13:31 -04:00
NickIOT72 f25af300ab Adafruit_SSD1306: added CH32V20X macro (line 53 on Adafruit_SSD1306.cpp); added compatibilty with CH32 RISC-V mcu family (line 55 on README.md); added compatibility with CH32V203 device (line 66 on README.md) 2025-05-02 16:32:31 -04:00
PreciousRoy0 97afc0362b Add 64x32 I2C example sketch 2025-01-01 15:53:29 +01:00
PreciousRoy0 18c7f13ddd Add 64x32 OLED display support 2025-01-01 15:50:38 +01:00
Tyeth GundryandGitHub 78d6a130b2 Update library.properties - bump version to 2.5.13 2024-10-29 22:03:25 +00:00
Limor "Ladyada" FriedandGitHub ea12e7df70 Merge pull request #258 from gabrielcsapo/master
bug: ARDUINO_ARCH_RP2040 does not include the right pgmspace header
2024-10-28 10:30:32 -04:00
Limor "Ladyada" FriedandGitHub 00fa0bdbca Merge pull request #273 from fabiopjve/patch-1
Add support for Renesas RL78
2024-10-28 10:30:03 -04:00
Tyeth GundryandGitHub c95c1c47d6 Update library.properties 2024-10-09 01:45:25 +01:00
Limor "Ladyada" FriedandGitHub 16ee8a2c29 Merge pull request #266 from RTduino-libraries/master
add ARDUINO_ARCH_RTTHREAD to support RT-Thread
2024-10-07 09:49:58 -04:00
Meco Man 95fef51c89 add ARDUINO_ARCH_RTTHREAD to support RT-Thread 2024-10-06 12:06:40 -04:00
Tyeth GundryandGitHub 14a4563e10 Update library.properties - bump version to 2.5.11 2024-07-30 17:18:46 +01:00
Limor "Ladyada" FriedandGitHub 2196a97447 Merge pull request #276 from makermelissa/master
Fix example for RP2040 Feather
2024-07-24 11:46:33 -04:00
Melissa LeBlanc-Williams 4ca34506f1 Fix example for RP2040 Feather 2024-07-24 08:29:46 -07:00
Fábio PereiraandGitHub 8a95baeced Add support to Renesas RL78
Compiling this library without this change results in a compile error because util/delay.h does not exist on RL78
2024-06-20 21:04:16 -04:00
Tyeth GundryandGitHub 5fa3388757 Update library.properties - bump version to 2.5.10 2024-05-01 16:11:24 +01:00
ladyada 1d52453e3b add c6 2024-04-23 15:21:49 -04:00
Tyeth GundryandGitHub 7a4d33ef04 Merge pull request #270 from tyeth/bump-version-2023-11-14-20-33-27
Update version number to 2.5.9
2023-11-15 12:58:05 +00:00
Tyeth Gundry d8acdafbdf Bump version number to 2.5.9 2023-11-14 20:33:28 +00:00
dherrada 36b0655f5c Update CI action versions 2023-05-12 11:24:07 -04:00
Gabriel Csapo 6ec47b6f1c bug: ARDUINO_ARCH_RP2040 does not include the right pgmspace header 2022-12-30 20:42:33 -08:00
Eva HerradaandGitHub 88711efc3e Bump to 2.5.7 2022-08-03 16:21:34 -04:00
Limor "Ladyada" FriedandGitHub 1dcc8b5efa Merge pull request #246 from BobbyIndustries/master
Added ESP-IDF component files
2022-08-01 17:38:27 -04:00
LayerDEandGitHub 2f6eb1c8fa Update CMakeLists.txt 2022-07-28 02:23:40 +02:00
LayerDEandGitHub c9eb7d3b12 Add files via upload 2022-07-28 02:08:33 +02:00
Eva HerradaandGitHub 33327d02a4 Bump to 2.5.6 2022-06-29 13:16:36 -04:00
Eva HerradaandGitHub 46512179c6 Bump to 2.5.5 2022-06-29 13:11:19 -04:00
Limor "Ladyada" FriedandGitHub ca3a261c95 Merge pull request #244 from waynepiekarski/master
Fix up error: declaration of 'spi' shadows a member
2022-06-28 17:26:41 -04:00
Wayne Piekarski 19b6a36f3b Fix up -Wshadow "error: declaration of 'spi' shadows a member of 'Adafruit_SSD1306'" 2022-06-22 10:37:07 -07:00
12 changed files with 497 additions and 21 deletions
Vendored
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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;
+11
View File
@@ -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)
+7
View File
@@ -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 -->
+1
View File
@@ -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
View File
@@ -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