Skip to content

Commit 0eead42

Browse files
committed
add display for sense tft
1 parent a6a8962 commit 0eead42

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ C_SRC += \
139139
src/dfu_init.c \
140140
src/flash_nrf5x.c \
141141
src/main.c \
142+
src/screen.c \
143+
src/images.c \
142144

143145
# all files in boards
144146
C_SRC += src/boards/boards.c
@@ -314,6 +316,7 @@ ifneq ($(USE_NFCT),yes)
314316
endif
315317

316318
CFLAGS += -DSOFTDEVICE_PRESENT
319+
CFLAGS += -DUF2_VERSION_BASE='"$(GIT_VERSION)"'
317320
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
318321
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
319322

src/boards/boards.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ void board_teardown(void) {
181181
//--------------------------------------------------------------------+
182182
#ifdef DISPLAY_PIN_SCK
183183

184+
#define TFT_MADCTL_MY 0x80 ///< Page addr order: Bottom to top
185+
#define TFT_MADCTL_MX 0x40 ///< Column addr order: Right to left
186+
#define TFT_MADCTL_MV 0x20 ///< Page/Column order: Reverse Mode ( X <-> Y )
187+
#define TFT_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
188+
#define TFT_MADCTL_MH 0x04 ///< LCD refresh right to left
189+
#define TFT_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
190+
#define TFT_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
191+
184192
// Note don't use SPIM3 since it has lots of errata
185193
NRF_SPIM_Type* _spim = NRF_SPIM0;
186194

@@ -199,19 +207,11 @@ static void spi_write(NRF_SPIM_Type *p_spim, uint8_t const *tx_buf, size_t tx_le
199207
static void tft_controller_init(void);
200208

201209
static inline void tft_cs(bool state) {
202-
if (state) {
203-
nrf_gpio_pin_set(DISPLAY_PIN_CS);
204-
} else {
205-
nrf_gpio_pin_clear(DISPLAY_PIN_CS);
206-
}
210+
nrf_gpio_pin_write(DISPLAY_PIN_CS, state);
207211
}
208212

209213
static inline void tft_dc(bool state) {
210-
if (state) {
211-
nrf_gpio_pin_set(DISPLAY_PIN_DC);
212-
} else {
213-
nrf_gpio_pin_clear(DISPLAY_PIN_DC);
214-
}
214+
nrf_gpio_pin_write(DISPLAY_PIN_DC, state);
215215
}
216216

217217
static void tft_cmd(uint8_t cmd, uint8_t const* data, size_t narg) {
@@ -250,17 +250,17 @@ void board_display_init(void) {
250250
//------------- Display Init -------------//
251251
nrf_gpio_cfg_output(DISPLAY_PIN_DC);
252252

253-
#if defined(DISPLAY_PIN_RST) && DISPLAY_PIN_RST >= 0
253+
#if defined(DISPLAY_PIN_RST) && DISPLAY_PIN_RST >= 0
254254
nrf_gpio_cfg_output(DISPLAY_PIN_RST);
255-
nrf_gpio_pin_write(DISPLAY_PIN_RST, 0);
255+
nrf_gpio_pin_clear(DISPLAY_PIN_RST);
256256
NRFX_DELAY_MS(10);
257-
nrf_gpio_pin_write(DISPLAY_PIN_RST, 1);
258-
#endif
257+
nrf_gpio_pin_set(DISPLAY_PIN_RST);
258+
#endif
259259

260-
#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
260+
#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
261261
nrf_gpio_cfg_output(DISPLAY_PIN_BL);
262262
nrf_gpio_pin_write(DISPLAY_PIN_BL, DISPLAY_BL_ON);
263-
#endif
263+
#endif
264264

265265
tft_controller_init();
266266
}
@@ -667,13 +667,9 @@ void neopixel_write (uint8_t *pixels) {
667667
}
668668
#endif
669669

670-
#define TFT_MADCTL_MY 0x80 ///< Page addr order: Bottom to top
671-
#define TFT_MADCTL_MX 0x40 ///< Column addr order: Right to left
672-
#define TFT_MADCTL_MV 0x20 ///< Page/Column order: Reverse Mode ( X <-> Y )
673-
#define TFT_MADCTL_ML 0x10 ///< LCD refresh Bottom to top
674-
#define TFT_MADCTL_MH 0x04 ///< LCD refresh right to left
675-
#define TFT_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
676-
#define TFT_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
670+
//--------------------------------------------------------------------+
671+
// Display controller
672+
//--------------------------------------------------------------------+
677673

678674
#ifdef DISPLAY_CONTROLLER_ST7789
679675

src/boards/feather_nrf52840_sense_tft/board.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@
4747
#define BUTTON_2 _PINNUM(1, 10) // DFU pin
4848
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
4949

50+
//--------------------------------------------------------------------+
51+
// Display
52+
//--------------------------------------------------------------------+
53+
#define DISPLAY_CONTROLLER_ST7789
54+
55+
#define DISPLAY_PIN_MOSI _PINNUM(0, 5)
56+
#define DISPLAY_PIN_SCK _PINNUM(0, 26)
57+
58+
#define DISPLAY_PIN_CS _PINNUM(1, 5)
59+
#define DISPLAY_PIN_DC _PINNUM(1, 1)
60+
#define DISPLAY_PIN_RST _PINNUM(1, 3)
61+
#define DISPLAY_PIN_BL _PINNUM(0, 27)
62+
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
63+
64+
#define DISPLAY_WIDTH 240
65+
#define DISPLAY_HEIGHT 135
66+
67+
#define DISPLAY_COL_OFFSET 53
68+
#define DISPLAY_ROW_OFFSET 40
69+
70+
// Memory Data Access Control & // Vertical Scroll Start Address
71+
#define DISPLAY_MADCTL (TFT_MADCTL_MX)
72+
#define DISPLAY_VSCSAD 0
73+
74+
#define DISPLAY_TITLE "Sense TFT"
75+
5076
//--------------------------------------------------------------------+
5177
// BLE OTA
5278
//--------------------------------------------------------------------+
@@ -62,7 +88,7 @@
6288

6389
//------------- UF2 -------------//
6490
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense TFT"
65-
#define UF2_VOLUME_LABEL "FTHRSNSBOOT"
91+
#define UF2_VOLUME_LABEL "SENSTFTBOOT"
6692
#define UF2_BOARD_ID "nRF52840-FeatherSenseTFT-revA"
6793
#define UF2_INDEX_URL "https://www.adafruit.com/product/"
6894

0 commit comments

Comments
 (0)