LED matrix display improvements

This commit is contained in:
Verkehrsrot committed 2019-05-31 13:20:11 +02:00
1 parent bac5bde28f
commit 23999c3e2b
8 files changed
+89 -20

No files matched your search

+7 -2
View File
@@ -23,8 +23,13 @@ void button_init(int pin) {
b->setOnClicked([]() {
#ifdef HAS_DISPLAY
refreshtheDisplay(true); // switch to next display page
#else
refreshTheDisplay(true); // switch to next display page
#endif
#ifdef HAS_MATRIX_DISPLAY
refreshTheMatrixDisplay(true); // switch to next display page
#endif
#if (!defined HAS_DISPLAY) && (!defined HAS_MATRIX_DISPLAY)
payload.reset();
payload.addButton(0x01);
SendPayload(BUTTONPORT, prio_normal);
+4 -5
View File
@@ -129,16 +129,17 @@ void init_display(const char *Productname, const char *Version) {
} // mutex
} // init_display
void refreshtheDisplay(bool nextPage) {
void refreshTheDisplay(bool nextPage) {
static uint8_t DisplayPage = 0;
const time_t t =
myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
// if display is switched off we don't refresh it to relax cpu
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
return;
const time_t t =
myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
// block i2c bus access
if (I2C_MUTEX_LOCK()) {
@@ -160,8 +161,6 @@ void refreshtheDisplay(bool nextPage) {
} // mutex
} // refreshDisplay()
void refreshtheDisplay() { refreshtheDisplay(false); }
void draw_page(time_t t, uint8_t page) {
char timeState, buff[16];
+1 -1
View File
@@ -36,7 +36,7 @@ void irqHandler(void *pvParameters) {
// display needs refresh?
#ifdef HAS_DISPLAY
if (InterruptStatus & DISPLAY_IRQ)
refreshtheDisplay();
refreshTheDisplay();
#endif
// LED Matrix display needs refresh?
+39 -5
View File
@@ -3,12 +3,14 @@
#include "globals.h"
#define NUMCHARS 5
#define MATRIX_DISPLAY_PAGES (2) // number of display pages
// local Tag for logging
static const char TAG[] = __FILE__;
uint8_t MatrixDisplayIsOn = 0;
static unsigned long ulLastNumMacs = 0;
static time_t ulLastTime = myTZ.toLocal(now());
LEDMatrix matrix(LED_MATRIX_LA_74138, LED_MATRIX_LB_74138, LED_MATRIX_LC_74138,
LED_MATRIX_LD_74138, LED_MATRIX_EN_74138, LED_MATRIX_DATA_R1,
@@ -17,7 +19,12 @@ LEDMatrix matrix(LED_MATRIX_LA_74138, LED_MATRIX_LB_74138, LED_MATRIX_LC_74138,
// Display Buffer 128 = 64 * 16 / 8
uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / NUMCHARS];
// --- SELECT YOUR FONT HERE ---
const FONT_INFO *ActiveFontInfo = &digital7_18ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &arialNarrow_17ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_18ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_16ptFontInfo;
const uint8_t *iaActiveFont = ActiveFontInfo->Bitmap;
const FONT_CHAR_INFO *ActiveFontCharInfo = ActiveFontInfo->Descriptors;
@@ -30,7 +37,9 @@ void init_matrix_display(bool reverse) {
DrawNumber(String("0"));
} // init_display
void refreshTheMatrixDisplay() {
void refreshTheMatrixDisplay(bool nextPage) {
static uint8_t DisplayPage = 0;
char buff[16];
// if Matrixdisplay is switched off we don't refresh it to relax cpu
if (!MatrixDisplayIsOn && (MatrixDisplayIsOn == cfg.screenon))
@@ -41,13 +50,38 @@ void refreshTheMatrixDisplay() {
MatrixDisplayIsOn = cfg.screenon;
}
if (ulLastNumMacs != macs.size()) {
ulLastNumMacs = macs.size();
if (nextPage) {
DisplayPage =
(DisplayPage >= MATRIX_DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
matrix.clear();
DrawNumber(String(ulLastNumMacs));
ESP_LOGD(TAG, "Setting display to counter: %lu",ulLastNumMacs);
}
switch (DisplayPage % MATRIX_DISPLAY_PAGES) {
// page 0: pax
// page 1: time
case 0:
if (ulLastNumMacs != macs.size()) {
ulLastNumMacs = macs.size();
matrix.clear();
DrawNumber(String(ulLastNumMacs));
}
case 1:
const time_t t = myTZ.toLocal(now());
if (ulLastTime != t) {
ulLastTime = t;
matrix.clear();
snprintf(buff, sizeof(buff), "%02d:%02d:%02d", hour(t), minute(t),
second(t));
DrawNumber(String(buff));
}
} // switch page
matrix.scan();
}
+32 -3
View File
@@ -205,6 +205,35 @@ const uint8_t arialNarrow_17ptBitmaps[] = {
0b00011100, 0b00000000, // ###
};
// Character descriptors for Arial Narrow 17pt
// { [Char width in bits], [Char height in bits], [Offset into
// arialNarrow_17ptBitmaps in bytes] }
const FONT_CHAR_INFO arialNarrow_17ptDescriptors[] = {
{10, 16, 0}, // -
{0, 0, 0}, // .
{0, 0, 0}, // /
{10, 16, 32}, // 0
{10, 16, 64}, // 1
{10, 16, 80}, // 2
{10, 16, 112}, // 3
{10, 16, 144}, // 4
{10, 16, 176}, // 5
{10, 16, 208}, // 6
{10, 16, 240}, // 7
{10, 16, 272}, // 8
{10, 16, 304}, // 9
};
// Font information for Arial Narrow 17pt
const FONT_INFO arialNarrow_17ptFontInfo = {
16, // Character height
'-', // Start character
'9', // End character
2, // Width, in pixels, of space character
arialNarrow_17ptDescriptors, // Character descriptor array
arialNarrow_17ptBitmaps}; // Character bitmap array
//
// Font data for Gill Sans MT Condensed 18pt
//
@@ -431,7 +460,7 @@ const FONT_CHAR_INFO gillSansMTCondensed_18ptDescriptors[] = {
// Font information for Gill Sans MT Condensed 18pt
const FONT_INFO gillSansMTCondensed_18ptFontInfo = {
2, // Character height
16, // Character height
'-', // Start character
'9', // End character
2, // Width, in pixels, of space character
@@ -642,7 +671,7 @@ const FONT_CHAR_INFO gillSansMTCondensed_16ptDescriptors[] = {
// Font information for Gill Sans MT Condensed 16pt
const FONT_INFO gillSansMTCondensed_16ptFontInfo = {
2, // Character height
14, // Character height
'-', // Start character
'9', // End character
2, // Width, in pixels, of space character
@@ -900,4 +929,4 @@ const FONT_INFO digital7_18ptFontInfo = {
2, // Width, in pixels, of space character
digital7_18ptDescriptors, // Character descriptor array
digital7_18ptBitmaps, // Character bitmap array
};
};