Expose rotation with a property

This commit is contained in:
Dave Astels 2019-07-31 15:00:21 -04:00
parent 741cd9c40a
commit 1f9cb44fa3
4 changed files with 25 additions and 1 deletions

View File

@ -329,6 +329,23 @@ const mp_obj_property_t displayio_display_height_obj = {
(mp_obj_t)&mp_const_none_obj}, (mp_obj_t)&mp_const_none_obj},
}; };
//| .. attribute:: rotation
//|
//| The rotation of the display as an int in degrees.
//|
STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) {
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation);
const mp_obj_property_t displayio_display_rotation_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&displayio_display_get_rotation_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| .. attribute:: bus //| .. attribute:: bus
//| //|
//| The bus being used by the display //| The bus being used by the display
@ -479,6 +496,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) },
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) },
{ MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) },
// { MP_ROM_QSTR(MP_QSTR_screenshot), MP_ROM_PTR(&displayio_display_screenshot_obj) }, // { MP_ROM_QSTR(MP_QSTR_screenshot), MP_ROM_PTR(&displayio_display_screenshot_obj) },
}; };

View File

@ -68,6 +68,7 @@ void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* s
uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self); uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self); uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self);
mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self); mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self);
bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness); bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness);

View File

@ -119,7 +119,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->width = width; self->width = width;
self->height = height; self->height = height;
rotation = rotation % 360; self->rotation = rotation % 360;
self->transform.x = 0; self->transform.x = 0;
self->transform.y = 0; self->transform.y = 0;
self->transform.scale = 1; self->transform.scale = 1;
@ -242,6 +242,10 @@ uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self){
return self->height; return self->height;
} }
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self){
return self->rotation;
}
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness) { void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness) {
self->auto_brightness = auto_brightness; self->auto_brightness = auto_brightness;
} }

View File

@ -55,6 +55,7 @@ typedef struct {
mp_float_t current_brightness; mp_float_t current_brightness;
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
uint16_t rotation;
_displayio_colorspace_t colorspace; _displayio_colorspace_t colorspace;
int16_t colstart; int16_t colstart;
int16_t rowstart; int16_t rowstart;