Skip to content

Commit 889b221

Browse files
committed
Added some examples for inkplate4
1 parent 0075d0d commit 889b221

File tree

18 files changed

+1444
-1
lines changed

18 files changed

+1444
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Inkplate4_Internal_IO_Expander example for Soldered Inkplate 4
3+
For this example you will need only a USB-C cable, Inkplate4, 330 Ohm resistor and LED diode.
4+
Select "Soldered Inkplate4" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate4" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
Connect resistor to P1-7 on IO expander header at the top on the backside
9+
(component side) of Inkplate. You will have to connect one side of 330 Ohm resistor to P1-7, then other side
10+
to anode of LED and finally, cathode pin of LED to GND.
11+
12+
This example will show you how you can manipulate with I/Os of internal IO Expander.
13+
You can only manipulate with Port B of IO Expander (P1-1->P1-7). Port 0 (or Port A) is used for epaper
14+
panel and TPS65186 PMIC.
15+
P1-0 is used for ESP32 GPIO0 so you can't use it either.
16+
P1-1 is used for enabling battery reading (if Batt solder bridge is bridged between second and third pad).
17+
P1-2 is used for tunring on and off the MOSFET for SD card (if solder bridge is bridged between second and third
18+
pad). If everything is connected ok, after you upload code, LED should blink.
19+
20+
DANGER: DO NOT USE P0-0 -> P0-7 and P1-0. In code those are pins from 0-8!!! Using those, you
21+
might permanently damage the screen. You should only use pins from 9-15.
22+
23+
Want to learn more about Inkplate? Visit www.inkplate.io
24+
Looking to get support? Write on our forums: https://forum.soldered.com/
25+
4 April 2023 by Soldered.
26+
*/
27+
28+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
29+
#ifndef ARDUINO_INKPLATE4
30+
#error "Wrong board selection for this example, please select Soldered Inkplate4 in the boards menu."
31+
#endif
32+
33+
#include "Inkplate.h" // Include Inkplate library to the sketch
34+
35+
// We are going to use pin P1-7.
36+
// Remember! P0-0 = 0, P0-1 = 1, ..., P0-7 = 7, P1-0 = 8, P1-1 = 9, ..., P1-7 = 15.
37+
#define LED_PIN IO_PIN_B7
38+
39+
Inkplate display; // Create an object on Inkplate library
40+
41+
void setup()
42+
{
43+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
44+
display.pinModeIO(LED_PIN, OUTPUT,
45+
IO_INT_ADDR); // Set P1-7 to output. On that pin, we sholud connect LED with current
46+
// limiting resistor and specify that we want use internal IO expander
47+
}
48+
49+
void loop()
50+
{
51+
display.digitalWriteIO(LED_PIN, LOW, IO_INT_ADDR); // Set output to low (LED does not light up)
52+
delay(1000); // Wait for one second
53+
display.digitalWriteIO(LED_PIN, HIGH, IO_INT_ADDR); // Set output to high (LED lights up)
54+
delay(1000); // Wait for one second
55+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
Inkplate4_EEPROM_Usage example for Soldered Inkplate 4
3+
For this example, you will need only a USB-C cable and Inkplate 4.
4+
Select "Soldered Inkplate4" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate4" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example will show you how to use EEPROM with Inkplate board.
9+
EEPROM is a permanent memory that holds data even if the power supply is disconnected.
10+
You can use EEPROM to store any data you don't want to lose during restarting or powering down the device.
11+
It shows how to use basic operations with EEPROM like clearing, writing, and reading.
12+
13+
Want to learn more about Inkplate? Visit www.inkplate.io
14+
Looking to get support? Write on our forums: https://forum.soldered.com/
15+
4 April 2023 by Soldered
16+
*/
17+
18+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
19+
#ifndef ARDUINO_INKPLATE4
20+
#error "Wrong board selection for this example, please select Soldered Inkplate4 in the boards menu."
21+
#endif
22+
23+
#include "EEPROM.h" // Include ESP32 EEPROM library
24+
#include "Inkplate.h" // Include Inkplate library to the sketch
25+
26+
#define EEPROM_SIZE 128 // How much data to write to EEPROM in this example
27+
28+
Inkplate display; // Create object on Inkplate library
29+
30+
void setup()
31+
{
32+
// Init library (you should call this function ONLY ONCE)
33+
display.begin();
34+
35+
// Init EEPROM library with 128 of EEPROM size.
36+
EEPROM.begin(EEPROM_SIZE);
37+
38+
display.setTextSize(4); // Set text size
39+
display.println("Clearing EEPROM...\n"); // Print message
40+
display.display(); // Full refresh the display
41+
clearEEPROM(); // Clear user EEPROM data
42+
delay(500); // Wait a little bit...
43+
44+
display.println("Writing data to EEPROM...\n"); // Print message
45+
display.partialUpdate(); // Use partial updates for refreshing the display
46+
writeEEPROM(); // Write some data to EEPROM
47+
delay(500); // Wait a little bit...
48+
49+
display.println("Reading data from EEPROM:\n"); // Print message
50+
display.partialUpdate(); // Use partial updates for refreshing the display
51+
display.setTextSize(2); // Use smaller text so everything can fit on display
52+
printEEPROM(); // Read data from EEPROM and display it on screen
53+
}
54+
55+
void loop()
56+
{
57+
// Empty...
58+
}
59+
60+
// Function for clearing EEPROM data
61+
void clearEEPROM()
62+
{
63+
// Go through each address and clear it (write 0)
64+
for (int i = 0; i < EEPROM_SIZE; i++)
65+
{
66+
EEPROM.write(i, 0);
67+
}
68+
EEPROM.commit();
69+
}
70+
71+
// Function writes data to EEPROM
72+
void writeEEPROM()
73+
{
74+
// Go through each address and write current index
75+
for (int i = 0; i < EEPROM_SIZE; i++)
76+
{
77+
EEPROM.write(i, i);
78+
}
79+
EEPROM.commit();
80+
}
81+
82+
// Function reads back previously written data and displays it on screen
83+
void printEEPROM()
84+
{
85+
// Go through each address and read a value from it
86+
for (int i = 0; i < EEPROM_SIZE; i++)
87+
{
88+
// Print read value in decimal
89+
display.print(EEPROM.read(i), DEC);
90+
91+
// Print a comma after each number except the last one
92+
if (i != EEPROM_SIZE - 1)
93+
display.print(", ");
94+
}
95+
display.partialUpdate();
96+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Inkplate4_Read_Battery_Voltage example for Soldered Inkplate 4
3+
For this example you will need a USB-C cable, Inkplate 4 and a Lithium battery (3.7V) with two pin JST connector.
4+
Select "Soldered Inkplate4" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate4" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example will show you how to read voltage of the battery
9+
10+
Want to learn more about Inkplate? Visit www.inkplate.io
11+
Looking to get support? Write on our forums: https://forum.soldered.com/
12+
4 April 2023 by Soldered
13+
*/
14+
15+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
16+
#ifndef ARDUINO_INKPLATE4
17+
#error "Wrong board selection for this example, please select Soldered Inkplate4 in the boards menu."
18+
#endif
19+
20+
#include "Inkplate.h" // Include Inkplate library to the sketch
21+
#include "battSymbol.h" // Include .h file that contains byte array for battery symbol.
22+
// It is in same folder as this sketch. You can even open it (read it) by clicking on battSymbol.h tab in Arduino IDE
23+
Inkplate display; // Create an object on Inkplate library
24+
25+
void setup()
26+
{
27+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
28+
display.clearDisplay(); // Clear frame buffer of display
29+
display.setTextSize(2); // Scale text to be two times bigger then original (5x7 px)
30+
display.setTextColor(BLACK, WHITE); // Set text color to black and background color to white
31+
}
32+
33+
void loop()
34+
{
35+
float voltage = display.readBattery(); // Read battery voltage
36+
display.clearDisplay(); // Clear everything in frame buffer of e-paper display
37+
display.drawImage(battSymbol, 100, 100, 106, 45, BLACK); // Draw battery symbol at position X=100 Y=100
38+
display.setCursor(210, 120);
39+
display.print(voltage, 2); // Print battery voltage
40+
display.print('V');
41+
display.display(); // Send everything to display (refresh the screen)
42+
delay(10000); // Wait 10 seconds before new measurement
43+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Bitmap size: 106x45
2+
const uint8_t battSymbol[] = {
3+
0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff,
4+
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00,
5+
0x00, 0x7f, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x7f,
6+
0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x03, 0xc0, 0x00, 0x00, 0xf7, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
7+
0x00, 0x01, 0xe0, 0x00, 0x00, 0xe1, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x01,
8+
0xe0, 0x7c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x01, 0xc0, 0x3f, 0x00, 0xff, 0xff,
9+
0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x03, 0xc0, 0x0f, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
10+
0x00, 0xe0, 0x00, 0x03, 0x80, 0x07, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x07, 0x00,
11+
0x07, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x0f, 0x00, 0x0f, 0x80, 0xff, 0xff, 0xff,
12+
0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00,
13+
0xff, 0x80, 0x0e, 0x00, 0x7c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0x0f, 0x00, 0xf8,
14+
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0x07, 0x83, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xff,
15+
0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0x0f, 0x07, 0xc0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff,
16+
0xc0, 0x0e, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0x1e, 0x0f, 0x00, 0x00,
17+
0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0x3c, 0x0f, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
18+
0xf8, 0x00, 0x00, 0xff, 0xc0, 0x78, 0x07, 0xc0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0,
19+
0xf0, 0x07, 0xc0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0xe0, 0x0f, 0x80, 0x00, 0xff,
20+
0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc1, 0xe0, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
21+
0x00, 0x00, 0xff, 0xc3, 0xc0, 0x7c, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc3, 0xe0,
22+
0xf8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc1, 0xe1, 0xf0, 0x00, 0x00, 0xff, 0xff,
23+
0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc0, 0xe3, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
24+
0x00, 0xff, 0xc1, 0xe7, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc1, 0xc7, 0x80,
25+
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc3, 0xc7, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff,
26+
0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xc3, 0x83, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00,
27+
0xff, 0x87, 0x07, 0xc0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x0f, 0x1f, 0x00, 0x00,
28+
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x0e, 0x3e, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
29+
0xff, 0xf8, 0x00, 0x00, 0xe0, 0x1e, 0x7c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0,
30+
0x1c, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x3b, 0xe0, 0x00, 0x00, 0x00,
31+
0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x01, 0xe0, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
32+
0xf8, 0x00, 0x03, 0xe0, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x07, 0xc0, 0xfe,
33+
0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x1f, 0xc0, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f,
34+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
35+
0xff, 0xff, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xc0, 0x00,
36+
0x00, 0x00, 0x00};
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Inkplate4_SD_Pictures example for Soldered Inkplate 4
3+
For this example you will need a USB-C cable, Inkplate4 and a SD card
4+
loaded with images that can be found inside folder of this example.
5+
Select "Soldered Inkplate4" from Tools -> Board menu.
6+
Don't have "Soldered Inkplate4" option? Follow our tutorial and add it:
7+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
8+
9+
This example will show you how you can read .bmp and .jpeg files (pictures) from an SD card and
10+
display that image on the e-paper display. You can open .bmp, .jpeg or .png files (but there are
11+
some limitations by the library) that have color depth of 1 bit (BW bitmap), 4 bit, 8 bit and
12+
24 bit AND have resoluton smaller than 400x300 or otherwise it won't fit on screen. Format your
13+
SD card in standard FAT fileformat.
14+
15+
Want to learn more about Inkplate? Visit www.inkplate.io
16+
Looking to get support? Write on our forums: https://forum.soldered.com/
17+
5 April 2023 by Soldered
18+
*/
19+
20+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
21+
#ifndef ARDUINO_INKPLATE4
22+
#error "Wrong board selection for this example, please select Soldered Inkplate4 in the boards menu."
23+
#endif
24+
25+
#include "Inkplate.h" // Include Inkplate library to the sketch
26+
Inkplate display; // Create an object on Inkplate library
27+
SdFile file; // Create SdFile object used for accessing files on SD card
28+
29+
void setup()
30+
{
31+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
32+
display.clearDisplay(); // Clear frame buffer of display
33+
display.setTextColor(BLACK); // Set text color to black
34+
display.setTextSize(3); // Set font size to 3
35+
36+
// Init SD card. Display if SD card is init propery or not.
37+
if (display.sdCardInit())
38+
{
39+
display.println("SD Card OK! Reading image...");
40+
display.display();
41+
42+
// If card is properly init, try to load image and display it on e-paper at position X=0, Y=0
43+
// NOTE: Both drawImage methods allow for an optional fifth "invert" parameter. Setting this parameter
44+
// to true will flip all colors on the image, making black white and white black. This may be necessary when
45+
// exporting bitmaps from certain softwares.
46+
if (!display.drawImage("image1.bmp", 0, 0, 1))
47+
{
48+
// If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
49+
// REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no
50+
// compression! You can turn of dithering for somewhat faster image load by changing the last 1 to 0, or
51+
// removing the parameter completely
52+
display.println("Image open error");
53+
}
54+
display.display();
55+
delay(5000);
56+
57+
// Now try to load image using SdFat library class (for more advanced users) and display image on epaper.
58+
display.clearDisplay();
59+
if (file.open("image2.bmp", O_RDONLY))
60+
{
61+
display.drawBitmapFromSd(&file, 0, 0, 1);
62+
}
63+
else
64+
{
65+
display.println("Image open error");
66+
}
67+
display.display();
68+
delay(5000);
69+
70+
// Now draw a JPEG
71+
display.clearDisplay();
72+
if (!display.drawImage("pyramid.jpg", 100, 0, true))
73+
{
74+
// If is something failed (wrong filename or wrong format), write error message on the screen.
75+
// You can turn off dithering for somewhat faster image load by changing the fourth parameter to false, or
76+
// removing the parameter completely
77+
display.println("Image open error");
78+
}
79+
display.display();
80+
}
81+
else
82+
{
83+
// If SD card init not success, display error on screen
84+
display.println("SD Card error!");
85+
display.display();
86+
}
87+
88+
// Turn off the MOSFET that powers the SD card
89+
display.sdCardSleep();
90+
}
91+
92+
void loop()
93+
{
94+
// Nothing...
95+
}
Binary file not shown.
Binary file not shown.
103 KB
Loading

0 commit comments

Comments
 (0)