Skip to content

Commit 03261fe

Browse files
authored
Merge pull request #8191 from gaweng/main
displayio: added Mapping to bits_per_value getter
2 parents be0028e + e58496f commit 03261fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

shared-bindings/displayio/Bitmap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_get_height_obj, displayio_bitmap_obj_
116116
MP_PROPERTY_GETTER(displayio_bitmap_height_obj,
117117
(mp_obj_t)&displayio_bitmap_get_height_obj);
118118

119+
//| bits_per_value: int
120+
//| """Bits per Pixel of the bitmap. (read only)"""
121+
STATIC mp_obj_t displayio_bitmap_obj_get_bits_per_value(mp_obj_t self_in) {
122+
displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in);
123+
124+
check_for_deinit(self);
125+
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_bits_per_value(self));
126+
}
127+
128+
MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_get_bits_per_value_obj, displayio_bitmap_obj_get_bits_per_value);
129+
130+
MP_PROPERTY_GETTER(displayio_bitmap_bits_per_value_obj,
131+
(mp_obj_t)&displayio_bitmap_get_bits_per_value_obj);
132+
133+
119134
//| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int:
120135
//| """Returns the value at the given index. The index can either be an x,y tuple or an int equal
121136
//| to ``y * width + x``.
@@ -260,6 +275,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_bitmap_deinit_obj, displayio_bitmap_obj_dein
260275
STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = {
261276
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_bitmap_height_obj) },
262277
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_bitmap_width_obj) },
278+
{ MP_ROM_QSTR(MP_QSTR_bits_per_value), MP_ROM_PTR(&displayio_bitmap_bits_per_value_obj) },
263279
{ MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&displayio_bitmap_fill_obj) },
264280
{ MP_ROM_QSTR(MP_QSTR_dirty), MP_ROM_PTR(&displayio_bitmap_dirty_obj) },
265281
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&displayio_bitmap_deinit_obj) },

0 commit comments

Comments
 (0)