Advertisement
Guest User

Untitled

a guest
Jan 13th, 2022
17
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. TM1638QYF.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 TM1638QYF_h
  20. #define TM1638QYF_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. class TM1638QYF : public TM16XX
  32. {
  33.   public:
  34.     /** Instantiate a tm1638 module specifying the display state, the starting intensity (0-7) data, clock and stobe pins. */
  35.     TM1638QYF(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay = true, byte intensity = 7);
  36.  
  37.     /** Set the display to a unsigned hexadecimal number (with or without leading zeros) */
  38.     void setDisplayToHexNumber(unsigned long number, byte dots, boolean leadingZeros = true,
  39.         const byte numberFont[] = FONT_DEFAULT);
  40.     /** Set the display to a unsigned decimal number (with or without leading zeros) */
  41.     void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros = true,
  42.         const byte numberFont[] = FONT_DEFAULT);
  43.     /** Set the display to a signed decimal number (with or without leading zeros) */
  44.     void setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros = true,
  45.         const byte numberFont[] = FONT_DEFAULT);
  46.     /** Set the display to a unsigned binary number */
  47.     void setDisplayToBinNumber(byte number, byte dots,
  48.         const byte numberFont[] = NUMBER_FONT);
  49.  
  50.     /** Clear the display */
  51.     virtual void clearDisplay();
  52.     /** Set the display to the String (defaults to built in font) - pos is ignored in common anode */
  53.     virtual void setDisplayToString(const char* string, const word dots = 0, const byte pos = 0,
  54.         const byte font[] = FONT_DEFAULT);
  55.     /** Set the display to the String (defaults to built in font) - pos is ignored in common anode */
  56.     virtual void setDisplayToString(String string, const word dots = 0, const byte pos = 0,
  57.         const byte font[] = FONT_DEFAULT);
  58.  
  59.     /** Returns the pressed buttons as a bit set (left to right). */
  60.     virtual word getButtons();
  61.  
  62.   protected:
  63.     /** Set the display to the values (left to right) */
  64.     virtual void setDisplay(const byte values[], unsigned int length = 8);
  65.  
  66.   private:
  67.     // unsupported in common anode design
  68.     virtual void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[] = NUMBER_FONT) { setDisplayToError(); };
  69.     // unsupported in common anode design
  70.     virtual void clearDisplayDigit(byte pos, boolean dot) { setDisplayToError(); };
  71.     // unsupported in common anode design
  72.     virtual void sendChar(byte pos, byte data, boolean dot) { setDisplayToError(); }
  73. };
  74.  
  75. #endif
  76.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement