Skip to content

Commit 58bbd04

Browse files
committed
add inkplate 6 examples
1 parent 0150ddf commit 58bbd04

175 files changed

Lines changed: 13521 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(template)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
solderedelectronics/inkplate:
3+
version: ">=1.0.0"
4+
idf:
5+
version: ">=6.0.0"
6+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "main.cpp"
2+
REQUIRES "inkplate"
3+
INCLUDE_DIRS ".")
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/**
2+
* @file main.cpp
3+
* @author Fran Fodor for Soldered
4+
* @brief I2C (Qwiic) scanner example for Soldered Inkplate 6.
5+
*
6+
* @details Scans the I2C bus for connected Qwiic/I2C devices and displays
7+
* detected device addresses both on the Serial Monitor and on
8+
* the Inkplate 6 e-paper display. Useful for validating proper
9+
* wiring and confirming device communication.
10+
*
11+
* Requirements:
12+
* - Board: Soldered Inkplate 6
13+
* - Framework: ESP-IDF v6.x
14+
* - Hardware: Inkplate 6, USB cable, optional Qwiic/I2C device
15+
* - Extra: None
16+
*
17+
* Configuration:
18+
* - Menuconfig -> Inkplate Boards -> Inkplate6
19+
*
20+
* How to use:
21+
* 1) Build and flash to Inkplate 6.
22+
* 2) Connect a Qwiic/I2C device to the Inkplate.
23+
* 3) Upload the sketch to Inkplate 6.
24+
* 4) Open the Serial Monitor (115200 baud).
25+
* 5) Detected I2C addresses will be shown on both the display and Serial.
26+
*
27+
* Expected output:
28+
* - Inkplate display lists detected I2C device addresses
29+
* - Serial Monitor logs scanning progress and addresses
30+
*
31+
* Notes:
32+
* - Valid I2C addresses range from 0x01 to 0x7E.
33+
* - Scan repeats every 5 seconds.
34+
*
35+
* Docs: https://docs.soldered.com/inkplate
36+
* Support: https://forum.soldered.com/
37+
* Image tool: https://tools.soldered.com/tools/image-converter/
38+
*/
39+
40+
#include "sdkconfig.h"
41+
42+
#ifndef CONFIG_INKPLATE_BOARD_INKPLATE6
43+
#error \
44+
"Wrong board selection for this example, please select Inkplate6 in the boards menu."
45+
#endif
46+
47+
#include "Inkplate.h"
48+
#include "driver/i2c_master.h"
49+
#include "esp_log.h"
50+
#include "freertos/FreeRTOS.h"
51+
#include "freertos/task.h"
52+
53+
extern I2C i2c;
54+
55+
static const char *TAG = "I2C_SCANNER";
56+
57+
static void scanI2C(Inkplate &display) {
58+
int nDevices = 0;
59+
int yCursor = 30;
60+
61+
display.clearDisplay();
62+
display.setCursor(0, 0);
63+
display.setTextSize(2);
64+
display.print("Scanning I2C...");
65+
display.setTextSize(1);
66+
67+
ESP_LOGI(TAG, "Scanning...");
68+
69+
for (uint8_t address = 1; address < 0x7F; address++) {
70+
// i2c_master_probe sends a start + address + stop and checks for ACK
71+
esp_err_t ret = i2c_master_probe(i2c.getBusHandle(), address, 10);
72+
73+
if (ret == ESP_OK) {
74+
ESP_LOGI(TAG, "I2C device found at address 0x%02X", address);
75+
76+
display.setCursor(0, yCursor);
77+
display.print("Found: 0x");
78+
if (address < 0x10)
79+
display.print("0");
80+
display.print(address, 16);
81+
yCursor += 12;
82+
nDevices++;
83+
}
84+
}
85+
86+
if (nDevices == 0) {
87+
ESP_LOGI(TAG, "No I2C devices found");
88+
display.setCursor(0, yCursor);
89+
display.print("No devices found.");
90+
} else {
91+
ESP_LOGI(TAG, "Scan done, %d device(s) found", nDevices);
92+
}
93+
94+
display.display();
95+
}
96+
97+
extern "C" void app_main(void) {
98+
Inkplate display;
99+
display.setDisplayMode(BLACK_AND_WHITE);
100+
101+
display.clearDisplay();
102+
display.setTextSize(4);
103+
display.setTextColor(BLACK, WHITE);
104+
display.setCursor(0, 0);
105+
display.print("Inkplate I2C Scanner");
106+
display.display();
107+
108+
while (true) {
109+
scanI2C(display);
110+
vTaskDelay(pdMS_TO_TICKS(5000));
111+
}
112+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
2+
CONFIG_SPIRAM=y
3+
CONFIG_SPIRAM_SPEED_40M=y
4+
CONFIG_SPIRAM_BOOT_INIT=y
5+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16384
6+
CONFIG_ESP_TLS_INSECURE=y
7+
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(template)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
solderedelectronics/inkplate:
3+
version: ">=1.0.0"
4+
idf:
5+
version: ">=6.0.0"
6+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "main.cpp"
2+
REQUIRES "inkplate"
3+
INCLUDE_DIRS ".")
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* @file main.cpp
3+
* @author Fran Fodor for Soldered
4+
* @brief Partial e-paper update with ESP32 deep sleep for Soldered
5+
* Inkplate 6.
6+
*
7+
* @details Demonstrates how to correctly use partial screen updates
8+
* together with ESP32 deep sleep on Inkplate 6. Since partial updates rely on
9+
* previously stored screen content in RAM, the screen must be recreated after
10+
* waking from deep sleep before calling partialUpdate(). This example shows how
11+
* to preserve variables in RTC memory, rebuild the screen, and safely perform
12+
* partial updates.
13+
*
14+
* Requirements:
15+
* - Board: Soldered Inkplate 6
16+
* - Framework: ESP-IDF v6.x
17+
* - Hardware: Inkplate 6, USB cable
18+
* - Extra: None
19+
*
20+
* Configuration:
21+
* - Menuconfig -> Inkplate Boards -> Inkplate6
22+
*
23+
* How to use:
24+
* 1) Build and flash to Inkplate 6.
25+
* 2) After first full refresh, the device will enter deep sleep.
26+
* 3) Every 10 seconds the ESP32 wakes up, updates variables,
27+
* rebuilds the screen buffer, and performs a partial update.
28+
* 4) Observe changing values on the display after each wake cycle.
29+
*
30+
* Expected output:
31+
* - First boot performs a full refresh.
32+
* - Subsequent wake-ups perform partial updates only.
33+
* - Counter and decimal value increment after each deep sleep cycle.
34+
*
35+
* Notes:
36+
* - Partial update works only in 1-bit (black & white) mode.
37+
* - Do NOT use standard partial update examples together with deep sleep.
38+
* - Always rebuild the screen content after deep sleep before calling
39+
* partialUpdate().
40+
* - It is recommended to perform a full refresh every 5–10 partial updates
41+
* to maintain good image quality.
42+
*
43+
* Docs: https://docs.soldered.com/inkplate
44+
* Support: https://forum.soldered.com/
45+
* Image tool: https://tools.soldered.com/tools/image-converter/
46+
*/
47+
48+
#include "sdkconfig.h"
49+
50+
#ifndef CONFIG_INKPLATE_BOARD_INKPLATE6
51+
#error \
52+
"Wrong board selection for this example, please select Inkplate6 in the boards menu."
53+
#endif
54+
55+
#include "esp_attr.h" // RTC_DATA_ATTR
56+
#include "esp_sleep.h"
57+
#include "freertos/FreeRTOS.h"
58+
#include "freertos/task.h"
59+
#include "rom/rtc.h" // rtc_get_reset_reason(), DEEPSLEEP_RESET
60+
61+
#include "Inkplate.h"
62+
63+
// 10 seconds in microseconds
64+
#define TIME_TO_SLEEP_US (10ULL * 1000000ULL)
65+
66+
// Counter variable (stored in RTC RAM that stores variable even if deep sleep
67+
// is used) Variables that are changed after each partial update has to be
68+
// stored in RTC RAM in order to recreate screen before deep sleep
69+
RTC_DATA_ATTR static int counter = 0;
70+
RTC_DATA_ATTR static float decimal = 3.14159265f;
71+
72+
static void createScreen(Inkplate *display) {
73+
display->setFont(NULL);
74+
display->setTextSize(3); // Set font to be scaled up three times
75+
display->setTextColor(BLACK, WHITE);
76+
77+
display->setCursor(200, 300); // Set text cursor @ X = 200, Y = 300
78+
display->print("First variable:");
79+
display->print(counter); // Write first variable to buffer
80+
81+
display->setCursor(200, 340); // Set text cursor @ X = 200, Y = 340
82+
display->print("Second variable:");
83+
display->print(
84+
decimal, 2); // Write second variable to buffer (use two decimals places)
85+
}
86+
87+
extern "C" void app_main(void) {
88+
Inkplate display;
89+
display.setDisplayMode(BLACK_AND_WHITE);
90+
91+
createScreen(&display); // Function that contains everything that has to be
92+
// written on screen
93+
94+
if (rtc_get_reset_reason(0) ==
95+
DEEPSLEEP_RESET) // Check if ESP32 is reseted by deep sleep or power up /
96+
// user manual reset (or some other reason)
97+
{
98+
display.preloadScreen(); // If is woken up by deep sleep, recreate whole
99+
// screen to be same as was before deep sleep
100+
// Update variable / variables
101+
counter++;
102+
decimal *= 1.23f;
103+
104+
display.clearDisplay(); // Clear everything in buffer
105+
createScreen(&display); // Create new screen with new variables
106+
display.partialUpdate(
107+
true); // Partial update of screen. (Use this only in this
108+
// scenario, otherwise YOU CAN DAMAGE YOUR SCRREN)
109+
} else // If is not deep sleep reset, that must be some thing else, so use
110+
// normal update procedure (full screen update)
111+
{
112+
display.display();
113+
}
114+
115+
esp_sleep_enable_timer_wakeup(
116+
TIME_TO_SLEEP_US); // Set EPS32 to be woken up in 10 seconds (in this
117+
// case)
118+
esp_deep_sleep_start(); // Put ESP32 into deep sleep (low power mode)
119+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
2+
CONFIG_SPIRAM=y
3+
CONFIG_SPIRAM_SPEED_40M=y
4+
CONFIG_SPIRAM_BOOT_INIT=y
5+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16384
6+
CONFIG_ESP_TLS_INSECURE=y
7+
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y

0 commit comments

Comments
 (0)