diff options
Diffstat (limited to 'components/axs15231b/axs15231b.c')
| -rw-r--r-- | components/axs15231b/axs15231b.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/components/axs15231b/axs15231b.c b/components/axs15231b/axs15231b.c index 7424a20..77708dd 100644 --- a/components/axs15231b/axs15231b.c +++ b/components/axs15231b/axs15231b.c | |||
| @@ -37,6 +37,7 @@ static spi_device_handle_t s_spi = NULL; | |||
| 37 | static uint16_t *s_fb = NULL; | 37 | static uint16_t *s_fb = NULL; |
| 38 | static int s_width = AXS15231B_WIDTH; | 38 | static int s_width = AXS15231B_WIDTH; |
| 39 | static int s_height = AXS15231B_HEIGHT; | 39 | static int s_height = AXS15231B_HEIGHT; |
| 40 | static int s_rotation = 0; | ||
| 40 | static uint8_t *s_swap_buf = NULL; | 41 | static uint8_t *s_swap_buf = NULL; |
| 41 | #define SWAP_BUF_PIXELS 2048 | 42 | #define SWAP_BUF_PIXELS 2048 |
| 42 | 43 | ||
| @@ -354,3 +355,34 @@ void axs15231b_flush(void) { | |||
| 354 | 355 | ||
| 355 | int axs15231b_get_width(void) { return s_width; } | 356 | int axs15231b_get_width(void) { return s_width; } |
| 356 | int axs15231b_get_height(void) { return s_height; } | 357 | int axs15231b_get_height(void) { return s_height; } |
| 358 | |||
| 359 | void axs15231b_set_rotation(int rotation) { | ||
| 360 | uint8_t madctl = MADCTL_RGB; | ||
| 361 | switch (rotation) { | ||
| 362 | case 0: | ||
| 363 | madctl = MADCTL_RGB; | ||
| 364 | s_width = AXS15231B_WIDTH; | ||
| 365 | s_height = AXS15231B_HEIGHT; | ||
| 366 | break; | ||
| 367 | case 1: | ||
| 368 | madctl = MADCTL_MX | MADCTL_MV; | ||
| 369 | s_width = AXS15231B_HEIGHT; | ||
| 370 | s_height = AXS15231B_WIDTH; | ||
| 371 | break; | ||
| 372 | case 2: | ||
| 373 | madctl = MADCTL_MX | MADCTL_MY; | ||
| 374 | s_width = AXS15231B_WIDTH; | ||
| 375 | s_height = AXS15231B_HEIGHT; | ||
| 376 | break; | ||
| 377 | case 3: | ||
| 378 | madctl = MADCTL_MY | MADCTL_MV; | ||
| 379 | s_width = AXS15231B_HEIGHT; | ||
| 380 | s_height = AXS15231B_WIDTH; | ||
| 381 | break; | ||
| 382 | default: | ||
| 383 | return; | ||
| 384 | } | ||
| 385 | s_rotation = rotation; | ||
| 386 | qspi_write_cmd_data8(MADCTL, madctl); | ||
| 387 | ESP_LOGI(TAG, "Rotation set to %d (%dx%d)", rotation, s_width, s_height); | ||
| 388 | } | ||