-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.h
53 lines (40 loc) · 1.38 KB
/
display.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
#ifndef __DISPLAY
#define __DISPLAY
#include "config.h"
#include "arduino.h"
typedef uint32_t (*get_pixel_func_t)(uint8_t x, uint8_t y);
class Display {
public:
enum Mode {
rows, // Left to right, top to bottom rows
U, // Two columns of rows, top to bottom, then bottom to top
N // Columns that alternate top to bottom, bottom to top
} __attribute__((packed));
Mode mode;
uint8_t width;
uint8_t height;
uint8_t RCLK_PIN;
uint8_t SRCLK_PIN;
uint8_t SER_PIN;
uint8_t OE_PIN;
uint8_t (*palette)[3];
Display(Mode mode, uint8_t width, uint8_t height,
uint8_t rclk_pin, uint8_t srclk_pin, uint8_t ser_pin, uint8_t oe_pin, bool neopixels) :
mode(mode), width(width), height(height),
RCLK_PIN(rclk_pin), SRCLK_PIN(srclk_pin), SER_PIN(ser_pin), OE_PIN(oe_pin),
palette(NULL), neopixels(neopixels) {}
// Returns whether the pixel was on before
uint8_t set_pixel(int8_t x, int8_t y, uint8_t val);
// Returns whether any pixel being set was set before
bool set_rect(int8_t x, int8_t y, int8_t width, int8_t height, uint8_t val);
uint8_t get_pixel(int8_t x, int8_t y);
void clear_all();
void refresh(bool multi_display = false, get_pixel_func_t get_pixel_func = NULL);
void set_brightness(uint8_t brightness);
uint8_t get_brightness();
bool neopixels;
private:
uint8_t brightness;
uint8_t state[MAX_DISPLAY_PIXELS];
};
#endif