-
Notifications
You must be signed in to change notification settings - Fork 2
/
StateList.h
58 lines (48 loc) · 1.2 KB
/
StateList.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
52
53
54
55
56
57
#pragma once
#include "Namespace.h"
#include "Config.h"
#include "Color.h"
#include "Interval.h"
#include "Pattern.h"
LED_CONTROLLER_NAMESPACE_ENTER
#define STATE_CHAR_PASSED 'p'
#define STATE_CHAR_FAILED 'f'
#define STATE_CHAR_BROKEN 'b'
/**
* A Pattern which represents a list of states. Visually, it is a sequence of
* colors, drawing from a small set of colors (green, black, blinking) which
* represents a set of states (passing, failed, broken) for tests.
*/
class StateList : public Pattern {
public:
typedef enum {
PASSED,
FAILED,
BROKEN
} State;
private:
int numKnownStates;
bool blinkOn;
Interval brokenBlinkInterval;
bool colorsChanged;
Color* stateColors[STRIP_LENGTH];
float historyScale;
static Color colorPassed;
Color colorPassedDim;
static Color colorFailed;
Color colorFailedDim;
Color colorBroken;
Color colorBrokenDim;
public:
StateList();
void parseStates(const char* stateString);
/**
* Set the factor by which to scale all but the first (most
* recent) state's colors. (Expected: dim all but the current
* state.)
*/
void setHistoryScale(float scale);
bool update();
void apply(Color* stripColors);
};
LED_CONTROLLER_NAMESPACE_EXIT