summaryrefslogtreecommitdiff
path: root/shared-module/displayio/Display.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-02-01 13:35:26 -0500
committerGitHub <noreply@github.com>2019-02-01 13:35:26 -0500
commit12917d323de2b4426c35c039a353d65b9acfad99 (patch)
treec48a82efc5d755f68dc1fbf2973012821e6d8788 /shared-module/displayio/Display.c
parent7d039a5467b90b7b974012ba682cf0f374987fb5 (diff)
parent845783a4572e919658b4c320cb1359f2c7ebbadd (diff)
Merge pull request #1513 from tannewt/rotation
Add support for display rotation and raw commands
Diffstat (limited to 'shared-module/displayio/Display.c')
-rw-r--r--shared-module/displayio/Display.c26
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)) {