first commit

This commit is contained in:
tiijay
2025-11-03 15:05:22 +01:00
commit 941c168de8
24 changed files with 728 additions and 0 deletions

7
lib/Fonts/library.json Normal file
View File

@@ -0,0 +1,7 @@
{
"name": "BlinkLed",
"version": "1.0.0",
"description": "A simple LED control library with internal LED helper.",
"authors": [{ "name": "TiiJay14" }],
"frameworks": "arduino"
}

View File

@@ -0,0 +1,59 @@
#include "font_5x7.h"
// Function to get font data for a character
const uint8_t *getFontChar(char c)
{
for (int i = 0; i < sizeof(font_chars) - 1; i++)
{
if (font_chars[i] == c)
{
return font_5x7[i];
}
}
return font_5x7[52]; // Return space if not found (index of ' ')
}
// Function to get character width
uint8_t getCharWidth(char c)
{
switch (c)
{
case 'I':
case '!':
case '.':
case ':':
case ';':
case '\'':
case '|':
return 1;
case 'i':
case ' ':
return 2;
case 'J':
case 'j':
case 'l':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
// Nachher (Korrektur):
case 176: // '°' als ASCII Code
case 149: // '•' als ASCII Code
return 3;
case 'a':
case 'c':
case 'e':
case 'f':
case 'k':
case 's':
case 't':
case '<':
case '>':
case '`':
return 4;
default:
return 5;
}
}

124
lib/Fonts/src/font_5x7.h Normal file
View File

@@ -0,0 +1,124 @@
#ifndef FONT_5X7_H
#define FONT_5X7_H
#include <Arduino.h>
// 5x7 Font mit optimierten Zeichenbreiten
const uint8_t font_5x7[][7] = {
// Uppercase letters (A-Z)
{0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11}, // 'A' Width: 5
{0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E}, // 'B' Width: 5
{0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E}, // 'C' Width: 5
{0x1E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1E}, // 'D' Width: 5
{0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F}, // 'E' Width: 5
{0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10}, // 'F' Width: 5
{0x0E, 0x11, 0x10, 0x13, 0x11, 0x11, 0x0F}, // 'G' Width: 5
{0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11}, // 'H' Width: 5
{0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x07}, // 'I' Width: 3
{0x07, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0C}, // 'J' Width: 4
{0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11}, // 'K' Width: 5
{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F}, // 'L' Width: 5
{0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11}, // 'M' Width: 5
{0x11, 0x19, 0x19, 0x15, 0x13, 0x13, 0x11}, // 'N' Width: 5
{0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E}, // 'O' Width: 5
{0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10}, // 'P' Width: 5
{0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0D}, // 'Q' Width: 5
{0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11}, // 'R' Width: 5
{0x0F, 0x10, 0x10, 0x0E, 0x01, 0x01, 0x1E}, // 'S' Width: 5
{0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // 'T' Width: 5
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E}, // 'U' Width: 5
{0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04}, // 'V' Width: 5
{0x11, 0x11, 0x11, 0x15, 0x15, 0x15, 0x0A}, // 'W' Width: 5
{0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11}, // 'X' Width: 5
{0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04}, // 'Y' Width: 5
{0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F}, // 'Z' Width: 5
// Lowercase letters (a-z)
{0x00, 0x00, 0x0E, 0x01, 0x0F, 0x11, 0x0F}, // 'a' Width: 4
{0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x1E}, // 'b' Width: 5
{0x00, 0x00, 0x0E, 0x11, 0x10, 0x11, 0x0E}, // 'c' Width: 4
{0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0F}, // 'd' Width: 5
{0x00, 0x00, 0x0E, 0x11, 0x1F, 0x10, 0x0E}, // 'e' Width: 4
{0x06, 0x09, 0x08, 0x1C, 0x08, 0x08, 0x08}, // 'f' Width: 4
{0x00, 0x0F, 0x11, 0x11, 0x0F, 0x01, 0x0E}, // 'g' Width: 5
{0x10, 0x10, 0x16, 0x19, 0x11, 0x11, 0x11}, // 'h' Width: 5
{0x00, 0x02, 0x00, 0x06, 0x02, 0x02, 0x07}, // 'i' Width: 2
{0x00, 0x02, 0x00, 0x06, 0x02, 0x12, 0x0C}, // 'j' Width: 3
{0x10, 0x10, 0x12, 0x14, 0x18, 0x14, 0x12}, // 'k' Width: 4
{0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x07}, // 'l' Width: 3
{0x00, 0x00, 0x1A, 0x15, 0x15, 0x15, 0x15}, // 'm' Width: 5
{0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11}, // 'n' Width: 5
{0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E}, // 'o' Width: 4
{0x00, 0x00, 0x1E, 0x11, 0x1E, 0x10, 0x10}, // 'p' Width: 5
{0x00, 0x00, 0x0D, 0x13, 0x0F, 0x01, 0x01}, // 'q' Width: 5
{0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10}, // 'r' Width: 5
{0x00, 0x00, 0x0E, 0x10, 0x0E, 0x01, 0x1E}, // 's' Width: 4
{0x08, 0x08, 0x1C, 0x08, 0x08, 0x09, 0x06}, // 't' Width: 4
{0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0D}, // 'u' Width: 5
{0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04}, // 'v' Width: 5
{0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A}, // 'w' Width: 5
{0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11}, // 'x' Width: 5
{0x00, 0x00, 0x11, 0x11, 0x0F, 0x01, 0x0E}, // 'y' Width: 5
{0x00, 0x00, 0x1F, 0x02, 0x04, 0x08, 0x1F}, // 'z' Width: 5
// Numbers (0-9)
{0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E}, // '0' Width: 5
{0x02, 0x06, 0x02, 0x02, 0x02, 0x02, 0x07}, // '1' Width: 3
{0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F}, // '2' Width: 5
{0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E}, // '3' Width: 5
{0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02}, // '4' Width: 5
{0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E}, // '5' Width: 5
{0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E}, // '6' Width: 5
{0x1F, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08}, // '7' Width: 5
{0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E}, // '8' Width: 5
{0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C}, // '9' Width: 5
// Punctuation and symbols
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' ' Width: 2
{0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01}, // '!' Width: 1
{0x0E, 0x11, 0x02, 0x04, 0x04, 0x00, 0x04}, // '?' Width: 5
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // '.' Width: 1
{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}, // ',' Width: 1
{0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00}, // ':' Width: 1
{0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x02}, // ';' Width: 1
{0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}, // "'" Width: 1
{0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, // '"' Width: 3
{0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00}, // '-' Width: 5
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F}, // '_' Width: 5
{0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00}, // '+' Width: 5
{0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00}, // '=' Width: 5
{0x00, 0x0A, 0x04, 0x1F, 0x04, 0x0A, 0x00}, // '*' Width: 5
{0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00}, // '/' Width: 5
{0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00}, // '\\' Width: 5
{0x01, 0x02, 0x04, 0x04, 0x04, 0x02, 0x01}, // '(' Width: 3
{0x04, 0x02, 0x01, 0x01, 0x01, 0x02, 0x04}, // ')' Width: 3
{0x07, 0x04, 0x04, 0x04, 0x04, 0x04, 0x07}, // '[' Width: 3
{0x07, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07}, // ']' Width: 3
{0x03, 0x02, 0x02, 0x04, 0x02, 0x02, 0x03}, // '{' Width: 3
{0x06, 0x02, 0x02, 0x01, 0x02, 0x02, 0x06}, // '}' Width: 3
{0x00, 0x01, 0x02, 0x04, 0x02, 0x01, 0x00}, // '<' Width: 4
{0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00}, // '>' Width: 4
{0x0E, 0x11, 0x17, 0x15, 0x17, 0x10, 0x0E}, // '@' Width: 5
{0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A}, // '#' Width: 5
{0x04, 0x0F, 0x14, 0x0E, 0x05, 0x1E, 0x04}, // '$' Width: 5
{0x18, 0x19, 0x02, 0x04, 0x08, 0x13, 0x03}, // '%' Width: 5
{0x0C, 0x12, 0x14, 0x08, 0x15, 0x12, 0x0D}, // '&' Width: 5
{0x04, 0x0A, 0x11, 0x00, 0x00, 0x00, 0x00}, // '^' Width: 5
{0x00, 0x00, 0x00, 0x0D, 0x12, 0x00, 0x00}, // '~' Width: 5
// Special characters
{0x07, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00}, // '°' Width: 3
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // '|' Width: 1
{0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}, // '`' Width: 2
{0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D}, // '¶' Width: 5
{0x00, 0x00, 0x02, 0x07, 0x02, 0x00, 0x00} // '•' Width: 3
};
// Character mapping
const char font_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 !?.,:;'\"-_+=*/\\()[]{}<>@#$%&^~°|`¶•";
// Declarations only
const uint8_t *getFontChar(char c);
uint8_t getCharWidth(char c);
#endif