Skip to content

Commit 0b84b4a

Browse files
Laurence BankLaurence Bank
authored andcommitted
Added C++ wrapper API and many new features
1 parent 0c3071e commit 0b84b4a

File tree

6 files changed

+2000
-1952
lines changed

6 files changed

+2000
-1952
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ It uses the SH1107 controller and behaves very similarly to the SH1106.
2121

2222
Features:<br>
2323
---------<br>
24+
- C API and C++ wrapper class which mimics the Adafruit_GFX API
2425
- Supports any number of simultaneous displays of any type (mix and match)<br>
2526
- Optionally detect the display address and type (I2C only)<br>
2627
- Supports 72x40, 96x16, 64x32, 128x32, 128x64, 64x128 (SH1107), 128x128 (SH1107) and 132x64 (SH1106) OLED display sizes<br>
2728
- Supports 96x68 HX1230, 84x48 Nokia 5110 and 128x64 ST7567/UC1701 mono LCDs<br>
2829
- Supports 144x168 and 400x240 Sharp Memory LCDs<br>
30+
- *NEW* supports the ST7302 low power LCD (250x122, 2.13")
2931
- Virtual displays of any size which can be drawn across multiple physical displays
3032
- Flexible copy function can convert the internal pixel format to any output format and orientation
3133
- Drive displays from I2C, SPI or any GPIO pins (virtual I2C/SPI)<br>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// Simple demo sketch to show how to use the new
3+
// C++ class which wraps the OneBitDisplay C API
4+
// This class was modeled after the Adafruit GFX API
5+
// to make it easier to port code, yet still retains
6+
// the unique features of OBD
7+
//
8+
// Written by Larry Bank
9+
// project started April 24, 2022
10+
//
11+
#include <OneBitDisplay.h>
12+
ONE_BIT_DISPLAY tft; // static class instantiation
13+
14+
void setup()
15+
{
16+
int i;
17+
// The I2Cbegin() method needs a minimum of the type of OLED/LCD being used
18+
// Optional parameters are for the I2C address (auto discovered if not specified)
19+
// and the I2C bus speed (defaults to 400Kbs)
20+
// The Arduino default I2C pins are used here (works on many setups)
21+
// If you need to specify them, use the setI2CPins() method
22+
tft.I2Cbegin(OLED_64x128);
23+
//
24+
// Here we're asking the library to allocate the backing buffer
25+
// If successful, the library will change the render flag to "RAM only" so that
26+
// all drawing occurs only to the internal buffer, and display() must be called
27+
// to see the changes. Without a backing buffer, the API will try to draw all
28+
// output directly to the display instead.
29+
//
30+
if (!tft.allocBuffer()) {
31+
tft.print("Alloc failed");
32+
}
33+
// tft.setRotation(3); // optionally rotate in 90 degree increments - only supports 0/180 without a RAM backing buffer
34+
tft.fillScreen(OLED_BLACK);
35+
tft.setScroll(true); // enable text printing to scroll the display buffer a line at a time
36+
tft.setFont(FONT_12x16); // Use the 6x8 (stretched+smoothed) font
37+
i = 0;
38+
while (1) {
39+
tft.print("Count = ");
40+
tft.println(i++, DEC); // this will keep the last line blank because it immediately scrolls up
41+
tft.display(); // copy the RAM buffer to the physical display
42+
delay(250); // slow it down a bit
43+
}
44+
}
45+
46+
void loop() {
47+
// nothing going on here
48+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=OneBitDisplay
2-
version=1.11.0
2+
version=2.0.0
33
author=Larry Bank
44
maintainer=Larry Bank
55
sentence=OLED and LCD library for 1-bit per pixel displays.

0 commit comments

Comments
 (0)