forked from bracci/Qlockthree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.cpp
81 lines (68 loc) · 1.88 KB
/
Event.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* Event.cpp
* Klasse für ein jährliches Event
*
* @mc Arduino/UNO
* @autor Manuel Bracher / [email protected]
* @version 1.0
* @created 02.01.15
*
* Versionshistorie:
* V 1.0: - Erstellt.
*/
#include "Configuration.h"
#include "Event.h"
#define DEBUG
#include "Debug.h"
#define MAX_STR 32
namespace EVENT {
void show(const Event * const e) {
char txt[MAX_STR+1] = {'0'};
Effects::eEffects effect = pgm_read_byte_near(&e->_effect);
eColors color = pgm_read_byte_near(&e->_color);
strncpy_P(txt, pgm_read_word_near(&e->_txt), MAX_STR);
DEBUG_PRINT(F("Ticker String: "));
DEBUG_PRINTLN(txt);
if (strlen(txt) != 0)
Effects::showTickerString(txt, TICKER_SPEED, settings.getColor());
if (effect < Effects::BITMAP_MIN) {
switch (effect)
{
case Effects::NO_EFFECT:
break;
case Effects::EFFECT_FIREWORK:
Effects::showFireWork(5, color);
Effects::showFireWork(2, color);
Effects::showFireWork(8, color);
break;
case Effects::EFFECT_HEART:
Effects::showHeart(DURATION_ANI_BM, color);
break;
case Effects::EFFECT_CANDLE:
Effects::showCandle(color);
break;
default:
;
}
}
if ((effect >= Effects::BITMAP_MIN) && (effect < Effects::ANI_BITMAP_MIN)) {
Effects::showBitmap(effect, DURATION_BM, color);
}
if (effect >= Effects::ANI_BITMAP_MIN) {
Effects::showAnimatedBitmap(effect, DURATION_ANI_BM, color);
}
}
bool checkDate(const Event * const e, byte actDate, byte actMonth) {
byte evtDate = pgm_read_byte_near(&e->_date);
byte evtMonth = pgm_read_byte_near(&e->_month);
DEBUG_PRINT(F("Check:"));
DEBUG_PRINT(actDate);
DEBUG_PRINT(F("="));
DEBUG_PRINT(evtDate);
DEBUG_PRINT(F(" "));
DEBUG_PRINT(actMonth);
DEBUG_PRINT(F("="));
DEBUG_PRINTLN(evtMonth);
return ((actDate == evtDate) & (actMonth == evtMonth));
}
}