| Parola for Arduino 1.0 Text effects for Parola modular hardware

- Main Page
- Related Pages
- Classes
- Files

- File List

MD_Parola_Wipe.cpp
1 /*
2 MD_Parola - Library for modular scrolling text and Effects
3
4 See header file for comments
5 This file contains implements wipe 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::effectWipe(bool bLightBar, bool bIn)
28 // Wipe the message over with a new one
29 // Print up the whole message and then remove the parts we
30 // don't need in order to do the animation.
31 {
32 static int16_t nextPos = 0;
33 static int8_t posOffset = -1;
34 static uint16_t startPos = 0;
35 static uint16_t posLimit = 0;
36
37 if (bIn) // incoming
38 {
39 switch (_fsmState)
40 {
41 case INITIALISE:
42 PRINT_STATE("I WIPE");
43 posOffset = (_textAlignment == RIGHT ? 1 : -1);
44 startPos = nextPos = (_textAlignment == RIGHT ? _limitRight : _limitLeft);
45 posLimit = (_textAlignment == RIGHT ? _limitLeft+1 : _limitRight);
46 _fsmState = PUT_CHAR;
47 // fall through to next state
48
49 case GET_FIRST_CHAR:
50 case GET_NEXT_CHAR:
51 case PUT_CHAR:
52 case PAUSE:
53 PRINT_STATE("I WIPE");
54 if (_fsmState == PAUSE)
55 _fsmState = PUT_CHAR;
56
57 commonPrint();
58 // blank out the part of the display we don't need
59 FSMPRINT(" - Clear ", nextPos);
60 FSMPRINT(" to ", posLimit);
61 FSMPRINT(" step ", posOffset);
62 for (uint8_t i=nextPos; i != posLimit; i += posOffset)
63 _D.setColumn(i, 0);
64
65 if (bLightBar && (nextPos != posLimit)) _D.setColumn(nextPos, LIGHTBAR);
66
67 // check if we have finished
68 if (nextPos == posLimit) _fsmState = PAUSE;
69
70 nextPos += posOffset; // for the next time around
71 break;
72
73 default:
74 PRINT_STATE("I WIPE");
75 _fsmState = PAUSE;
76 }
77 }
78 else // exiting
79 {
80 switch (_fsmState)
81 {
82 case PAUSE:
83 case INITIALISE:
84 PRINT_STATE("O WIPE");
85 startPos = nextPos = (_textAlignment == RIGHT ? _limitRight : _limitLeft);
86 posLimit = (_textAlignment == RIGHT ? _limitLeft+1 : _limitRight);
87 posOffset = (_textAlignment == RIGHT ? 1 : -1);
88 _fsmState = PUT_CHAR;
89 // fall through to next state
90
91 case GET_FIRST_CHAR:
92 case GET_NEXT_CHAR:
93 case PUT_CHAR:
94 PRINT_STATE("O WIPE");
95 commonPrint();
96
97 // blank out the part of the display we don't need
98 FSMPRINT(" - Clear ", nextPos);
99 FSMPRINT(" to ", posLimit);
100 FSMPRINT(" step ", posOffset);
101 for (uint8_t i=startPos; i != nextPos; i += posOffset)
102 _D.setColumn(i, 0);
103
104 if (bLightBar && (nextPos != posLimit)) _D.setColumn(nextPos, LIGHTBAR);
105
106 // check if we have finished
107 if (nextPos == posLimit) _fsmState = END;
108
109 nextPos += posOffset; // for the next time around
110 break;
111
112 default:
113 PRINT_STATE("O WIPE");
114 _fsmState = END;
115 break;
116 }
117 }
118 }