diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2020-04-17 13:27:48 -0400 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2020-04-17 13:27:48 -0400 |
| commit | 25245bc44204856c6fd834d7d2bc30187a77bc3a (patch) | |
| tree | 61995279880cd0a49b797d0ad3897a38e3312bbc /shared-module/displayio/Bitmap.c | |
| parent | 3c50098dfc353b0f30f3a743d45dce9de95e060a (diff) | |
| parent | 1a71c8c51577cc7014d5db1c05084778c0b977e9 (diff) | |
Merge remote-tracking branch 'upstream/master' into stm32-docfix
Diffstat (limited to 'shared-module/displayio/Bitmap.c')
| -rw-r--r-- | shared-module/displayio/Bitmap.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 59971d25c..8bcda6086 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -162,3 +162,24 @@ void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) { self->dirty_area.x1 = 0; self->dirty_area.x2 = 0; } + +void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only object")); + } + // Update the dirty area. + self->dirty_area.x1 = 0; + self->dirty_area.x2 = self->width; + self->dirty_area.y1 = 0; + self->dirty_area.y2 = self->height; + + // build the packed word + uint32_t word = 0; + for (uint8_t i=0; i<32 / self->bits_per_value; i++) { + word |= (value & self->bitmask) << (32 - ((i+1)*self->bits_per_value)); + } + // copy it in + for (uint32_t i=0; i<self->stride * self->height; i++) { + self->data[i] = word; + } +} |
