ledmatrix: bugfix scrolling
This commit is contained in:
parent
526fc2900c
commit
012bf545c4
@ -13,6 +13,6 @@ void refreshTheMatrixDisplay(bool nextPage = false);
|
|||||||
void DrawNumber(String strNum, uint8_t iDotPos = 0);
|
void DrawNumber(String strNum, uint8_t iDotPos = 0);
|
||||||
uint8_t GetCharFromFont(char cChar);
|
uint8_t GetCharFromFont(char cChar);
|
||||||
uint8_t GetCharWidth(char cChar);
|
uint8_t GetCharWidth(char cChar);
|
||||||
void ShiftLeft(uint8_t *arr, uint32_t len);
|
void ScrollLeft(uint8_t *buf, uint16_t cols, uint16_t rows);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -2,16 +2,14 @@
|
|||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
#define NUMROWS 16
|
|
||||||
#define NUMCOLS 64
|
|
||||||
#define MATRIX_DISPLAY_PAGES (2) // number of display pages
|
#define MATRIX_DISPLAY_PAGES (2) // number of display pages
|
||||||
#define LINE_DIAGRAM_DIVIDER (2) // scales pax numbers to led rows
|
#define LINE_DIAGRAM_DIVIDER (2) // scales pax numbers to led rows
|
||||||
|
|
||||||
// local Tag for logging
|
// local Tag for logging
|
||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
static const uint32_t DisplaySize = LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / 8;
|
uint8_t MatrixDisplayIsOn = 0;
|
||||||
uint8_t MatrixDisplayIsOn = 0, displaybuf[DisplaySize] = {0};
|
static uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / 8] = {0};
|
||||||
static unsigned long ulLastNumMacs = 0;
|
static unsigned long ulLastNumMacs = 0;
|
||||||
static time_t ulLastTime = myTZ.toLocal(now());
|
static time_t ulLastTime = myTZ.toLocal(now());
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ void init_matrix_display(bool reverse) {
|
|||||||
if (reverse)
|
if (reverse)
|
||||||
matrix.reverse();
|
matrix.reverse();
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
matrix.drawPoint(0, NUMROWS - 1, 1);
|
matrix.drawPoint(0, LED_MATRIX_HEIGHT - 1, 1);
|
||||||
} // init_display
|
} // init_display
|
||||||
|
|
||||||
void refreshTheMatrixDisplay(bool nextPage) {
|
void refreshTheMatrixDisplay(bool nextPage) {
|
||||||
@ -93,10 +91,10 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
if (macs.size() == 0) {
|
if (macs.size() == 0) {
|
||||||
|
|
||||||
// matrix full? then scroll left 1 dot, else increment column
|
// matrix full? then scroll left 1 dot, else increment column
|
||||||
if (col < NUMCOLS - 1)
|
if (col < (LED_MATRIX_WIDTH - 1))
|
||||||
col++;
|
col++;
|
||||||
else
|
else
|
||||||
ShiftLeft(displaybuf, DisplaySize);
|
ScrollLeft(displaybuf, LED_MATRIX_WIDTH, LED_MATRIX_HEIGHT);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
matrix.drawPoint(col, row, 0); // clear current dot
|
matrix.drawPoint(col, row, 0); // clear current dot
|
||||||
@ -104,7 +102,9 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
// scale and set new dot
|
// scale and set new dot
|
||||||
ulLastNumMacs = macs.size();
|
ulLastNumMacs = macs.size();
|
||||||
level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER;
|
level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER;
|
||||||
row = level <= NUMROWS ? NUMROWS - 1 - level % NUMROWS : 0;
|
row = level <= LED_MATRIX_HEIGHT
|
||||||
|
? LED_MATRIX_HEIGHT - 1 - level % LED_MATRIX_HEIGHT
|
||||||
|
: 0;
|
||||||
matrix.drawPoint(col, row, 1);
|
matrix.drawPoint(col, row, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,12 +204,17 @@ uint8_t GetCharWidth(char cChar) {
|
|||||||
return CharDescriptor.width;
|
return CharDescriptor.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShiftLeft(uint8_t *arr, uint32_t len) {
|
void ScrollLeft(uint8_t *buf, uint16_t cols, uint16_t rows) {
|
||||||
uint32_t i;
|
uint32_t i, k, idx;
|
||||||
for (i = 0; i < len - 1; ++i) {
|
|
||||||
arr[i] = (arr[i] << 1) | ((arr[i + 1] >> 31) & 1);
|
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;
|
||||||
|
buf[idx] = (buf[idx] << 1) | ((buf[idx + 1] >> 7) & 1);
|
||||||
|
}
|
||||||
|
buf[idx + 1] <<= 1;
|
||||||
}
|
}
|
||||||
arr[len - 1] = arr[len - 1] << 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_MATRIX_DISPLAY
|
#endif // HAS_MATRIX_DISPLAY
|
Loading…
Reference in New Issue
Block a user