first commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
||||||
10
.vscode/extensions.json
vendored
Normal file
10
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
],
|
||||||
|
"unwantedRecommendations": [
|
||||||
|
"ms-vscode.cpptools-extension-pack"
|
||||||
|
]
|
||||||
|
}
|
||||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"ostream": "cpp",
|
||||||
|
"font_5x7,cpp": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
26
diagram.json
Normal file
26
diagram.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"author": "RGB Matrix Pico W Project",
|
||||||
|
"editor": "wokwi",
|
||||||
|
"parts": [
|
||||||
|
{
|
||||||
|
"type": "board-pi-pico-w",
|
||||||
|
"id": "picow",
|
||||||
|
"top": 1014.35,
|
||||||
|
"left": 3.55
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"id": "matrix",
|
||||||
|
"top": -617.6,
|
||||||
|
"left": 1.1,
|
||||||
|
"attrs": { "rows": "64", "cols": "64", "pixels": "[]" }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
["matrix:VDD", "picow:VBUS", "red", ["v96", "h-91.4"]],
|
||||||
|
["matrix:VSS", "picow:GND.8", "black", ["v0"]],
|
||||||
|
["matrix:DIN", "picow:GP28", "green", ["v0"]]
|
||||||
|
],
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
37
include/README
Normal file
37
include/README
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
This directory is intended for project header files.
|
||||||
|
|
||||||
|
A header file is a file containing C declarations and macro definitions
|
||||||
|
to be shared between several project source files. You request the use of a
|
||||||
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
|
```src/main.c
|
||||||
|
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Including a header file produces the same results as copying the header file
|
||||||
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
|
and error-prone. With a header file, the related declarations appear
|
||||||
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
|
place, and programs that include the header file will automatically use the
|
||||||
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
|
In C, the convention is to give header files names that end with `.h'.
|
||||||
|
|
||||||
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
|
* Include Syntax
|
||||||
|
* Include Operation
|
||||||
|
* Once-Only Headers
|
||||||
|
* Computed Includes
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||||
7
lib/BlinkLed/library.json
Normal file
7
lib/BlinkLed/library.json
Normal 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"
|
||||||
|
}
|
||||||
16
lib/BlinkLed/src/BlinkInternLed.h
Normal file
16
lib/BlinkLed/src/BlinkInternLed.h
Normal 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
|
||||||
25
lib/BlinkLed/src/BlinkLed.cpp
Normal file
25
lib/BlinkLed/src/BlinkLed.cpp
Normal 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);
|
||||||
|
}
|
||||||
24
lib/BlinkLed/src/BlinkLed.h
Normal file
24
lib/BlinkLed/src/BlinkLed.h
Normal 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
7
lib/Fonts/library.json
Normal 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"
|
||||||
|
}
|
||||||
59
lib/Fonts/src/font_5x7.cpp
Normal file
59
lib/Fonts/src/font_5x7.cpp
Normal 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
124
lib/Fonts/src/font_5x7.h
Normal 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
|
||||||
7
lib/LedMatrix/library.json
Normal file
7
lib/LedMatrix/library.json
Normal 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"
|
||||||
|
}
|
||||||
11
lib/LedMatrix/src/LedMatrix.cpp
Normal file
11
lib/LedMatrix/src/LedMatrix.cpp
Normal 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()
|
||||||
|
{
|
||||||
|
}
|
||||||
64
lib/LedMatrix/src/LedMatrix.h
Normal file
64
lib/LedMatrix/src/LedMatrix.h
Normal 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
7
lib/MyClass/library.json
Normal 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"
|
||||||
|
}
|
||||||
18
lib/MyClass/src/MyClass.cpp
Normal file
18
lib/MyClass/src/MyClass.cpp
Normal 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
16
lib/MyClass/src/MyClass.h
Normal 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
46
lib/README
Normal 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
|
||||||
22
platformio.ini
Normal file
22
platformio.ini
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:rpipicow]
|
||||||
|
platform = raspberrypi
|
||||||
|
board = rpipicow
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
build_flags =
|
||||||
|
-D PICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1
|
||||||
|
|
||||||
|
lib_deps = fastled/FastLED@^3.10.3
|
||||||
|
|
||||||
|
; Add this to see build flags during compilation
|
||||||
|
; build_flags = -v
|
||||||
80
src/main.cpp
Normal file
80
src/main.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#include <FastLED.h>
|
||||||
|
#include <MyClass.h>
|
||||||
|
#include <BlinkInternLed.h>
|
||||||
|
#include <LedMatrix.h>
|
||||||
|
#include <font_5x7.h>
|
||||||
|
|
||||||
|
LedMatrix matrix;
|
||||||
|
|
||||||
|
void printCharMatrixSimple(char c)
|
||||||
|
{
|
||||||
|
const uint8_t *fontData = getFontChar(c);
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
Serial.print("'");
|
||||||
|
Serial.print(c);
|
||||||
|
Serial.println("':");
|
||||||
|
|
||||||
|
String mtrx = "";
|
||||||
|
for (int row = 0; row < 7; row++)
|
||||||
|
{
|
||||||
|
uint8_t line = fontData[row];
|
||||||
|
for (int col = 0; col < 5; col++)
|
||||||
|
{
|
||||||
|
if (line & (1 << (4 - col)))
|
||||||
|
{
|
||||||
|
mtrx += "•";
|
||||||
|
Serial.print("#"); // Einfaches # für Pixel
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtrx += ".";
|
||||||
|
Serial.print("."); // Punkt für leere Pixel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mtrx += "\n\r";
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
Serial.println(mtrx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void playWithBlinkLed()
|
||||||
|
{
|
||||||
|
BlinkInternLed internLed = BlinkInternLed();
|
||||||
|
String led_status = internLed.ledStatus();
|
||||||
|
Serial.println("PinStatus: " + led_status);
|
||||||
|
|
||||||
|
internLed.on();
|
||||||
|
delay(200);
|
||||||
|
led_status = internLed.ledStatus();
|
||||||
|
Serial.println("PinStatus: " + led_status);
|
||||||
|
|
||||||
|
internLed.off();
|
||||||
|
delay(200);
|
||||||
|
led_status = internLed.ledStatus();
|
||||||
|
Serial.println("PinStatus: " + led_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
matrix.setBrightness(255);
|
||||||
|
|
||||||
|
matrix.clear();
|
||||||
|
matrix.show();
|
||||||
|
|
||||||
|
// Draw static "HELLO WORLD"
|
||||||
|
matrix.drawText(1, 1, "Hello", CRGB::Red);
|
||||||
|
matrix.drawText(35, 1, "World", CRGB::Blue);
|
||||||
|
matrix.drawText(1, 20, "<°|`¶>", CRGB::Yellow);
|
||||||
|
matrix.drawText(1, 30, "Bottom", CRGB::Yellow);
|
||||||
|
matrix.show();
|
||||||
|
|
||||||
|
// printCharMatrixSimple('S');
|
||||||
|
|
||||||
|
// playWithBlinkLed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
94
src/main___.cpp
Normal file
94
src/main___.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
#ifdef DO_NOT_USE_MAIN___
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <pico/cyw43_arch.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
|
||||||
|
#include <Adafruit_NeoMatrix.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
// #include <Fonts/TomThumb.h>
|
||||||
|
|
||||||
|
#include "MyClass.h"
|
||||||
|
|
||||||
|
// LED pin definitions
|
||||||
|
#define LED_ONBOARD LED_BUILTIN
|
||||||
|
|
||||||
|
// Matrix setup
|
||||||
|
#define MATRIX_PIN 28
|
||||||
|
#define MATRIX_WIDTH 64
|
||||||
|
#define MATRIX_HEIGHT 64
|
||||||
|
|
||||||
|
// Adafruit NeoMatrix initialisieren
|
||||||
|
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(
|
||||||
|
MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_PIN,
|
||||||
|
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
|
||||||
|
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
|
||||||
|
NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
int textX = matrix.width();
|
||||||
|
int textMin = 0;
|
||||||
|
|
||||||
|
void connect_wifi()
|
||||||
|
{
|
||||||
|
// For Wokwi simulation - use simulated WiFi
|
||||||
|
Serial.println("Connecting to WiFi...");
|
||||||
|
|
||||||
|
// In Wokwi, WiFi connects automatically in simulation
|
||||||
|
WiFi.begin("Wokwi-GUEST", ""); // Wokwi's simulated WiFi
|
||||||
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
|
{
|
||||||
|
delay(250);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
Serial.println("\nConnected to WiFi!");
|
||||||
|
Serial.print("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupLEDMatrix()
|
||||||
|
{
|
||||||
|
// Matrix initialisieren
|
||||||
|
matrix.begin();
|
||||||
|
|
||||||
|
matrix.setBrightness(200);
|
||||||
|
matrix.fillScreen(0);
|
||||||
|
matrix.setCursor(18, 12);
|
||||||
|
matrix.setTextColor(matrix.Color(0, 255, 0));
|
||||||
|
matrix.print("HELLO");
|
||||||
|
matrix.show();
|
||||||
|
Serial.println("Adafruit NeoMatrix ready - Showing 'Hello World'");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup___()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
connect_wifi();
|
||||||
|
|
||||||
|
MyClass myClassObj; // Create an object of MyClass
|
||||||
|
|
||||||
|
// Access attributes and set values
|
||||||
|
myClassObj.myNum = 15;
|
||||||
|
myClassObj.myString = "Some text";
|
||||||
|
|
||||||
|
pinMode(LED_ONBOARD, OUTPUT);
|
||||||
|
Serial.println("Blink example started!");
|
||||||
|
myClassObj.display();
|
||||||
|
|
||||||
|
setupLEDMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop___()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Turn LED on
|
||||||
|
digitalWrite(LED_ONBOARD, HIGH);
|
||||||
|
Serial.println("LED ON");
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
// Turn LED off
|
||||||
|
digitalWrite(LED_ONBOARD, LOW);
|
||||||
|
Serial.println("LED OFF");
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
11
test/README
Normal file
11
test/README
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
This directory is intended for PlatformIO Test Runner and project tests.
|
||||||
|
|
||||||
|
Unit Testing is a software testing method by which individual units of
|
||||||
|
source code, sets of one or more MCU program modules together with associated
|
||||||
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
|
in the development cycle.
|
||||||
|
|
||||||
|
More information about PlatformIO Unit Testing:
|
||||||
|
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||||
6
wokwi.toml
Normal file
6
wokwi.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[wokwi]
|
||||||
|
version = 1
|
||||||
|
firmware = ".pio/build/rpipicow/firmware.uf2"
|
||||||
|
|
||||||
|
rfc2217ServerPort = 4000
|
||||||
|
gdbServerPort = 3333
|
||||||
Reference in New Issue
Block a user