-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGridTransformer.h
82 lines (71 loc) · 1.79 KB
/
GridTransformer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// LED matrix library transformer to map a rectangular canvas onto a complex
// chain of matrices.
// Author: Tony DiCola
#ifndef GRIDTRANSFORMER_H
#define GRIDTRANSFORMER_H
#include <cassert>
#include <vector>
#include <math.h>
#include "led-matrix.h"
class GridTransformer: public rgb_matrix::Canvas, public rgb_matrix::CanvasTransformer {
public:
struct Panel {
int order;
int rotate;
int parallel;
};
GridTransformer();
GridTransformer(int width, int height, int panel_width, int panel_height,
int chain_length, const std::vector<Panel>& panels);
virtual ~GridTransformer();
// Canvas interface implementation:
virtual int width() const {
return _width;
}
virtual int height() const {
return _height;
}
virtual void Clear() {
assert(_source != NULL);
_source->Clear();
}
virtual void Fill(uint8_t red, uint8_t green, uint8_t blue) {
assert(_source != NULL);
_source->Fill(red, green, blue);
}
// GridTransformer methods
void FillRemaining(uint8_t red, uint8_t green, uint8_t blue);
bool GetPixelState(int x, int y);
void SetCutoff(int value);
void SetMaxBrightness(int value);
void SetMirrorX(bool value);
void SetMirrorY(bool value);
// Canvas methods
virtual void SetPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue);
virtual rgb_matrix::Canvas* Transform(rgb_matrix::Canvas* source);
// Other attribute accessors.
int getRows() const
{
return _rows;
}
int getColumns() const
{
return _cols;
}
private:
int _width,
_height,
_panel_width,
_panel_height,
_chain_length,
_rows,
_cols;
int cutoff;
int maxBrightness;
bool mirrorX, mirrorY, overrideCutoff;
bool** pixels;
rgb_matrix::Canvas* _source;
std::vector<Panel> _panels;
void ResetPixels();
};
#endif