reorginasation + matrix test tool
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
LEDMatrix::LEDMatrix(uint8_t width, uint8_t height, uint16_t numLeds, uint16_t lastVisibleLed, CRGB* leds)
|
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) {
|
: kMatrixWidth(width), kMatrixHeight(height), NUM_LEDS(numLeds), LAST_VISIBLE_LED(lastVisibleLed), leds(leds) {
|
||||||
|
//the led matrix reference table
|
||||||
static const int table[] = {
|
static const int table[] = {
|
||||||
248, 247, 232, 231, 216, 215, 200, 199, 184, 183, 168, 167, 152, 151, 136, 135, 120, 119, 104, 103, 88, 87, 72, 71, 56, 55, 40, 39, 24, 23, 8, 7,
|
248, 247, 232, 231, 216, 215, 200, 199, 184, 183, 168, 167, 152, 151, 136, 135, 120, 119, 104, 103, 88, 87, 72, 71, 56, 55, 40, 39, 24, 23, 8, 7,
|
||||||
249, 246, 233, 230, 217, 214, 201, 198, 185, 182, 169, 166, 153, 150, 137, 134, 121, 118, 105, 102, 89, 86, 73, 70, 57, 54, 41, 38, 25, 22, 9, 6,
|
249, 246, 233, 230, 217, 214, 201, 198, 185, 182, 169, 166, 153, 150, 137, 134, 121, 118, 105, 102, 89, 86, 73, 70, 57, 54, 41, 38, 25, 22, 9, 6,
|
||||||
@@ -67,3 +68,19 @@ void LEDMatrix::drawText(const char* text, int x, int y, CRGB color) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LEDMatrix::setLEDColor(uint16_t index, CRGB color) {
|
||||||
|
if (index <= LAST_VISIBLE_LED) {
|
||||||
|
leds[index] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LEDMatrix::setLEDArray(const long ledarray[]) {
|
||||||
|
for (uint16_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
if (ledarray[i] == 255) {
|
||||||
|
setLEDColor(i, CRGB::White); // Set the color to white for simplicity
|
||||||
|
} else {
|
||||||
|
setLEDColor(i, CRGB::Black); // Turn off the LED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -11,6 +11,8 @@ public:
|
|||||||
void drawPixel(uint8_t x, uint8_t y, CRGB color);
|
void drawPixel(uint8_t x, uint8_t y, CRGB color);
|
||||||
void drawChar(char c, int x, int y, CRGB color);
|
void drawChar(char c, int x, int y, CRGB color);
|
||||||
void drawText(const char* text, int x, int y, CRGB color);
|
void drawText(const char* text, int x, int y, CRGB color);
|
||||||
|
void setLEDColor(uint16_t index, CRGB color);
|
||||||
|
void setLEDArray(const long ledarray[]);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint8_t kMatrixWidth;
|
const uint8_t kMatrixWidth;
|
||||||
@@ -18,7 +20,7 @@ private:
|
|||||||
const uint16_t NUM_LEDS;
|
const uint16_t NUM_LEDS;
|
||||||
const uint16_t LAST_VISIBLE_LED;
|
const uint16_t LAST_VISIBLE_LED;
|
||||||
const int* XYTable;
|
const int* XYTable;
|
||||||
CRGB* leds; // Add this line
|
CRGB* leds;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LEDMATRIX_H
|
#endif // LEDMATRIX_H
|
27
src/matrixTester/matrixTester.ino
Normal file
27
src/matrixTester/matrixTester.ino
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
//The only thing this does is light up each LED one by one in red, then clear them all and repeat.
|
||||||
|
|
||||||
|
#include <FastLED.h>
|
||||||
|
|
||||||
|
#define NUM_LEDS 512 // 8x32 matrix * 2
|
||||||
|
#define DATA_PIN D2 // Data pin for WS2812
|
||||||
|
|
||||||
|
CRGB leds[NUM_LEDS]; // Array of LEDs
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS); // Initialize FastLED
|
||||||
|
FastLED.setBrightness(100); // Set brightness (0-255)
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Clear all LEDs
|
||||||
|
FastLED.clear();
|
||||||
|
|
||||||
|
// Enable each LED one by one
|
||||||
|
for (int i = 0; i < NUM_LEDS; i++) {
|
||||||
|
leds[i] = CRGB::Red; // Set to a color (e.g., red)
|
||||||
|
FastLED.show(); // Update the LED matrix
|
||||||
|
delay(50); // Adjust the speed of the LED lighting (lower = faster)
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(1000); // Hold the final state for a while before clearing
|
||||||
|
}
|
Reference in New Issue
Block a user