|
3 | 3 | * |
4 | 4 | * The MIT License (MIT) |
5 | 5 | * |
6 | | - * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries |
| 6 | + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries |
7 | 7 | * |
8 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | 9 | * of this software and associated documentation files (the "Software"), to deal |
|
25 | 25 | */ |
26 | 26 |
|
27 | 27 | #include "boards/board.h" |
28 | | -#include "board_busses.h" |
| 28 | +#include "supervisor/shared/board_busses.h" |
29 | 29 | #include "mpconfigboard.h" |
30 | 30 | #include "hal/include/hal_gpio.h" |
31 | 31 |
|
32 | 32 | #include "shared-module/displayio/__init__.h" |
| 33 | +#include "shared-module/displayio/mipi_constants.h" |
33 | 34 |
|
34 | 35 | #include "tick.h" |
35 | 36 |
|
| 37 | +#define DELAY 0x80 |
| 38 | + |
| 39 | +uint8_t display_init_sequence[] = { |
| 40 | + 0xEF, 3, 0x03, 0x80, 0x02, |
| 41 | + 0xCF, 3, 0x00, 0xC1, 0x30, |
| 42 | + 0xED, 4, 0x64, 0x03, 0x12, 0x81, |
| 43 | + 0xE8, 3, 0x85, 0x00, 0x78, |
| 44 | + 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, |
| 45 | + 0xF7, 1, 0x20, |
| 46 | + 0xEA, 2, 0x00, 0x00, |
| 47 | + 0xc0, 1, 0x23, // Power control VRH[5:0] |
| 48 | + 0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0] |
| 49 | + 0xc5, 2, 0x3e, 0x28, // VCM control |
| 50 | + 0xc7, 1, 0x86, // VCM control2 |
| 51 | + 0x36, 1, 0x38, // Memory Access Control |
| 52 | + 0x37, 1, 0x00, // Vertical scroll zero |
| 53 | + 0x3a, 1, 0x55, // COLMOD: Pixel Format Set |
| 54 | + 0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors) |
| 55 | + 0xb6, 3, 0x08, 0x82, 0x27, // Display Function Control |
| 56 | + 0xF2, 1, 0x00, // 3Gamma Function Disable |
| 57 | + 0x26, 1, 0x01, // Gamma curve selected |
| 58 | + 0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma |
| 59 | + 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, |
| 60 | + 0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma |
| 61 | + 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, |
| 62 | + 0x11, DELAY, 120, // Exit Sleep |
| 63 | + 0x29, DELAY, 120, // Display on |
| 64 | +}; |
| 65 | + |
36 | 66 | void board_init(void) { |
| 67 | + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; |
| 68 | + bus->base.type = &displayio_fourwire_type; |
| 69 | + common_hal_displayio_fourwire_construct(bus, |
| 70 | + board_spi(), |
| 71 | + &pin_PB09, // Command or data |
| 72 | + &pin_PB06, // Chip select |
| 73 | + &pin_PA00); // Reset |
| 74 | + |
| 75 | + displayio_display_obj_t* display = &displays[0].display; |
| 76 | + display->base.type = &displayio_display_type; |
| 77 | + common_hal_displayio_display_construct(display, |
| 78 | + bus, |
| 79 | + 320, // Width |
| 80 | + 240, // Height |
| 81 | + 0, // column start |
| 82 | + 0, // row start |
| 83 | + 16, // Color depth |
| 84 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command |
| 85 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command |
| 86 | + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command |
| 87 | + display_init_sequence, |
| 88 | + sizeof(display_init_sequence)); |
37 | 89 | } |
38 | 90 |
|
39 | 91 | bool board_requests_safe_mode(void) { |
40 | 92 | return false; |
41 | 93 | } |
42 | 94 |
|
43 | 95 | void reset_board(void) { |
44 | | - common_hal_displayio_display_show(&primary_display_obj, NULL); |
45 | 96 | } |
0 commit comments