|
6 | 6 |
|
7 | 7 | #include "supervisor/board.h"
|
8 | 8 | #include "mpconfigboard.h"
|
| 9 | +#include "shared-bindings/board/__init__.h" |
| 10 | +#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h" |
| 11 | +#include "shared-bindings/dotclockframebuffer/__init__.h" |
| 12 | +#include "shared-bindings/framebufferio/FramebufferDisplay.h" |
9 | 13 | #include "shared-bindings/microcontroller/Pin.h"
|
| 14 | +#include "shared-module/displayio/__init__.h" |
| 15 | +#include "shared-module/os/__init__.h" |
| 16 | + |
| 17 | +static const mcu_pin_obj_t *blue_pins[] = { |
| 18 | + &pin_GPIO8, |
| 19 | + &pin_GPIO3, |
| 20 | + &pin_GPIO46, |
| 21 | + &pin_GPIO9, |
| 22 | + &pin_GPIO1 |
| 23 | +}; |
| 24 | +static const mcu_pin_obj_t *green_pins[] = { |
| 25 | + &pin_GPIO5, |
| 26 | + &pin_GPIO6, |
| 27 | + &pin_GPIO7, |
| 28 | + &pin_GPIO15, |
| 29 | + &pin_GPIO16, |
| 30 | + &pin_GPIO4 |
| 31 | +}; |
| 32 | +static const mcu_pin_obj_t *red_pins[] = { |
| 33 | + &pin_GPIO45, |
| 34 | + &pin_GPIO48, |
| 35 | + &pin_GPIO47, |
| 36 | + &pin_GPIO21, |
| 37 | + &pin_GPIO14 |
| 38 | +}; |
| 39 | + |
| 40 | +static void display_init(void) { |
| 41 | + |
| 42 | + mp_int_t height = 0, width = 0, frequency = 0; |
| 43 | + os_getenv_err_t result; |
| 44 | + |
| 45 | + result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width); |
| 46 | + if (result == GETENV_OK && width == 800) { |
| 47 | + width = 800; |
| 48 | + height = 480; |
| 49 | + frequency = 6500000; |
| 50 | + } else if (result == GETENV_OK && width == 1024) { |
| 51 | + width = 1024; |
| 52 | + height = 600; |
| 53 | + frequency = 10000000; |
| 54 | + } |
| 55 | + |
| 56 | + if (height == 0) { |
| 57 | + width = 800; |
| 58 | + height = 480; |
| 59 | + frequency = 6500000; |
| 60 | + } |
| 61 | + |
| 62 | + dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock; |
| 63 | + framebuffer->base.type = &dotclockframebuffer_framebuffer_type; |
| 64 | + |
| 65 | + common_hal_dotclockframebuffer_framebuffer_construct( |
| 66 | + framebuffer, |
| 67 | + &pin_GPIO40, // de |
| 68 | + &pin_GPIO41, // vsync |
| 69 | + &pin_GPIO39, // hsync |
| 70 | + &pin_GPIO42, // pclk |
| 71 | + red_pins, MP_ARRAY_SIZE(red_pins), |
| 72 | + green_pins, MP_ARRAY_SIZE(green_pins), |
| 73 | + blue_pins, MP_ARRAY_SIZE(blue_pins), |
| 74 | + frequency, // Frequency |
| 75 | + width, // width |
| 76 | + height, // height |
| 77 | + 30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low |
| 78 | + 13, 10, 22, false, // vert: pulse, back porch, front porch, idle low |
| 79 | + false, // DE idle high |
| 80 | + false, // pclk active high |
| 81 | + false, // pclk idle high |
| 82 | + 0 // overscan left |
| 83 | + ); |
| 84 | + |
| 85 | + framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display; |
| 86 | + display->base.type = &framebufferio_framebufferdisplay_type; |
| 87 | + common_hal_framebufferio_framebufferdisplay_construct( |
| 88 | + display, |
| 89 | + framebuffer, |
| 90 | + 0, // rotation |
| 91 | + true // auto-refresh |
| 92 | + ); |
| 93 | +} |
10 | 94 |
|
11 | 95 | void board_init(void) {
|
| 96 | + display_init(); |
12 | 97 | }
|
13 | 98 |
|
14 | 99 | // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
|
0 commit comments