Skip to content

Commit 28fe0ac

Browse files
committed
add clue support to image_upload example
1 parent 05dd24c commit 28fe0ac

File tree

1 file changed

+55
-42
lines changed

1 file changed

+55
-42
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,55 @@
1818

1919
/* This sketch demonstrates the "Image Upload" feature of Bluefruit Mobile App.
2020
* Following TFT Display are supported
21-
* - https://www.adafruit.com/product/3315
22-
* - https://www.adafruit.com/product/3651
23-
* - https://www.adafruit.com/product/4367
21+
* - TFT 3.5" : FeatherWing https://www.adafruit.com/product/3651
22+
* - TFT 2.4" : FeatherWing https://www.adafruit.com/product/3315
23+
* - TFT Gizmo : https://www.adafruit.com/product/4367
24+
* - Adafruit CLUE : https://www.adafruit.com/product/4500
2425
*/
2526

26-
#define TFT_35_FEATHERWING 1
27-
#define TFT_24_FEATHERWING 2
28-
#define TFT_GIZMO 3
2927

30-
// [Configurable] Please select one of above supported Display to match your hardware setup
31-
#define TFT_IN_USE TFT_35_FEATHERWING
32-
33-
34-
#if defined(ARDUINO_NRF52832_FEATHER)
35-
// Feather nRF52832
36-
#define TFT_DC 11
37-
#define TFT_CS 31
38-
39-
#elif defined(ARDUINO_NRF52840_CIRCUITPLAY)
40-
// Circuit Playground Bluefruit for use with TFT 1.5" GIZMO
41-
#define TFT_DC 1
42-
#define TFT_CS 0
28+
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
29+
// Circuit Playground Bluefruit use with TFT GIZMO
4330
#define TFT_BACKLIGHT A3
4431

45-
#else
46-
// Default for others
47-
#define TFT_DC 10
48-
#define TFT_CS 9
49-
#endif
50-
32+
#include "Adafruit_ST7789.h"
33+
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI, 0, 1, -1); // CS = 0, DC = 1
5134

52-
#if TFT_IN_USE == TFT_35_FEATHERWING
53-
#include "Adafruit_HX8357.h"
54-
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC);
55-
56-
#elif TFT_IN_USE == TFT_24_FEATHERWING
57-
#include <Adafruit_ILI9341.h>
58-
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
59-
60-
#elif TFT_IN_USE == TFT_GIZMO
35+
#elif defined(ARDUINO_NRF52840_CLUE)
36+
// CLUE use on-board TFT
6137
#include "Adafruit_ST7789.h"
62-
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI, TFT_CS, TFT_DC, -1);
63-
64-
#else
65-
#error "TFT display is not supported"
66-
#endif
38+
Adafruit_ST7789 tft = Adafruit_ST7789(&SPI1, 31, 32, 33); // CS = 31, DC = 32, RST = 33
6739

40+
#else
41+
#define TFT_35_FEATHERWING 1
42+
#define TFT_24_FEATHERWING 2
43+
44+
// [Configurable] For other boards please select which external display to match your hardware setup
45+
#define TFT_IN_USE TFT_35_FEATHERWING
46+
47+
#if defined(ARDUINO_NRF52832_FEATHER)
48+
// Feather nRF52832 pin map is different from others
49+
#define TFT_DC 11
50+
#define TFT_CS 31
51+
#else
52+
// Default for others
53+
#define TFT_DC 10
54+
#define TFT_CS 9
55+
#endif // 832
56+
57+
#if TFT_IN_USE == TFT_35_FEATHERWING
58+
#include "Adafruit_HX8357.h"
59+
Adafruit_HX8357 tft = Adafruit_HX8357(TFT_CS, TFT_DC);
60+
#elif TFT_IN_USE == TFT_24_FEATHERWING
61+
#include <Adafruit_ILI9341.h>
62+
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
63+
#else
64+
#error "TFT display is not supported"
65+
#endif // TFT
66+
67+
#endif // board variants
68+
69+
// Universal color
6870
#define COLOR_WHITE 0xFFFF
6971
#define COLOR_BLACK 0x0000
7072
#define COLOR_YELLOW 0xFFE0
@@ -110,11 +112,22 @@ void setup()
110112
{
111113
Serial.begin(115200);
112114

113-
#if TFT_IN_USE == TFT_GIZMO
115+
#if defined(ARDUINO_NRF52840_CIRCUITPLAY)
114116
tft.init(240, 240);
115117
tft.setRotation(2);
116-
pinMode(TFT_BACKLIGHT, OUTPUT);
117-
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
118+
119+
// turn backlight on
120+
uint8_t backlight = A3;
121+
pinMode(backlight, OUTPUT);
122+
digitalWrite(backlight, HIGH);
123+
124+
#elif defined(ARDUINO_NRF52840_CLUE)
125+
tft.init(240, 240);
126+
tft.setRotation(1);
127+
128+
// Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
129+
uint8_t rtna = 0x01;
130+
tft.sendCommand(0xC6, &rtna, 1);;
118131

119132
#else
120133
tft.begin();

0 commit comments

Comments
 (0)