Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default font tables overridable #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 17 additions & 0 deletions Adafruit_LEDBackpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@

#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 ///< Override default font table
#define USE_DEFAULT_SEVENSEG_FONTTABLE ///< Use default sevensegfonttable
#define USE_DEFAULT_ALPHASEG_FONTTABLE ///< Use default alphafonttable
#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 +483,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
Loading