Skip to content

Commit

Permalink
add large non-bold clock font
Browse files Browse the repository at this point in the history
  • Loading branch information
jekader committed Oct 23, 2023
1 parent 56fd3e5 commit da41b93
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/PixelIt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ uint8_t clockColorR = 255, clockColorG = 255, clockColorB = 255;
uint clockAutoFallbackTime = 30;
bool forceClock = false;
bool clockBlinkAnimated = true;
uint clockFontChoise = 2;
bool clockLargeFont = false;
bool clockFatFont = false;
bool clockDrawWeekDays = true;

Expand Down Expand Up @@ -517,6 +519,7 @@ void SaveConfig()
json["clockDateDayMonth"] = clockDateDayMonth;
json["clockDayOfWeekFirstMonday"] = clockDayOfWeekFirstMonday;
json["clockBlinkAnimated"] = clockBlinkAnimated;
json["clockLargeFont"] = clockLargeFont;
json["clockFatFont"] = clockFatFont;
json["clockDrawWeekDays"] = clockDrawWeekDays;
json["scrollTextDefaultDelay"] = scrollTextDefaultDelay;
Expand Down Expand Up @@ -746,11 +749,15 @@ void SetConfigVariables(JsonObject &json)
clockDayOfWeekFirstMonday = json["clockDayOfWeekFirstMonday"].as<bool>();
}

if (json.containsKey("clockLargeFont"))
{
clockLargeFont = json["clockLargeFont"].as<bool>();
}

if (json.containsKey("clockFatFont"))
{
clockFatFont = json["clockFatFont"].as<bool>();
}

if (json.containsKey("clockDrawWeekDays"))
{
clockDrawWeekDays = json["clockDrawWeekDays"].as<bool>();
Expand Down Expand Up @@ -1559,7 +1566,12 @@ void CreateFrames(JsonObject &json, int forceDuration)
logMessage += F("fatFont, ");
clockFatFont = json["clock"]["fatFont"];
}

bool isLargeFontSet = json["clock"]["largeFont"].is<bool>();
if (isLargeFontSet)
{
logMessage += F("largeFont, ");
clockLargeFont = json["clock"]["largeFont"];
}
bool isDrawWeekDaysSet = json["clock"]["drawWeekDays"].is<bool>();
if (isDrawWeekDaysSet)
{
Expand Down Expand Up @@ -2169,9 +2181,9 @@ void DrawTextHelper(String text, int bigFont, bool centerText, bool scrollText,
// Position correction
posY = posY - 1;
}
else if (bigFont == 2) // very large font, only to be used for time display / very large font, only for the time display
else if (bigFont == 2) // fat font, only to be used for time display
{
// Set very large font
// Set fat font
matrix->setFont(&FatPixels);

matrix->getTextBounds(text, 0, 0, &boundsx1, &boundsy1, &boundsw, &boundsh);
Expand All @@ -2180,6 +2192,17 @@ void DrawTextHelper(String text, int bigFont, bool centerText, bool scrollText,
// Position correction
posY = posY + 6;
}
else if (bigFont == 3) // very large font, only to be used for time display
{
// Set very large font
matrix->setFont(&LargePixels);

matrix->getTextBounds(text, 0, 0, &boundsx1, &boundsy1, &boundsw, &boundsh);
xTextWidth = boundsw;

// Position correction
posY = posY + 6;
}
else
{
// Set small font
Expand Down Expand Up @@ -2457,17 +2480,20 @@ void DrawClock(bool fromJSON)
{
clockCounterClock++;
}

if (clockLargeFont) // use non-bold font
{
clockFontChoise = 3;
}
if (clockCounterClock > clockSwitchSec)
{
clockCounterDate = 0;

if (clockFatFont) // fade rather than vertical animate purely because DrawTextCenter doesnt have a Y argument...
{
DrawTextCenter(String(time), 2, clockColorR, clockColorG, clockColorB, 0, 1);
DrawTextCenter(String(time), clockFontChoise, clockColorR, clockColorG, clockColorB, 0, 1);
FadeOut(30);
matrix->clear();
DrawTextCenter(String(date), 2, clockColorR, clockColorG, clockColorB, 0, 1);
DrawTextCenter(String(date), clockFontChoise, clockColorR, clockColorG, clockColorB, 0, 1);
FadeIn(30);
}
else
Expand All @@ -2492,7 +2518,7 @@ void DrawClock(bool fromJSON)
else if (clockFatFont)
{

DrawTextCenter(String(time), 2, clockColorR, clockColorG, clockColorB, 0, 1);
DrawTextCenter(String(time), clockFontChoise, clockColorR, clockColorG, clockColorB, 0, 1);
}
else
{
Expand Down
51 changes: 51 additions & 0 deletions src/PixelItFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,57 @@ const GFXglyph PixelItGlyphs[] PROGMEM = {

const GFXfont PixelItFont PROGMEM = {(uint8_t *)PixelItBitmaps, (GFXglyph *)PixelItGlyphs, 0x20, 0xE9, 6};

const uint8_t LargePixels_Bitmaps[] PROGMEM = {
// ASCII code and symbol
0x00, // 0x20 ' '
0x80, // 0x21 '!'
0x74, 0x63, 0x18, 0xC6, 0x2E, // 0x30 '0'
0x59, 0x24, 0x97, // 0x31 '1'
0x74, 0x42, 0x22, 0x22, 0x1F, // 0x32 '2'
0x74, 0x42, 0x60, 0x86, 0x2E, // 0x33 '3'
0x19, 0x53, 0x1F, 0x84, 0x21, // 0x34 '4'
0xFC, 0x21, 0xE0, 0x86, 0x2E, // 0x35 '5'
0x74, 0x61, 0xE8, 0xC6, 0x2E, // 0x36 '6'
0xF8, 0x42, 0x22, 0x21, 0x08, // 0x37 '7'
0x74, 0x62, 0xE8, 0xC6, 0x2E, // 0x38 '8'
0x74, 0x63, 0x17, 0x86, 0x2E, // 0x39 '9'
0x90 // 0x3A ':'
};

// {offset, width, height, advance cursor, x offset, y offset}
const GFXglyph LargePixels_Glyphs[] PROGMEM = {
// ASCII code and symbol
{0, 1, 1, 2, 0, -5}, // 0x20 ' '
{0, 0, 0, 0, 0, 0}, // 0x21 '!'
{0, 0, 0, 0, 0, 0}, // 0x22 '"'
{0, 0, 0, 0, 0, 0}, // 0x23 '#'
{0, 0, 0, 0, 0, 0}, // 0x24 '$'
{0, 0, 0, 0, 0, 0}, // 0x25 '%'
{0, 0, 0, 0, 0, 0}, // 0x26 '&'
{0, 0, 0, 0, 0, 0}, // 0x27 '''
{0, 0, 0, 0, 0, 0}, // 0x28 '('
{0, 0, 0, 0, 0, 0}, // 0x29 ')'
{0, 0, 0, 0, 0, 0}, // 0x2A '*'
{0, 0, 0, 0, 0, 0}, // 0x2B '+'
{0, 0, 0, 0, 0, 0}, // 0x2C ','
{0, 0, 0, 0, 0, 0}, // 0x2D '-'
{1, 1, 1, 2, 0, 0}, // 0x2E '.'
{0, 0, 0, 0, 0, 0}, // 0x2F '/'
{2, 5, 8, 6, 0, -7}, // 0x30 '0'
{7, 3, 8, 4, 0, -7}, // 0x31 '1'
{10, 5, 8, 6, 0, -7}, // 0x32 '2'
{15, 5, 8, 6, 0, -7}, // 0x33 '3'
{20, 5, 8, 6, 0, -7}, // 0x34 '4'
{25, 5, 8, 6, 0, -7}, // 0x35 '5'
{30, 5, 8, 6, 0, -7}, // 0x36 '6'
{35, 5, 8, 6, 0, -7}, // 0x37 '7'
{40, 5, 8, 6, 0, -7}, // 0x38 '8'
{45, 5, 8, 6, 0, -7}, // 0x39 '9'
{50, 1, 4, 2, 0, -5} // 0x3A ':'
};

const GFXfont LargePixels PROGMEM = {(uint8_t *)LargePixels_Bitmaps, (GFXglyph *)LargePixels_Glyphs, 0x20, 0x3A, 8};

const uint8_t FatPixels_Bitmaps[] PROGMEM = {
// ASCII code and symbol
0x00, // 0x20 ' '
Expand Down

0 comments on commit da41b93

Please sign in to comment.