LED matrix display improvements
This commit is contained in:
parent
bac5bde28f
commit
23999c3e2b
@ -9,8 +9,7 @@ extern uint8_t DisplayIsOn;
|
|||||||
extern HAS_DISPLAY u8x8;
|
extern HAS_DISPLAY u8x8;
|
||||||
|
|
||||||
void init_display(const char *Productname, const char *Version);
|
void init_display(const char *Productname, const char *Version);
|
||||||
void refreshtheDisplay(void);
|
void refreshTheDisplay(bool nextPage = false);
|
||||||
void refreshtheDisplay(bool nextPage);
|
|
||||||
void draw_page(time_t t, uint8_t page);
|
void draw_page(time_t t, uint8_t page);
|
||||||
void DisplayKey(const uint8_t *key, uint8_t len, bool lsb);
|
void DisplayKey(const uint8_t *key, uint8_t len, bool lsb);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ extern uint8_t MatrixDisplayIsOn;
|
|||||||
extern LEDMatrix matrix;
|
extern LEDMatrix matrix;
|
||||||
|
|
||||||
void init_matrix_display(bool reverse = false);
|
void init_matrix_display(bool reverse = false);
|
||||||
void refreshTheMatrixDisplay(void);
|
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);
|
||||||
|
@ -20,9 +20,12 @@ struct FONT_INFO {
|
|||||||
const uint8_t *Bitmap;
|
const uint8_t *Bitmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Font data for Microsoft Sans Serif 11pt
|
// Font data for Arial Narrow 17pt
|
||||||
extern const uint8_t arialNarrow_17ptBitmaps[];
|
extern const uint8_t arialNarrow_17ptBitmaps[];
|
||||||
|
extern const FONT_INFO arialNarrow_17ptFontInfo;
|
||||||
|
extern const FONT_CHAR_INFO arialNarrow_17ptDescriptors[];
|
||||||
|
|
||||||
|
// Font data for Gill Sans MT Condensed 18pt
|
||||||
extern const uint8_t gillSansMTCondensed_18ptBitmaps[];
|
extern const uint8_t gillSansMTCondensed_18ptBitmaps[];
|
||||||
extern const FONT_INFO gillSansMTCondensed_18ptFontInfo;
|
extern const FONT_INFO gillSansMTCondensed_18ptFontInfo;
|
||||||
extern const FONT_CHAR_INFO gillSansMTCondensed_18ptDescriptors[];
|
extern const FONT_CHAR_INFO gillSansMTCondensed_18ptDescriptors[];
|
||||||
|
@ -23,8 +23,13 @@ void button_init(int pin) {
|
|||||||
|
|
||||||
b->setOnClicked([]() {
|
b->setOnClicked([]() {
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
refreshtheDisplay(true); // switch to next display page
|
refreshTheDisplay(true); // switch to next display page
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAS_MATRIX_DISPLAY
|
||||||
|
refreshTheMatrixDisplay(true); // switch to next display page
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (!defined HAS_DISPLAY) && (!defined HAS_MATRIX_DISPLAY)
|
||||||
payload.reset();
|
payload.reset();
|
||||||
payload.addButton(0x01);
|
payload.addButton(0x01);
|
||||||
SendPayload(BUTTONPORT, prio_normal);
|
SendPayload(BUTTONPORT, prio_normal);
|
||||||
|
@ -129,16 +129,17 @@ void init_display(const char *Productname, const char *Version) {
|
|||||||
} // mutex
|
} // mutex
|
||||||
} // init_display
|
} // init_display
|
||||||
|
|
||||||
void refreshtheDisplay(bool nextPage) {
|
void refreshTheDisplay(bool nextPage) {
|
||||||
|
|
||||||
static uint8_t DisplayPage = 0;
|
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 display is switched off we don't refresh it to relax cpu
|
||||||
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
|
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const time_t t =
|
||||||
|
myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
|
||||||
|
|
||||||
// block i2c bus access
|
// block i2c bus access
|
||||||
if (I2C_MUTEX_LOCK()) {
|
if (I2C_MUTEX_LOCK()) {
|
||||||
|
|
||||||
@ -160,8 +161,6 @@ void refreshtheDisplay(bool nextPage) {
|
|||||||
} // mutex
|
} // mutex
|
||||||
} // refreshDisplay()
|
} // refreshDisplay()
|
||||||
|
|
||||||
void refreshtheDisplay() { refreshtheDisplay(false); }
|
|
||||||
|
|
||||||
void draw_page(time_t t, uint8_t page) {
|
void draw_page(time_t t, uint8_t page) {
|
||||||
|
|
||||||
char timeState, buff[16];
|
char timeState, buff[16];
|
||||||
|
@ -36,7 +36,7 @@ void irqHandler(void *pvParameters) {
|
|||||||
// display needs refresh?
|
// display needs refresh?
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
if (InterruptStatus & DISPLAY_IRQ)
|
if (InterruptStatus & DISPLAY_IRQ)
|
||||||
refreshtheDisplay();
|
refreshTheDisplay();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// LED Matrix display needs refresh?
|
// LED Matrix display needs refresh?
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
#define NUMCHARS 5
|
#define NUMCHARS 5
|
||||||
|
#define MATRIX_DISPLAY_PAGES (2) // number of display pages
|
||||||
|
|
||||||
// local Tag for logging
|
// local Tag for logging
|
||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
uint8_t MatrixDisplayIsOn = 0;
|
uint8_t MatrixDisplayIsOn = 0;
|
||||||
static unsigned long ulLastNumMacs = 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,
|
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,
|
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
|
// Display Buffer 128 = 64 * 16 / 8
|
||||||
uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / NUMCHARS];
|
uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / NUMCHARS];
|
||||||
|
|
||||||
|
// --- SELECT YOUR FONT HERE ---
|
||||||
const FONT_INFO *ActiveFontInfo = &digital7_18ptFontInfo;
|
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 uint8_t *iaActiveFont = ActiveFontInfo->Bitmap;
|
||||||
const FONT_CHAR_INFO *ActiveFontCharInfo = ActiveFontInfo->Descriptors;
|
const FONT_CHAR_INFO *ActiveFontCharInfo = ActiveFontInfo->Descriptors;
|
||||||
|
|
||||||
@ -30,7 +37,9 @@ void init_matrix_display(bool reverse) {
|
|||||||
DrawNumber(String("0"));
|
DrawNumber(String("0"));
|
||||||
} // init_display
|
} // 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 Matrixdisplay is switched off we don't refresh it to relax cpu
|
||||||
if (!MatrixDisplayIsOn && (MatrixDisplayIsOn == cfg.screenon))
|
if (!MatrixDisplayIsOn && (MatrixDisplayIsOn == cfg.screenon))
|
||||||
@ -41,13 +50,38 @@ void refreshTheMatrixDisplay() {
|
|||||||
MatrixDisplayIsOn = cfg.screenon;
|
MatrixDisplayIsOn = cfg.screenon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ulLastNumMacs != macs.size()) {
|
if (nextPage) {
|
||||||
ulLastNumMacs = macs.size();
|
DisplayPage =
|
||||||
|
(DisplayPage >= MATRIX_DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||||
matrix.clear();
|
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();
|
matrix.scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +205,35 @@ const uint8_t arialNarrow_17ptBitmaps[] = {
|
|||||||
0b00011100, 0b00000000, // ###
|
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
|
// 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
|
// Font information for Gill Sans MT Condensed 18pt
|
||||||
const FONT_INFO gillSansMTCondensed_18ptFontInfo = {
|
const FONT_INFO gillSansMTCondensed_18ptFontInfo = {
|
||||||
2, // Character height
|
16, // Character height
|
||||||
'-', // Start character
|
'-', // Start character
|
||||||
'9', // End character
|
'9', // End character
|
||||||
2, // Width, in pixels, of space 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
|
// Font information for Gill Sans MT Condensed 16pt
|
||||||
const FONT_INFO gillSansMTCondensed_16ptFontInfo = {
|
const FONT_INFO gillSansMTCondensed_16ptFontInfo = {
|
||||||
2, // Character height
|
14, // Character height
|
||||||
'-', // Start character
|
'-', // Start character
|
||||||
'9', // End character
|
'9', // End character
|
||||||
2, // Width, in pixels, of space character
|
2, // Width, in pixels, of space character
|
||||||
|
Loading…
Reference in New Issue
Block a user