Skip to content

Commit f368710

Browse files
committed
extmod/modframebuf: Consistently use "col" as name for colour variables.
Thanks to @kamikaze, aka Oleg Korsak, for the original idea and patch.
1 parent 0893b27 commit f368710

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

extmod/modframebuf.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ typedef struct _mp_framebuf_p_t {
6262

6363
// Functions for MHLSB and MHMSB
6464

65-
STATIC void mono_horiz_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t color) {
65+
STATIC void mono_horiz_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {
6666
size_t index = (x + y * fb->stride) >> 3;
6767
int offset = fb->format == FRAMEBUF_MHMSB ? x & 0x07 : 7 - (x & 0x07);
68-
((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((color != 0) << offset);
68+
((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset);
6969
}
7070

7171
STATIC uint32_t mono_horiz_getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
@@ -90,10 +90,10 @@ STATIC void mono_horiz_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int
9090

9191
// Functions for MVLSB format
9292

93-
STATIC void mvlsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t color) {
93+
STATIC void mvlsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {
9494
size_t index = (y >> 3) * fb->stride + x;
9595
uint8_t offset = y & 0x07;
96-
((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((color != 0) << offset);
96+
((uint8_t*)fb->buf)[index] = (((uint8_t*)fb->buf)[index] & ~(0x01 << offset)) | ((col != 0) << offset);
9797
}
9898

9999
STATIC uint32_t mvlsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
@@ -114,19 +114,19 @@ STATIC void mvlsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, in
114114

115115
// Functions for RGB565 format
116116

117-
STATIC void rgb565_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t color) {
118-
((uint16_t*)fb->buf)[x + y * fb->stride] = color;
117+
STATIC void rgb565_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {
118+
((uint16_t*)fb->buf)[x + y * fb->stride] = col;
119119
}
120120

121121
STATIC uint32_t rgb565_getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
122122
return ((uint16_t*)fb->buf)[x + y * fb->stride];
123123
}
124124

125-
STATIC void rgb565_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t colour) {
125+
STATIC void rgb565_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, uint32_t col) {
126126
uint16_t *b = &((uint16_t*)fb->buf)[x + y * fb->stride];
127127
while (h--) {
128128
for (int ww = w; ww; --ww) {
129-
*b++ = colour;
129+
*b++ = col;
130130
}
131131
b += fb->stride - w;
132132
}
@@ -156,7 +156,7 @@ STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w,
156156
col &= 0x0f;
157157
uint8_t *pixel_pair = &((uint8_t*)fb->buf)[(x + y * fb->stride) >> 1];
158158
uint8_t col_shifted_left = col << 4;
159-
uint8_t colored_pixel_pair = col_shifted_left | col;
159+
uint8_t col_pixel_pair = col_shifted_left | col;
160160
int pixel_count_till_next_line = (fb->stride - w) >> 1;
161161
bool odd_x = (x % 2 == 1);
162162

@@ -169,7 +169,7 @@ STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w,
169169
ww--;
170170
}
171171

172-
memset(pixel_pair, colored_pixel_pair, ww >> 1);
172+
memset(pixel_pair, col_pixel_pair, ww >> 1);
173173
pixel_pair += ww >> 1;
174174

175175
if (ww % 2) {
@@ -191,8 +191,8 @@ STATIC mp_framebuf_p_t formats[] = {
191191
[FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
192192
};
193193

194-
static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t color) {
195-
formats[fb->format].setpixel(fb, x, y, color);
194+
static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {
195+
formats[fb->format].setpixel(fb, x, y, col);
196196
}
197197

198198
static inline uint32_t getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
@@ -277,9 +277,9 @@ STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) {
277277
mp_int_t y = mp_obj_get_int(args[2]);
278278
mp_int_t width = mp_obj_get_int(args[3]);
279279
mp_int_t height = mp_obj_get_int(args[4]);
280-
mp_int_t color = mp_obj_get_int(args[5]);
280+
mp_int_t col = mp_obj_get_int(args[5]);
281281

282-
fill_rect(self, x, y, width, height, color);
282+
fill_rect(self, x, y, width, height, col);
283283

284284
return mp_const_none;
285285
}
@@ -444,14 +444,13 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
444444
int y1 = MAX(0, -y);
445445
int x0end = MIN(self->width, x + source->width);
446446
int y0end = MIN(self->height, y + source->height);
447-
uint32_t color;
448447

449448
for (; y0 < y0end; ++y0) {
450449
int cx1 = x1;
451450
for (int cx0 = x0; cx0 < x0end; ++cx0) {
452-
color = getpixel(source, cx1, y1);
453-
if (color != (uint32_t)key) {
454-
setpixel(self, cx0, y0, color);
451+
uint32_t col = getpixel(source, cx1, y1);
452+
if (col != (uint32_t)key) {
453+
setpixel(self, cx0, y0, col);
455454
}
456455
++cx1;
457456
}

0 commit comments

Comments
 (0)