1212#include "shared-module/displayio/mipi_constants.h"
1313#include "driver/gpio.h"
1414#include "common-hal/microcontroller/Pin.h"
15-
15+ #include "shared-module/os/__init__.h"
1616
1717uint8_t display_init_sequence [] = {
1818 0x01 , 0x80 , 0x80 , // # Software reset then delay 0x80 (128ms)
@@ -43,6 +43,7 @@ uint8_t display_init_sequence[] = {
4343static void display_init (void ) {
4444 fourwire_fourwire_obj_t * bus = & allocate_display_bus ()-> fourwire_bus ;
4545 busio_spi_obj_t * spi = & bus -> inline_bus ;
46+ mp_int_t rotation ;
4647 common_hal_busio_spi_construct (spi , & pin_GPIO14 , & pin_GPIO13 , & pin_GPIO12 , false);
4748 common_hal_busio_spi_never_reset (spi );
4849
@@ -58,13 +59,18 @@ static void display_init(void) {
5859
5960 busdisplay_busdisplay_obj_t * display = & allocate_display ()-> display ;
6061 display -> base .type = & busdisplay_busdisplay_type ;
62+ os_getenv_err_t result = common_hal_os_getenv_int ("CIRCUITPY_DISP_ROTATION" , & rotation );
63+ if (result != GETENV_OK ) {
64+ rotation = 0 ;
65+ }
66+
6167 common_hal_busdisplay_busdisplay_construct (display ,
6268 bus ,
6369 320 , // Width
6470 240 , // Height
6571 0 , // column start
6672 0 , // row start
67- 270 , // rotation
73+ rotation , // rotation
6874 16 , // Color depth
6975 false, // Grayscale
7076 false, // pixels in a byte share a row. Only valid for depths < 8
@@ -102,4 +108,4 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
102108 return false;
103109}
104110
105- // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
111+ // Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
0 commit comments