|
24 | 24 | * THE SOFTWARE.
|
25 | 25 | */
|
26 | 26 |
|
27 |
| -#include "supervisor/board.h" |
28 |
| - |
| 27 | +#include "shared-bindings/board/__init__.h" |
| 28 | +#include "shared-bindings/displayio/FourWire.h" |
| 29 | +#include "shared-module/displayio/__init__.h" |
| 30 | +#include "shared-module/displayio/mipi_constants.h" |
| 31 | +#include "shared-bindings/busio/SPI.h" |
29 | 32 | #include "shared-bindings/microcontroller/Pin.h"
|
30 | 33 | #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h"
|
31 | 34 | #include "supervisor/shared/board.h"
|
32 | 35 |
|
| 36 | +displayio_fourwire_obj_t board_display_obj; |
| 37 | + |
| 38 | +#define DELAY 0x80 |
| 39 | + |
| 40 | +uint8_t display_init_sequence[] = { |
| 41 | + 0xae, 0, // sleep |
| 42 | + 0xd5, 1, 0x80, // fOsc divide by 2 |
| 43 | + 0xa8, 1, 0x3f, // multiplex 64 |
| 44 | + 0xd3, 1, 0x00, // offset 0 |
| 45 | + 0x40, 1, 0x00, // start line 0 |
| 46 | + 0xad, 1, 0x8b, // dc/dc on |
| 47 | + 0xa1, 0, // segment remap = 0 |
| 48 | + 0xc8, 0, // scan incr |
| 49 | + 0xda, 1, 0x12, // com pins |
| 50 | + 0x81, 1, 0xff, // contrast 255 |
| 51 | + 0xd9, 1, 0x1f, // pre/dis-charge 2DCLKs/2CLKs |
| 52 | + 0xdb, 1, 0x20, // VCOM deslect 0.770 |
| 53 | + 0x20, 1, 0x20, |
| 54 | + 0x33, 0, // VPP 9V |
| 55 | + 0xa6, 0, // not inverted |
| 56 | + 0xa4, 0, // normal |
| 57 | + 0xaf, 0, // on |
| 58 | +}; |
| 59 | + |
33 | 60 | void board_init(void) {
|
| 61 | + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; |
| 62 | + common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL); |
| 63 | + common_hal_busio_spi_never_reset(spi); |
| 64 | + |
| 65 | + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; |
| 66 | + bus->base.type = &displayio_fourwire_type; |
| 67 | + common_hal_displayio_fourwire_construct(bus, |
| 68 | + spi, |
| 69 | + &pin_GPIO24, // Command or data |
| 70 | + &pin_GPIO22, // Chip select |
| 71 | + &pin_GPIO23, // Reset |
| 72 | + 1000000, // Baudrate |
| 73 | + 0, // Polarity |
| 74 | + 0); // Phase |
| 75 | + |
| 76 | + displayio_display_obj_t *display = &displays[0].display; |
| 77 | + display->base.type = &displayio_display_type; |
| 78 | + common_hal_displayio_display_construct(display, |
| 79 | + bus, |
| 80 | + 128, // Width |
| 81 | + 64, // Height |
| 82 | + 2, // column start |
| 83 | + 0, // row start |
| 84 | + 0, // rotation |
| 85 | + 1, // Color depth |
| 86 | + true, // grayscale |
| 87 | + false, // pixels in byte share row. Only used with depth < 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 | + 0, // Set column command |
| 92 | + 0, // Set row command |
| 93 | + 0, // Write memory command |
| 94 | + 0xd3, // set vertical scroll command |
| 95 | + display_init_sequence, |
| 96 | + sizeof(display_init_sequence), |
| 97 | + NULL, |
| 98 | + 0x81, |
| 99 | + 1.0f, // brightness |
| 100 | + false, // auto_brightness |
| 101 | + true, // single_byte_bounds |
| 102 | + true, // data as commands |
| 103 | + true, // auto_refresh |
| 104 | + 60, // native_frames_per_second |
| 105 | + true, // backlight_on_high |
| 106 | + true); // SH1107_addressing |
34 | 107 | }
|
35 | 108 |
|
36 | 109 | bool board_requests_safe_mode(void) {
|
|
0 commit comments