1+ /* *
2+ **************************************************
3+ *
4+ * @file BluetoothSerial.ino
5+ * @brief Example showing how to use Bluetooth Serial on Inkplate 6FLICK
6+ * with an LVGL-based UI that safely renders incoming text.
7+ *
8+ * HOW TO USE
9+ * - Upload this example to Inkplate 6FLICK.
10+ * - Pair your phone with the device in Bluetooth settings (device name: "Inkplate 6FLICK").
11+ * - Open a Serial Bluetooth Terminal app (or similar) and connect to "Inkplate 6FLICK".
12+ * - Anything you type in the app will be shown on the serial monitor.
13+ * - Anything you type in the Arduino Serial Monitor will be sent to the phone.
14+ *
15+ *
16+ * For info on how to quickly get started with Inkplate 6FLICK visit
17+ * https://soldered.com/documentation/inkplate/6flick/overview/
18+ *
19+ * @authors Soldered
20+ * @date November 2025
21+ ***************************************************/
22+
23+
24+ #include < Inkplate-LVGL.h>
25+ #include " BluetoothSerial.h"
26+
27+ Inkplate inkplate (INKPLATE_1BIT); // Inkplate LVGL display instance
28+ BluetoothSerial SerialBT; // Bluetooth Serial object
29+
30+ const char *btDeviceName = " Inkplate 6FLICK" ; // Bluetooth device name
31+
32+ // Forward declaration
33+ void setLabelText (lv_obj_t *label, const char *text);
34+
35+ void setup ()
36+ {
37+ Serial.begin (115200 );
38+
39+ // Initialize Inkplate in FULL render mode (for LVGL)
40+ inkplate.begin (LV_DISP_RENDER_MODE_FULL);
41+
42+ // Set white background
43+ lv_obj_set_style_bg_color (lv_screen_active (), lv_color_hex (0xFFFFFF ), LV_PART_MAIN);
44+
45+ // Create centered LVGL label
46+ lv_obj_t *label = lv_label_create (lv_screen_active ());
47+ lv_obj_set_style_text_color (label, lv_color_hex (0x000000 ), LV_PART_MAIN);
48+ lv_obj_set_style_text_font (label, &lv_font_montserrat_28, 0 );
49+ lv_obj_align (label, LV_ALIGN_CENTER, 0 , 0 );
50+
51+ // Initial startup message
52+ Serial.println (" Initializing Bluetooth..." );
53+
54+ // Attempt to start Bluetooth
55+ if (!SerialBT.begin (btDeviceName))
56+ {
57+ setLabelText (label, " Error initializing Bluetooth!" );
58+ }
59+ else
60+ {
61+ // Success message
62+ setLabelText (label,
63+ " Bluetooth Serial\n\n "
64+ " Device: Inkplate 6FLICK\n\n "
65+ " Pair your phone and connect\n "
66+ " using a Serial Bluetooth app.\n\n "
67+ " Baud: 115200" );
68+ }
69+
70+ // Render the LVGL content
71+ lv_tick_inc (50 );
72+ lv_timer_handler ();
73+ inkplate.display ();
74+ }
75+
76+ void loop ()
77+ {
78+ // Forward data from USB Serial → Bluetooth
79+ if (Serial.available ())
80+ {
81+ while (Serial.available ())
82+ {
83+ SerialBT.write (Serial.read ());
84+ }
85+ }
86+
87+ // Forward data from Bluetooth → USB Serial
88+ if (SerialBT.available ())
89+ {
90+ while (SerialBT.available ())
91+ {
92+ Serial.write (SerialBT.read ());
93+ }
94+ }
95+
96+ delay (20 );
97+ }
98+
99+
100+ // update LVGL label text and refresh display
101+ void setLabelText (lv_obj_t *label, const char *text)
102+ {
103+ lv_label_set_text (label, text);
104+ lv_obj_align (label, LV_ALIGN_CENTER, 0 , 0 );
105+
106+ lv_tick_inc (50 );
107+ lv_timer_handler ();
108+ inkplate.display ();
109+ }
0 commit comments