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

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,16 @@
#ifndef BLINKINTERNLED
#define BLINKINTERNLED
#include <Arduino.h>
#include "BlinkLed.h"
class BlinkInternLed : public BlinkLed
{
private:
/* data */
public:
BlinkInternLed() : BlinkLed(LED_BUILTIN) {}
~BlinkInternLed() {}
};
#endif

View File

@@ -0,0 +1,25 @@
#include "BlinkLed.h"
BlinkLed::BlinkLed(byte pin)
{
BlinkLed();
_pin = pin;
pinMode(_pin, OUTPUT);
}
String BlinkLed::ledStatus()
{
return _ledStatus == HIGH ? "HIGH" : "LOW";
}
void BlinkLed::on()
{
_ledStatus = HIGH;
digitalWrite(_pin, _ledStatus);
}
void BlinkLed::off()
{
_ledStatus = LOW;
digitalWrite(_pin, _ledStatus);
}

View File

@@ -0,0 +1,24 @@
#ifndef BLINKLED
#define BLINKLED
#include <Arduino.h>
class BlinkLed
{
private:
PinStatus _ledStatus;
byte _pin;
/* data */
BlinkLed() { _ledStatus = LOW; }
public:
BlinkLed(byte pin);
~BlinkLed() {}
void on();
void off();
String ledStatus();
};
#endif

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

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,11 @@
#include "LedMatrix.h"
LedMatrix::LedMatrix(uint8_t h, uint8_t w)
: height(h), width(w), num_leds(h * w), leds(num_leds)
{
addLeds<WS2812B, MATRIX_PIN, RGB>(leds.data(), num_leds);
}
LedMatrix::~LedMatrix()
{
}

View File

@@ -0,0 +1,64 @@
#ifndef LEDMATRIX
#define LEDMATRIX
using namespace std;
#include <Arduino.h>
#include <FastLED.h>
#include <vector>
#include <font_5x7.h>
class LedMatrix : public CFastLED
{
private:
uint8_t height;
uint8_t width;
static const uint8_t MATRIX_PIN = 28;
uint16_t num_leds; // default 64x64 = 4096 LEDs
vector<CRGB> leds; // Automatic memory management
public:
LedMatrix(uint8_t h = 64, uint8_t w = 64);
~LedMatrix();
void drawPixel(int x, int y, CRGB color)
{
if (x >= 0 && x < 64 && y >= 0 && y < 64)
{
int index = y * 64 + x; // Row-major order
leds[index] = color;
}
}
void drawChar(int x, int y, char c, CRGB color)
{
const uint8_t *fontData = getFontChar(c);
for (int row = 0; row < 7; row++)
{
uint8_t line = fontData[row];
for (int col = 0; col < 5; col++)
{
if (line & (1 << (4 - col)))
{
drawPixel(x + col, y + row, color);
}
}
}
}
// Draw text string
void drawText(int x, int y, const char *text, CRGB color)
{
int cursorX = x;
for (int i = 0; text[i] != '\0'; i++)
{
drawChar(cursorX, y, text[i], color);
cursorX += 6; // 5 pixels width + 1 pixel spacing
}
}
};
#endif

7
lib/MyClass/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,18 @@
#include "MyClass.h"
MyClass::MyClass() : myNum(0), myString("Default")
{
}
MyClass::MyClass(int num, const String &str)
: myNum(num), myString(str)
{
}
void MyClass::display()
{
Serial.print("Number: ");
Serial.print(myNum);
Serial.print(", String: ");
Serial.println(myString);
}

16
lib/MyClass/src/MyClass.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef MYCLASS_H
#define MYCLASS_H
#include <Arduino.h> // Required for String type
class MyClass {
public:
int myNum;
String myString; // Arduino String
MyClass();
MyClass(int num, const String& str);
void display();
};
#endif

46
lib/README Normal file
View File

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file.
The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]").
For example, see the structure of the following example libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
Example contents of `src/main.c` using Foo and Bar:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html