|
18 | 18 |
|
19 | 19 | /* This sketch demonstrates the "Image Upload" feature of Bluefruit Mobile App. |
20 | 20 | * 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 |
24 | 25 | */ |
25 | 26 |
|
26 | | -#define TFT_35_FEATHERWING 1 |
27 | | -#define TFT_24_FEATHERWING 2 |
28 | | -#define TFT_GIZMO 3 |
29 | 27 |
|
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 |
43 | 30 | #define TFT_BACKLIGHT A3 |
44 | 31 |
|
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 |
51 | 34 |
|
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 |
61 | 37 | #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 |
67 | 39 |
|
| 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 |
68 | 70 | #define COLOR_WHITE 0xFFFF |
69 | 71 | #define COLOR_BLACK 0x0000 |
70 | 72 | #define COLOR_YELLOW 0xFFE0 |
@@ -110,11 +112,22 @@ void setup() |
110 | 112 | { |
111 | 113 | Serial.begin(115200); |
112 | 114 |
|
113 | | -#if TFT_IN_USE == TFT_GIZMO |
| 115 | +#if defined(ARDUINO_NRF52840_CIRCUITPLAY) |
114 | 116 | tft.init(240, 240); |
115 | 117 | 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);; |
118 | 131 |
|
119 | 132 | #else |
120 | 133 | tft.begin(); |
|
0 commit comments