From f134f86291e717abf50341853e93609b1284942e Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Fri, 19 Aug 2022 15:13:38 -0500 Subject: [PATCH] Two small fixes, remove hardcoded height and non-scale issues --- shared-bindings/is31fl3741/IS31FL3741.h | 2 +- shared-module/is31fl3741/FrameBuffer.c | 9 +++++---- shared-module/is31fl3741/IS31FL3741.c | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shared-bindings/is31fl3741/IS31FL3741.h b/shared-bindings/is31fl3741/IS31FL3741.h index 2b81b01617..62302a3ac2 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.h +++ b/shared-bindings/is31fl3741/IS31FL3741.h @@ -46,4 +46,4 @@ void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self); void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current); uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self); void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page); -void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping); +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); diff --git a/shared-module/is31fl3741/FrameBuffer.c b/shared-module/is31fl3741/FrameBuffer.c index 400f6f843d..d795c0d5e7 100644 --- a/shared-module/is31fl3741/FrameBuffer.c +++ b/shared-module/is31fl3741/FrameBuffer.c @@ -141,8 +141,7 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel if (!self->paused) { common_hal_is31fl3741_begin_transaction(self->is31fl3741); - uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix - + uint8_t dirty_row_flags = 0xFF; if (self->scale) { // Based on the Arduino IS31FL3741 driver code // dirtyrows flag current not implemented for scaled displays @@ -173,7 +172,7 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel } else { color = (rsum << 16) + (gsum << 8) + bsum; } - common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping, self->height); } } } else { @@ -194,9 +193,11 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel color = *buffer; } - common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping, self->height); buffer++; } + } else { + buffer += self->width; // row did not have to be redrawn, skip it in the buffer } } } diff --git a/shared-module/is31fl3741/IS31FL3741.c b/shared-module/is31fl3741/IS31FL3741.c index bb92b5b32c..08598743b7 100644 --- a/shared-module/is31fl3741/IS31FL3741.c +++ b/shared-module/is31fl3741/IS31FL3741.c @@ -148,16 +148,17 @@ void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t l common_hal_busio_i2c_write(self->i2c, self->device_address, cmd, 2); } -void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) { +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) { uint8_t r = color >> 16 & 0xFF; uint8_t g = color >> 8 & 0xFF; uint8_t b = color & 0xFF; - int16_t x1 = (x * 5 + y) * 3; + int16_t x1 = (x * display_height + y) * 3; uint16_t ridx = mapping[x1 + 2]; if (ridx != 65535) { uint16_t gidx = mapping[x1 + 1]; uint16_t bidx = mapping[x1 + 0]; + common_hal_is31fl3741_set_led(self, ridx, r, 0); common_hal_is31fl3741_set_led(self, gidx, g, 0); common_hal_is31fl3741_set_led(self, bidx, b, 0);