Skip to content

Commit 1143247

Browse files
authored
Merge pull request #11 from ThingPulse/master
upstream changes
2 parents ee628ee + 906d0c5 commit 1143247

File tree

11 files changed

+245
-116
lines changed

11 files changed

+245
-116
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ jobs:
1313
example: [examples/SSD1306UiDemo, examples/SSD1306SimpleDemo, examples/SSD1306DrawingDemo, examples/SSD1306OTADemo, examples/SSD1306ClockDemo, examples/SSD1306TwoScreenDemo]
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Cache pip
18-
uses: actions/cache@v2
18+
uses: actions/cache@v3
1919
with:
2020
path: ~/.cache/pip
2121
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
2222
restore-keys: ${{ runner.os }}-pip-
2323
- name: Cache PlatformIO
24-
uses: actions/cache@v2
24+
uses: actions/cache@v3
2525
with:
2626
path: ~/.platformio
2727
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
2828
- name: Set up Python
29-
uses: actions/setup-python@v2
29+
uses: actions/setup-python@v5
3030
- name: Install PlatformIO
3131
run: |
3232
python -m pip install --upgrade pip
3333
pip install --upgrade platformio
3434
- name: Install library dependencies
35-
run: pio lib -g install "paulstoffregen/Time@^1.6"
35+
run: pio pkg install -g -l "paulstoffregen/Time@^1.6"
3636
- name: Run PlatformIO
3737
run: pio ci --lib="." --board=nodemcuv2 --board=d1_mini --board=esp-wrover-kit --board=esp32doit-devkit-v1
3838
env:

README.md

+52-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
[![Build Status](https://github.com/ThingPulse/esp8266-oled-ssd1306/actions/workflows/main.yml/badge.svg)](https://github.com/ThingPulse/esp8266-oled-ssd1306/actions)
2-
31
# ThingPulse OLED SSD1306 (ESP8266/ESP32/Mbed-OS)
42

5-
This is a driver for SSD1306 128x64, 128x32, 64x48 and 64x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
3+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/thingpulse/library/ESP8266%20and%20ESP32%20OLED%20driver%20for%20SSD1306%20displays.svg)](https://registry.platformio.org/libraries/thingpulse/ESP8266%20and%20ESP32%20OLED%20driver%20for%20SSD1306%20displays)
4+
[![Build Status](https://github.com/ThingPulse/esp8266-oled-ssd1306/actions/workflows/main.yml/badge.svg)](https://github.com/ThingPulse/esp8266-oled-ssd1306/actions)
5+
6+
This is a driver for SSD1306 and SH1106 128x64, 128x32, 64x48 and 64x32 OLED displays running on the Arduino/ESP8266 & ESP32 and mbed-os platforms.
67
Can be used with either the I2C or SPI version of the display.
78

89
This library drives the OLED display included in the [ThingPulse IoT starter kit](https://thingpulse.com/product/esp8266-iot-electronics-starter-kit-weatherstation-planespotter-worldclock/) aka classic kit aka weather station kit.
@@ -261,6 +262,27 @@ void setTextAlignment(OLEDDISPLAY_TEXT_ALIGNMENT textAlignment);
261262
void setFont(const uint8_t* fontData);
262263
```
263264
265+
## Arduino `Print` functionality
266+
267+
Because this class has been "derived" from Arduino's `Print` class, you can use the functions it provides. In plain language, this means that you can use `print`, `println` and `printf` to the display. Internally, a buffer holds the text that was printed to the display previously (that would still fit on the display) and every time you print something, this buffer is put on the screen, using the functions from the previous section.
268+
269+
What that means is that printing using `print` and "manually" putting things on the display are somewhat mutually exclusive: as soon as you print, everything that was on the display already is gone and only what you put there before with `print`, `println` or `printf` remains. Still, using `print` is a very simple way to put something on the display quickly.
270+
271+
One extra function is provided: `cls()`
272+
```cpp
273+
// cls() will clear the display immediately and empty the logBuffer, meaning
274+
// the next print statement will print at the top of the display again.
275+
// cls() should not be confused with clear(), which only clears the internal
276+
// graphics buffer, which can then be shown on the display with display().
277+
void cls();
278+
279+
> _Note that printing to the display, contrary to what you might expect, does not wrap your lines, so everything on a line that doesn't fit on the screen is cut off._
280+
```
281+
282+
 
283+
284+
<hr>
285+
264286
## Ui Library (OLEDDisplayUi)
265287

266288
The Ui Library is used to provide a basic set of user interface elements called `Frames` and `Overlays`. A `Frame` is used to provide
@@ -401,6 +423,33 @@ OLEDDisplayUiState* getUiState();
401423
int8_t update();
402424
```
403425
426+
## Creating and using XBM bitmaps
427+
428+
If you want to display your own images with this library, the best way to do this is using a bitmap.
429+
430+
There are two options to convert an image to a compatible bitmap:
431+
1. **Using Gimp.**
432+
In this case exporting the bitmap in an 1-bit XBM format is sufficient.
433+
2. **Using a converter website.**
434+
You could also use online converter services like e.g. [https://javl.github.io/image2cpp/](https://javl.github.io/image2cpp/). The uploaded image should have the same dimension as the screen (e.g. 128x64). The following output settings should be set:
435+
- Draw Mode: Horizontal - 1 bit per pixel
436+
- Swap bits in byte: swap checkbox should be checked.
437+
438+
The resulting bitmap can be put into a header file:
439+
```C++
440+
const unsigned char epd_example [] PROGMEM = {
441+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ...
442+
...
443+
};
444+
```
445+
446+
Subsequently, it can be used like this:
447+
```C++
448+
display.clear();
449+
display.drawXbm(0, 0, 128, 64, epd_example); // assuming your bitmap is 128x64
450+
display.display();
451+
```
452+
404453
## Example: SSD1306Demo
405454

406455
### Frame 1

examples/SSD1306DrawingDemo/SSD1306DrawingDemo.ino

+1-10
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ void drawCircle(void) {
171171
}
172172

173173
void printBuffer(void) {
174-
// Initialize the log buffer
175-
// allocate memory to store 8 lines of text and 30 chars per line.
176-
display.setLogBuffer(5, 30);
177-
178174
// Some test data
179175
const char* test[] = {
180176
"Hello",
@@ -189,15 +185,10 @@ void printBuffer(void) {
189185
"scrolling is",
190186
"working"
191187
};
192-
188+
display.clear();
193189
for (uint8_t i = 0; i < 11; i++) {
194-
display.clear();
195190
// Print to the screen
196191
display.println(test[i]);
197-
// Draw it to the internal screen buffer
198-
display.drawLogBuffer(0, 0);
199-
// Display it on the screen
200-
display.display();
201192
delay(500);
202193
}
203194
}

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ESP8266 and ESP32 OLED driver for SSD1306 displays",
3-
"version": "4.3.0",
3+
"version": "4.4.1",
44
"keywords": "ssd1306, oled, display, i2c",
55
"description": "I2C display driver for SSD1306 OLED displays connected to ESP8266, ESP32, Mbed-OS",
66
"license": "MIT",

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP8266 and ESP32 OLED driver for SSD1306 displays
2-
version=4.3.0
2+
version=4.4.1
33
author=ThingPulse, Fabrice Weinberg
44
maintainer=ThingPulse <info@thingpulse.com>
55
sentence=I2C display driver for SSD1306 OLED displays connected to ESP8266, ESP32, Mbed-OS

0 commit comments

Comments
 (0)