Skip to content

Commit 1a06073

Browse files
committed
Add remaining examples
1 parent aabc1fc commit 1a06073

File tree

5 files changed

+394
-0
lines changed

5 files changed

+394
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file BluetoothSerial.ino
5+
* @brief Example showing how to use Bluetooth Serial on Inkplate 6
6+
* with an LVGL-based UI that safely renders incoming text.
7+
*
8+
* HOW TO USE
9+
* - Upload this example to Inkplate 6COLOR.
10+
* - Pair your phone with the device in Bluetooth settings (device name: "Inkplate 6COLOR").
11+
* - Open a Serial Bluetooth Terminal app (or similar) and connect to "Inkplate6".
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 6 visit
17+
* https://soldered.com/documentation/inkplate/6/overview/
18+
*
19+
* @authors Soldered
20+
* @date November 2025
21+
**************************************************
22+
*/
23+
24+
25+
#include <Inkplate-LVGL.h>
26+
#include "BluetoothSerial.h"
27+
28+
Inkplate inkplate; // Inkplate LVGL display instance
29+
BluetoothSerial SerialBT; // Bluetooth Serial object
30+
31+
const char *btDeviceName = "Inkplate 6COLOR"; // Bluetooth device name
32+
33+
// Forward declaration
34+
void setLabelText(lv_obj_t *label, const char *text);
35+
36+
void setup()
37+
{
38+
Serial.begin(115200);
39+
40+
// Initialize Inkplate in FULL render mode (for LVGL)
41+
inkplate.begin(LV_DISP_RENDER_MODE_FULL);
42+
43+
// Set white background
44+
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xFFFFFF), LV_PART_MAIN);
45+
46+
// Create centered LVGL label
47+
lv_obj_t *label = lv_label_create(lv_screen_active());
48+
lv_obj_set_style_text_color(label, lv_color_hex(0x000000), LV_PART_MAIN);
49+
lv_obj_set_style_text_font(label, &lv_font_montserrat_28, 0);
50+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
51+
52+
// Initial startup message
53+
Serial.println("Initializing Bluetooth...");
54+
55+
// Attempt to start Bluetooth
56+
if (!SerialBT.begin(btDeviceName))
57+
{
58+
setLabelText(label, "Error initializing Bluetooth!");
59+
}
60+
else
61+
{
62+
// Success message
63+
setLabelText(label,
64+
"Bluetooth Serial\n\n"
65+
"Device: Inkplate 6COLOR\n\n"
66+
"Pair your phone and connect\n"
67+
"using a Serial Bluetooth app.\n\n"
68+
"Baud: 115200");
69+
}
70+
71+
// Render the LVGL content
72+
lv_tick_inc(50);
73+
lv_timer_handler();
74+
inkplate.display();
75+
}
76+
77+
void loop()
78+
{
79+
// Forward data from USB Serial → Bluetooth
80+
if (Serial.available())
81+
{
82+
while (Serial.available())
83+
{
84+
SerialBT.write(Serial.read());
85+
}
86+
}
87+
88+
// Forward data from Bluetooth → USB Serial
89+
if (SerialBT.available())
90+
{
91+
while (SerialBT.available())
92+
{
93+
Serial.write(SerialBT.read());
94+
}
95+
}
96+
97+
delay(20);
98+
}
99+
100+
101+
// update LVGL label text and refresh display
102+
void setLabelText(lv_obj_t *label, const char *text)
103+
{
104+
lv_label_set_text(label, text);
105+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
106+
107+
lv_tick_inc(50);
108+
lv_timer_handler();
109+
inkplate.display();
110+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file ExternalExpander.ino
5+
* @brief Example showing how to set up the external expander to blink an LED on all of the pins
6+
*
7+
* For info on how to quickly get started with Inkplate 6COLOR visit https://soldered.com/documentation/inkplate/6color/overview/
8+
*
9+
* Connect an LED alongside a 330ohm resistor to one of the external expander pins
10+
*
11+
* @authors Soldered
12+
* @date November 2025
13+
***************************************************/
14+
15+
#include "Inkplate-LVGL.h" //Include Inkplate library to the sketch
16+
17+
18+
Inkplate display; // Create an instance of the Inkplate object
19+
20+
void setup()
21+
{
22+
display.begin(LV_DISP_RENDER_MODE_PARTIAL); // Init Inkplate library and LVGL in PARTIAL rende mode
23+
// Set all of the pins (P0-0 to P1-7) to output
24+
// Note: P0-0 is defined as 0, up to P1-7 which is defined as 15
25+
for(int i=0;i<16;i++)
26+
{
27+
display.externalIO.pinMode(i, OUTPUT);
28+
}
29+
}
30+
31+
void loop()
32+
{
33+
// Set all of the GPIO pins to LOW
34+
for(int i=0;i<16;i++)
35+
{
36+
display.externalIO.digitalWrite(i, LOW);
37+
}
38+
delay(1000); // Wait for one second
39+
// Set all of the GPIO pins to HIGH
40+
for(int i=0;i<16;i++)
41+
{
42+
display.externalIO.digitalWrite(i, HIGH);
43+
}
44+
delay(1000); // Wait for one second
45+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file EEPROMUsage.ino
5+
* @brief Example showing how to clear, write to and read from the onboard EEPROM
6+
*
7+
* For info on how to quickly get started with Inkplate 6COLOR visit https://soldered.com/documentation/inkplate/6color/overview/
8+
*
9+
* @authors Soldered
10+
* @date November 2025
11+
***************************************************/
12+
13+
#include "EEPROM.h" // Include ESP32 EEPROM library
14+
#include "Inkplate-LVGL.h" // Include Inkplate library to the sketch
15+
16+
#define EEPROM_SIZE 128 // How much data to write to EEPROM in this example
17+
18+
Inkplate display; // Create object on Inkplate library and set library to work in monochrome mode
19+
20+
void setup()
21+
{
22+
Serial.begin(115200); // Init serial monitor to display what's happening
23+
display.begin(LV_DISP_RENDER_MODE_FULL); // Init library (you should call this function ONLY ONCE)
24+
25+
// Init EEPROM library with 128 of EEPROM size.
26+
EEPROM.begin(EEPROM_SIZE);
27+
28+
Serial.println("Cleaning EEPROM..."); // Print message on serial monitor
29+
clearEEPROM(); // Clear user EEPROM data
30+
delay(500); // Wait a little bit...
31+
32+
Serial.println("Writing data to EEPROM..."); // Print message on serial monitor
33+
writeEEPROM(); // Write some data to EEPROM
34+
delay(500); // Wait a little bit...
35+
36+
Serial.println("Reading data from EEPROM..."); // Print message on the Sserial Monitor
37+
printEEPROM(); // Read data from EEPROM and display it on screen
38+
delay(500); // Wait a little bit...
39+
}
40+
41+
void loop()
42+
{
43+
// Empty...
44+
}
45+
46+
// Function for clearing EEPROM data
47+
void clearEEPROM()
48+
{
49+
for (int i = 0; i < EEPROM_SIZE; i++)
50+
{
51+
EEPROM.write(i, 0);
52+
}
53+
EEPROM.commit();
54+
}
55+
56+
// Function writes data to EEPROM
57+
void writeEEPROM()
58+
{
59+
for (int i = 0; i < EEPROM_SIZE; i++)
60+
{
61+
EEPROM.write(i, i);
62+
}
63+
EEPROM.commit();
64+
}
65+
66+
// Function reads back previously written data and displays it on serial monitor and screen.
67+
void printEEPROM()
68+
{
69+
for (int i = 0; i < EEPROM_SIZE; i++)
70+
{
71+
Serial.print(EEPROM.read(i), DEC);
72+
if (i != EEPROM_SIZE - 1)
73+
{
74+
Serial.print(", ");
75+
}
76+
}
77+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file ImageFromBuffer.ino
5+
* @brief Example showing how to read the battery voltage and display it on the screen
6+
*
7+
* For info on how to quickly get started with Inkplate 6COLOR visit https://soldered.com/documentation/inkplate/6color/overview/
8+
*
9+
* @authors Soldered
10+
* @date November 2025
11+
***************************************************/
12+
13+
14+
#include <Inkplate-LVGL.h>
15+
16+
Inkplate inkplate; // Create an instance of the Inkplate object
17+
18+
// Helper function to update LVGL label and refresh display
19+
void updateLabel(lv_obj_t *label, const char *text)
20+
{
21+
lv_label_set_text(label, text);
22+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
23+
24+
lv_tick_inc(50);
25+
lv_timer_handler();
26+
inkplate.display();
27+
}
28+
29+
void setup()
30+
{
31+
// Initialize Inkplate in FULL mode (required for LVGL)
32+
inkplate.begin(LV_DISP_RENDER_MODE_FULL);
33+
34+
// White background
35+
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xFFFFFF), LV_PART_MAIN);
36+
37+
// Create LVGL label for voltage display
38+
lv_obj_t *label = lv_label_create(lv_screen_active());
39+
lv_obj_set_style_text_font(label, &lv_font_montserrat_48, 0);
40+
lv_obj_set_style_text_color(label, lv_color_hex(0x0000AA), LV_PART_MAIN); // blue-ish
41+
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
42+
}
43+
44+
void loop()
45+
{
46+
float voltage = inkplate.readBattery(); // Read battery voltage
47+
48+
// Format voltage text
49+
char txt[32];
50+
snprintf(txt, sizeof(txt), "%.2f V", voltage);
51+
52+
// Update existing LVGL label (child #0)
53+
lv_obj_t *label = lv_obj_get_child(lv_screen_active(), 0);
54+
updateLabel(label, txt);
55+
56+
delay(60000); // Refresh every 60 seconds
57+
}

0 commit comments

Comments
 (0)