| Parola for Arduino 1.0 Text effects for Parola modular hardware

- Main Page
- Related Pages
- Classes
- Files

- File List

MD_Parola_VScroll.cpp
1 /*
2 MD_Parola - Library for modular scrolling text and Effects
3
4 See header file for comments
5 This file contains implements vertical scrolling effect text display
6
7 Copyright (C) 2013 Marco Colli. All rights reserved.
8
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
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include <MD_Parola.h>
25 #include <MD_Parola_lib.h>
26
27 void MD_Parola::effectVScroll(textEffect_t effectSelect, bool bIn)
28 // Scroll the display horizontally up of down, depending on the selected effect
29 {
30 static uint8_t bitOffset = 0;
31
32 if (bIn) // incoming
33 {
34 switch (_fsmState)
35 {
36 case INITIALISE:
37 PRINT_STATE("I VSCROLL");
38 bitOffset = 0;
39 _D.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::OFF);
40 _fsmState = PUT_CHAR;
41 // fall through to next state
42
43 case GET_FIRST_CHAR:
44 case GET_NEXT_CHAR:
45 case PUT_CHAR:
46 case PAUSE:
47 PRINT_STATE("I VSCROLL");
48
49 displayClear();
50 commonPrint();
51
52 for (uint8_t i=bitOffset; i<7; i++)
53 // scroll the whole display so that the message appears to be animated
54 // Note: Directions are reversed because we start with the message in the
55 // middle position thru commonprint() and to see it animated move DOWN we
56 // need to scroll it UP, and vice versa.
57 _D.transform(effectSelect == SCROLL_UP ? MD_MAX72XX::TSD : MD_MAX72XX::TSU);
58
59 // check if we have finished
60 if (bitOffset == 7) _fsmState = PAUSE;
61
62 bitOffset++;
63 break;
64
65 default:
66 PRINT_STATE("I VSCROLL");
67 _fsmState = PAUSE;
68 }
69 }
70 else // exiting
71 {
72 switch (_fsmState)
73 {
74 case PAUSE:
75 case INITIALISE:
76 PRINT_STATE("O VSCROLL");
77 bitOffset = 0;
78 _fsmState = PUT_CHAR;
79 // fall through to next state
80
81 case GET_FIRST_CHAR:
82 case GET_NEXT_CHAR:
83 case PUT_CHAR:
84 PRINT_STATE("O VSCROLL");
85
86 _D.transform(effectSelect == SCROLL_UP ? MD_MAX72XX::TSU : MD_MAX72XX::TSD);
87
88 // check if we have finished
89 if (bitOffset == 7) _fsmState = END;
90
91 bitOffset++;
92 break;
93
94 default:
95 PRINT_STATE("O VSCROLL");
96 _fsmState = END;
97 break;
98 }
99 }
100 }