Skip to content

Commit dc75746

Browse files
committed
add docstring, clean up
1 parent 49fff2d commit dc75746

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

shared-bindings/displayio/Bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
178178
return mp_const_none;
179179
}
180180

181-
//| .. method:: fill()
181+
//| .. method:: fill(value)
182182
//|
183-
//| Fills the bitmap.
183+
//| Fills the bitmap with the supplied palette index value.
184184
//|
185185
STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) {
186186
displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in);

shared-module/displayio/Bitmap.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,21 @@ void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) {
164164
}
165165

166166
void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) {
167+
if (self->read_only) {
168+
mp_raise_RuntimeError(translate("Read-only object"));
169+
}
170+
// Update the dirty area.
171+
self->dirty_area.x1 = 0;
172+
self->dirty_area.x2 = self->width;
173+
self->dirty_area.y1 = 0;
174+
self->dirty_area.y2 = self->height;
167175

176+
// Update our data
177+
int32_t row_start;
178+
uint32_t bytes_per_value = self->bits_per_value / 8;
168179
for (uint32_t x=0; x<self->width; x++) {
169180
for (uint32_t y=0; y<self->height; y++) {
170-
int32_t row_start = y * self->stride;
171-
uint32_t bytes_per_value = self->bits_per_value / 8;
181+
row_start = y * self->stride;
172182
if (bytes_per_value < 1) {
173183
uint32_t bit_position = (sizeof(size_t) * 8 - ((x & self->x_mask) + 1) * self->bits_per_value);
174184
uint32_t index = row_start + (x >> self->x_shift);
@@ -188,9 +198,4 @@ void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value)
188198
}
189199
}
190200
}
191-
192-
self->dirty_area.x1 = 0;
193-
self->dirty_area.x2 = self->width;
194-
self->dirty_area.y1 = 0;
195-
self->dirty_area.y2 = self->height;
196201
}

0 commit comments

Comments
 (0)