Skip to content

Commit 539fe96

Browse files
committed
Update some examples and add Factory programming example
1 parent f5a9840 commit 539fe96

File tree

77 files changed

+4533
-24282
lines changed

Some content is hidden

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

77 files changed

+4533
-24282
lines changed

examples/Inkplate10/Advanced/Communications/Inkplate10_Bluetooth_Peripheral_Mode/Inkplate10_Bluetooth_Peripheral_Mode.ino

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,78 @@
66
https://soldered.com/learn/add-inkplate-6-board-definition-to-arduino-ide/
77
88
This example shows how to use Inkplate as a peripheral device over Bluetooth.
9-
Note: for this to work you need to use ESP32 Wroover Board definition, as ours currently has a bug :(
9+
More about peripheral mode: https://inkplate.readthedocs.io/en/latest/peripheral-mode.html
10+
11+
Upload this example to the Inkplate and connect your phone to it via Bluetooth.
12+
First, you have to pair the Inkplate with your phone in Bluetooth settings in your phone, then go to the
13+
Serial Bluetooth Terminal app and you can find the Inkplate in the device list. You can use another similar app.
14+
If Bluetooth starts successfully, you can send commands from your phone. Don't forget you need to send #L(1)* after
15+
each command to show it on the display (equal to display->display()).
1016
1117
Want to learn more about Inkplate? Visit www.inkplate.io
1218
Looking to get support? Write on our forums: https://forum.soldered.com/
13-
15 July 2020 by Soldered
19+
28 March 2023 by Soldered
1420
*/
1521

1622
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
1723
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
18-
#error "Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
24+
#error \
25+
"Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
1926
#endif
2027

21-
#include "Inkplate.h"
22-
28+
// Include Inkplate and BluetoothSerial library to the sketch
2329
#include "BluetoothSerial.h"
30+
#include "Inkplate.h"
2431

25-
#define BUFFER_SIZE 1000
26-
32+
// Include peripheral functions
2733
#include "Peripheral.h"
2834

29-
// Declare Inkplate and SerialBluetooth objects
35+
// Create an object on Inkplate library and also set library into 1-bit mode (BW)
3036
Inkplate display(INKPLATE_1BIT);
37+
38+
// Create SerialBT object for Bluetooth communication
3139
BluetoothSerial SerialBT;
3240

41+
// Size of buffer for receiving commands
42+
#define BUFFER_SIZE 1000
43+
3344
// Temporary buffer to send to Peripheral mode code
3445
char commandBuffer[BUFFER_SIZE + 1];
3546

3647
void setup() // Initialize everything
3748
{
49+
// Init serial communication
3850
Serial.begin(115200);
3951

40-
if (!SerialBT.begin("ESP32"))
52+
// Init Inkplate library (you should call this function ONLY ONCE)
53+
display.begin();
54+
55+
// Init BT communication
56+
if (!SerialBT.begin("Inkplate10"))
4157
{
4258
Serial.println("An error occurred initializing Bluetooth");
4359
}
44-
45-
display.begin();
60+
else
61+
{
62+
Serial.println("The device started, now you can pair it with Bluetooth and send commands!");
63+
}
4664
}
4765

4866
void loop()
4967
{
50-
while (SerialBT.available()) // When Bluetooth available save it and pass to Peripheral.h code
68+
// When Bluetooth available save it and pass to Peripheral.h code
69+
while (SerialBT.available())
5170
{
5271
for (int i = 0; i < (BUFFER_SIZE - 1); i++)
5372
{
5473
commandBuffer[i] = commandBuffer[i + 1];
5574
}
5675
commandBuffer[BUFFER_SIZE - 1] = SerialBT.read();
57-
Serial.print(commandBuffer[BUFFER_SIZE - 1]);
5876
}
5977

6078
// Function in peripheral.h
61-
run(commandBuffer, BUFFER_SIZE);
79+
run(commandBuffer, BUFFER_SIZE, &display, &SerialBT);
6280

81+
// Wait a bit
6382
delay(50);
6483
}

0 commit comments

Comments
 (0)