summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorcaternuson <caternuson@gmail.com>2020-04-09 08:37:07 -0700
committercaternuson <caternuson@gmail.com>2020-04-09 08:43:50 -0700
commit49fff2d9b47a51e0f2f600602aaa2fddc234b4be (patch)
tree1f968d7b28b28c5a83b3ecdac2b2eb323b5e16af /shared-bindings
parentb3b8b5ca71dc58415083180d04b407185514c216 (diff)
initial working fill
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/displayio/Bitmap.c19
-rw-r--r--shared-bindings/displayio/Bitmap.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c
index 91c17f2d1..48d04c215 100644
--- a/shared-bindings/displayio/Bitmap.c
+++ b/shared-bindings/displayio/Bitmap.c
@@ -178,9 +178,28 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
return mp_const_none;
}
+//| .. method:: fill()
+//|
+//| Fills the bitmap.
+//|
+STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) {
+ displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in);
+
+ mp_int_t value = mp_obj_get_int(value_obj);
+ if (value >= 1 << common_hal_displayio_bitmap_get_bits_per_value(self)) {
+ mp_raise_ValueError(translate("pixel value requires too many bits"));
+ }
+ common_hal_displayio_bitmap_fill(self, value);
+
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(displayio_bitmap_fill_obj, displayio_bitmap_obj_fill);
+
STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_bitmap_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_bitmap_width_obj) },
+ { MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&displayio_bitmap_fill_obj) },
+
};
STATIC MP_DEFINE_CONST_DICT(displayio_bitmap_locals_dict, displayio_bitmap_locals_dict_table);
diff --git a/shared-bindings/displayio/Bitmap.h b/shared-bindings/displayio/Bitmap.h
index 90694951f..46c337329 100644
--- a/shared-bindings/displayio/Bitmap.h
+++ b/shared-bindings/displayio/Bitmap.h
@@ -41,5 +41,6 @@ uint16_t common_hal_displayio_bitmap_get_width(displayio_bitmap_t *self);
uint32_t common_hal_displayio_bitmap_get_bits_per_value(displayio_bitmap_t *self);
void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y, uint32_t value);
uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y);
+void common_hal_displayio_bitmap_fill(displayio_bitmap_t *bitmap, uint32_t value);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_BITMAP_H