Skip to content

Commit 9500c20

Browse files
authored
Merge pull request #6784 from gamblor21/is31fl3741-fix
Two small fixes, remove hardcoded height and non-scaled display issues
2 parents f5f63da + f134f86 commit 9500c20

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

shared-bindings/is31fl3741/IS31FL3741.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self);
4646
void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current);
4747
uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self);
4848
void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page);
49-
void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping);
49+
void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping, uint8_t display_height);

shared-module/is31fl3741/FrameBuffer.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel
141141
if (!self->paused) {
142142
common_hal_is31fl3741_begin_transaction(self->is31fl3741);
143143

144-
uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix
145-
144+
uint8_t dirty_row_flags = 0xFF;
146145
if (self->scale) {
147146
// Based on the Arduino IS31FL3741 driver code
148147
// dirtyrows flag current not implemented for scaled displays
@@ -173,7 +172,7 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel
173172
} else {
174173
color = (rsum << 16) + (gsum << 8) + bsum;
175174
}
176-
common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping);
175+
common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping, self->height);
177176
}
178177
}
179178
} else {
@@ -194,9 +193,11 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel
194193
color = *buffer;
195194
}
196195

197-
common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping);
196+
common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping, self->height);
198197
buffer++;
199198
}
199+
} else {
200+
buffer += self->width; // row did not have to be redrawn, skip it in the buffer
200201
}
201202
}
202203
}

shared-module/is31fl3741/IS31FL3741.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,17 @@ void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t l
148148
common_hal_busio_i2c_write(self->i2c, self->device_address, cmd, 2);
149149
}
150150

151-
void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) {
151+
void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping, uint8_t display_height) {
152152
uint8_t r = color >> 16 & 0xFF;
153153
uint8_t g = color >> 8 & 0xFF;
154154
uint8_t b = color & 0xFF;
155155

156-
int16_t x1 = (x * 5 + y) * 3;
156+
int16_t x1 = (x * display_height + y) * 3;
157157
uint16_t ridx = mapping[x1 + 2];
158158
if (ridx != 65535) {
159159
uint16_t gidx = mapping[x1 + 1];
160160
uint16_t bidx = mapping[x1 + 0];
161+
161162
common_hal_is31fl3741_set_led(self, ridx, r, 0);
162163
common_hal_is31fl3741_set_led(self, gidx, g, 0);
163164
common_hal_is31fl3741_set_led(self, bidx, b, 0);

0 commit comments

Comments
 (0)