@@ -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
185193NRF_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
199207static void tft_controller_init (void );
200208
201209static 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
209213static 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
217217static 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
0 commit comments