2727#include "boards/board.h"
2828#include "mpconfigboard.h"
2929#include "hal/include/hal_gpio.h"
30+ #include "shared-bindings/busio/SPI.h"
3031#include "shared-bindings/displayio/FourWire.h"
3132#include "shared-module/displayio/__init__.h"
3233#include "shared-module/displayio/mipi_constants.h"
@@ -50,7 +51,7 @@ uint8_t display_init_sequence[] = {
5051 0xc4 , 2 , 0x8a , 0xee ,
5152 0xc5 , 1 , 0x0e , // _VMCTR1 VCOMH = 4V, VOML = -1.1V
5253 0x2a , 0 , // _INVOFF
53- 0x36 , 1 , 0x18 , // _MADCTL bottom to top refresh
54+ 0x36 , 1 , 0x00 , // _MADCTL top to bottom refresh in vsync aligned order.
5455 // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie,
5556 // fix on VTL
5657 0x3a , 1 , 0x05 , // COLMOD - 16bit color
@@ -68,11 +69,16 @@ uint8_t display_init_sequence[] = {
6869 0x29 , 0 | DELAY , 100 , // _DISPON
6970};
7071
72+ STATIC busio_spi_obj_t display_spi_obj ;
73+
7174void board_init (void ) {
75+ common_hal_busio_spi_construct (& display_spi_obj , & pin_PB13 , & pin_PB12 , NULL );
76+ common_hal_busio_spi_never_reset (& display_spi_obj );
77+
7278 displayio_fourwire_obj_t * bus = & displays [0 ].fourwire_bus ;
7379 bus -> base .type = & displayio_fourwire_type ;
7480 common_hal_displayio_fourwire_construct (bus ,
75- board_spi () ,
81+ & display_spi_obj ,
7682 & pin_PB05 , // TFT_DC Command or data
7783 & pin_PB07 , // TFT_CS Chip select
7884 & pin_PA01 ); // TFT_RST Reset
@@ -81,11 +87,11 @@ void board_init(void) {
8187 display -> base .type = & displayio_display_type ;
8288 common_hal_displayio_display_construct (display ,
8389 bus ,
84- 128 , // Width
90+ 160 , // Width
8591 128 , // Height
86- 2 , // column start
87- 1 , // row start
88- 0 , // rotation
92+ 0 , // column start
93+ 0 , // row start
94+ 270 , // rotation
8995 16 , // Color depth
9096 MIPI_COMMAND_SET_COLUMN_ADDRESS , // Set column command
9197 MIPI_COMMAND_SET_PAGE_ADDRESS , // Set row command
0 commit comments