Skip to content

Commit 5fe3e79

Browse files
committed
Merge remote-tracking branch 'origin/inkplate6flick-examples'
2 parents 098f6f4 + 1574d20 commit 5fe3e79

File tree

26 files changed

+3396
-0
lines changed

26 files changed

+3396
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file BluetoothSerial.ino
5+
* @brief Example showing how to use Bluetooth Serial on Inkplate 6FLICK
6+
* with an LVGL-based UI that safely renders incoming text.
7+
*
8+
* HOW TO USE
9+
* - Upload this example to Inkplate 6FLICK.
10+
* - Pair your phone with the device in Bluetooth settings (device name: "Inkplate 6FLICK").
11+
* - Open a Serial Bluetooth Terminal app (or similar) and connect to "Inkplate 6FLICK".
12+
* - Anything you type in the app will be shown on the serial monitor.
13+
* - Anything you type in the Arduino Serial Monitor will be sent to the phone.
14+
*
15+
*
16+
* For info on how to quickly get started with Inkplate 6FLICK visit
17+
* https://soldered.com/documentation/inkplate/6flick/overview/
18+
*
19+
* @authors Soldered
20+
* @date November 2025
21+
***************************************************/
22+
23+
24+
#include <Inkplate-LVGL.h>
25+
#include "BluetoothSerial.h"
26+
27+
Inkplate inkplate(INKPLATE_1BIT); // Inkplate LVGL display instance
28+
BluetoothSerial SerialBT; // Bluetooth Serial object
29+
30+
const char *btDeviceName = "Inkplate 6FLICK"; // Bluetooth device name
31+
32+
// Forward declaration
33+
void setLabelText(lv_obj_t *label, const char *text);
34+
35+
void setup()
36+
{
37+
Serial.begin(115200);
38+
39+
// Initialize Inkplate in FULL render mode (for LVGL)
40+
inkplate.begin(LV_DISP_RENDER_MODE_FULL);
41+
42+
// Set white background
43+
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xFFFFFF), LV_PART_MAIN);
44+
45+
// Create centered LVGL label
46+
lv_obj_t *label = lv_label_create(lv_screen_active());
47+
lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_PART_MAIN);
48+
lv_obj_set_style_text_font(label, &lv_font_montserrat_28, 0);
49+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
50+
51+
// Initial startup message
52+
Serial.println("Initializing Bluetooth...");
53+
54+
// Attempt to start Bluetooth
55+
if (!SerialBT.begin(btDeviceName))
56+
{
57+
setLabelText(label, "Error initializing Bluetooth!");
58+
}
59+
else
60+
{
61+
// Success message
62+
setLabelText(label,
63+
"Bluetooth Serial\n\n"
64+
"Device: Inkplate 6FLICK\n\n"
65+
"Pair your phone and connect\n"
66+
"using a Serial Bluetooth app.\n\n"
67+
"Baud: 115200");
68+
}
69+
70+
// Render the LVGL content
71+
lv_tick_inc(50);
72+
lv_timer_handler();
73+
inkplate.display();
74+
}
75+
76+
void loop()
77+
{
78+
// Forward data from USB Serial → Bluetooth
79+
if (Serial.available())
80+
{
81+
while (Serial.available())
82+
{
83+
SerialBT.write(Serial.read());
84+
}
85+
}
86+
87+
// Forward data from Bluetooth → USB Serial
88+
if (SerialBT.available())
89+
{
90+
while (SerialBT.available())
91+
{
92+
Serial.write(SerialBT.read());
93+
}
94+
}
95+
96+
delay(20);
97+
}
98+
99+
100+
// update LVGL label text and refresh display
101+
void setLabelText(lv_obj_t *label, const char *text)
102+
{
103+
lv_label_set_text(label, text);
104+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
105+
106+
lv_tick_inc(50);
107+
lv_timer_handler();
108+
inkplate.display();
109+
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Qwiic.ino
5+
* @brief Example demonstrating easyC/Qwiic (I2C) communication between Inkplate 6FLICK and
6+
* a Soldered BME280 or BME680 environmental sensor, using the LVGL library
7+
* for display rendering.
8+
*
9+
* This example reads temperature, humidity, and pressure data from a
10+
* Soldered BME280 sensor connected via the easyC interface and displays
11+
* it on the Inkplate 6FLICK e-paper screen using LVGL elements.
12+
*
13+
* Note: Both BME280 and BME680 sensors are supported by the same
14+
* Soldered BME280/BME680 library. In this example, the BME280 is used,
15+
* as defined in the code. The sensor communicates over easyC (I2C)
16+
* using the default 0x76 address.
17+
*
18+
* For setup instructions and more information about Inkplate 6FLICK, visit:
19+
* https://soldered.com/documentation/inkplate/6flick/overview/
20+
*
21+
* @hardware Inkplate 6FLICK (ESP32-based e-paper display)
22+
* @sensors Soldered BME280 (or BME680) via easyC connector
23+
* @library Soldered BME280/BME680 Gas Sensor Arduino Library
24+
* https://github.com/SolderedElectronics/Soldered-BME280-BME680-Gas-Sensor-Arduino-Library
25+
*
26+
* @authors Soldered
27+
* @date November 2025
28+
***************************************************/
29+
30+
#include <Inkplate-LVGL.h>
31+
#include <BME280-SOLDERED.h> // Soldered BME280/BME680 library (easyC/I2C)
32+
33+
// Inkplate in 1-bit mode (fast partial updates)
34+
Inkplate inkplate(INKPLATE_1BIT);
35+
BME280 bme280; // easyC/I2C (Soldered uses 0x76)
36+
37+
// Optional temperature calibration offset
38+
const float TEMPERATURE_OFFSET = 0.0f;
39+
40+
// UI elements
41+
static lv_obj_t *panel_data;
42+
static lv_obj_t *lbl_title;
43+
static lv_obj_t *lbl_temp;
44+
static lv_obj_t *lbl_hum;
45+
static lv_obj_t *lbl_press;
46+
static lv_obj_t *lbl_warn;
47+
48+
// Refresh policy (do a FULL every ~20 partials)
49+
static int partialCount = 0;
50+
static const int FULL_REFRESH_EVERY = 20;
51+
52+
// Helpers
53+
static inline int dispW() { auto *d = lv_display_get_default(); return lv_display_get_horizontal_resolution(d); }
54+
static inline int dispH() { auto *d = lv_display_get_default(); return lv_display_get_vertical_resolution(d); }
55+
56+
static void make_opaque(lv_obj_t *obj) {
57+
lv_obj_set_style_bg_color(obj, lv_color_hex(0xFFFFFF), 0);
58+
lv_obj_set_style_bg_opa(obj, LV_OPA_COVER, 0);
59+
lv_obj_set_style_border_width(obj, 0, 0);
60+
}
61+
62+
// Minimal LVGL UI (no GFX icons to keep it LVGL-only)
63+
static void ui_create() {
64+
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xFFFFFF), LV_PART_MAIN);
65+
66+
lbl_title = lv_label_create(lv_screen_active());
67+
lv_label_set_text(lbl_title, "easyC • BME280");
68+
lv_obj_set_style_text_color(lbl_title, lv_color_hex(0x000000), 0);
69+
lv_obj_set_pos(lbl_title, 8, 8);
70+
make_opaque(lbl_title);
71+
72+
panel_data = lv_obj_create(lv_screen_active());
73+
make_opaque(panel_data);
74+
lv_obj_set_style_pad_all(panel_data, 0, 0);
75+
lv_obj_set_style_border_width(panel_data, 0, 0);
76+
lv_obj_set_pos(panel_data, 0, 40);
77+
lv_obj_set_size(panel_data, dispW(), dispH() - 80);
78+
79+
lbl_temp = lv_label_create(panel_data);
80+
lv_obj_set_style_text_color(lbl_temp, lv_color_hex(0x000000), 0);
81+
lv_obj_set_pos(lbl_temp, 24, 40);
82+
83+
lbl_hum = lv_label_create(panel_data);
84+
lv_obj_set_style_text_color(lbl_hum, lv_color_hex(0x000000), 0);
85+
lv_obj_set_pos(lbl_hum, 24, 140);
86+
87+
lbl_press = lv_label_create(panel_data);
88+
lv_obj_set_style_text_color(lbl_press, lv_color_hex(0x000000), 0);
89+
lv_obj_set_pos(lbl_press, 24, 240);
90+
91+
lbl_warn = lv_label_create(panel_data); // shown only if sensor looks unresponsive
92+
lv_obj_set_style_text_color(lbl_warn, lv_color_hex(0x000000), 0);
93+
lv_obj_set_pos(lbl_warn, 24, 320);
94+
lv_label_set_text(lbl_warn, "");
95+
}
96+
97+
static void update_readings() {
98+
// Read sensor
99+
float tC = bme280.readTemperature() + TEMPERATURE_OFFSET; // °C
100+
float hum = bme280.readHumidity() / 10.0f; // library returns x10
101+
float hPa = bme280.readPressure() * 10.0f; // hPa (original style)
102+
103+
// Basic sanity check (some libs return 0 or extreme values if not connected)
104+
bool looks_bad = (hPa <= 0.0f) || (hum < 0.0f || hum > 100.0f) || (tC < -40.0f || tC > 85.0f);
105+
106+
char bufT[32], bufH[32], bufP[32];
107+
snprintf(bufT, sizeof(bufT), "Temperature: %.1f *C", tC);
108+
snprintf(bufH, sizeof(bufH), "Humidity: %.0f %%", hum);
109+
snprintf(bufP, sizeof(bufP), "Pressure: %.0f hPa", hPa);
110+
111+
lv_label_set_text(lbl_temp, bufT);
112+
lv_label_set_text(lbl_hum, bufH);
113+
lv_label_set_text(lbl_press, bufP);
114+
115+
if (looks_bad) {
116+
lv_label_set_text(lbl_warn, "Warning: sensor readings look invalid.\nCheck easyC cable and sensor power.");
117+
} else {
118+
lv_label_set_text(lbl_warn, "");
119+
}
120+
}
121+
122+
void setup() {
123+
Serial.begin(115200);
124+
125+
// LVGL + Inkplate in PARTIAL mode
126+
inkplate.begin(LV_DISP_RENDER_MODE_PARTIAL);
127+
inkplate.selectDisplayMode(INKPLATE_1BIT);
128+
129+
// Init BME280 (void return in this library)
130+
bme280.begin();
131+
132+
ui_create();
133+
update_readings();
134+
135+
// Initial FULL refresh
136+
lv_tick_inc(20);
137+
lv_timer_handler();
138+
inkplate.display();
139+
}
140+
141+
void loop() {
142+
update_readings();
143+
144+
lv_tick_inc(10);
145+
lv_timer_handler();
146+
147+
if (partialCount >= FULL_REFRESH_EVERY) {
148+
inkplate.display(); // FULL
149+
partialCount = 0;
150+
} else {
151+
inkplate.partialUpdate();
152+
partialCount++;
153+
}
154+
155+
delay(10000); // ~10 s between readings
156+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file DeepSleepButton.ino
5+
* @brief Wake from deep sleep by button (EXT0) or by timer (30 s).
6+
*
7+
* For info on how to quickly get started with Inkplate 6FLICK visit
8+
* https://soldered.com/documentation/inkplate/6flick/overview/
9+
*
10+
*
11+
* @authors Soldered
12+
* @date November 2025
13+
***************************************************/
14+
15+
#include <Inkplate-LVGL.h>
16+
17+
// Deep sleep timing
18+
#define uS_TO_S_FACTOR 1000000ULL
19+
#define TIME_TO_SLEEP 30
20+
21+
// Keep count across deep sleep cycles
22+
RTC_DATA_ATTR int bootCount = 0;
23+
24+
// Create Inkplate LVGL display object in explicit bit mode
25+
// Use INKPLATE_1BIT for fastest b/w, or INKPLATE_3BIT for grayscale.
26+
Inkplate inkplate(INKPLATE_1BIT);
27+
28+
void setup()
29+
{
30+
Serial.begin(115200);
31+
32+
// Initialize display + LVGL in FULL render mode
33+
inkplate.begin(LV_DISP_RENDER_MODE_FULL);
34+
35+
// Increment boot counter
36+
bootCount++;
37+
38+
// Figure out wake reason
39+
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
40+
const char *reasonText = "Wakeup: Unknown";
41+
switch (wakeup_reason)
42+
{
43+
case ESP_SLEEP_WAKEUP_EXT0: reasonText = "Wakeup: Button"; break;
44+
case ESP_SLEEP_WAKEUP_TIMER: reasonText = "Wakeup: Timer"; break;
45+
default: break;
46+
}
47+
48+
// Prepare label text
49+
char labelText[128];
50+
snprintf(labelText, sizeof(labelText),
51+
"Boot count: %d\n%s", bootCount, reasonText);
52+
53+
// White background
54+
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xFFFFFF), LV_PART_MAIN);
55+
56+
// Centered label (use default font to avoid config deps)
57+
lv_obj_t *label = lv_label_create(lv_screen_active());
58+
lv_label_set_text(label, labelText);
59+
lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_PART_MAIN);
60+
lv_obj_set_style_text_font(label, LV_FONT_DEFAULT, 0);
61+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
62+
63+
// Render & show
64+
lv_tick_inc(50);
65+
lv_timer_handler();
66+
inkplate.display();
67+
68+
Serial.printf("Boot count: %d | %s\n", bootCount, reasonText);
69+
70+
// Enable wake on timer
71+
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
72+
73+
// Enable wake on button (GPIO 36, active LOW)
74+
esp_sleep_enable_ext0_wakeup(GPIO_NUM_36, 0);
75+
76+
// Enter deep sleep
77+
esp_deep_sleep_start();
78+
}
79+
80+
void loop()
81+
{
82+
// never reached
83+
}

0 commit comments

Comments
 (0)