Terkel

Matrix Scroll Up

Jun 29th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. // This example shows the use of INSTANT_OPTIONS_MODE
  2. // When set it stops the text routine from having to scroll all
  3. // of the existing text off the display before changing the scroll
  4. // direction.
  5.  
  6. #include <FastLED.h>
  7.  
  8. #include <LEDMatrix.h>
  9. #include <LEDText.h>
  10. #include <Font12x16.h>
  11.  
  12. // Change the next 6 defines to match your matrix type and size
  13.  
  14. #define LED_PIN 7
  15. #define COLOR_ORDER GRB
  16. #define CHIPSET WS2812B
  17.  
  18. #define MATRIX_WIDTH 12
  19. #define MATRIX_HEIGHT 46
  20. #define MATRIX_TYPE VERTICAL_ZIGZAG_MATRIX
  21.  
  22. cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;
  23.  
  24. cLEDText ScrollingMsg;
  25.  
  26. const unsigned char TxtDemo[] = { EFFECT_FRAME_RATE "\x02"
  27. // EFFECT_HSV_AH "\x00\xff\xff\xff\xff\xff"
  28. // EFFECT_SCROLL_LEFT " The "
  29. EFFECT_SCROLL_UP "Quick "
  30. // EFFECT_SCROLL_LEFT "Brown "
  31. // EFFECT_SCROLL_DOWN "Fox"
  32. // EFFECT_SCROLL_LEFT "Jumps "
  33. EFFECT_SCROLL_UP "Over "
  34. // EFFECT_SCROLL_LEFT "The "
  35. // EFFECT_SCROLL_DOWN "Lazy "
  36. // EFFECT_SCROLL_LEFT "Dog "
  37. };
  38.  
  39. cLEDText ScrollingMsg2;
  40.  
  41. const unsigned char TxtDemo2[] = {EFFECT_FRAME_RATE "\x03"
  42. EFFECT_SCROLL_UP "HELLO WORLD "
  43. };
  44.  
  45. uint16_t Options;
  46.  
  47.  
  48.  
  49. void setup()
  50. {
  51. FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
  52. FastLED.setBrightness(64);
  53. FastLED.clear(true);
  54. delay(500);
  55. FastLED.showColor(CRGB::Red);
  56. delay(1000);
  57. FastLED.showColor(CRGB::Lime);
  58. delay(1000);
  59. FastLED.showColor(CRGB::Blue);
  60. delay(1000);
  61. FastLED.showColor(CRGB::White);
  62. delay(1000);
  63. FastLED.show();
  64.  
  65. ScrollingMsg.SetFont(Font12x16Data);
  66. ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight() + 14, 0, 0);
  67. ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);
  68. ScrollingMsg.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 0xff, 0x00, 0xff);
  69. Options = INSTANT_OPTIONS_MODE;
  70. ScrollingMsg.SetOptionsChangeMode(Options);
  71.  
  72. ScrollingMsg2.SetFont(Font12x16Data);
  73. ScrollingMsg2.Init(&leds, leds.Width(), ScrollingMsg2.FontHeight() + 14, 0, 0);
  74. ScrollingMsg2.SetText((unsigned char *)TxtDemo2, sizeof(TxtDemo2) - 1);
  75. ScrollingMsg2.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 100, 000, 255);
  76. Options = INSTANT_OPTIONS_MODE;
  77. ScrollingMsg2.SetOptionsChangeMode(Options);
  78. }
  79.  
  80.  
  81. void loop()
  82. {
  83. if (ScrollingMsg.UpdateText() == -1)
  84. {
  85. ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);
  86. Options ^= INSTANT_OPTIONS_MODE;
  87. ScrollingMsg.SetOptionsChangeMode(Options);
  88. }
  89. else
  90. FastLED.show();
  91. delay(10);
  92. }
  93.  
  94.  
  95. {
  96.  
  97. if (ScrollingMsg2.UpdateText() == -1)
  98. {
  99. ScrollingMsg2.SetText((unsigned char *)TxtDemo2, sizeof(TxtDemo2) - 1);
  100. Options ^= INSTANT_OPTIONS_MODE;
  101. ScrollingMsg2.SetOptionsChangeMode(Options);
  102. }
  103. else
  104. FastLED.show();
  105. delay(10);
  106. }
Advertisement
Add Comment
Please, Sign In to add comment