This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
matrix.h
52 lines (44 loc) · 3.24 KB
/
matrix.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
#ifndef MATRIX_H
#define MATRIX_H
#include <FastLED.h>
#include "config.h"
//currently PROGMEM in class members doesnt work on ESP8266
#ifdef ESP8266
#define PROG_MEM
#else
#define PROG_MEM PROGMEM
#endif
class Matrix
{
private:
CRGB leds[MATRIX_WIDTH * MATRIX_HEIGHT];
int rotation = MATRIX_ROTATION;
void loadPgmImage(const long *image);
const long errorImage[256] PROG_MEM = {
0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b,
0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b,
0x0b0b0b, 0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b, 0x0b0b0b,
0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff,
0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b,
0x0b0b0b, 0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b, 0x0b0b0b,
0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0xffffff, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xffffff, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b,
0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b, 0x0b0b0b
};
public:
Matrix();
int xyToIndex(int x, int y);
void setPixel(byte x, byte y, CRGB color);
CRGB getPixel(byte x, byte y);
void swapPixel(byte x1, byte y1, byte x2, byte y2);
void showError();
void update();
};
#endif