Skip to content

Commit

Permalink
Make default font tables overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebs committed Mar 10, 2024
1 parent c4ec132 commit 0fed416
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Adafruit_LEDBackpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
} ///< 16-bit var swap
#endif

#ifdef USE_DEFAULT_SEVENSEG_FONTTABLE
static const PROGMEM uint8_t sevensegfonttable[] = {

0b00000000, // (space)
Expand Down Expand Up @@ -150,7 +151,9 @@ static const PROGMEM uint8_t sevensegfonttable[] = {
0b00000001, // ~
0b00000000, // del
};
#endif

#ifdef USE_DEFAULT_ALPHASEG_FONTTABLE
static const PROGMEM uint16_t alphafonttable[] = {

0b0000000000000001, 0b0000000000000010, 0b0000000000000100,
Expand Down Expand Up @@ -262,6 +265,7 @@ static const PROGMEM uint16_t alphafonttable[] = {
0b0011111111111111,

};
#endif

void Adafruit_LEDBackpack::setDisplayState(bool state) {
uint8_t buffer;
Expand Down
16 changes: 16 additions & 0 deletions Adafruit_LEDBackpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@

#define SEVENSEG_DIGITS 5 ///< # Digits in 7-seg displays, plus NUL end

// You have to define ADAFRUIT_USER_DEFINED_FONT to override default font table and define the font table content
#ifndef ADAFRUIT_USER_DEFINED_FONT
#define USE_DEFAULT_SEVENSEG_FONTTABLE
#define USE_DEFAULT_ALPHASEG_FONTTABLE
#else
extern const PROGMEM uint8_t sevensegfonttable[];
extern const PROGMEM uint16_t alphafonttable[];
#endif

/*
Segment names for 14-segment alphanumeric displays.
See https://learn.adafruit.com/14-segment-alpha-numeric-led-featherwing/usage
Expand Down Expand Up @@ -473,6 +482,13 @@ class Adafruit_AlphaNum4 : public Adafruit_LEDBackpack {
/*!
@brief Write single character of alphanumeric display as raw bits
(not a general print function).
f-----------
a| 7\ 6| 5/ e|
9---- 8----
b| 4/ 3| 2\ d|
c----------- 1.
The 16 bit digit you pass in for raw image has this mapping:
0(=0) 1 2 3 4 5 6 7 8 9 a b c d e f
@param n Character index (0-3).
@param bitmask Segment bitmask.
*/
Expand Down

0 comments on commit 0fed416

Please sign in to comment.