forked from rjbatista/tm1638-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TM16XX.h
81 lines (65 loc) · 2.7 KB
/
TM16XX.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
/*
TM16XX.h - Library for TM1638.
Copyright (C) 2011 Ricardo Batista <rjbatista at gmail dot com>
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TM16XX_h
#define TM16XX_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "TM16XXFonts.h"
class TM16XX
{
public:
/**
* Instantiate a tm16xx module specifying the number of displays, display state,
* the starting intensity (0-7) data, clock and stobe pins.
*/
TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean activateDisplay = true,
byte intensity = 7);
/** Set the display (segments and LEDs) active or off and intensity (range from 0-7). */
virtual void setupDisplay(boolean active, byte intensity);
/** Set a single display at pos (starting at 0) to a digit (left to right) */
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT);
/** Set the display to an error message */
virtual void setDisplayToError();
/** Clear a single display at pos (starting at 0, left to right) */
virtual void clearDisplayDigit(byte pos, boolean dot);
/** Set the display to the values (left to right) */
virtual void setDisplay(const byte values[], unsigned int length = 8);
/** Clear the display */
virtual void clearDisplay();
/** Set the display to the string (defaults to built in font) */
virtual void setDisplayToString(const char* string, const word dots = 0, const byte pos = 0,
const byte font[] = FONT_DEFAULT);
/** Set the display to the String (defaults to built in font) */
virtual void setDisplayToString(String string, const word dots = 0, const byte pos = 0,
const byte font[] = FONT_DEFAULT);
protected:
#if defined(ARDUINO) && ARDUINO >= 100
// pure virtual is NOT supported in older Arduino IDE
virtual void sendChar(byte pos, byte data, boolean dot) = 0;
#else
virtual void sendChar(byte pos, byte data, boolean dot);
#endif
virtual void sendCommand(byte led);
virtual void sendData(byte add, byte data);
virtual void send(byte data);
virtual byte receive();
byte displays;
byte dataPin;
byte clockPin;
byte strobePin;
};
#endif