diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-02-01 00:32:03 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-02-01 00:32:03 -0800 |
| commit | 448ae64d8e2eb0cce9c5bd9dabd7f2354bb48682 (patch) | |
| tree | 9f156429c3638e7149fe3e0d7e585bf1fd2462e9 /shared-module/displayio/Display.c | |
| parent | d72cd5b2d6cbc95665c41a43d6d914e71ac58017 (diff) | |
Add support for display rotation and raw commands
Display rotation is relative to the scan order of the display.
The scan order can be found by scrolling the display with command
0x37 `display_bus.send(0x37, struct.pack(">H", i % 128))`
Fixes #1504
Diffstat (limited to 'shared-module/displayio/Display.c')
| -rw-r--r-- | shared-module/displayio/Display.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index ef0334d10..f14a27b78 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -41,12 +41,10 @@ #define DELAY 0x80 void common_hal_displayio_display_construct(displayio_display_obj_t* self, - mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, + mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, uint8_t set_column_command, uint8_t set_row_command, - uint8_t write_ram_command, uint8_t* init_sequence, uint16_t init_sequence_len, + uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin) { - self->width = width; - self->height = height; self->color_depth = color_depth; self->set_column_command = set_column_command; self->set_row_command = set_row_command; @@ -100,6 +98,26 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, self->refresh = true; self->current_group = &circuitpython_splash; + self->width = width; + self->height = height; + rotation = rotation % 360; + self->mirror_x = false; + self->mirror_y = false; + self->transpose_xy = false; + if (rotation == 0 || rotation == 180) { + if (rotation == 180) { + self->mirror_x = true; + self->mirror_y = true; + } + } else { + self->transpose_xy = true; + if (rotation == 90) { + self->mirror_y = true; + } else { + self->mirror_x = true; + } + } + // Always set the backlight type in case we're reusing memory. self->backlight_inout.base.type = &mp_type_NoneType; if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) { |
