forked from adafruit/Adafruit_LED_Backpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_LEDBackpack.h
171 lines (123 loc) · 3.89 KB
/
Adafruit_LEDBackpack.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/***************************************************
This is a library for our I2C LED Backpacks
Designed specifically to work with the Adafruit LED Matrix backpacks
----> http://www.adafruit.com/products/
----> http://www.adafruit.com/products/
These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#ifndef Adafruit_LEDBackpack_h
#define Adafruit_LEDBackpack_h
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
#include "Adafruit_GFX.h"
#define LED_ON 1
#define LED_OFF 0
#define LED_RED 1
#define LED_YELLOW 2
#define LED_GREEN 3
#define HT16K33_BLINK_CMD 0x80
#define HT16K33_BLINK_DISPLAYON 0x01
#define HT16K33_BLINK_OFF 0
#define HT16K33_BLINK_2HZ 1
#define HT16K33_BLINK_1HZ 2
#define HT16K33_BLINK_HALFHZ 3
#define HT16K33_CMD_BRIGHTNESS 0xE0
#define SEVENSEG_DIGITS 5
// this is the raw HT16K33 controller
class Adafruit_LEDBackpack {
public:
Adafruit_LEDBackpack(void);
void begin(uint8_t _addr);
void setBrightness(uint8_t b);
void blinkRate(uint8_t b);
void writeDisplay(void);
void clear(void);
uint16_t displaybuffer[8];
void init(uint8_t a);
protected:
uint8_t i2c_addr;
};
class Adafruit_AlphaNum4 : public Adafruit_LEDBackpack {
public:
Adafruit_AlphaNum4(void);
void writeDigitRaw(uint8_t n, uint16_t bitmask);
void writeDigitAscii(uint8_t n, uint8_t ascii, boolean dot = false);
private:
};
class Adafruit_24bargraph : public Adafruit_LEDBackpack {
public:
Adafruit_24bargraph(void);
void setBar(uint8_t bar, uint8_t color);
private:
};
class Adafruit_8x16matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
Adafruit_8x16matrix(void);
void drawPixel(int16_t x, int16_t y, uint16_t color);
private:
};
class Adafruit_8x16minimatrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
Adafruit_8x16minimatrix(void);
void drawPixel(int16_t x, int16_t y, uint16_t color);
private:
};
class Adafruit_8x8matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
Adafruit_8x8matrix(void);
void drawPixel(int16_t x, int16_t y, uint16_t color);
private:
};
class Adafruit_BicolorMatrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
Adafruit_BicolorMatrix(void);
void drawPixel(int16_t x, int16_t y, uint16_t color);
private:
};
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0
class Adafruit_7segment : public Adafruit_LEDBackpack {
public:
Adafruit_7segment(void);
size_t write(uint8_t c);
void print(char, int = BYTE);
void print(unsigned char, int = BYTE);
void print(int, int = DEC);
void print(unsigned int, int = DEC);
void print(long, int = DEC);
void print(unsigned long, int = DEC);
void print(double, int = 2);
void println(char, int = BYTE);
void println(unsigned char, int = BYTE);
void println(int, int = DEC);
void println(unsigned int, int = DEC);
void println(long, int = DEC);
void println(unsigned long, int = DEC);
void println(double, int = 2);
void println(void);
void writeDigitRaw(uint8_t x, uint8_t bitmask);
void writeDigitNum(uint8_t x, uint8_t num, boolean dot = false);
void drawColon(boolean state);
void printNumber(long, uint8_t = 2);
void printFloat(double, uint8_t = 2, uint8_t = DEC);
void printError(void);
void writeColon(void);
private:
uint8_t position;
};
#endif // Adafruit_LEDBackpack_h