Skip to content

Commit ab9483b

Browse files
committed
Add internal display definitions, fails at startup
1 parent b5b94b7 commit ab9483b

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

ports/stm32f4/boards/meowbit_v121/board.c

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,89 @@
2727
#include "boards/board.h"
2828
#include "mpconfigboard.h"
2929

30+
#include "shared-bindings/board/__init__.h"
31+
#include "shared-bindings/displayio/FourWire.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
34+
#include "shared-bindings/busio/SPI.h"
35+
36+
#include "supervisor/spi_flash_api.h"
37+
38+
#include "tick.h"
39+
40+
displayio_fourwire_obj_t board_display_obj;
41+
42+
#define DELAY 0x80
43+
44+
uint8_t display_init_sequence[] = {
45+
0x01, 0 | DELAY, 150, // SWRESET
46+
0x11, 0 | DELAY, 255, // SLPOUT
47+
0xb1, 3, 0x01, 0x2C, 0x2D, // _FRMCTR1
48+
0xb2, 3, 0x01, 0x2C, 0x2D, //
49+
0xb3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D,
50+
0xb4, 1, 0x07, // _INVCTR line inversion
51+
0xc0, 3, 0xa2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA
52+
0xc1, 1, 0xc5, // _PWCTR2 VGH=14.7V, VGL=-7.35V
53+
0xc2, 2, 0x0a, 0x00, // _PWCTR3 Opamp current small, Boost frequency
54+
0xc3, 2, 0x8a, 0x2a,
55+
0xc4, 2, 0x8a, 0xee,
56+
0xc5, 1, 0x0e, // _VMCTR1 VCOMH = 4V, VOML = -1.1V
57+
0x20, 0, // _INVOFF //MISMATCh 0x2a vs 0x20
58+
0x36, 1, 0x18, // _MADCTL bottom to top refresh
59+
// 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie,
60+
// fix on VTL
61+
0x3a, 1, 0x05, // COLMOD - 16bit color
62+
0xe0, 0x10, 0x02, 0x1c, 0x07, 0x12,
63+
0x37, 0x32, 0x29, 0x2d,
64+
0x29, 0x25, 0x2B, 0x39,
65+
0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma
66+
0xe1, 0x10, 0x03, 0x1d, 0x07, 0x06,
67+
0x2E, 0x2C, 0x29, 0x2D,
68+
0x2E, 0x2E, 0x37, 0x3F,
69+
0x00, 0x00, 0x02, 0x10, // _GMCTRN1
70+
0x13, 0 | DELAY, 10, // _NORON
71+
0x29, 0 | DELAY, 100, // _DISPON
72+
};
73+
3074
void board_init(void) {
75+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
76+
bus->base.type = &displayio_fourwire_type;
77+
busio_spi_obj_t *internal_spi = &spi;
78+
common_hal_displayio_fourwire_construct(bus,
79+
internal_spi,
80+
&pin_PA08, // Command or data
81+
&pin_PB12, // Chip select
82+
&pin_PB10, // Reset
83+
24000000);
84+
85+
displayio_display_obj_t* display = &displays[0].display;
86+
display->base.type = &displayio_display_type;
87+
common_hal_displayio_display_construct(display,
88+
bus,
89+
160, // Width
90+
128, // Height
91+
0, // column start
92+
0, // row start
93+
90, // rotation
94+
16, // Color depth
95+
false, // Grayscale
96+
false, // Pixels in a byte share a row. Only used for depth < 8
97+
1, // bytes per cell. Only valid for depths < 8
98+
false, // reverse_pixels_in_byte. Only valid for depths < 8
99+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
100+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
101+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
102+
0x37, // set vertical scroll command
103+
display_init_sequence,
104+
sizeof(display_init_sequence),
105+
&pin_PB03,
106+
NO_BRIGHTNESS_COMMAND,
107+
1.0f, // brightness (ignored)
108+
true, // auto_brightness
109+
false, // single_byte_bounds
110+
false, // data_as_commands
111+
true, // auto_refresh
112+
60); // native_frames_per_second
31113
}
32114

33115
bool board_requests_safe_mode(void) {

ports/stm32f4/boards/meowbit_v121/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#define BOARD_OSC_DIV 12
3939
#define BOARD_NO_VBUS_SENSE
40-
#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
40+
// #define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
4141
#define BOARD_USE_INTERNAL_SPI
4242

4343
// On-board flash

ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
99
EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ
1010
LONGINT_IMPL = MPZ
1111

12-
BOOTLOADER_OFFSET = 0x8010000
12+
# BOOTLOADER_OFFSET = 0x8010000
1313

1414
# INTERNAL_FLASH_FILESYSTEM = 1
1515
# LONGINT_IMPL = NONE
@@ -19,5 +19,5 @@ MCU_VARIANT = stm32f4
1919
MCU_SUB_VARIANT = stm32f401xe
2020
MCU_PACKAGE = 64
2121
CMSIS_MCU = STM32F401xE
22-
LD_FILE = boards/STM32F401_boot.ld
23-
# LD_FILE = boards/STM32F401_fs.ld #use for internal flash
22+
# LD_FILE = boards/STM32F401_boot.ld
23+
LD_FILE = boards/STM32F401_fs.ld #use for internal flash

ports/stm32f4/boards/meowbit_v121/pins.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "shared-bindings/board/__init__.h"
22
#include "supervisor/spi_flash_api.h"
33

4+
#include "shared-module/displayio/__init__.h"
5+
46
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
57
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PB04) },
68
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PB05) },
@@ -61,5 +63,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
6163
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PB00) },
6264

6365
{ MP_ROM_QSTR(MP_QSTR_INTERNAL_SPI), MP_ROM_PTR(&spi) },
66+
67+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
6468
};
6569
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)