Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-IDF (Espressif IoT Development Framework) support #386

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vscode
.vs
.pio
out
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS src)
set(COMPONENT_PRIV_REQUIRES arduino-esp32)
set(COMPONENT_SRCDIRS src)
register_component()
register_component()
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ The init sequence for the SSD1306 was inspired by Adafruit's library for the sam
## mbed-os
This library has been adopted to support the ARM mbed-os environment. A copy of this library is available in mbed-os under the name OLED_SSD1306 by Helmut Tschemernjak. An alternate installation option is to copy the following files into your mbed-os project: OLEDDisplay.cpp OLEDDisplay.h OLEDDisplayFonts.h OLEDDisplayUi.cpp OLEDDisplayUi.h SSD1306I2C.h

## ESP-IDF (Espressif IoT Development Framework)
This library has been adopted to support Espressif IoT Development Framework (ESP-IDF). See [the example](#esp-idf-example) below and in the `examples\ESP-IDF` directory.

## Usage

Check out the examples folder for a few comprehensive demonstrations how to use the library. Also check out the [ESP8266 Weather Station](https://github.com/ThingPulse/esp8266-weather-station) library which uses the OLED library to display beautiful weather information.
Expand Down Expand Up @@ -131,6 +134,33 @@ SH1106Spi display(D0, D2, CS); // RES, DC, CS

In case the CS pin is not used (hard wired to ground), pass CS as -1.


### <a name="esp-idf-example"></a>ESP-IDF (Espressif IoT Development Framework) on PlatformIO

`platformIO.ini` example:
```
[env:nodemcu-32s]
platform = espressif32@^6.3.0
board = nodemcu-32s
framework = espidf
lib_deps =
;https://github.com/ThingPulse/esp8266-oled-ssd1306.git@^4.5.0 ; will works only with the new version of the library
;ThingPulse/esp8266-oled-ssd1306^4.5.0 ; will works only with the new version of the library
https://github.com/osmanovv/esp-idf-oled.git#70c29beb4fa42d2b9045d1da110cf5d9b46fa166 ; my fork for testing purpose - remove
```

Then use `SSD1306I2C` implementation in your code:
```C++
#include <SSD1306I2C.h>

static const uint8_t SSD1306_ADDRESS = 0x3C;
static const gpio_num_t SDA = 21;
static const gpio_num_t SCL = 22;

SSD1306I2C display(SSD1306_ADDRESS, SDA, SCL);
```


## API

### Display Control
Expand Down
5 changes: 5 additions & 0 deletions examples/ESP-IDF/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
3 changes: 3 additions & 0 deletions examples/ESP-IDF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ESPIDFDemo)
18 changes: 18 additions & 0 deletions examples/ESP-IDF/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nodemcu-32s]
platform = espressif32@^6.3.0
board = nodemcu-32s
framework = espidf
lib_deps =
;https://github.com/ThingPulse/esp8266-oled-ssd1306.git@^4.5.0 ; will works only with the new version of the library
;ThingPulse/esp8266-oled-ssd1306^4.5.0 ; will works only with the new version of the library
https://github.com/osmanovv/esp-idf-oled.git#70c29beb4fa42d2b9045d1da110cf5d9b46fa166 ; my fork for testing purpose
Loading