Parola for Arduino  1.0
Text effects for Parola modular hardware
MD_Parola_Blinds.cpp
1 /*
2 MD_Parola - Library for modular scrolling text and Effects
3 
4 See header file for comments
5 /**
6 \brief This file implements blinds effect text display
7 
8 Copyright (C) 2013 Marco Colli. All rights reserved.
9 
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14 
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include <MD_Parola.h>
26 #include <MD_Parola_lib.h>
27 
28 #define BLINDS_SIZE 4
29 
30 void MD_Parola::effectBlinds(bool bIn)
31 // Transfer between messages with blinds effects
32 {
33  static uint8_t blindCount;
34 
35  switch (_fsmState)
36  {
37  case INITIALISE: // bIn = true
38  case PAUSE: // bIn = false
39  PRINT_STATE("IO BLIND");
40  blindCount = 0;
41  _fsmState = GET_FIRST_CHAR;
42  // fall through
43 
44  case GET_FIRST_CHAR: // blinds closing
45  PRINT_STATE("IO BLIND");
46 
47  blindCount++;
48  for (uint16_t i=0; i<_D.getColumnCount(); i++)
49  {
50  if (i % BLINDS_SIZE < blindCount)
51  _D.setColumn(i, 0xff);
52  }
53 
54  if (blindCount == BLINDS_SIZE)
55  {
56  blindCount = BLINDS_SIZE;
57  _fsmState = GET_NEXT_CHAR;
58  }
59  break;
60 
61  case GET_NEXT_CHAR: // blinds opening
62  PRINT_STATE("IO BLIND");
63  displayClear();
64  if (bIn) commonPrint(); // only do this when putting hte message up
65 
66  blindCount--;
67  for (uint16_t i=0; i<_D.getColumnCount(); i++)
68  {
69  if (i % BLINDS_SIZE < blindCount)
70  _D.setColumn(i, 0xff);
71  }
72 
73  if (blindCount == 0)
74  _fsmState = PUT_CHAR;
75  break;
76 
77  case PUT_CHAR:
78  PRINT_STATE("IO BLIND");
79  displayClear();
80  if (bIn) commonPrint();
81  _fsmState = (bIn ? PAUSE : END);
82  break;
83 
84  default:
85  PRINT_STATE("IO BLIND");
86  _fsmState = (bIn ? PAUSE : END);
87  }
88 }