|
26 | 26 |
|
27 | 27 | #include "supervisor/board.h"
|
28 | 28 | #include "mpconfigboard.h"
|
| 29 | +#include "shared-bindings/board/__init__.h" |
| 30 | +#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h" |
| 31 | +#include "shared-bindings/dotclockframebuffer/__init__.h" |
| 32 | +#include "shared-bindings/framebufferio/FramebufferDisplay.h" |
29 | 33 | #include "shared-bindings/microcontroller/Pin.h"
|
| 34 | +#include "shared-module/displayio/__init__.h" |
| 35 | + |
| 36 | +static const mcu_pin_obj_t *blue_pins[] = { |
| 37 | + &pin_GPIO3, |
| 38 | + &pin_GPIO4, |
| 39 | + &pin_GPIO5, |
| 40 | + &pin_GPIO6, |
| 41 | + &pin_GPIO7 |
| 42 | +}; |
| 43 | +static const mcu_pin_obj_t *green_pins[] = { |
| 44 | + &pin_GPIO8, |
| 45 | + &pin_GPIO9, |
| 46 | + &pin_GPIO10, |
| 47 | + &pin_GPIO11, |
| 48 | + &pin_GPIO12, |
| 49 | + &pin_GPIO13 |
| 50 | +}; |
| 51 | +static const mcu_pin_obj_t *red_pins[] = { |
| 52 | + &pin_GPIO14, |
| 53 | + &pin_GPIO15, |
| 54 | + &pin_GPIO16, |
| 55 | + &pin_GPIO17, |
| 56 | + &pin_GPIO18 |
| 57
+}; |
| 58 | + |
| 59 | +static void display_init(void) { |
| 60 | + |
| 61 | + // Turn on backlight |
| 62 | + // gpio_set_direction(2, GPIO_MODE_DEF_OUTPUT); |
| 63 | + // gpio_set_level(2, true); |
| 64 | + common_hal_never_reset_pin(&pin_GPIO39); |
| 65 | + |
| 66 | + dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock; |
| 67 | + framebuffer->base.type = &dotclockframebuffer_framebuffer_type; |
| 68 | + |
| 69 | + common_hal_dotclockframebuffer_framebuffer_construct( |
| 70 | + framebuffer, |
| 71 | + &pin_GPIO45, // de |
| 72 | + &pin_GPIO48, // vsync |
| 73 | + &pin_GPIO47, // hsync |
| 74 | + &pin_GPIO21, // pclk |
| 75 | + red_pins, MP_ARRAY_SIZE(red_pins), |
| 76 | + green_pins, MP_ARRAY_SIZE(green_pins), |
| 77 | + blue_pins, MP_ARRAY_SIZE(blue_pins), |
| 78 | + 6500000, // Frequency |
| 79 | + 800, // width |
| 80 | + 480, // height |
| 81 | + 30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low |
| 82 | + 13, 10, 22, false, // vert: pulse, back porch, front porch, idle low |
| 83 | + false, // DE idle high |
| 84 | + false, // pclk active high |
| 85 | + false, // pclk idle high |
| 86 | + 0 // overscan left |
| 87 | + ); |
| 88 | + |
| 89 | + framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display; |
| 90 | + display->base.type = &framebufferio_framebufferdisplay_type; |
| 91 | + common_hal_framebufferio_framebufferdisplay_construct( |
| 92 | + display, |
| 93 | + framebuffer, |
| 94 | + 0, // rotation |
| 95 | + true // auto-refresh |
| 96 | + ); |
| 97 | +} |
30 | 98 |
|
31 | 99 | void board_init(void) {
|
32 | 100 | // Debug UART
|
33 | 101 | #ifdef DEBUG
|
34 | 102 | common_hal_never_reset_pin(&pin_GPIO43);
|
35 | 103 | common_hal_never_reset_pin(&pin_GPIO44);
|
36 | 104 | #endif
|
| 105 | + display_init(); |
37 | 106 | }
|
38 | 107 |
|
39 | 108 | // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
0 commit comments