-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplayControl.h
119 lines (104 loc) · 2.72 KB
/
DisplayControl.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* @file DisplayControl.h
* @author Ryan Johnson ([email protected])
* @brief Display view models and controllers
* @version 0.1
* @date 2020-06-13
*
* @copyright Copyright (c) 2020
*
*/
#ifndef DISPLAY_CONTROL_H
#define DISPLAY_CONTROL_H
#include "FaultHandling.h"
#include "MotionStateMachine.h"
#include <Adafruit_LiquidCrystal.h>
namespace Display {
/**
* Normal Operation
*
* +--------------------+
* |MOVING P:-360.00|
* |RAISING R:-360.00|
* |-1-- -2-- -3-- -4-- |
* |OK OK HALT HALT |
* +--------------------+
*
* +--------------------+
* |STOPPED P:-360.00|
* |SYSTEM OK R:-360.00|
* |-1-- -2-- -3-- -4-- |
* |OFF OFF OFF OFF |
* +--------------------+
*
*/
/**
* FAULT
* Fault conditions active:
* +--------------------+
* | /!\ Fault Detected | <--- Fault header
* |INCLINOMETER_INIT | <--- error code
* | (re-boot required) | <--- Recoverable or non-recoverable fault
* |Incl. 1 start failed| <--- Short human-readable
* +--------------------+
*
* +--------------------+
* | /!\ Fault Detected | <--- Fault header
* |INCLINOMETER_UNREADY| <--- error code
* | (please try again) | <--- Recoverable or non-recoverable fault
* |Sensor timed out | <--- Short human-readable
* +--------------------+
*
* Fault condition latched:
* +--------------------+
* |FAULTED P:-360.00|
* |CAN RESUME R:-360.00|
* |-1-- -2-- -3-- -4-- |
* |OFF OFF OFF OFF |
* +--------------------+
*/
typedef struct {
Motion::MotionStateMachine::STATE motionState;
double pitch;
double roll;
bool ram1;
bool ram2;
bool ram3;
bool ram4;
bool enable;
Motion::MovementDirection dirn;
Fault::Type faultType;
} SystemDisplayState;
typedef union {
struct __attribute__((packed)) {
char line1[21];
char line2[21];
char line3[21];
char line4[21];
} line_struct;
char array[4][21];
} DisplayableText;
class Controller {
public:
Controller() : lcd{0} {};
bool begin();
void writeRaw(DisplayableText &t);
void update(SystemDisplayState &state);
private:
Adafruit_LiquidCrystal lcd;
};
class AbstractDisplayView {
public:
virtual DisplayableText Render(const SystemDisplayState &dispState) = 0;
void BlankDisplayableText(DisplayableText *text);
};
class DisplayViewFault : public AbstractDisplayView {
public:
DisplayableText Render(const SystemDisplayState &dispState) override;
};
class DisplayViewNormal : public AbstractDisplayView {
public:
DisplayableText Render(const SystemDisplayState &dispState) override;
};
} // namespace Display
#endif // DISPLAY_CONTROL_H