v.0.0.1 setup Serial output
This commit is contained in:
@@ -9,3 +9,43 @@ LedMatrix::LedMatrix(uint8_t h, uint8_t w)
|
|||||||
LedMatrix::~LedMatrix()
|
LedMatrix::~LedMatrix()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LedMatrix::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 LedMatrix::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 LedMatrix::drawText(int x, int y, const char *text, CRGB color)
|
||||||
|
{
|
||||||
|
int cursorX = x;
|
||||||
|
for (int i = 0; text[i] != '\0'; i++)
|
||||||
|
{
|
||||||
|
u_int8_t w = getCharWidth(text[i]);
|
||||||
|
// Debug output
|
||||||
|
Serial.printf("Char %d: '%c' -> width %d at X=%d\n\r",
|
||||||
|
i, text[i], w, cursorX);
|
||||||
|
drawChar(cursorX, y, text[i], color);
|
||||||
|
cursorX += 6; // 5 pixels width + 1 pixel spacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,41 +24,10 @@ public:
|
|||||||
|
|
||||||
~LedMatrix();
|
~LedMatrix();
|
||||||
|
|
||||||
void drawPixel(int x, int y, CRGB color)
|
void drawPixel(int x, int y, CRGB color);
|
||||||
{
|
void drawChar(int x, int y, char c, 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
|
// Draw text string
|
||||||
void drawText(int x, int y, const char *text, CRGB color)
|
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
|
#endif
|
||||||
@@ -57,6 +57,14 @@ void playWithBlinkLed()
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
// Initialize Serial for debug output
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
// Wait for Serial to be ready (important for some boards)
|
||||||
|
while (!Serial)
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
matrix.setBrightness(255);
|
matrix.setBrightness(255);
|
||||||
|
|
||||||
matrix.clear();
|
matrix.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user