Merge pull request #413 from cyberman54/development

Bugfixes
This commit is contained in:
Verkehrsrot 2019-08-18 22:31:12 +02:00 committed by GitHub
commit 8f257e524c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 21 deletions

View File

@ -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

View File

@ -24,8 +24,8 @@
// LED Matrix display settings // LED Matrix display settings
#define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output #define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output
#define LED_MATRIX_WIDTH 64 // Width in pixels (LEDs) of your display #define LED_MATRIX_WIDTH (32*2) // Width (cols) in pixels (LEDs) of your display, must be 32X
#define LED_MATRIX_HEIGHT 16 // Height in pixels (LEDs ) of your display #define LED_MATRIX_HEIGHT (16*1) // Height (rows) in pixels (LEDs) of your display, must be 16X
// Explanation of pin signals see https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/new-wiring // Explanation of pin signals see https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/new-wiring
#define MATRIX_DISPLAY_SCAN_US 500 // Matrix display scan rate in microseconds (1ms is about 'acceptable') #define MATRIX_DISPLAY_SCAN_US 500 // Matrix display scan rate in microseconds (1ms is about 'acceptable')

View File

@ -11,8 +11,8 @@
// LED Matrix display settings // LED Matrix display settings
#define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output #define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output
#define LED_MATRIX_WIDTH 64 // Width in pixels (LEDs) of your display #define LED_MATRIX_WIDTH (32*2) // Width (cols) in pixels (LEDs) of your display, must be 32X
#define LED_MATRIX_HEIGHT 16 // Height in pixels (LEDs ) of your display #define LED_MATRIX_HEIGHT (16*1) // Height (rows) in pixels (LEDs) of your display, must be 16X
// Pin numbers work fine for Wemos Lolin32 board (all used pins are on 1 side of the board) // Pin numbers work fine for Wemos Lolin32 board (all used pins are on 1 side of the board)
// Explanation of pin signals see https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/new-wiring // Explanation of pin signals see https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/new-wiring

View File

@ -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

View File

@ -36,7 +36,6 @@ timesync_req 1 3 processes realtime time sync requests
lmictask 1 2 MCCI LMiC LORAWAN stack lmictask 1 2 MCCI LMiC LORAWAN stack
irqhandler 1 1 display, timesync, gps, etc. triggered by timers irqhandler 1 1 display, timesync, gps, etc. triggered by timers
gpsloop 1 1 reads data from GPS via serial or i2c gpsloop 1 1 reads data from GPS via serial or i2c
looptask 1 1 arduino loop (unused)
IDLE 1 0 ESP32 arduino scheduler -> runs wifi channel rotator IDLE 1 0 ESP32 arduino scheduler -> runs wifi channel rotator
Low priority numbers denote low priority tasks. Low priority numbers denote low priority tasks.

View File

@ -66,6 +66,10 @@ finish:
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec,
timesource_t mytimesource) { timesource_t mytimesource) {
// called with invalid timesource?
if (mytimesource == _unsynced)
return;
// increment t_sec only if t_msec > 1000 // increment t_sec only if t_msec > 1000
time_t time_to_set = (time_t)(t_sec + t_msec / 1000); time_t time_to_set = (time_t)(t_sec + t_msec / 1000);

View File

@ -178,7 +178,7 @@ int recv_timesync_ans(uint8_t seq_no, uint8_t buf[], uint8_t buf_len) {
// the 5th byte contains the fractional seconds in 2^-8 second steps // the 5th byte contains the fractional seconds in 2^-8 second steps
// (= 1/250th sec), we convert this to ms // (= 1/250th sec), we convert this to ms
uint16_t timestamp_msec = 4 * buf[4]; uint16_t timestamp_msec = 4 * buf[4];
// pointers to 4 bytes 4 bytes containing UTC seconds since unix epoch, msb // pointers to 4 bytes containing UTC seconds since unix epoch, msb
uint32_t timestamp_sec, *timestamp_ptr; uint32_t timestamp_sec, *timestamp_ptr;
// convert buffer to uint32_t, octet order is big endian // convert buffer to uint32_t, octet order is big endian