|
3 | 3 | // SPDX-License-Identifier: MIT |
4 | 4 |
|
5 | 5 | #include "supervisor/board.h" |
| 6 | +#include "mpconfigboard.h" |
| 7 | +#include "shared-bindings/microcontroller/Pin.h" |
| 8 | + |
| 9 | +#include "shared-bindings/qspibus/QSPIBus.h" |
| 10 | +#include "shared-bindings/busdisplay/BusDisplay.h" |
| 11 | +#include "shared-module/displayio/__init__.h" |
| 12 | +#include "shared-module/displayio/mipi_constants.h" |
| 13 | + |
| 14 | +// RM690B0 AMOLED initialization sequence. |
| 15 | +// Format: command byte, length | 0x80 (if delay), data bytes..., [delay ms] |
| 16 | +// Based on vendor recommendations, tested with Waveshare 2.41" AMOLED panel. |
| 17 | +static const uint8_t display_init_sequence[] = { |
| 18 | + // Page select and configuration |
| 19 | + 0xFE, 0x01, 0x20, // Enter user command mode |
| 20 | + 0x26, 0x01, 0x0A, // Bias setting |
| 21 | + 0x24, 0x01, 0x80, // Source output control |
| 22 | + 0xFE, 0x01, 0x13, // Page 13 |
| 23 | + 0xEB, 0x01, 0x0E, // Vendor command |
| 24 | + 0xFE, 0x01, 0x00, // Return to page 0 |
| 25 | + // Display configuration |
| 26 | + 0x3A, 0x01, 0x55, // COLMOD: 16-bit RGB565 |
| 27 | + 0xC2, 0x81, 0x00, 0x0A, // Vendor command + 10ms delay |
| 28 | + 0x35, 0x00, // Tearing effect line on (no data) |
| 29 | + 0x51, 0x81, 0x00, 0x0A, // Brightness control + 10ms delay |
| 30 | + // Power on |
| 31 | + 0x11, 0x80, 0x50, // Sleep out + 80ms delay |
| 32 | + // Display window (MV=1: CASET→rows, RASET→cols) |
| 33 | + 0x2A, 0x04, 0x00, 0x10, 0x01, 0xD1, // CASET: 16..465 (450px + 16 offset) |
| 34 | + 0x2B, 0x04, 0x00, 0x00, 0x02, 0x57, // RASET: 0..599 (600px) |
| 35 | + // Enable display |
| 36 | + 0x29, 0x80, 0x0A, // Display on + 10ms delay |
| 37 | + // Memory access: MV=1, ML=1 for landscape |
| 38 | + 0x36, 0x81, 0x30, 0x0A, // MADCTL + 10ms delay |
| 39 | + // Brightness |
| 40 | + 0x51, 0x01, 0xFF, // Set brightness to maximum |
| 41 | +}; |
6 | 42 |
|
7 | 43 | void board_init(void) { |
| 44 | + // 1. Allocate and construct QSPI bus |
| 45 | + qspibus_qspibus_obj_t *bus = &allocate_display_bus_or_raise()->qspi_bus; |
| 46 | + bus->base.type = &qspibus_qspibus_type; |
| 47 | + |
| 48 | + common_hal_qspibus_qspibus_construct(bus, |
| 49 | + CIRCUITPY_LCD_CLK, // clock |
| 50 | + CIRCUITPY_LCD_D0, // data0 |
| 51 | + CIRCUITPY_LCD_D1, // data1 |
| 52 | + CIRCUITPY_LCD_D2, // data2 |
| 53 | + CIRCUITPY_LCD_D3, // data3 |
| 54 | + CIRCUITPY_LCD_CS, // cs |
| 55 | + NULL, // dcx (not used, QSPI uses encoded commands) |
| 56 | + CIRCUITPY_LCD_RESET, // reset |
| 57 | + 40000000); // 40 MHz |
| 58 | + |
| 59 | + // 2. Allocate and construct BusDisplay with RM690B0 init sequence. |
| 60 | + // Physical panel: 450 cols × 600 rows. |
| 61 | + // MADCTL MV=1 swaps row/col → logical 600×450 landscape. |
| 62 | + busdisplay_busdisplay_obj_t *display = &allocate_display_or_raise()->display; |
| 63 | + display->base.type = &busdisplay_busdisplay_type; |
| 64 | + |
| 65 | + common_hal_busdisplay_busdisplay_construct(display, |
| 66 | + bus, |
| 67 | + 600, // width (logical, after MV=1 swap) |
| 68 | + 450, // height (logical, after MV=1 swap) |
| 69 | + 0, // colstart |
| 70 | + 16, // rowstart (physical row offset) |
| 71 | + 0, // rotation |
| 72 | + 16, // color_depth (RGB565) |
| 73 | + false, // grayscale |
| 74 | + false, // pixels_in_byte_share_row |
| 75 | + 1, // bytes_per_cell |
| 76 | + false, // reverse_pixels_in_byte |
| 77 | + false, // reverse_bytes_in_word |
| 78 | + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set_column_command |
| 79 | + MIPI_COMMAND_SET_PAGE_ADDRESS, // set_row_command |
| 80 | + MIPI_COMMAND_WRITE_MEMORY_START, // write_ram_command |
| 81 | + (uint8_t *)display_init_sequence, |
| 82 | + sizeof(display_init_sequence), |
| 83 | + NULL, // backlight_pin (AMOLED — no backlight GPIO) |
| 84 | + 0x51, // brightness_command |
| 85 | + 1.0f, // brightness |
| 86 | + false, // single_byte_bounds |
| 87 | + false, // data_as_commands |
| 88 | + true, // auto_refresh |
| 89 | + 60, // native_frames_per_second |
| 90 | + true, // backlight_on_high |
| 91 | + false, // SH1107_addressing |
| 92 | + 50000); // backlight_pwm_frequency |
8 | 93 | } |
| 94 | + |
| 95 | +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. |
0 commit comments