Skip to content

Commit 3d920bf

Browse files
committed
- add slash screen for CLUE
- optimize ST77XX_SWRESET, skip if reset pin is available.
1 parent ed9bf7a commit 3d920bf

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.17)
2+
find_package(Python COMPONENTS Interpreter)
23

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

34+
set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
35+
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)
36+
3337
#-------------------
3438
# Bootloader
3539
#-------------------
@@ -301,6 +305,8 @@ add_custom_command(TARGET bootloader POST_BUILD
301305
add_custom_command(TARGET bootloader POST_BUILD
302306
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
303307
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.hex
308+
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}
309+
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
304310
VERBATIM)
305311

306312
#----------------------------------
@@ -311,11 +317,16 @@ if (NOT DEFINED NRFJPROG)
311317
set(NRFJPROG nrfjprog)
312318
endif()
313319

314-
add_custom_target(flash
320+
add_custom_target(flash-jlink
315321
DEPENDS bootloader
316322
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
317323
)
318324

325+
add_custom_target(flash-uf2
326+
DEPENDS bootloader
327+
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} --deploy $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2
328+
)
329+
319330
add_custom_target(flash-sd
320331
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52 --reset
321332
)

src/boards/boards.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void board_display_init(void) {
255255
nrf_gpio_pin_clear(DISPLAY_PIN_RST);
256256
NRFX_DELAY_MS(10);
257257
nrf_gpio_pin_set(DISPLAY_PIN_RST);
258+
NRFX_DELAY_MS(20);
258259
#endif
259260

260261
#if defined(DISPLAY_PIN_BL) && DISPLAY_PIN_BL >= 0
@@ -698,6 +699,7 @@ void neopixel_write (uint8_t *pixels) {
698699
#define ST77XX_TEOFF 0x34
699700
#define ST77XX_TEON 0x35
700701
#define ST77XX_MADCTL 0x36
702+
#define ST77XX_VSCSAD 0x37
701703
#define ST77XX_COLMOD 0x3A
702704

703705
#define ST77XX_MADCTL_MY 0x80
@@ -725,23 +727,27 @@ void neopixel_write (uint8_t *pixels) {
725727
static void tft_controller_init(void) {
726728
// Init commands for 7789 screens
727729
uint8_t cmdinit_st7789[] = {
728-
// 1: Software reset, no args, w/delay ~150 ms delay
730+
#if !defined(DISPLAY_PIN_RST) || (DISPLAY_PIN_RST < 0)
731+
// Software reset if rst pin not available, no args, w/delay ~150 ms delay
729732
ST77XX_SWRESET, ST_CMD_DELAY, 150,
730-
// 2: Out of sleep mode, no args, w/delay 10 ms delay
733+
#endif
734+
// Out of sleep mode, no args, w/delay 10 ms delay
731735
ST77XX_SLPOUT, ST_CMD_DELAY, 10,
732-
// 3: Set color mode, 1 arg + delay: 16-bit color, 10 ms delay
736+
// Set color mode, 1 arg + delay: 16-bit color, 10 ms delay
733737
ST77XX_COLMOD, 1 + ST_CMD_DELAY, 0x55, 10,
734-
// 4: Mem access ctrl (directions), 1 arg: Row/col addr, bottom-top refresh
738+
// Mem access ctrl (directions), 1 arg: Row/col addr, bottom-top refresh
735739
ST77XX_MADCTL, 1, DISPLAY_MADCTL,
736-
// 5: Column addr set, 4 args, no delay: XSTART = 0, XEND = 240
740+
// Vertical Scroll Start Address of RAM
741+
// ST77XX_VSCSAD, 2, DISPLAY_VSCSAD >> 8, DISPLAY_VSCSAD & 0xFF,
742+
// Column addr set, 4 args, no delay: XSTART = 0, XEND = 240
737743
ST77XX_CASET, 4, 0x00, 0, 0, 240,
738-
// 6: Row addr set, 4 args, no delay: YSTART = 0 YEND = 320
744+
// Row addr set, 4 args, no delay: YSTART = 0 YEND = 320
739745
ST77XX_RASET, 4, 0x00, 0, 320 >> 8, 320 & 0xFF,
740-
// 7: hack
746+
// Inversion on
741747
ST77XX_INVON, ST_CMD_DELAY, 10,
742-
// 8: Normal display on, no args, w/delay 10 ms delay
748+
// Normal display on, no args, w/delay 10 ms delay
743749
ST77XX_NORON, ST_CMD_DELAY, 10,
744-
// 9: Main screen turn on, no args, delay 10 ms delay
750+
// Main screen turn on, no args, delay 10 ms delay
745751
ST77XX_DISPON, ST_CMD_DELAY, 10
746752
};
747753

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MCU_VARIANT nrf52840)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MCU_VARIANT nrf52840)

src/boards/clue_nrf52840/board.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@
4646
#define BUTTON_2 _PINNUM(1, 10) // right button
4747
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
4848

49+
//--------------------------------------------------------------------+
50+
// Display
51+
//--------------------------------------------------------------------+
52+
#define DISPLAY_CONTROLLER_ST7789
53+
54+
#define DISPLAY_PIN_SCK _PINNUM(0, 14)
55+
#define DISPLAY_PIN_MOSI _PINNUM(0, 15)
56+
57+
#define DISPLAY_PIN_CS _PINNUM(0, 12)
58+
#define DISPLAY_PIN_DC _PINNUM(0, 13)
59+
#define DISPLAY_PIN_RST _PINNUM(1, 3)
60+
#define DISPLAY_PIN_BL _PINNUM(1, 5)
61+
#define DISPLAY_BL_ON 1 // GPIO state to enable back light
62+
63+
#define DISPLAY_WIDTH 240
64+
#define DISPLAY_HEIGHT 240
65+
66+
#define DISPLAY_COL_OFFSET 0
67+
#define DISPLAY_ROW_OFFSET 80
68+
69+
// Memory Data Access Control & // Vertical Scroll Start Address
70+
#define DISPLAY_MADCTL (TFT_MADCTL_MY)
71+
#define DISPLAY_VSCSAD 0
72+
73+
#define DISPLAY_TITLE "CLUE"
74+
4975
//--------------------------------------------------------------------+
5076
// BLE OTA
5177
//--------------------------------------------------------------------+

src/boards/feather_nrf52840_sense_tft/board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
//--------------------------------------------------------------------+
5353
#define DISPLAY_CONTROLLER_ST7789
5454

55-
#define DISPLAY_PIN_MOSI _PINNUM(0, 5)
5655
#define DISPLAY_PIN_SCK _PINNUM(0, 26)
56+
#define DISPLAY_PIN_MOSI _PINNUM(0, 5)
5757

5858
#define DISPLAY_PIN_CS _PINNUM(1, 5)
5959
#define DISPLAY_PIN_DC _PINNUM(1, 1)

0 commit comments

Comments
 (0)