Skip to content

Commit 7b8de27

Browse files
committed
Added examples for Inkplate 6FLICK
1 parent 4a02213 commit 7b8de27

File tree

625 files changed

+181458
-39
lines changed

Some content is hidden

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

625 files changed

+181458
-39
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Inkplate6FLICK_Bluetooth_Peripheral_Mode example for Soldered Inkplate 6FLICK
3+
For this example you will need USB cable and an Inkplate 6FLICK
4+
Select "Soldered Inkplate 6FLICK" from Tools -> Board menu.
5+
Don't have "Soldered Inkplate 6FLICK" 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+
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()).
16+
17+
Want to learn more about Inkplate? Visit www.inkplate.io
18+
Looking to get support? Write on our forums: https://forum.soldered.com/
19+
18 March 2024 by Soldered
20+
*/
21+
22+
// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
23+
#ifndef ARDUINO_INKPLATE6FLICK
24+
#error "Wrong board selection for this example, please select Soldered Inkplate 6FLICK"
25+
#endif
26+
27+
// Include Inkplate and BluetoothSerial library to the sketch
28+
#include "BluetoothSerial.h"
29+
#include "Inkplate.h"
30+
31+
// Include peripheral functions
32+
#include "Peripheral.h"
33+
34+
// Create an object on Inkplate library and also set library into 1-bit mode (BW)
35+
Inkplate display(INKPLATE_1BIT);
36+
37+
// Create SerialBT object for Bluetooth communication
38+
BluetoothSerial SerialBT;
39+
40+
// Size of buffer for receiving commands
41+
#define BUFFER_SIZE 1000
42+
43+
// Temporary buffer to send to Peripheral mode code
44+
char commandBuffer[BUFFER_SIZE + 1];
45+
46+
void setup() // Initialize everything
47+
{
48+
// Init serial communication
49+
Serial.begin(115200);
50+
51+
// Init Inkplate library (you should call this function ONLY ONCE)
52+
53+
display.begin();
54+
55+
// Init BT communication
56+
if (!SerialBT.begin("Inkplate 6FLICK"))
57+
{
58+
Serial.println("An error occurred initializing Bluetooth");
59+
}
60+
else
61+
{
62+
Serial.println("The device started, now you can pair it with Bluetooth and send commands!");
63+
}
64+
}
65+
66+
void loop()
67+
{
68+
// When Bluetooth available save it and pass to Peripheral.h code
69+
while (SerialBT.available())
70+
{
71+
for (int i = 0; i < (BUFFER_SIZE - 1); i++)
72+
{
73+
commandBuffer[i] = commandBuffer[i + 1];
74+
}
75+
commandBuffer[BUFFER_SIZE - 1] = SerialBT.read();
76+
}
77+
78+
// Function in peripheral.h
79+
run(commandBuffer, BUFFER_SIZE, &display, &SerialBT);
80+
81+
// Wait a bit
82+
delay(50);
83+
}

0 commit comments

Comments
 (0)