Emphasize that ALIGN_BITS is a constant

This commit is contained in:
Jeff Epler 2023-01-01 16:40:06 -06:00
parent d2361ae4f9
commit d808185744
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -30,12 +30,12 @@
#include "py/runtime.h" #include "py/runtime.h"
enum { align_bits = 8 * sizeof(uint32_t) }; enum { ALIGN_BITS = 8 * sizeof(uint32_t) };
static int stride(uint32_t width, uint32_t bits_per_value) { static int stride(uint32_t width, uint32_t bits_per_value) {
uint32_t row_width = width * bits_per_value; uint32_t row_width = width * bits_per_value;
// align to uint32_t // align to uint32_t
return (row_width + align_bits - 1) / align_bits; return (row_width + ALIGN_BITS - 1) / ALIGN_BITS;
} }
void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width, void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width,
@ -66,7 +66,7 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
self->x_shift = 0; // Used to divide the index by the number of pixels per word. Its used in a self->x_shift = 0; // Used to divide the index by the number of pixels per word. Its used in a
// shift which effectively divides by 2 ** x_shift. // shift which effectively divides by 2 ** x_shift.
uint32_t power_of_two = 1; uint32_t power_of_two = 1;
while (power_of_two < align_bits / bits_per_value) { while (power_of_two < ALIGN_BITS / bits_per_value) {
self->x_shift++; self->x_shift++;
power_of_two <<= 1; power_of_two <<= 1;
} }