| Parola for Arduino 1.0 Text effects for Parola modular hardware

- Main Page
- Related Pages
- Classes
- Files

- File List

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