Skip to content

Commit

Permalink
add display for sense tft
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jan 5, 2024
1 parent a6a8962 commit 0eead42
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ C_SRC += \
src/dfu_init.c \
src/flash_nrf5x.c \
src/main.c \
src/screen.c \
src/images.c \

# all files in boards
C_SRC += src/boards/boards.c
Expand Down Expand Up @@ -314,6 +316,7 @@ ifneq ($(USE_NFCT),yes)
endif

CFLAGS += -DSOFTDEVICE_PRESENT
CFLAGS += -DUF2_VERSION_BASE='"$(GIT_VERSION)"'
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'

Expand Down
42 changes: 19 additions & 23 deletions src/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ void board_teardown(void) {
//--------------------------------------------------------------------+
#ifdef DISPLAY_PIN_SCK

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

// Note don't use SPIM3 since it has lots of errata
NRF_SPIM_Type* _spim = NRF_SPIM0;

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

static inline void tft_cs(bool state) {
if (state) {
nrf_gpio_pin_set(DISPLAY_PIN_CS);
} else {
nrf_gpio_pin_clear(DISPLAY_PIN_CS);
}
nrf_gpio_pin_write(DISPLAY_PIN_CS, state);
}

static inline void tft_dc(bool state) {
if (state) {
nrf_gpio_pin_set(DISPLAY_PIN_DC);
} else {
nrf_gpio_pin_clear(DISPLAY_PIN_DC);
}
nrf_gpio_pin_write(DISPLAY_PIN_DC, state);
}

static void tft_cmd(uint8_t cmd, uint8_t const* data, size_t narg) {
Expand Down Expand Up @@ -250,17 +250,17 @@ void board_display_init(void) {
//------------- Display Init -------------//
nrf_gpio_cfg_output(DISPLAY_PIN_DC);

#if defined(DISPLAY_PIN_RST) && DISPLAY_PIN_RST >= 0
#if defined(DISPLAY_PIN_RST) && DISPLAY_PIN_RST >= 0
nrf_gpio_cfg_output(DISPLAY_PIN_RST);
nrf_gpio_pin_write(DISPLAY_PIN_RST, 0);
nrf_gpio_pin_clear(DISPLAY_PIN_RST);
NRFX_DELAY_MS(10);
nrf_gpio_pin_write(DISPLAY_PIN_RST, 1);
#endif
nrf_gpio_pin_set(DISPLAY_PIN_RST);
#endif

#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
nrf_gpio_cfg_output(DISPLAY_PIN_BL);
nrf_gpio_pin_write(DISPLAY_PIN_BL, DISPLAY_BL_ON);
#endif
#endif

tft_controller_init();
}
Expand Down Expand Up @@ -667,13 +667,9 @@ void neopixel_write (uint8_t *pixels) {
}
#endif

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

#ifdef DISPLAY_CONTROLLER_ST7789

Expand Down
28 changes: 27 additions & 1 deletion src/boards/feather_nrf52840_sense_tft/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@
#define BUTTON_2 _PINNUM(1, 10) // DFU pin
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP

//--------------------------------------------------------------------+
// Display
//--------------------------------------------------------------------+
#define DISPLAY_CONTROLLER_ST7789

#define DISPLAY_PIN_MOSI _PINNUM(0, 5)
#define DISPLAY_PIN_SCK _PINNUM(0, 26)

#define DISPLAY_PIN_CS _PINNUM(1, 5)
#define DISPLAY_PIN_DC _PINNUM(1, 1)
#define DISPLAY_PIN_RST _PINNUM(1, 3)
#define DISPLAY_PIN_BL _PINNUM(0, 27)
#define DISPLAY_BL_ON 1 // GPIO state to enable back light

#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 135

#define DISPLAY_COL_OFFSET 53
#define DISPLAY_ROW_OFFSET 40

// Memory Data Access Control & // Vertical Scroll Start Address
#define DISPLAY_MADCTL (TFT_MADCTL_MX)
#define DISPLAY_VSCSAD 0

#define DISPLAY_TITLE "Sense TFT"

//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
Expand All @@ -62,7 +88,7 @@

//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Sense TFT"
#define UF2_VOLUME_LABEL "FTHRSNSBOOT"
#define UF2_VOLUME_LABEL "SENSTFTBOOT"
#define UF2_BOARD_ID "nRF52840-FeatherSenseTFT-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/product/"

Expand Down

0 comments on commit 0eead42

Please sign in to comment.