|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2017 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 "supervisor/board.h" |
| 28 | + |
| 29 | +#include "shared-bindings/board/__init__.h" |
| 30 | +#include "shared-bindings/displayio/FourWire.h" |
| 31 | +#include "shared-module/displayio/__init__.h" |
| 32 | +#include "shared-module/displayio/mipi_constants.h" |
| 33 | +#include "shared-bindings/busio/SPI.h" |
| 34 | + |
| 35 | +displayio_fourwire_obj_t board_display_obj; |
| 36 | + |
| 37 | +#define DELAY 0x80 |
| 38 | + |
| 39 | +uint8_t display_init_sequence[] = { |
| 40 | + 0xe2, 0, // reset |
| 41 | + 0x2f, 0, // power on |
| 42 | + 0x80, 0, // contrast 0 |
| 43 | + 0xa4, 0, // display normal |
| 44 | + 0xaf, 0, // display on |
| 45 | + 0x40, 0, // start line 0 |
| 46 | +}; |
| 47 | + |
| 48 | +void board_init(void) { |
| 49 | + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; |
| 50 | + common_hal_busio_spi_construct(spi, &pin_PA23, &pin_PA22, NULL, false); |
| 51 | + common_hal_busio_spi_never_reset(spi); |
| 52 | + |
| 53 | + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; |
| 54 | + bus->base.type = &displayio_fourwire_type; |
| 55 | + common_hal_displayio_fourwire_construct(bus, |
| 56 | + spi, |
| 57 | + NULL, // Command or data |
| 58 | + &pin_PA19, // Chip select |
| 59 | + &pin_PA18, // Reset |
| 60 | + 40000000LL, // Baudrate |
| 61 | + 0, // Polarity |
| 62 | + 0); // Phase |
| 63 | + |
| 64 | + displayio_display_obj_t *display = &displays[0].display; |
| 65 | + display->base.type = &displayio_display_type; |
| 66 | + common_hal_displayio_display_construct(display, |
| 67 | + bus, |
| 68 | + 96, // Width |
| 69 | + 68, // Height |
| 70 | + 0, // column start |
| 71 | + 0, // row start |
| 72 | + 180, // rotation |
| 73 | + 1, // Color depth |
| 74 | + true, // grayscale |
| 75 | + false, // pixels in byte share row. Only used with depth < 8 |
| 76 | + 1, // bytes per cell. Only valid for depths < 8 |
| 77 | + false, // reverse_pixels_in_byte. Only valid for depths < 8 |
| 78 | + false, // reverse_pixels_in_word |
| 79 | + 0, // Set column command |
| 80 | + 0, // Set row command |
| 81 | + 0, // Write memory command |
| 82 | + display_init_sequence, |
| 83 | + sizeof(display_init_sequence), |
| 84 | + NULL, // &pin_PA17, // brightness pin |
| 85 | + NO_BRIGHTNESS_COMMAND, |
| 86 | + 0.0f, // brightness |
| 87 | + false, // auto_brightness |
| 88 | + false, // single_byte_bounds |
| 89 | + true, // data as commands |
| 90 | + true, // auto_refresh |
| 91 | + 2, // native_frames_per_second |
| 92 | + true, // backlight_on_high |
| 93 | + true); // SH1107_addressing |
| 94 | +} |
| 95 | + |
| 96 | +bool board_requests_safe_mode(void) { |
| 97 | + return false; |
| 98 | +} |
| 99 | + |
| 100 | +void reset_board(void) { |
| 101 | +} |
| 102 | + |
| 103 | +void board_deinit(void) { |
| 104 | +} |
0 commit comments