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.

scroll.ino 1.6KB

3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. HCMS Display
  3. Language: Arduino/Wiring
  4. Displays a string on an Avago HCMS-297x display.
  5. Scrolls the string left and right.
  6. created 12 Jun. 2008
  7. modified 11 March 2010
  8. by Tom Igoe
  9. */
  10. #include <LedDisplay.h>
  11. // Define pins for the LED display.
  12. // You can change these, just re-wire your board:
  13. #define dataPin 6 // connects to the display's data in
  14. #define registerSelect 7 // the display's register select pin
  15. #define clockPin 8 // the display's clock pin
  16. #define enable 9 // the display's chip enable pin
  17. #define reset 10 // the display's reset pin
  18. #define displayLength 8 // number of characters in the display
  19. // create am instance of the LED display:
  20. LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin,
  21. enable, reset, displayLength);
  22. int brightness = 15; // screen brightness
  23. int myDirection = 1; // direction of scrolling. -1 = left, 1 = right.
  24. void setup() {
  25. Serial.begin(9600);
  26. // initialize the display library:
  27. myDisplay.begin();
  28. myDisplay.clear();
  29. myDisplay.setString("weasels smell funny!");
  30. myDisplay.setBrightness(brightness);
  31. delay(100);
  32. }
  33. void loop() {
  34. // when the string scrolls off the display, reverse scroll direction.
  35. // On the right, it scrolls off at position 8.
  36. // on the left, it scrolls off when the cursor is less than -(the length of the string):
  37. if ((myDisplay.getCursor() > displayLength) ||
  38. (myDisplay.getCursor() <= -(myDisplay.stringLength()))) {
  39. myDirection = -myDirection;
  40. delay(1000);
  41. }
  42. // scroll:
  43. myDisplay.scroll(myDirection);
  44. delay(100);
  45. }