| Parola for Arduino 1.0 Text effects for Parola modular hardware

- Main Page
- Related Pages
- Classes
- Files

- File List

MD_Parola_Close.cpp
1 /*
2 MD_Parola - Library for modular scrolling text and Effects
3
4 See header file for comments
5 This file contains implements closing 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::effectClose(bool bLightBar, bool bIn)
28 // Dissolve the current message in/out
29 {
30 static int16_t offset;
31
32 if (bIn)
33 {
34 switch (_fsmState)
35 {
36 case INITIALISE:
37 case GET_FIRST_CHAR:
38 case GET_NEXT_CHAR:
39 PRINT_STATE("I CLOSE");
40 offset = 0;
41 displayClear();
42 if (bLightBar)
43 {
44 _D.setColumn(_limitLeft, LIGHTBAR);
45 _D.setColumn(_limitRight,LIGHTBAR);
46 }
47 _fsmState = PUT_CHAR;
48 // fall through
49
50 case PUT_CHAR:
51 PRINT_STATE("I CLOSE");
52 FSMPRINT(" - offset ", offset);
53 displayClear();
54 commonPrint();
55 {
56 const uint16_t halfWidth = (_limitLeft-_limitRight)/2;
57
58 if (offset > halfWidth)
59 {
60 _fsmState = PAUSE;
61 }
62 else
63 {
64 for (uint16_t i=_limitRight+offset+1; i<_limitLeft-offset; i++)
65 _D.setColumn(i, 0);
66
67 offset++;
68 if (bLightBar && (offset <= halfWidth))
69 {
70 _D.setColumn(_limitLeft - offset, LIGHTBAR);
71 _D.setColumn(_limitRight + offset, LIGHTBAR);
72 }
73 }
74 }
75 break;
76
77 default:
78 PRINT_STATE("I CLOSE");
79 _fsmState = PAUSE;
80 }
81 }
82 else // exiting
83 {
84 switch (_fsmState)
85 {
86 case PAUSE:
87
88 case GET_FIRST_CHAR:
89 case GET_NEXT_CHAR:
90 PRINT_STATE("O CLOSE");
91 FSMPRINT(" - limits R:", _limitRight);
92 FSMPRINT(" L:", _limitLeft);
93 offset = (_limitLeft-_limitRight)/2;
94 FSMPRINT(" O:", offset);
95 displayClear();
96 commonPrint();
97 if (bLightBar)
98 {
99 _D.setColumn(_limitLeft-offset, LIGHTBAR);
100 _D.setColumn(_limitRight+offset, LIGHTBAR);
101 }
102 _fsmState = PUT_CHAR;
103 break;
104
105 case PUT_CHAR:
106 PRINT_STATE("O CLOSE");
107 FSMPRINT(" - offset ", offset);
108 if (offset < 0)
109 {
110 _fsmState = END;
111 }
112 else
113 {
114 _D.setColumn(_limitLeft - offset, 0);
115 _D.setColumn(_limitRight + offset, 0);
116
117 offset--;
118 if (bLightBar && (offset >= 0))
119 {
120 _D.setColumn(_limitLeft - offset, LIGHTBAR);
121 _D.setColumn(_limitRight + offset, LIGHTBAR);
122 }
123 }
124 break;
125
126 default:
127 PRINT_STATE("O CLOSE");
128 _fsmState = END;
129 }
130 }
131 }