Skip to content

Commit d7f456b

Browse files
committed
Corrected some examples for inkplate5
1 parent 5316a1f commit d7f456b

File tree

13 files changed

+292
-349
lines changed

13 files changed

+292
-349
lines changed

examples/Inkplate5/Advanced/Communications/Inkplate5_Bluetooth_Peripheral_Mode/Inkplate5_Bluetooth_Peripheral_Mode.ino

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ char commandBuffer[BUFFER_SIZE + 1];
4040

4141
void setup()
4242
{
43-
Serial.begin(115200); // Init serial communication for debugging
4443
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
4544
display.setTextSize(4); // Scale text to be 4 times bigger then original (5x7 px)
4645

4746
// Init BT communication
4847
if (!SerialBT.begin("Inkplate5"))
4948
{
50-
Serial.println("An error occurred initializing Bluetooth");
5149
display.println("An error occurred initializing Bluetooth");
5250
}
5351
else
@@ -69,11 +67,10 @@ void loop()
6967
commandBuffer[i] = commandBuffer[i + 1];
7068
}
7169
commandBuffer[BUFFER_SIZE - 1] = SerialBT.read();
72-
Serial.print(commandBuffer[BUFFER_SIZE - 1]);
7370
}
7471

7572
// Function in peripheral.h
76-
run(commandBuffer, BUFFER_SIZE);
73+
run(commandBuffer, BUFFER_SIZE, &display, &SerialBT);
7774

7875
// Wait a bit
7976
delay(50);

examples/Inkplate5/Advanced/Communications/Inkplate5_Bluetooth_Peripheral_Mode/Peripheral.h

Lines changed: 194 additions & 198 deletions
Large diffs are not rendered by default.

examples/Inkplate5/Advanced/Communications/Inkplate5_Second_SPI/Inkplate5_Second_SPI.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
66
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
77
8+
This example shows how to use a second SPI for any breakout that uses SPI communication.
9+
It's important to specify pins inside SPI.begin() or else the example won't work.
10+
This example will show you how you can read an RFID tag ID with the MFRC522 breakout
11+
and print it on the Inkplate screen. When you approximate a card to the reader,
12+
if everything is connected properly, on the Inkplate screen will be displayed the card type and ID.
13+
814
For this example you have to install Soldered MFRC522 library:
915
https://github.com/SolderedElectronics/Soldered-MFRC522-RFID-Reader-Arduino-Library
1016
@@ -18,9 +24,7 @@
1824
SCK - IO14
1925
SDA - IO15
2026
21-
This example will show you how you can read a tag ID and print it on the Inkplate screen.
22-
23-
NOTE: you have to cut JP3 and connect the other 2 contacts in order to work!
27+
IMPORTANT: you have to cut JP3 and connect/solder the other 2 contacts in order to work!
2428
2529
Want to learn more about Inkplate? Visit www.inkplate.io
2630
Looking to get support? Write on our forums: https://forum.soldered.com/
@@ -48,7 +52,7 @@ MFRC522 rfid(SS_PIN, RST_PIN);
4852
// Create an object on Inkplate library and also set library into 1-bit mode (BW)
4953
Inkplate display(INKPLATE_1BIT);
5054

51-
// Font scale for the text on the screen. The scale of 1 is 7px height
55+
// Font scale for the text on the screen. The scale of 1 is 7px in height and 5 pixels in width
5256
#define BIG_TEXT_SCALE 4
5357
#define SMALL_TEXT_SCALE 3
5458

@@ -58,6 +62,8 @@ void setup()
5862
display.begin();
5963

6064
// Init SPI bus
65+
// IMPORTANT: you have to specify pins!
66+
// The pins are: SPI.begin(SCK, MISO, MOSI, SS);
6167
SPI.begin(14, 12, 13, 15);
6268

6369
// Init MFRC522
@@ -82,10 +88,10 @@ void loop()
8288
// If the new tag is available
8389
if (rfid.PICC_IsNewCardPresent())
8490
{
85-
// If the NUID has been read
91+
// If the ID has been read
8692
if (rfid.PICC_ReadCardSerial())
8793
{
88-
// Check if the content fits on the screen expecting 2 line of the text
94+
// Check if the content fits on the screen expecting 2 lines of the text
8995
if (display.getCursorY() + 2 * SMALL_TEXT_SCALE * 7 > E_INK_HEIGHT)
9096
{
9197
// Clear the frame buffer of the display and set cursor to the beginning of the screen

examples/Inkplate5/Advanced/Other/Inkplate5_EEPROM_Usage/Inkplate5_EEPROM_Usage.ino

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ void setup()
4949
display.partialUpdate(); // Use partial updates for refreshing the display
5050
display.setTextSize(2); // Use smaller text so everything can fit on display
5151
printEEPROM(); // Read data from EEPROM and display it on screen
52-
delay(500); // Wait a little bit...
5352
}
5453

5554
void loop()
@@ -60,6 +59,7 @@ void loop()
6059
// Function for clearing EEPROM data
6160
void clearEEPROM()
6261
{
62+
// Go through each address and clear it (write 0)
6363
for (int i = 0; i < EEPROM_SIZE; i++)
6464
{
6565
EEPROM.write(i, 0);
@@ -70,19 +70,24 @@ void clearEEPROM()
7070
// Function writes data to EEPROM
7171
void writeEEPROM()
7272
{
73+
// Go through each address and write current index
7374
for (int i = 0; i < EEPROM_SIZE; i++)
7475
{
7576
EEPROM.write(i, i);
7677
}
7778
EEPROM.commit();
7879
}
7980

80-
// Function reads back previously written data and displays it on screen.
81+
// Function reads back previously written data and displays it on screen
8182
void printEEPROM()
8283
{
84+
// Go through each address and read a value from it
8385
for (int i = 0; i < EEPROM_SIZE; i++)
8486
{
87+
// Print read value in decimal
8588
display.print(EEPROM.read(i), DEC);
89+
90+
// Print a comma after each number except the last one
8691
if (i != EEPROM_SIZE - 1)
8792
display.print(", ");
8893
}

examples/Inkplate5/Advanced/SD/Inkplate5_SD_Pictures/Inkplate5_SD_Pictures.ino

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/*
22
Inkplate5_SD_Pictures example for Soldered Inkplate 5
3-
For this example you will need a USB-C cable, Inkplate5 and a SD card loaded with
4-
images that can be found inside folder of this example.
3+
For this example you will need a USB-C cable, Inkplate5 and a SD card
4+
loaded with images that can be found inside folder of this example.
55
Select "Soldered Inkplate5" from Tools -> Board menu.
66
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
77
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
88
9-
You can open .bmp, .jpeg or .png files (but there are some limitations by the library) that have
10-
color depth of 1 bit (BW bitmap), 4 bit, 8 bit and 24 bit AND have resoluton smaller than 800x600
11-
or otherwise it won't fit on screen. Format your SD card in standard FAT fileformat.
12-
13-
This example will show you how you can read .bmp and .jpeg files (pictures) from SD card and
14-
display that image on e-paper display.
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 960x540 or otherwise it won't fit on screen. Format your
13+
SD card in standard FAT fileformat.
1514
1615
Want to learn more about Inkplate? Visit www.inkplate.io
1716
Looking to get support? Write on our forums: https://forum.soldered.com/
@@ -49,7 +48,7 @@ void setup()
4948
// If is something failed (wrong filename or wrong bitmap format), write error message on the screen.
5049
// REMEMBER! You can only use Windows Bitmap file with color depth of 1, 4, 8 or 24 bits with no
5150
// compression! You can turn of dithering for somewhat faster image load by changing the last 1 to 0, or
52-
// removing the 1 argument completely
51+
// removing the parameter completely
5352
display.println("Image open error");
5453
}
5554
display.display();
@@ -70,10 +69,10 @@ void setup()
7069

7170
// Now draw a JPEG
7271
display.clearDisplay();
73-
if (!display.drawImage("pyramid.jpg", 100, 0, true, false))
72+
if (!display.drawImage("pyramid.jpg", 100, 0, true))
7473
{
7574
// If is something failed (wrong filename or wrong format), write error message on the screen.
76-
// You can turn off dithering for somewhat faster image load by changing the fifth parameter to false, or
75+
// You can turn off dithering for somewhat faster image load by changing the fourth parameter to false, or
7776
// removing the parameter completely
7877
display.println("Image open error");
7978
}

examples/Inkplate5/Advanced/SD/Inkplate5_SD_TXT_Read/Inkplate5_SD_TXT_Read.ino

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
77
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
88
9-
You can open your own .txt file, but in order to this example works properly it should
10-
not have more than 500 chars and you should name it text.txt
11-
12-
This example will show you how to open .txt files and display the content of that file on Inkplate epaper display.
9+
This example will show you how to open .txt files, limit the number of characters
10+
to read, and display the content of that file on the Inkplate e-paper display.
11+
You can open any other .txt file, just make sure that if there are more than 500 chars,
12+
increase the MAX_LENGTH to your needs. You can also change the file name.
1313
1414
Want to learn more about Inkplate? Visit www.inkplate.io
1515
Looking to get support? Write on our forums: https://forum.soldered.com/
@@ -25,6 +25,12 @@
2525
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
2626
SdFile file; // Create SdFile object used for accessing files on SD card
2727

28+
// Define how many characters will be read from the .txt file. Change if you want to read larger files
29+
#define MAX_LENGTH 500
30+
31+
// Here is the specified name of the file
32+
const char fileName[] = "/text.txt";
33+
2834
void setup()
2935
{
3036
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
@@ -38,9 +44,11 @@ void setup()
3844
display.println("SD Card ok! Reading data...");
3945
display.partialUpdate();
4046

41-
// Try to load text with max lenght of 200 chars.
42-
if (!file.open("/text.txt", O_RDONLY))
43-
{ // If it fails to open, send error message to display and put sd card in sleep mode, otherwise read the file.
47+
// Try to load text with a max length of 500 chars. You can change this by changing MAX_LENGTH define
48+
if (!file.open(fileName, O_RDONLY))
49+
{
50+
// If it fails to open, send error message to display and put sd card in sleep mode, otherwise read the
51+
// file.
4452
display.println("File open error");
4553
display.display();
4654
display.sdCardSleep();
@@ -49,24 +57,24 @@ void setup()
4957
{
5058
display.clearDisplay(); // Clear everything that is stored in frame buffer of epaper
5159
display.setCursor(0, 0); // Set print position at the begining of the screen
52-
char text[501]; // Array where data from SD card is stored (max 500 chars here)
60+
char text[MAX_LENGTH + 1]; // An array where data from an SD card is stored (max 500 chars here plus one for
61+
// the null terminating char)
5362
int len = file.fileSize(); // Read how big is file that we are opening
54-
if (len > 500)
55-
len = 500; // If it's more than 500 bytes (500 chars), limit to max 500 bytes
56-
file.read(text, len); // Read data from file and save it in text array
57-
text[len] = 0; // Put null terminating char at the and of data
63+
if (len > MAX_LENGTH)
64+
len = MAX_LENGTH; // If it's more than 500 bytes (500 chars), limit to max 500 bytes
65+
file.read(text, len); // Read 500 chars from the file and save it in the text array
66+
text[len] = 0; // Put the null terminating char at the end of data
5867
display.print(text); // Print data/text
59-
display.sdCardSleep(); // Put sd card in sleep mode
68+
display.sdCardSleep(); // Put the SD card in sleep mode
6069
display.display(); // Do a full refresh of display
6170
}
6271
}
6372
else
64-
{ // If card init was not successful, display error on screen and stop the program (using infinite loop)
73+
{
74+
// If card init was not successful, display error on screen and stop the program (using infinite loop)
6575
display.println("SD Card error!");
6676
display.partialUpdate();
6777
display.sdCardSleep();
68-
while (true)
69-
;
7078
}
7179
}
7280

examples/Inkplate5/Advanced/SD/Inkplate5_SD_TXT_Write/Inkplate5_SD_TXT_Write.ino

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
66
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
77
8-
This example will show you how to write in .txt file.
8+
This example shows how you can use Inkplate 5 to write in a .txt file.
9+
The file name is specified below and you can change it. Just make sure that
10+
you specified the .txt extension or otherwise it will create a file that you
11+
can't open. You can also change the content that will be written in the file
12+
by changing the array called dataToWrite.
13+
14+
If you don't change anything, after uploading the example the Inkplate will
15+
create a file named test.txt and write "Hello! This is the file writing example
16+
for Inkplate 5." into the file. It will also add a new line at the end, so if
17+
you run the example again, it will write once again the same string in the next line.
918
1019
Want to learn more about Inkplate? Visit www.inkplate.io
1120
Looking to get support? Write on our forums: https://forum.soldered.com/
@@ -21,7 +30,8 @@
2130
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
2231
SdFile file; // Create SdFile object used for accessing files on SD card
2332

24-
char *fileName = "test.txt"; // The name of a file with the extension.
33+
// The name of a file with the extension
34+
char *fileName = "test.txt";
2535

2636
// The text you want to write in the file
2737
char *dataToWrite = "Hello! This is the file writing example for Inkplate 5.\n"; // "\n" represents a new line
@@ -33,16 +43,17 @@ void setup()
3343
display.display(); // Put clear image on display
3444
display.setTextSize(3); // Set text to be 3 times bigger than original (5x7 px)
3545

36-
// Init SD card. Display if SD card is init propery or not.
46+
// Init SD card. Display if SD card is init propery or not
3747
if (display.sdCardInit())
3848
{
49+
// Print a message on the display
3950
display.println("SD Card ok!");
4051
display.partialUpdate();
4152

4253
// Try to create text.txt file.
4354
if (!file.open(fileName, FILE_WRITE))
4455
{
45-
// If it fails to create, send an error message to display, otherwise write to file.
56+
// If it fails to create, send an error message to display, otherwise write to file
4657
display.println("Error while creating the file!");
4758
display.partialUpdate();
4859
display.sdCardSleep();
@@ -60,13 +71,14 @@ void setup()
6071
}
6172
else
6273
{
63-
// If card init was not successful, display error on screen, put sd card in sleep mode, and stop the program
64-
// (using infinite loop)
74+
// If card init was not successful, display an error on the screen, and put the
75+
// SD card in sleep mode (turn off the MOSFET that turns off the power for SD).
76+
// It is desirable to stop the program after the SD card fails, but there is no
77+
// next part in this example, only an empty loop().You can do it, for example,
78+
// by calling while(1); at the end of this code block, after sdCardSleep();
6579
display.println("SD Card error!");
6680
display.partialUpdate();
6781
display.sdCardSleep();
68-
while (true)
69-
;
7082
}
7183
}
7284

examples/Inkplate5/Advanced/WEB_WiFi/Inkplate5_HTTPS_POST_Request/Inkplate5_HTTPS_POST_Request.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const char *pass = "";
3636
const char *apiUrl = "https://jsonplaceholder.typicode.com/posts";
3737

3838
// Specify the delay time between 2 POST requests in milliseconds
39-
#define DELAY_BETWEEN_REQUESTS 10000
39+
#define DELAY_BETWEEN_REQUESTS 10000 // Here is 10 seconds
4040

4141
// Create objects from included libraries
4242
WiFiClientSecure client;
@@ -48,7 +48,7 @@ void setup()
4848
// Init serial communication
4949
Serial.begin(115200);
5050

51-
// Init the display
51+
// Init library (you should call this function ONLY ONCE)
5252
display.begin();
5353

5454
// Clear the display and print message
@@ -87,15 +87,20 @@ void loop()
8787
http.addHeader("Content-Type", "application/json");
8888

8989
// Create a JSON document for serializing data
90-
const size_t CAPACITY = JSON_OBJECT_SIZE(1);
90+
const size_t CAPACITY = JSON_OBJECT_SIZE(2);
9191
StaticJsonDocument<CAPACITY> doc;
9292

9393
// Convert the JSON document to a JSON object in order to add data
9494
JsonObject object = doc.to<JsonObject>();
9595

9696
// Add data in the JSON object
97+
// Add some title
9798
object["title"] = "Hello Inkplate";
9899

100+
// Add some random number from 0 to 100
101+
// In the same way, you can add some sensor readings or something similar
102+
object["sensor_reading"] = random(100);
103+
99104
// Serialize the JSON object with your data to a JSON document for sending
100105
char jsonOutput[128];
101106
serializeJson(doc, jsonOutput);

examples/Inkplate5/Projects/Inkplate5_Daily_Weather_Station/Inkplate5_Daily_Weather_Station.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
This example will show you how you can use Inkplate 5 to display API data,
99
e.g. Openweather public weather API. It shows the forecast weather for 4 days
1010
at 15 o'clock (3 PM). If it's passed 3 PM, the first rectangle shows the
11-
forecast weather for tomorrow at 3 PM.
11+
forecast weather for tomorrow at 3 PM. What happens here is basically ESP32
12+
connects to WiFi and sends an API call and the server returns data in JSON
13+
format containing data about weather, then using the library ArduinoJson we
14+
extract only temperature per day from JSON data and show it on Inkplate 5.
15+
After displaying the weather, ESP32 goes to sleep and wakes up every DELAY_MS
16+
milliseconds to show new weather (you can change the time interval).
1217
1318
IMPORTANT:
1419
Make sure to change your desired city and wifi credentials below.

examples/Inkplate5/Projects/Inkplate5_Hourly_Weather_Station/Inkplate5_Hourly_Weather_Station.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
88
This example will show you how you can use Inkplate 5 to display API data,
99
e.g. OpenWeather public weather API for real time data. It shows the forecast
10-
weather for 4 hours.
10+
weather for 4 hours. What happens here is basically ESP32 connects to WiFi and
11+
sends an API call and the server returns data in JSON format containing data
12+
about weather, then using the library ArduinoJson we extract only temperature
13+
per hour from JSON data and show it on Inkplate 5. After displaying the weather,
14+
ESP32 goes to sleep and wakes up every DELAY_MS milliseconds to show new weather
15+
(you can change the time interval).
1116
1217
IMPORTANT:
1318
Make sure to change your desired city and wifi credentials below.

0 commit comments

Comments
 (0)