forked from 2dom/PxMatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PxMatrix.h
80 lines (55 loc) · 2.07 KB
/
PxMatrix.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
/*********************************************************************
This is a library for Chinese LED matrix displays
Written by Dominic Buchstaller.
BSD license, check license.txt for more information
*********************************************************************/
#ifndef _PxMATRIX_H
#define _PxMATRIX_H
// This is how many color levels the display shows - the more the slower the update
#define color_depth 8
#include "Adafruit_GFX.h"
#include "Arduino.h"
#include <SPI.h>
class PxMATRIX : public Adafruit_GFX {
public:
PxMATRIX(uint8_t width, uint8_t height,uint8_t LATCH, uint8_t OE, uint8_t A,uint8_t B,uint8_t C);
PxMATRIX(uint8_t width, uint8_t height,uint8_t LATCH, uint8_t OE, uint8_t A,uint8_t B,uint8_t C,uint8_t D);
PxMATRIX(uint8_t width, uint8_t height,uint8_t LATCH, uint8_t OE, uint8_t A,uint8_t B,uint8_t C,uint8_t D,uint8_t E);
void begin(uint8_t pattern);
void begin();
void clearDisplay(void);
void display(uint16_t show_time);
void drawPixelRGB565(int16_t x, int16_t y, uint16_t color);
void drawPixel(int16_t x, int16_t y, uint16_t color);
void drawPixelRGB888(int16_t x, int16_t y, uint8_t r, uint8_t g,uint8_t b);
uint8_t getPixel(int8_t x, int8_t y);
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
void displayTestPattern(uint16_t showtime);
void flushDisplay();
void setRotate(bool rotate);
private:
uint8_t _display_color;
uint8_t _LATCH_PIN;
uint8_t _OE_PIN;
uint8_t _A_PIN;
uint8_t _B_PIN;
uint8_t _C_PIN;
uint8_t _D_PIN;
uint8_t _E_PIN;
uint8_t _width;
uint8_t _height;
uint16_t _row_offset[64];
uint8_t _pattern;
uint8_t _pattern_color_bytes;
uint8_t _send_buffer_size;
bool _rotate;
uint16_t _test_pixel_counter;
uint8_t _test_line_counter;
unsigned long _test_last_call;
void fillMatrixBuffer(int16_t x, int16_t y, uint8_t r, uint8_t g,uint8_t b);
// Init code common to both constructors
void init(uint8_t width, uint8_t height ,uint8_t LATCH, uint8_t OE, uint8_t A,uint8_t B,uint8_t C);
void latch(uint16_t show_time );
void set_mux(uint8_t value);
};
#endif