35
35
36
36
displayio_fourwire_obj_t board_display_obj ;
37
37
38
+ typedef struct {
39
+ const uint32_t * config_data ;
40
+ void * handoverHID ;
41
+ void * handoverMSC ;
42
+ const char * info_uf2 ;
43
+ } UF2_BInfo ;
44
+
45
+ #define APP_START_ADDRESS 0x00004000
46
+ #define UF2_BINFO ((UF2_BInfo *)(APP_START_ADDRESS - sizeof(UF2_BInfo)))
47
+
48
+ #define CFG_DISPLAY_CFG0 39
49
+ #define CFG_MAGIC0 0x1e9e10f1
50
+
38
51
#define DELAY 0x80
39
52
53
+ uint32_t lookupCfg (uint32_t key , uint32_t defl ) {
54
+ const uint32_t * ptr = UF2_BINFO -> config_data ;
55
+ if (!ptr || (((uint32_t )ptr ) & 3 ) || * ptr != CFG_MAGIC0 ) {
56
+ // no config data!
57
+ } else {
58
+ ptr += 4 ;
59
+ while (* ptr ) {
60
+ if (* ptr == key )
61
+ return ptr [1 ];
62
+ ptr += 2 ;
63
+ }
64
+ }
65
+ return defl ;
66
+ }
67
+
40
68
uint8_t display_init_sequence [] = {
41
69
0x01 , 0 | DELAY , 150 , // SWRESET
42
70
0x11 , 0 | DELAY , 255 , // SLPOUT
@@ -63,8 +91,6 @@ uint8_t display_init_sequence[] = {
63
91
0x2E , 0x2C , 0x29 , 0x2D ,
64
92
0x2E , 0x2E , 0x37 , 0x3F ,
65
93
0x00 , 0x00 , 0x02 , 0x10 ,
66
- 0x2a , 3 , 0x02 , 0x00 , 0x81 , // _CASET XSTART = 2, XEND = 129
67
- 0x2b , 3 , 0x02 , 0x00 , 0x81 , // _RASET XSTART = 2, XEND = 129
68
94
0x13 , 0 | DELAY , 10 , // _NORON
69
95
0x29 , 0 | DELAY , 100 , // _DISPON
70
96
};
@@ -83,14 +109,17 @@ void board_init(void) {
83
109
& pin_PA17 , // TFT_RST Reset
84
110
60000000 );
85
111
112
+ uint32_t cfg0 = lookupCfg (CFG_DISPLAY_CFG0 , 0x000000 );
113
+ uint32_t offX = (cfg0 >> 8 ) & 0xff ;
114
+ uint32_t offY = (cfg0 >> 16 ) & 0xff ;
86
115
displayio_display_obj_t * display = & displays [0 ].display ;
87
116
display -> base .type = & displayio_display_type ;
88
117
common_hal_displayio_display_construct (display ,
89
118
bus ,
90
119
160 , // Width (after rotation)
91
120
128 , // Height (after rotation)
92
- 0 , // column start
93
- 0 , // row start
121
+ offX , // column start
122
+ offY , // row start
94
123
0 , // rotation
95
124
16 , // Color depth
96
125
false, // grayscale
0 commit comments