My Project
TM1638.h
Go to the documentation of this file.
1 /*
2 TM1638.h - Library for TM1638.
3 
4 Copyright (C) 2011 Ricardo Batista <rjbatista at gmail dot com>
5 
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the version 3 GNU General Public License as
8 published by the Free Software Foundation.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef TM1638_h
20 #define TM1638_h
21 
22 #if defined(ARDUINO) && ARDUINO >= 100
23  #include "Arduino.h"
24 #else
25  #include "WProgram.h"
26 #endif
27 
28 #include "TM16XX.h"
29 #include "TM16XXFonts.h"
30 
31 #define TM1638_COLOR_NONE 0
32 #define TM1638_COLOR_RED 1
33 #define TM1638_COLOR_GREEN 2
34 
35 class TM1638 : public TM16XX
36 {
37  public:
39  TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay = true, byte intensity = 7);
40 
42  void setDisplayToHexNumber(unsigned long number, byte dots, boolean leadingZeros = true,
43  const byte numberFont[] = NUMBER_FONT);
45  void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros = true,
46  const byte numberFont[] = NUMBER_FONT);
48  void setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros = true,
49  const byte numberFont[] = NUMBER_FONT);
51  void setDisplayToBinNumber(byte number, byte dots,
52  const byte numberFont[] = NUMBER_FONT);
53 
55  virtual void setLED(byte color, byte pos);
57  void setLEDs(word led);
58 
60  virtual byte getButtons();
61 
62  protected:
63  virtual void sendChar(byte pos, byte data, boolean dot);
64  void setDisplayToDecNumberAt(unsigned long number, byte dots, byte startingPos,
65  boolean leadingZeros, const byte numberFont[]);
66 };
67 
68 #endif
byte dataPin
Definition: TM16XX.h:76
void setLEDs(word led)
Definition: TM1638.cpp:101
byte strobePin
Definition: TM16XX.h:78
byte clockPin
Definition: TM16XX.h:77
const byte NUMBER_FONT[]
Definition: TM16XXFonts.h:34
Definition: TM1638.h:35
TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay=true, byte intensity=7)
Definition: TM1638.cpp:28
void setDisplayToHexNumber(unsigned long number, byte dots, boolean leadingZeros=true, const byte numberFont[]=NUMBER_FONT)
Definition: TM1638.cpp:34
void setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros=true, const byte numberFont[]=NUMBER_FONT)
Definition: TM1638.cpp:74
void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros=true, const byte numberFont[]=NUMBER_FONT)
Definition: TM1638.cpp:68
Definition: TM16XX.h:30
virtual void sendChar(byte pos, byte data, boolean dot)
Definition: TM1638.cpp:132
void setDisplayToBinNumber(byte number, byte dots, const byte numberFont[]=NUMBER_FONT)
Definition: TM1638.cpp:89
virtual void setLED(byte color, byte pos)
Definition: TM1638.cpp:96
void setDisplayToDecNumberAt(unsigned long number, byte dots, byte startingPos, boolean leadingZeros, const byte numberFont[])
Definition: TM1638.cpp:47
virtual byte getButtons()
Definition: TM1638.cpp:118