PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LedDisplay.h 4.1KB

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. LedDisplay -- controller library for Avago HCMS-297x displays -- version 0.3
  3. 27 Jan 2010 ML: extended a bit to support up to four (4) 8 character displays.
  4. Copyright (c) 2009 Tom Igoe. Some right reserved.
  5. Revisions on version 0.2 and 0.3 by Mark Liebman, 27 Jan 2010
  6. * extended a bit to support up to four (4) 8 character displays.
  7. vim: set ts=4:
  8. Controls an Avago HCMS29xx display. This display has 8 characters, each 5x7 LEDs
  9. This library is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU Lesser General Public
  11. License as published by the Free Software Foundation; either
  12. version 2.1 of the License, or (at your option) any later version.
  13. This library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. Lesser General Public License for more details.
  17. You should have received a copy of the GNU Lesser General Public
  18. License along with this library; if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. Version changes:
  21. * Version 3 adds support for multiple displays. Just change the displayLength to
  22. the total number of characters (for example, 3 8-character displays, displayLength = 24).
  23. */
  24. // ensure this library description is only included once
  25. #ifndef LedDisplay_h
  26. #define LedDisplay_h
  27. // supports up to four 8 character displays, connected as documented here,
  28. // under "Multiple Displays" http://playground.arduino.cc/Main/LedDisplay
  29. #define LEDDISPLAY_MAXCHARS 32
  30. // include types & constants of Wiring core API
  31. #if ARDUINO >= 100
  32. #include "Arduino.h"
  33. #else
  34. #include "WProgram.h"
  35. #endif
  36. // Arduino Print library provides print() and println() functionality
  37. #include "Print.h"
  38. // library interface description
  39. class LedDisplay : public Print {
  40. public:
  41. // constructor:
  42. LedDisplay(uint8_t _dataPin,
  43. uint8_t _registerSelect,
  44. uint8_t _clockPin,
  45. uint8_t _chipEnable,
  46. uint8_t _resetPin,
  47. uint8_t _displayLength);
  48. // initializer method:
  49. void begin();
  50. void clear(); // clear the display
  51. void home(); // set cursor to far left hand position
  52. void setCursor(int whichPosition); // set cursor to any position
  53. int getCursor(); // get the cursor position
  54. #if ARDUINO >= 100
  55. virtual size_t write(uint8_t b); // write a character to the display and advance cursor
  56. #else
  57. virtual void write(uint8_t b); // write a character to the display and advance cursor
  58. #endif
  59. using Print::write;
  60. void setString(const char* _stringToDisplay); // set the displayString variable
  61. const char * getString(); // get the displayString
  62. int stringLength(); // get the length of displayString
  63. void scroll(int direction); // scroll whatever string is stored in library's displayString variable
  64. void setBrightness(uint8_t bright); // set display brightness, 0 - 15
  65. // Control register setters. for addressing the display directly:
  66. void loadControlRegister(uint8_t dataByte);
  67. void loadAllControlRegisters(uint8_t dataByte);
  68. void loadDotRegister();
  69. int version(void); // return library version
  70. private:
  71. // Character display setters:
  72. void writeCharacter(char whatCharacter, byte whatPosition); // write a character to a buffer which will
  73. // be sent to the display by loadDotRegister()
  74. int cursorPos; // position of the cursor
  75. uint8_t dotRegister[LEDDISPLAY_MAXCHARS * 5]; // 5 bytes per character * maxchars
  76. // Define pins for the LED display:
  77. uint8_t dataPin; // connects to the display's data in
  78. uint8_t registerSelect; // the display's register select pin
  79. uint8_t clockPin; // the display's clock pin
  80. uint8_t chipEnable; // the display's chip enable pin
  81. uint8_t resetPin; // the display's reset pin
  82. uint8_t displayLength; // number of bytes needed to pad the string
  83. char stringBuffer[LEDDISPLAY_MAXCHARS+1]; // buffer to hold initial display string
  84. const char * displayString; // string for scrolling
  85. };
  86. #endif