Skip to content

Commit

Permalink
- add slash screen for CLUE
Browse files Browse the repository at this point in the history
- optimize ST77XX_SWRESET, skip if reset pin is available.
  • Loading branch information
hathach committed Jan 5, 2024
1 parent ed9bf7a commit 3d920bf
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 11 deletions.
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.17)
find_package(Python COMPONENTS Interpreter)

if (NOT DEFINED BOARD)
message(FATAL_ERROR "BOARD is not defined")
Expand Down Expand Up @@ -30,6 +31,9 @@ set(SDK ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components)
set(SOFTDEVICE ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice)
set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)

set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)

#-------------------
# Bootloader
#-------------------
Expand Down Expand Up @@ -301,6 +305,8 @@ add_custom_command(TARGET bootloader POST_BUILD
add_custom_command(TARGET bootloader POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.hex
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/tools/hexmerge.py --overlap=replace -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex $<TARGET_FILE_DIR:bootloader>/bootloader.hex ${MBR_HEX}
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} -c -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2 $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex
VERBATIM)

#----------------------------------
Expand All @@ -311,11 +317,16 @@ if (NOT DEFINED NRFJPROG)
set(NRFJPROG nrfjprog)
endif()

add_custom_target(flash
add_custom_target(flash-jlink
DEPENDS bootloader
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
)

add_custom_target(flash-uf2
DEPENDS bootloader
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} --deploy $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2
)

add_custom_target(flash-sd
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52 --reset
)
Expand Down
24 changes: 15 additions & 9 deletions src/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void board_display_init(void) {
nrf_gpio_pin_clear(DISPLAY_PIN_RST);
NRFX_DELAY_MS(10);
nrf_gpio_pin_set(DISPLAY_PIN_RST);
NRFX_DELAY_MS(20);
#endif

#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
Expand Down Expand Up @@ -698,6 +699,7 @@ void neopixel_write (uint8_t *pixels) {
#define ST77XX_TEOFF 0x34
#define ST77XX_TEON 0x35
#define ST77XX_MADCTL 0x36
#define ST77XX_VSCSAD 0x37
#define ST77XX_COLMOD 0x3A

#define ST77XX_MADCTL_MY 0x80
Expand Down Expand Up @@ -725,23 +727,27 @@ void neopixel_write (uint8_t *pixels) {
static void tft_controller_init(void) {
// Init commands for 7789 screens
uint8_t cmdinit_st7789[] = {
// 1: Software reset, no args, w/delay ~150 ms delay
#if !defined(DISPLAY_PIN_RST) || (DISPLAY_PIN_RST < 0)
// Software reset if rst pin not available, no args, w/delay ~150 ms delay
ST77XX_SWRESET, ST_CMD_DELAY, 150,
// 2: Out of sleep mode, no args, w/delay 10 ms delay
#endif
// Out of sleep mode, no args, w/delay 10 ms delay
ST77XX_SLPOUT, ST_CMD_DELAY, 10,
// 3: Set color mode, 1 arg + delay: 16-bit color, 10 ms delay
// Set color mode, 1 arg + delay: 16-bit color, 10 ms delay
ST77XX_COLMOD, 1 + ST_CMD_DELAY, 0x55, 10,
// 4: Mem access ctrl (directions), 1 arg: Row/col addr, bottom-top refresh
// Mem access ctrl (directions), 1 arg: Row/col addr, bottom-top refresh
ST77XX_MADCTL, 1, DISPLAY_MADCTL,
// 5: Column addr set, 4 args, no delay: XSTART = 0, XEND = 240
// Vertical Scroll Start Address of RAM
// ST77XX_VSCSAD, 2, DISPLAY_VSCSAD >> 8, DISPLAY_VSCSAD & 0xFF,
// Column addr set, 4 args, no delay: XSTART = 0, XEND = 240
ST77XX_CASET, 4, 0x00, 0, 0, 240,
// 6: Row addr set, 4 args, no delay: YSTART = 0 YEND = 320
// Row addr set, 4 args, no delay: YSTART = 0 YEND = 320
ST77XX_RASET, 4, 0x00, 0, 320 >> 8, 320 & 0xFF,
// 7: hack
// Inversion on
ST77XX_INVON, ST_CMD_DELAY, 10,
// 8: Normal display on, no args, w/delay 10 ms delay
// Normal display on, no args, w/delay 10 ms delay
ST77XX_NORON, ST_CMD_DELAY, 10,
// 9: Main screen turn on, no args, delay 10 ms delay
// Main screen turn on, no args, delay 10 ms delay
ST77XX_DISPON, ST_CMD_DELAY, 10
};

Expand Down
1 change: 1 addition & 0 deletions src/boards/circuitplayground_nrf52840/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
1 change: 1 addition & 0 deletions src/boards/clue_nrf52840/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(MCU_VARIANT nrf52840)
26 changes: 26 additions & 0 deletions src/boards/clue_nrf52840/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@
#define BUTTON_2 _PINNUM(1, 10) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP

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

#define DISPLAY_PIN_SCK _PINNUM(0, 14)
#define DISPLAY_PIN_MOSI _PINNUM(0, 15)

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

#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 240

#define DISPLAY_COL_OFFSET 0
#define DISPLAY_ROW_OFFSET 80

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

#define DISPLAY_TITLE "CLUE"

//--------------------------------------------------------------------+
// BLE OTA
//--------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion src/boards/feather_nrf52840_sense_tft/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
//--------------------------------------------------------------------+
#define DISPLAY_CONTROLLER_ST7789

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

#define DISPLAY_PIN_CS _PINNUM(1, 5)
#define DISPLAY_PIN_DC _PINNUM(1, 1)
Expand Down

0 comments on commit 3d920bf

Please sign in to comment.