Skip to content

Commit 2af58f0

Browse files
committed
Added some examples for Inkplate5
1 parent e84f314 commit 2af58f0

File tree

42 files changed

+5413
-838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5413
-838
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Inkplate5_Bluetooth_Peripheral_Mode example for Soldered Inkplate 5
3+
For this example you will need USB cable, Inkplate 5 and smartphone.
4+
Select "Soldered Inkplate5" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate5" option? Follow our tutorial and add it:
6+
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
7+
8+
This example shows how to use Inkplate as a peripheral device over Bluetooth.
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+
21 March 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_INKPLATE5
17+
#error "Wrong board selection for this example, please select Soldered Inkplate5 in the boards menu."
18+
#endif
19+
20+
// Include Inkplate and BluetoothSerial library to the sketch
21+
#include "Inkplate.h"
22+
#include "BluetoothSerial.h"
23+
24+
#include "Peripheral.h"
25+
26+
#define BUFFER_SIZE 1000
27+
28+
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)
29+
BluetoothSerial SerialBT; // Create SerialBT object for Bluetooth communication
30+
31+
// Temporary buffer to send to Peripheral mode code
32+
char commandBuffer[BUFFER_SIZE + 1];
33+
34+
void setup()
35+
{
36+
Serial.begin(115200); // Init serial communication for debugging
37+
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
38+
display.setTextSize(4); // Scale text to be 4 times bigger then original (5x7 px)
39+
40+
// Init BT communication
41+
if (!SerialBT.begin("Inkplate5"))
42+
{
43+
Serial.println("An error occurred initializing Bluetooth");
44+
display.println("An error occurred initializing Bluetooth");
45+
}
46+
else
47+
{
48+
display.println("The device started, now you can pair it with Bluetooth and send commands!");
49+
}
50+
51+
// Show a message on the screen
52+
display.display();
53+
}
54+
55+
void loop()
56+
{
57+
// When Bluetooth available save it and pass to Peripheral.h code
58+
while (SerialBT.available())
59+
{
60+
for (int i = 0; i < (BUFFER_SIZE - 1); i++)
61+
{
62+
commandBuffer[i] = commandBuffer[i + 1];
63+
}
64+
commandBuffer[BUFFER_SIZE - 1] = SerialBT.read();
65+
Serial.print(commandBuffer[BUFFER_SIZE - 1]);
66+
}
67+
68+
// Function in peripheral.h
69+
run(commandBuffer, BUFFER_SIZE);
70+
71+
// Wait a bit
72+
delay(50);
73+
}

0 commit comments

Comments
 (0)