Skip to content

Commit 471ee6f

Browse files
committed
add: display initialisation
1 parent 4654f9c commit 471ee6f

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

ports/espressif/boards/oxocard_artwork/board.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,90 @@
2525
*/
2626

2727
#include "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
#include "shared-module/displayio/__init__.h"
31+
#include "shared-module/displayio/mipi_constants.h"
32+
33+
#define DELAY 0x80
34+
35+
// display init sequence
36+
uint8_t display_init_sequence[] = {
37+
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
38+
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD (65K of RGB, 16 bits/pixel) and Delay 10ms
40+
0x36, 0x01, 0x00, // _MADCTL
41+
0x2A, 0x04, 0x00, 0x00, 0x00, 0xF0, // _CASET (0..240)
42+
0x2B, 0x04, 0x00, 0x00, 0x00, 0xF0, // _RASET (0..240)
43+
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
44+
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
45+
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
46+
};
47+
48+
static void display_init(void) {
49+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
50+
busio_spi_obj_t *spi = &bus->inline_bus;
51+
52+
common_hal_busio_spi_construct(
53+
spi,
54+
&pin_GPIO14, // CLK
55+
&pin_GPIO13, // MOSI
56+
&pin_GPIO12, // MISO
57+
false); // Not half-duplex
58+
59+
common_hal_busio_spi_never_reset(spi);
60+
61+
bus->base.type = &fourwire_fourwire_type;
62+
63+
common_hal_fourwire_fourwire_construct(
64+
bus,
65+
spi,
66+
&pin_GPIO27, // DC
67+
&pin_GPIO15, // CS
68+
&pin_GPIO4, // RST
69+
24000000, // baudrate
70+
0, // polarity
71+
0 // phase
72+
);
73+
74+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
75+
display->base.type = &busdisplay_busdisplay_type;
76+
77+
common_hal_busdisplay_busdisplay_construct(
78+
display,
79+
bus,
80+
240, // width (after rotation)
81+
240, // height (after rotation)
82+
0, // column start
83+
80, // row start
84+
0, // rotation
85+
16, // color depth
86+
false, // grayscale
87+
false, // pixels in a byte share a row. Only valid for depths < 8
88+
1, // bytes per cell. Only valid for depths < 8
89+
false, // reverse_pixels_in_byte. Only valid for depths < 8
90+
true, // reverse_pixels_in_word
91+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
92+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
93+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
94+
display_init_sequence,
95+
sizeof(display_init_sequence),
96+
&pin_GPIO19, // backlight pin
97+
NO_BRIGHTNESS_COMMAND,
98+
1.0f, // brightness
99+
false, // single_byte_bounds
100+
false, // data_as_commands
101+
true, // auto_refresh
102+
60, // native_frames_per_second
103+
true, // backlight_on_high
104+
false, // SH1107_addressing
105+
50000 // backlight pwm frequency
106+
);
107+
}
108+
109+
void board_init(void) {
110+
// Display
111+
display_init();
112+
}
28113

29114
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

ports/espressif/boards/oxocard_galaxy/board.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,90 @@
2525
*/
2626

2727
#include "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
#include "shared-module/displayio/__init__.h"
31+
#include "shared-module/displayio/mipi_constants.h"
32+
33+
#define DELAY 0x80
34+
35+
// display init sequence
36+
uint8_t display_init_sequence[] = {
37+
0x01, DELAY, 0x96, // _SWRESET and Delay 150ms
38+
0x11, DELAY, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, DELAY | 1, 0x55, 0x0A, // _COLMOD (65K of RGB, 16 bits/pixel) and Delay 10ms
40+
0x36, 0x01, 0x00, // _MADCTL
41+
0x2A, 0x04, 0x00, 0x00, 0x00, 0xF0, // _CASET (0..240)
42+
0x2B, 0x04, 0x00, 0x00, 0x00, 0xF0, // _RASET (0..240)
43+
0x21, DELAY, 0x0A, // _INVON Hack and Delay 10ms
44+
0x13, DELAY, 0x0A, // _NORON and Delay 10ms
45+
0x29, DELAY, 0xFF, // _DISPON and Delay 500ms
46+
};
47+
48+
static void display_init(void) {
49+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
50+
busio_spi_obj_t *spi = &bus->inline_bus;
51+
52+
common_hal_busio_spi_construct(
53+
spi,
54+
&pin_GPIO14, // CLK
55+
&pin_GPIO13, // MOSI
56+
&pin_GPIO12, // MISO
57+
false); // Not half-duplex
58+
59+
common_hal_busio_spi_never_reset(spi);
60+
61+
bus->base.type = &fourwire_fourwire_type;
62+
63+
common_hal_fourwire_fourwire_construct(
64+
bus,
65+
spi,
66+
&pin_GPIO27, // DC
67+
&pin_GPIO15, // CS
68+
&pin_GPIO4, // RST
69+
24000000, // baudrate
70+
0, // polarity
71+
0 // phase
72+
);
73+
74+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
75+
display->base.type = &busdisplay_busdisplay_type;
76+
77+
common_hal_busdisplay_busdisplay_construct(
78+
display,
79+
bus,
80+
240, // width (after rotation)
81+
240, // height (after rotation)
82+
0, // column start
83+
80, // row start
84+
0, // rotation
85+
16, // color depth
86+
false, // grayscale
87+
false, // pixels in a byte share a row. Only valid for depths < 8
88+
1, // bytes per cell. Only valid for depths < 8
89+
false, // reverse_pixels_in_byte. Only valid for depths < 8
90+
true, // reverse_pixels_in_word
91+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
92+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
93+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
94+
display_init_sequence,
95+
sizeof(display_init_sequence),
96+
&pin_GPIO19, // backlight pin
97+
NO_BRIGHTNESS_COMMAND,
98+
1.0f, // brightness
99+
false, // single_byte_bounds
100+
false, // data_as_commands
101+
true, // auto_refresh
102+
60, // native_frames_per_second
103+
true, // backlight_on_high
104+
false, // SH1107_addressing
105+
50000 // backlight pwm frequency
106+
);
107+
}
108+
109+
void board_init(void) {
110+
// Display
111+
display_init();
112+
}
28113

29114
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

0 commit comments

Comments
 (0)