-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNixieEffect.h
51 lines (43 loc) · 1.26 KB
/
NixieEffect.h
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
#pragma once
#include "NixieDisplay.h"
namespace Nixie {
template <class Model>
class Effect {
public:
void setDisplay(Display<Model> *display);
inline void setDriver(uint8_t value);
inline void setAnode(uint8_t tube, bool enabled);
inline void updateTube(uint8_t tube, uint8_t tick, uint8_t progress);
public:
virtual void perform(uint8_t tube, uint8_t tick, uint8_t progress) = 0;
protected:
Display<Model> *display;
uint8_t current_tube;
};
enum {
OLD_DIGIT = 20,
NEW_DIGIT = 21
};
template <class Model>
inline void Effect<Model>::setDisplay(Display<Model> *display) {
this->display = display;
}
template <class Model>
inline void Effect<Model>::setDriver(uint8_t value) {
if (value == OLD_DIGIT)
display->setDriver(display->prevdigits[current_tube]);
else if (value == NEW_DIGIT)
display->setDriver(display->digits[current_tube]);
else
display->setDriver(value);
}
template <class Model>
inline void Effect<Model>::setAnode(uint8_t tube, bool enabled) {
display->setAnode(tube, enabled);
}
template <class Model>
inline void Effect<Model>::updateTube(uint8_t tube, uint8_t tick, uint8_t progress) {
current_tube = tube;
perform(tube, tick, progress);
}
}