added mqtt and cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "LEDMatrix.h"
|
||||
#include "font.h"
|
||||
|
||||
LEDMatrix::LEDMatrix(uint8_t width, uint8_t height, uint16_t numLeds, uint16_t lastVisibleLed, CRGB* leds)
|
||||
: kMatrixWidth(width), kMatrixHeight(height), NUM_LEDS(numLeds), LAST_VISIBLE_LED(lastVisibleLed), leds(leds) {
|
||||
@@ -40,4 +41,29 @@ void LEDMatrix::drawPixel(uint8_t x, uint8_t y, CRGB color) {
|
||||
if (index <= LAST_VISIBLE_LED) {
|
||||
leds[index] = color;
|
||||
}
|
||||
}
|
||||
|
||||
void LEDMatrix::drawChar(char c, int x, int y, CRGB color) {
|
||||
if (c < 32 || c > 127) return; // Ignore non-printable characters
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
uint8_t line = font[(c - 32) * 5 + i]; // Access the font array as a one-dimensional array
|
||||
for (int j = 0; j < 7; j++) {
|
||||
if (line & 0x1) {
|
||||
drawPixel(x + i, y + j, color);
|
||||
}
|
||||
line >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LEDMatrix::drawText(const char* text, int x, int y, CRGB color) {
|
||||
while (*text) {
|
||||
drawChar(*text++, x, y, color);
|
||||
x += 6; // Move to the next character position
|
||||
if (x >= kMatrixWidth) { // Handle overflow to the next screen
|
||||
x = 0;
|
||||
y += 8; // Move to the next line
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user