|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2021 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 "mpconfigboard.h" |
| 30 | +#include "shared-bindings/busio/SPI.h" |
| 31 | +#include "shared-bindings/displayio/FourWire.h" |
| 32 | +#include "shared-bindings/microcontroller/Pin.h" |
| 33 | +#include "shared-module/displayio/__init__.h" |
| 34 | +#include "shared-bindings/board/__init__.h" |
| 35 | +#include "supervisor/shared/board.h" |
| 36 | + |
| 37 | +#define DELAY 0x80 |
| 38 | + |
| 39 | +// This is an SPD1656 control chip. The display is a 5.7" ACeP EInk. |
| 40 | + |
| 41 | +const uint8_t display_start_sequence[] = { |
| 42 | + 0x01, 4, 0x37, 0x00, 0x23, 0x23, // power setting |
| 43 | + 0x00, 2, 0xef, 0x08, // panel setting (PSR) |
| 44 | + 0x03, 1, 0x00, // PFS |
| 45 | + 0x06, 3, 0xc7, 0xc7, 0x1d, // booster |
| 46 | + 0x30, 1, 0x3c, // PLL setting |
| 47 | + 0x41, 1, 0x00, // TSE |
| 48 | + 0x50, 1, 0x37, // vcom and data interval setting |
| 49 | + 0x60, 1, 0x22, // tcon setting |
| 50 | + 0x61, 4, 0x02, 0x58, 0x01, 0xc0, // tres |
| 51 | + 0xe3, 1, 0xaa, // PWS |
| 52 | + 0x04, DELAY | 0, 0xc8, // VCM DC and delay 200ms |
| 53 | +}; |
| 54 | + |
| 55 | +const uint8_t display_stop_sequence[] = { |
| 56 | + 0x02, 1, 0x00, // power off |
| 57 | + 0x07, 1, 0xa5 // deep sleep |
| 58 | +}; |
| 59 | + |
| 60 | +const uint8_t refresh_sequence[] = { |
| 61 | + 0x12, 0x00 |
| 62 | +}; |
| 63 | + |
| 64 | +void board_init(void) { |
| 65 | + displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; |
| 66 | + busio_spi_obj_t *spi = common_hal_board_create_spi(0); |
| 67 | + |
| 68 | + bus->base.type = &displayio_fourwire_type; |
| 69 | + common_hal_displayio_fourwire_construct(bus, |
| 70 | + spi, |
| 71 | + &pin_GPIO28, // EPD_DC Command or data |
| 72 | + &pin_GPIO17, // EPD_CS Chip select |
| 73 | + &pin_GPIO27, // EPD_RST Reset |
| 74 | + 1000000, // Baudrate |
| 75 | + 0, // Polarity |
| 76 | + 0); // Phase |
| 77 | + |
| 78 | + displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display; |
| 79 | + display->base.type = &displayio_epaperdisplay_type; |
| 80 | + common_hal_displayio_epaperdisplay_construct( |
| 81 | + display, |
| 82 | + bus, |
| 83 | + display_start_sequence, sizeof(display_start_sequence), |
| 84 | + 1.0, // start up time |
| 85 | + display_stop_sequence, sizeof(display_stop_sequence), |
| 86 | + 600, // width |
| 87 | + 448, // height |
| 88 | + 640, // ram_width |
| 89 | + 480, // ram_height |
| 90 | + 0, // colstart |
| 91 | + 0, // rowstart |
| 92 | + 180, // rotation |
| 93 | + NO_COMMAND, // set_column_window_command |
| 94 | + NO_COMMAND, // set_row_window_command |
| 95 | + NO_COMMAND, // set_current_column_command |
| 96 | + NO_COMMAND, // set_current_row_command |
| 97 | + 0x10, // write_black_ram_command |
| 98 | + false, // black_bits_inverted |
| 99 | + NO_COMMAND, // write_color_ram_command |
| 100 | + false, // color_bits_inverted |
| 101 | + 0x000000, // highlight_color |
| 102 | + refresh_sequence, sizeof(refresh_sequence), |
| 103 | + 28.0, // refresh_time |
| 104 | + NULL, // busy_pin |
| 105 | + false, // busy_state |
| 106 | + 30.0, // seconds_per_frame |
| 107 | + false, // always_toggle_chip_select |
| 108 | + false, // grayscale |
| 109 | + true, // acep |
| 110 | + false, // two_byte_sequence_length |
| 111 | + false); // address_little_endian |
| 112 | +} |
| 113 | + |
| 114 | +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. |
0 commit comments