PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. LedDisplay Library
  2. For details, see http://www.arduino.cc/playground/Main/LedDisplay
  3. This library allows you to send text to an Avago HCMS-29xx LED display. The HCMS 29xx displays are pretty little displays that contain a row of 5x7 LED matrices.
  4. The displays have a synchronous serial interface. You'll need five digital output lines to control them. The pins are as follows:
  5. * data - bits in from the microcontroller
  6. * register select - selects whether you're sending display data or control data
  7. * clock - timing clock from the microcontroller
  8. * enable - enables or disables the display
  9. * reset - resets the display
  10. The library manages all the necessary pin control and data shifting for you.
  11. Methods:
  12. LedDisplay(int dataPin, int registerSelect, int clockPin, int chipEnable, int resetPin, int displayLength) - instantiates the library. The first five parameters are the Arduino pin numbers that are connected to the display. The last sets the length of the display (8 for the HCMS-291x and HCMS-297x, 4 for the HCMS-290x and 296x).
  13. example:
  14. LedDisplay myDisplay = LedDisplay(2,3,4,5,6,8);
  15. begin() - initializes and resets the display.
  16. example:
  17. myDisplay.begin();
  18. Printing methods
  19. write(char whatCharacter, byte whatPosition) - writes a single character to the display at a particular position
  20. example:
  21. myDisplay.write('A', 4);
  22. LedDisplay inherits all the print() and println() methods from the Print library, so you can use those methods to print to the display, as long as what you print fits within the display. For example here's how to print the millis and a title string to the display:
  23. myDisplay.print("ms:");
  24. myDisplay.print(millis());
  25. You can also do the usual Print things, like:
  26. int myInt = 12;
  27. myDisplay.print(myInt, DEC);
  28. // or
  29. myDisplay.print(myInt, HEX);
  30. Scrolling methods
  31. If you want to be able to automatically scroll a string of text, you need to use the setString() method first. This method stores a character string in the library instance, so you can then use the scroll() method to move it left and right.
  32. setString(char* stringToDisplay) - displays a string on the display. If the string is longer than the display, the beginning of the string is displayed. You can use the scroll() method to step the string forward on the display.
  33. getString() - returns the string to display.
  34. example:
  35. // print out the display string for debugging:
  36. Serial.println(myDisplay.getString());
  37. stringLength() - returns the length of the display string. See the scrolling example below for usage.
  38. scroll(int direction) - scrolls the display using the string set by setString(). Negative numbers scroll left, positive numbers scroll right.
  39. example:
  40. ...
  41. void setup() {
  42. ...
  43. // scroll a string that's longer than the display:
  44. myDisplay.setString("This is a very long string");
  45. }
  46. void loop() {
  47. // when the string scrolls off the display, reverse scroll direction.
  48. // On the right, it scrolls off at position 8.
  49. // on the left, it scrolls off when the cursor is less than -(the length of the string):
  50. if ((myDisplay.cursorPosition() > displayLength) ||
  51. (myDisplay.cursorPosition() <= -(myDisplay.stringLength()))) {
  52. myDirection = -myDirection;
  53. delay(1000);
  54. }
  55. // scroll:
  56. myDisplay.scroll(myDirection);
  57. delay(100);
  58. }
  59. Cursor control methods
  60. clear() - clear the display.
  61. example:
  62. myDisplay.clear();
  63. home() - set cursor to far left hand position.
  64. example:
  65. myDisplay.home();
  66. setCursor(int whichPosition) - set cursor to any position.
  67. example:
  68. myDisplay.serCursor(4);
  69. getCursor() - get the cursor position.
  70. example:
  71. int cursorPosition = myDisplay.getCursor();
  72. Display Control methods
  73. setBrightness(int bright) - lets you set the brightness from 0 to 15.
  74. example:
  75. myDisplay.setBrightness(15);
  76. If you want to set the opcodes of the display directly (you can learn them from the data sheet), the following methods will do the trick.
  77. loadControlRegister(int dataByte) - sends 8 bits to one of the control registers.
  78. loadDotRegister() - sends 320 bits to the dot register
  79. Version method
  80. version() - returns the version number of the library.