49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
#ifndef CLEDCONTROLLERPHYSICALMATRIX_H
|
|
#define CLEDCONTROLLERPHYSICALMATRIX_H
|
|
|
|
#include "LEDHAL2D.h"
|
|
#include "ILEDArrangement.h"
|
|
|
|
class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
|
public:
|
|
CLEDControllerPhysicalMatrix(CLEDController* _controller, char* ledName, ILEDArrangement& _arrangement,
|
|
int16_t width, int16_t height): LEDHAL2D(width, height, ledName, true), controller(_controller), arrangement(_arrangement) {}
|
|
virtual ~CLEDControllerPhysicalMatrix() {}
|
|
|
|
void drawPixel(int16_t x, int16_t y, CRGB color) {
|
|
controller->leds()[XY(x, y)] = color;
|
|
}
|
|
|
|
void setColor(int16_t pixel, CRGB color) {
|
|
controller->leds()[pixel] = color;
|
|
}
|
|
|
|
CRGB getColor(int16_t pixel) {
|
|
return controller->leds()[pixel];
|
|
}
|
|
|
|
CRGB getColor(int16_t x, int16_t y) {
|
|
return getColor(XY(x, y));
|
|
}
|
|
|
|
int16_t XY(int16_t x, int16_t y) {
|
|
return arrangement.XY(x, y, getWidth(), getHeight());
|
|
}
|
|
|
|
uint16_t getNumLEDs() {
|
|
return getWidth() * getHeight();
|
|
}
|
|
|
|
protected:
|
|
void updateLEDs() {
|
|
controller->showLeds(255);
|
|
}
|
|
|
|
private:
|
|
CLEDController*
|
|
controller;
|
|
ILEDArrangement&
|
|
arrangement;
|
|
};
|
|
|
|
#endif |