|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
| 27 | +#include "boards/board.h" |
| 28 | +#include "mpconfigboard.h" |
| 29 | +#include "hal/include/hal_gpio.h" |
| 30 | + |
| 31 | +#include "shared-module/displayio/__init__.h" |
| 32 | +#include "shared-module/displayio/mipi_constants.h" |
| 33 | + |
| 34 | +#include "tick.h" |
| 35 | + |
| 36 | +#define DELAY 0x80 |
| 37 | + |
| 38 | +uint8_t display_init_sequence[] = { |
| 39 | + 0xEF, 3, 0x03, 0x80, 0x02, |
| 40 | + 0xCF, 3, 0x00, 0xC1, 0x30, |
| 41 | + 0xED, 4, 0x64, 0x03, 0x12, 0x81, |
| 42 | + 0xE8, 3, 0x85, 0x00, 0x78, |
| 43 | + 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, |
| 44 | + 0xF7, 1, 0x20, |
| 45 | + 0xEA, 2, 0x00, 0x00, |
| 46 | + 0xc0, 1, 0x23, // Power control VRH[5:0] |
| 47 | + 0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0] |
| 48 | + 0xc5, 2, 0x3e, 0x28, // VCM control |
| 49 | + 0xc7, 1, 0x86, // VCM control2 |
| 50 | + 0x36, 1, 0xa8, // Memory Access Control |
| 51 | + 0x37, 1, 0x00, // Vertical scroll zero |
| 52 | + 0x3a, 1, 0x55, // COLMOD: Pixel Format Set |
| 53 | + 0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors) |
| 54 | + 0xb6, 3, 0x08, 0xa2, 0x27, // Display Function Control |
| 55 | + 0xF2, 1, 0x00, // 3Gamma Function Disable |
| 56 | + 0x26, 1, 0x01, // Gamma curve selected |
| 57 | + 0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma |
| 58 | + 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, |
| 59 | + 0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma |
| 60 | + 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, |
| 61 | + 0x11, DELAY, 120, // Exit Sleep |
| 62 | + 0x29, DELAY, 120, // Display on |
| 63 | +}; |
| 64 | + |
| 65 | +void board_init(void) { |
| 66 | + displayio_parallelbus_obj_t* bus = &displays[0].parallel_bus; |
| 67 | + bus->base.type = &displayio_parallelbus_type; |
| 68 | + common_hal_displayio_parallelbus_construct(bus, |
| 69 | + &pin_PA16, // Data0 |
| 70 | + &pin_PB05, // Command or data |
| 71 | + &pin_PB06, // Chip select |
| 72 | + &pin_PB09, // Write |
| 73 | + &pin_PB04, // Read |
| 74 | + &pin_PA00); // Reset |
| 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 | + 320, // Width |
| 81 | + 240, // Height |
| 82 | + 0, // column start |
| 83 | + 0, // row start |
| 84 | + 0, // rotation |
| 85 | + 16, // Color depth |
| 86 | + false, // grayscale |
| 87 | + false, // pixels_in_byte_share_row (unused 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 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command |
| 91 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command |
| 92 | + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command |
| 93 | + 0x37, // Set vertical scroll command |
| 94 | + display_init_sequence, |
| 95 | + sizeof(display_init_sequence), |
| 96 | + &pin_PB31, // Backlight pin |
| 97 | + NO_BRIGHTNESS_COMMAND, |
| 98 | + 1.0f, // brightness (ignored) |
| 99 | + true, // auto_brightness |
| 100 | + false, // single_byte_bounds |
| 101 | + false); // data_as_commands |
| 102 | +} |
| 103 | + |
| 104 | +bool board_requests_safe_mode(void) { |
| 105 | + return false; |
| 106 | +} |
| 107 | + |
| 108 | +void reset_board(void) { |
| 109 | +} |
0 commit comments