File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ uint8_t target_lut;
6262
6363typedef struct _ugfx_obj_t { mp_obj_base_t base ; } ugfx_obj_t ;
6464
65+ extern bool ugfx_screen_flipped ;
6566static orientation_t get_orientation (int a ){
6667 if (a == 90 )
6768 return GDISP_ROTATE_90 ;
@@ -146,11 +147,19 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(ugfx_get_lut_obj, ugfx_get_lut);
146147STATIC mp_obj_t ugfx_set_orientation (mp_uint_t n_args , const mp_obj_t * args ) {
147148 if (n_args > 0 ){
148149 int a = mp_obj_get_int (args [0 ]);
150+ a %= 360 ;
151+ if (a >= 180 ) {
152+ ugfx_screen_flipped = true;
153+ a -= 180 ;
154+ }
149155 gdispSetOrientation (get_orientation (a ));
150-
151156 }
152157
153- return mp_obj_new_int (gdispGetOrientation ());
158+ int a = gdispGetOrientation ();
159+ if (ugfx_screen_flipped )
160+ a += 180 ;
161+ a %= 360 ;
162+ return mp_obj_new_int (a );
154163}
155164STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (ugfx_set_orientation_obj , 0 , 1 , ugfx_set_orientation );
156165
You can’t perform that action at this time.
0 commit comments