My Project
TM16XX.h
Go to the documentation of this file.
1 /*
2 TM16XX.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 TM16XX_h
20 #define TM16XX_h
21 
22 #if defined(ARDUINO) && ARDUINO >= 100
23  #include "Arduino.h"
24 #else
25  #include "WProgram.h"
26 #endif
27 
28 #include "TM16XXFonts.h"
29 
30 class TM16XX
31 {
32  public:
37  TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean activateDisplay = true,
38  byte intensity = 7);
39 
41  virtual void setupDisplay(boolean active, byte intensity);
42 
44  virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT);
46  virtual void setDisplayToError();
48  virtual void clearDisplayDigit(byte pos, boolean dot);
50  virtual void setDisplay(const byte values[], unsigned int length = 8);
52  virtual void clearDisplay();
53 
55  virtual void setDisplayToString(const char* string, const word dots = 0, const byte pos = 0,
56  const byte font[] = FONT_DEFAULT);
58  virtual void setDisplayToString(String string, const word dots = 0, const byte pos = 0,
59  const byte font[] = FONT_DEFAULT);
60 
61  protected:
62  #if defined(ARDUINO) && ARDUINO >= 100
63  // pure virtual is NOT supported in older Arduino IDE
64  virtual void sendChar(byte pos, byte data, boolean dot) = 0;
65  #else
66  virtual void sendChar(byte pos, byte data, boolean dot);
67  #endif
68 
69 
70  virtual void sendCommand(byte led);
71  virtual void sendData(byte add, byte data);
72  virtual void send(byte data);
73  virtual byte receive();
74 
75  byte displays;
76  byte dataPin;
77  byte clockPin;
78  byte strobePin;
79 };
80 
81 #endif
virtual void sendChar(byte pos, byte data, boolean dot)
Definition: TM16XX.cpp:177
virtual void clearDisplay()
Definition: TM16XX.cpp:91
virtual void clearDisplayDigit(byte pos, boolean dot)
Definition: TM16XX.cpp:79
virtual void setDisplayToError()
Definition: TM16XX.cpp:70
byte dataPin
Definition: TM16XX.h:76
virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[]=NUMBER_FONT)
Definition: TM16XX.cpp:65
byte strobePin
Definition: TM16XX.h:78
virtual void sendCommand(byte led)
Definition: TM16XX.cpp:122
byte clockPin
Definition: TM16XX.h:77
const byte FONT_DEFAULT[]
Definition: TM16XXFonts.h:68
virtual void sendData(byte add, byte data)
Definition: TM16XX.cpp:129
const byte NUMBER_FONT[]
Definition: TM16XXFonts.h:34
virtual void setDisplayToString(const char *string, const word dots=0, const byte pos=0, const byte font[]=FONT_DEFAULT)
Definition: TM16XX.cpp:98
virtual void send(byte data)
Definition: TM16XX.cpp:138
byte displays
Definition: TM16XX.h:75
virtual void setDisplay(const byte values[], unsigned int length=8)
Definition: TM16XX.cpp:84
Definition: TM16XX.h:30
virtual void setupDisplay(boolean active, byte intensity)
Definition: TM16XX.cpp:54
virtual byte receive()
Definition: TM16XX.cpp:148
TM16XX(byte dataPin, byte clockPin, byte strobePin, byte displays, boolean activateDisplay=true, byte intensity=7)
Definition: TM16XX.cpp:28