Skip to content

Commit 3615893

Browse files
committed
rename pairing_display to pairing_passkey
1 parent e0cda21 commit 3615893

File tree

1 file changed

+61
-129
lines changed

1 file changed

+61
-129
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/pairing_display/pairing_display.ino renamed to libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino

Lines changed: 61 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
any redistribution
1313
*********************************************************************/
1414

15+
#if defined(ARDUINO_NRF52840_CIRCUITPLAY) || defined(ARDUINO_NRF52840_CLUE)
16+
#define USE_ARCADA
17+
#endif
18+
19+
#ifdef USE_ARCADA
20+
#include <Adafruit_Arcada.h>
21+
22+
Adafruit_Arcada arcada;
23+
Adafruit_SPITFT* tft;
24+
#endif
25+
1526
#include <SPI.h>
1627
#include <Adafruit_GFX.h>
1728
#include <bluefruit.h>
@@ -33,68 +44,11 @@
3344

3445
/* This sketch demonstrates the "Image Upload" feature of Bluefruit Mobile App.
3546
* Following TFT Display are supported
36-
* - TFT 3.5" : FeatherWing https://www.adafruit.com/product/3651
37-
* - TFT 2.4" : FeatherWing https://www.adafruit.com/product/3315
47+
* - Circuit Playground Bluefruit: https://www.adafruit.com/product/4333
3848
* - TFT Gizmo : https://www.adafruit.com/product/4367
3949
* - Adafruit CLUE : https://www.adafruit.com/product/4500
4050
*/
4151

42-
#define TFT_NO_DISPLAY 0
43-
#define TFT_GIZMO 1 // used with Circuit Playground Bluefruit
44-
#define TFT_CLUE 2 // CLUE's on-board display
45-
#define TFT_24_FEATHERWING 3
46-
#define TFT_35_FEATHERWING 4
47-
48-
49-
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
50-
// Circuit Playground Bluefruit use with TFT GIZMO
51-
#define TFT_IN_USE TFT_GIZMO
52-
#define DEVICE_NAME "CPLAY"
53-
54-
#include "Adafruit_ST7789.h"
55-
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI, 0, 1, -1); // CS = 0, DC = 1
56-
57-
#elif defined(ARDUINO_NRF52840_CLUE)
58-
// CLUE use on-board TFT
59-
#define TFT_IN_USE TFT_CLUE
60-
#define DEVICE_NAME "CLUE"
61-
62-
#include "Adafruit_ST7789.h"
63-
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST);
64-
65-
#else
66-
// [Configurable] For other boards please select which external display to match your hardware setup
67-
#define TFT_IN_USE TFT_24_FEATHERWING
68-
#define DEVICE_NAME "Feather"
69-
70-
#if defined(ARDUINO_NRF52832_FEATHER)
71-
// Feather nRF52832 pin map is different from others
72-
#define TFT_DC 11
73-
#define TFT_CS 31
74-
#else
75-
// Default for others
76-
#define TFT_DC 10
77-
#define TFT_CS 9
78-
#endif
79-
80-
#if TFT_IN_USE == TFT_35_FEATHERWING
81-
#include "Adafruit_HX8357.h"
82-
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC);
83-
84-
#elif TFT_IN_USE == TFT_24_FEATHERWING
85-
#include <Adafruit_ILI9341.h>
86-
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
87-
#endif // TFT
88-
89-
#endif // board variants
90-
91-
92-
#define COLOR_WHITE 0xFFFF
93-
#define COLOR_BLACK 0x0000
94-
#define COLOR_YELLOW 0xFFE0
95-
#define COLOR_GREEN 0x07E0
96-
#define COLOR_RED 0xF800
97-
9852
// BLE Service
9953
BLEUart bleuart; // uart over ble
10054

@@ -105,35 +59,14 @@ void setup()
10559
Serial.println("Bluefruit52 Pairing Display Example");
10660
Serial.println("-----------------------------------\n");
10761

108-
#if TFT_IN_USE == TFT_CLUE
109-
tft.init(240, 240);
110-
tft.setRotation(1);
111-
112-
// Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
113-
uint8_t rtna = 0x01;
114-
tft.sendCommand(0xC6, &rtna, 1);;
115-
116-
// turn back light on
117-
uint8_t backlight = PIN_TFT_LITE;
118-
pinMode(backlight, OUTPUT);
119-
digitalWrite(backlight, HIGH);
120-
121-
#elif TFT_IN_USE == TFT_GIZMO
122-
tft.init(240, 240);
123-
tft.setRotation(2);
124-
125-
// turn back light on
126-
uint8_t backlight = A3;
127-
pinMode(backlight, OUTPUT);
128-
digitalWrite(backlight, HIGH);
129-
130-
#elif TFT_IN_USE != TFT_NO_DISPLAY
131-
tft.begin();
132-
133-
#endif // TFT
62+
arcada.arcadaBegin();
63+
arcada.displayBegin();
64+
arcada.setBacklight(255);
13465

135-
pinMode(PIN_BUTTON1, INPUT_PULLUP);
136-
pinMode(PIN_BUTTON2, INPUT_PULLUP);
66+
tft = arcada.display;
67+
tft->setCursor(0, 0);
68+
tft->setTextWrap(true);
69+
tft->setTextSize(2);
13770

13871
// Setup the BLE LED to be enabled on CONNECT
13972
// Note: This is actually the default behavior, but provided
@@ -147,7 +80,6 @@ void setup()
14780

14881
Bluefruit.begin();
14982
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
150-
Bluefruit.setName(DEVICE_NAME);
15183

15284
// clear bonds if BUTTON A is pressed
15385
Serial.println("Hold button A to clear bonds ..... ");
@@ -182,12 +114,12 @@ void setup()
182114
bleuart.setPermission(SECMODE_ENC_WITH_MITM);
183115
bleuart.begin();
184116

185-
#if TFT_IN_USE != TFT_NO_DISPLAY
186-
tft.fillScreen(COLOR_BLACK);
187-
tft.setTextColor(COLOR_WHITE);
188-
tft.setTextSize(2);
189-
tft.setCursor(0, 0);
190-
tft.print("Advertising...");
117+
#ifdef USE_ARCADA
118+
tft->fillScreen(ARCADA_BLACK);
119+
tft->setTextColor(ARCADA_WHITE);
120+
tft->setTextSize(2);
121+
tft->setCursor(0, 0);
122+
tft->print("Advertising...");
191123
#endif
192124

193125
Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode");
@@ -261,11 +193,11 @@ void connect_callback(uint16_t conn_handle)
261193
Serial.print("Connected to ");
262194
Serial.println(central_name);
263195

264-
#if TFT_IN_USE != TFT_NO_DISPLAY
265-
tft.fillScreen(COLOR_BLACK);
266-
tft.setTextSize(2);
267-
tft.setCursor(0, 0);
268-
tft.println("Connected");
196+
#ifdef USE_ARCADA
197+
tft->fillScreen(ARCADA_BLACK);
198+
tft->setTextSize(2);
199+
tft->setCursor(0, 0);
200+
tft->println("Connected");
269201
#endif
270202
}
271203

@@ -279,15 +211,15 @@ bool pairing_passkey_callback(uint16_t conn_handle, uint8_t const passkey[6], bo
279211
Serial.println("Pairing Passkey");
280212
Serial.printf(" %.3s %.3s\n", passkey, passkey+3);
281213

282-
#if TFT_IN_USE != TFT_NO_DISPLAY
283-
tft.fillScreen(COLOR_BLACK);
284-
tft.println("Pairing Passkey\n");
285-
tft.setTextColor(COLOR_YELLOW);
286-
tft.setTextSize(4);
287-
tft.printf(" %.3s %.3s\n", passkey, passkey+3);
214+
#ifdef USE_ARCADA
215+
tft->fillScreen(ARCADA_BLACK);
216+
tft->println("Pairing Passkey\n");
217+
tft->setTextColor(ARCADA_YELLOW);
218+
tft->setTextSize(4);
219+
tft->printf(" %.3s %.3s\n", passkey, passkey+3);
288220

289-
tft.setTextColor(COLOR_WHITE);
290-
tft.setTextSize(2);
221+
tft->setTextColor(ARCADA_WHITE);
222+
tft->setTextSize(2);
291223
#endif
292224

293225

@@ -296,18 +228,18 @@ bool pairing_passkey_callback(uint16_t conn_handle, uint8_t const passkey[6], bo
296228
Serial.println("Do you want to pair");
297229
Serial.println("Press Button A to accept, Button B to reject");
298230

299-
#if TFT_IN_USE != TFT_NO_DISPLAY
300-
tft.println("\nDo you accept ?\n\n");
231+
#ifdef USE_ARCADA
232+
tft->println("\nDo you accept ?\n\n");
301233

302-
tft.setTextSize(3);
303-
tft.setTextColor(COLOR_GREEN);
304-
tft.print("<< Yes");
305-
tft.setTextColor(COLOR_RED);
306-
tft.println(" No >>");
234+
tft->setTextSize(3);
235+
tft->setTextColor(ARCADA_GREEN);
236+
tft->print("<< Yes");
237+
tft->setTextColor(ARCADA_RED);
238+
tft->println(" No >>");
307239

308-
tft.setTextColor(COLOR_WHITE);
309-
tft.setTextSize(2);
310-
tft.println();
240+
tft->setTextColor(ARCADA_WHITE);
241+
tft->setTextSize(2);
242+
tft->println();
311243
#endif
312244

313245
// wait until either button is pressed
@@ -343,30 +275,30 @@ void pairing_complete_callback(uint16_t conn_handle, uint8_t auth_status)
343275
Serial.println("Failed");
344276
}
345277

346-
#if TFT_IN_USE != TFT_NO_DISPLAY
278+
#ifdef USE_ARCADA
347279
if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS)
348280
{
349-
tft.setTextColor(COLOR_GREEN);
350-
tft.println("Succeeded");
281+
tft->setTextColor(ARCADA_GREEN);
282+
tft->println("Succeeded");
351283
}else
352284
{
353-
tft.setTextColor(COLOR_RED);
354-
tft.println("Failed");
285+
tft->setTextColor(ARCADA_RED);
286+
tft->println("Failed");
355287
}
356288

357-
tft.setTextColor(COLOR_WHITE);
358-
tft.setTextSize(2);
289+
tft->setTextColor(ARCADA_WHITE);
290+
tft->setTextSize(2);
359291
#endif
360292
}
361293

362294
void connection_secured_callback(uint16_t conn_handle)
363295
{
364296
Serial.println("Secured");
365297

366-
#if TFT_IN_USE != TFT_NO_DISPLAY
367-
tft.setTextColor(COLOR_YELLOW);
368-
tft.println("secured");
369-
tft.setTextColor(COLOR_WHITE);
298+
#ifdef USE_ARCADA
299+
tft->setTextColor(ARCADA_YELLOW);
300+
tft->println("secured");
301+
tft->setTextColor(ARCADA_WHITE);
370302
#endif
371303
}
372304

@@ -383,7 +315,7 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
383315
Serial.println();
384316
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
385317

386-
#if TFT_IN_USE != TFT_NO_DISPLAY
387-
tft.println("Advertising ...");
318+
#ifdef USE_ARCADA
319+
tft->println("Advertising ...");
388320
#endif
389321
}

0 commit comments

Comments
 (0)