diff --git a/include/ledmatrixdisplay.h b/include/ledmatrixdisplay.h index d5878f71..b7ec5a3b 100644 --- a/include/ledmatrixdisplay.h +++ b/include/ledmatrixdisplay.h @@ -13,6 +13,6 @@ void refreshTheMatrixDisplay(bool nextPage = false); void DrawNumber(String strNum, uint8_t iDotPos = 0); uint8_t GetCharFromFont(char cChar); uint8_t GetCharWidth(char cChar); -void ScrollLeft(uint8_t *buf, uint16_t cols, uint16_t rows); +void ScrollLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows); #endif \ No newline at end of file diff --git a/src/ledmatrixdisplay.cpp b/src/ledmatrixdisplay.cpp index ffdad8c0..881f57fe 100644 --- a/src/ledmatrixdisplay.cpp +++ b/src/ledmatrixdisplay.cpp @@ -204,13 +204,14 @@ uint8_t GetCharWidth(char cChar) { return CharDescriptor.width; } -void ScrollLeft(uint8_t *buf, uint16_t cols, uint16_t rows) { +void ScrollLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows) { uint32_t i, k, idx; + const uint32_t x = cols / 8; for (k = 0; k < rows; k++) { // scroll a line with x bytes one dot to the left - for (i = 0; i < cols / 8 - 1; ++i) { - idx = i + k * cols / 8; + for (i = 0; i < x - 1; ++i) { + idx = i + k * x; buf[idx] = (buf[idx] << 1) | ((buf[idx + 1] >> 7) & 1); } buf[idx + 1] <<= 1;