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

Fat clock font #169

Merged
merged 10 commits into from
May 6, 2022
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Thanks to these great people for supporting this project.
<sub><b>Fab!an</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/rozza-m">
<img src="https://avatars.githubusercontent.com/u/1784953?v=4" width="100;" alt="rozza-m"/>
<br />
<sub><b>Rozza-m</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/hermannbach">
<img src="https://avatars.githubusercontent.com/u/6616722?v=4" width="100;" alt="hermannbach"/>
Expand All @@ -62,21 +69,6 @@ Thanks to these great people for supporting this project.
<br />
<sub><b>Hamster65</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/pplucky">
<img src="https://avatars.githubusercontent.com/u/16407309?v=4" width="100;" alt="pplucky"/>
<br />
<sub><b>pplucky</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/rozza-m">
<img src="https://avatars.githubusercontent.com/u/1784953?v=4" width="100;" alt="rozza-m"/>
<br />
<sub><b>Rozza-m</b></sub>
</a>
</td></tr>
</table>
<!-- readme: contributors -end -->
Expand Down
130 changes: 102 additions & 28 deletions src/PixelIt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ uint8_t clockColorR = 255, clockColorG = 255, clockColorB = 255;
uint clockAutoFallbackTime = 30;
bool forceClock = false;
bool clockBlinkAnimated = true;
bool clockFatFont = false;

// Scrolltext Vars
bool scrollTextAktivLoop = false;
Expand Down Expand Up @@ -328,6 +329,7 @@ void SaveConfig()
json["clockDateDayMonth"] = clockDateDayMonth;
json["clockDayOfWeekFirstMonday"] = clockDayOfWeekFirstMonday;
json["clockBlinkAnimated"] = clockBlinkAnimated;
json["clockFatFont"] = clockFatFont;
json["scrollTextDefaultDelay"] = scrollTextDefaultDelay;
json["bootScreenAktiv"] = bootScreenAktiv;
json["mqttAktiv"] = mqttAktiv;
Expand Down Expand Up @@ -552,6 +554,11 @@ void SetConfigVariables(JsonObject &json)
clockDayOfWeekFirstMonday = json["clockDayOfWeekFirstMonday"].as<bool>();
}

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

if (json.containsKey("scrollTextDefaultDelay"))
{
scrollTextDefaultDelay = json["scrollTextDefaultDelay"].as<uint>();
Expand Down Expand Up @@ -1222,6 +1229,11 @@ void CreateFrames(JsonObject &json)
clockWithSeconds = json["clock"]["withSeconds"];
clockBlinkAnimated = json["clock"]["blinkAnimated"];

if (json["clock"]["fatFont"])
{
clockFatFont = json["clock"]["fatFont"];
}

if (json["clock"]["color"]["r"].as<char *>() != NULL)
{
clockColorR = json["clock"]["color"]["r"].as<uint8_t>();
Expand Down Expand Up @@ -1650,29 +1662,31 @@ String GetButtons()

/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
void DrawText(String text, bool bigFont, int colorRed, int colorGreen, int colorBlue, int posX, int posY)
void DrawText(String text, int bigFont, int colorRed, int colorGreen, int colorBlue, int posX, int posY)
{
DrawTextHelper(text, bigFont, false, false, false, false, false, NULL, colorRed, colorGreen, colorBlue, posX, posY);
}

void DrawTextCenter(String text, bool bigFont, bool withBMP, int colorRed, int colorGreen, int colorBlue)
void DrawTextCenter(String text, int bigFont, bool withBMP, int colorRed, int colorGreen, int colorBlue)
{
DrawTextHelper(text, bigFont, true, false, false, withBMP, false, NULL, colorRed, colorGreen, colorBlue, 0, 1);
}

void DrawTextScrolled(String text, bool bigFont, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue)
void DrawTextScrolled(String text, int bigFont, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue)
{
DrawTextHelper(text, bigFont, false, true, false, withBMP, fadeInRequired, bmpArray, colorRed, colorGreen, colorBlue, 0, 1);
}

void DrawAutoTextScrolled(String text, bool bigFont, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue)
void DrawAutoTextScrolled(String text, int bigFont, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue)
{
DrawTextHelper(text, bigFont, false, false, true, withBMP, fadeInRequired, bmpArray, colorRed, colorGreen, colorBlue, 0, 1);
}

void DrawTextHelper(String text, bool bigFont, bool centerText, bool scrollText, bool autoScrollText, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue, int posX, int posY)
void DrawTextHelper(String text, int bigFont, bool centerText, bool scrollText, bool autoScrollText, bool withBMP, bool fadeInRequired, uint16_t bmpArray[64], int colorRed, int colorGreen, int colorBlue, int posX, int posY)
{
uint16_t xPixelText, xPixel;
int16_t boundsx1, boundsy1;
uint16_t boundsw, boundsh;

text = Utf8ToAscii(text);

Expand All @@ -1688,14 +1702,25 @@ void DrawTextHelper(String text, bool bigFont, bool centerText, bool scrollText,
xPixel = 32;
}

if (bigFont)
if (bigFont == 1)
{
// Grosse Schrift setzten
matrix->setFont();
xPixelText = text.length() * 6;
// Positions Korrektur
posY = posY - 1;
}
else if (bigFont == 2) // very large font, only to be used for time display / sehr große Schrift, nür für die Zeitanzeige
{
// Sehr grosse Schrift setzten
matrix->setFont(&FatPixels);

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

// Positions Korrektur
posY = posY + 6;
}
else
{
// Kleine Schrift setzten
Expand Down Expand Up @@ -1930,7 +1955,7 @@ void DrawClock(bool fromJSON)
sprintf_P(date, PSTR("%02d/%02d"), month(), day());
}

if (clock24Hours && clockWithSeconds)
if (clock24Hours && clockWithSeconds && !clockFatFont)
{
xPosTime = 2;
sprintf_P(time, PSTR("%02d:%02d:%02d"), hour(), minute(), second());
Expand All @@ -1942,12 +1967,26 @@ void DrawClock(bool fromJSON)
if (clockBlink && clockBlinkAnimated)
{
clockBlink = false;
sprintf_P(time, PSTR("%2d %02d %s"), hourFormat12(), minute(), isAM() ? "AM" : "PM");
if (!clockFatFont)
{
sprintf_P(time, PSTR("%2d %02d %s"), hourFormat12(), minute(), isAM() ? "AM" : "PM");
}
else
{
sprintf_P(time, PSTR("%2d %02d"), hourFormat12(), minute());
}
}
else
{
clockBlink = !clockBlink;
sprintf_P(time, PSTR("%2d:%02d %s"), hourFormat12(), minute(), isAM() ? "AM" : "PM");
if (!clockFatFont)
{
sprintf_P(time, PSTR("%2d:%02d %s"), hourFormat12(), minute(), isAM() ? "AM" : "PM");
}
else
{
sprintf_P(time, PSTR("%2d:%02d"), hourFormat12(), minute());
}
}
}
else
Expand Down Expand Up @@ -1977,22 +2016,39 @@ void DrawClock(bool fromJSON)
{
clockCounterDate = 0;

int counter = 0;
while (counter <= 6)
if (clockFatFont) // fade rather than vertical animate purely because DrawTextCenter doesnt have a Y argument...
{
counter++;
DrawTextCenter(String(time), 2, false, clockColorR, clockColorG, clockColorB);
FadeOut(30);
matrix->clear();
DrawText(String(time), false, clockColorR, clockColorG, clockColorB, xPosTime, (1 + counter));
DrawText(String(date), false, clockColorR, clockColorG, clockColorB, 7, (-6 + counter));
matrix->drawLine(0, 7, 33, 7, 0);
DrawWeekDay();
matrix->show();
delay(35);
DrawTextCenter(String(date), 2, false, clockColorR, clockColorG, clockColorB);
FadeIn(30);
}
else
{
int counter = 0;
while (counter <= 6) // vertical animate
{
counter++;
matrix->clear();
DrawText(String(time), false, clockColorR, clockColorG, clockColorB, xPosTime, (1 + counter));
DrawText(String(date), false, clockColorR, clockColorG, clockColorB, 7, (-6 + counter));
matrix->drawLine(0, 7, 33, 7, 0);
DrawWeekDay();
matrix->show();
delay(35);
}
}
}
else if (clockFatFont)
{

DrawTextCenter(String(time), 2, false, clockColorR, clockColorG, clockColorB);
}
else
{
DrawText(String(time), false, clockColorR, clockColorG, clockColorB, xPosTime, 1);
xPosTime = 3;
}
}
else
Expand All @@ -2003,26 +2059,44 @@ void DrawClock(bool fromJSON)
{
clockCounterClock = 0;

int counter = 0;
while (counter <= 6)
if (clockFatFont) // fade rather than vertical animate purely because DrawTextCenter doesnt have a Y argument...
{
counter++;
DrawTextCenter(String(date), 2, false, clockColorR, clockColorG, clockColorB);
FadeOut(30);
matrix->clear();
DrawText(String(date), false, clockColorR, clockColorG, clockColorB, 7, (1 + counter));
DrawText(String(time), false, clockColorR, clockColorG, clockColorB, xPosTime, (-6 + counter));
matrix->drawLine(0, 7, 33, 7, 0);
DrawWeekDay();
matrix->show();
delay(35);
DrawTextCenter(String(time), 2, false, clockColorR, clockColorG, clockColorB);
FadeIn(30);
}
else
{
int counter = 0;
while (counter <= 6) // vertical animate
{
counter++;
matrix->clear();
DrawText(String(date), false, clockColorR, clockColorG, clockColorB, 7, (1 + counter));
DrawText(String(time), false, clockColorR, clockColorG, clockColorB, xPosTime, (-6 + counter));
matrix->drawLine(0, 7, 33, 7, 0);
DrawWeekDay();
matrix->show();
delay(35);
}
}
}
else if (clockFatFont)
{
DrawTextCenter(String(date), 2, false, clockColorR, clockColorG, clockColorB);
}
else
{
DrawText(String(date), false, clockColorR, clockColorG, clockColorB, 7, 1);
}
}

DrawWeekDay();
if (!clockFatFont)
{
DrawWeekDay();
}

// Wenn der Aufruf nicht über JSON sondern über den Loop kommt
// muss ich mich selbst ums Show kümmern.
Expand Down
40 changes: 40 additions & 0 deletions src/PixelItFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,43 @@ const GFXglyph PixelItGlyphs[] PROGMEM = {
};

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

const uint8_t FatPixels_Bitmaps[] PROGMEM = {
0x00, 0x80, 0x77,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-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 FatPixels PROGMEM = {(uint8_t *) FatPixels_Bitmaps, (GFXglyph *)FatPixels_Glyphs, 0x20, 0x3A, 8};
3 changes: 2 additions & 1 deletion webui/src/views/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
<ColorPickerTextfield />
<v-switch v-model="config.clockDayLightSaving" label="Daylight saving" dense hide-details></v-switch>
<v-switch v-model="config.clock24Hours" label="24 Hours" persistent-hint dense hide-details></v-switch>
<v-switch v-model="config.clockWithSeconds" label="Clock with sek" :disabled="!config.clock24Hours" dense hide-details></v-switch>
<v-switch v-model="config.clockFatFont" label="Big clock font" persistent-hint dense hide-details></v-switch>
<v-switch v-model="config.clockWithSeconds" label="Clock with sek" :disabled="!config.clock24Hours || config.clockFatFont" dense hide-details></v-switch>
<v-switch v-model="config.clockSwitchAktiv" label="Switch clock/date active" dense hide-details></v-switch>
<v-switch v-model="config.clockBlinkAnimated" label="Flashing time separator" dense hide-details></v-switch>
<v-switch v-model="config.clockDayOfWeekFirstMonday" label="Monday as start of the week" dense hide-details></v-switch>
Expand Down