forked from DCC-EX/CommandStation-EX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHmiInterface.hpp
112 lines (90 loc) · 2.69 KB
/
HmiInterface.hpp
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
//-------------------------------------------------------------------
#ifndef __HmiInterface_Hpp__
#define __HmiInterface_Hpp__
//-------------------------------------------------------------------
#ifdef USE_HMI
#include "CircularBuffer.hpp"
#define HmiInterfaceEvent_WifiStartConnection 0
#define HmiInterfaceEvent_WifiConnected 1
#define HmiInterfaceEvent_WifiEndConnection 2
#define HmiInterfaceEvent_NewClient 10
#define HmiInterfaceEvent_CloseClient 11
#define HmiInterfaceEvent_ChangeSpeed 20
#define HmiInterfaceEvent_ChangeDirection 21
#define HmiInterfaceEvent_ChangeFunction 22
#define HmiInterfaceEvent_DccOn 30
#define HmiInterfaceEvent_DccOff 31
#define HmiInterfaceEvent_DccShort 32
#define HmiInterfaceEvent_DccEmergencyStop 33
#define HmiInterfaceEvent_DccGeneralStop 34
#define HmiInterfaceEvent_LocoAdd 40
#define HmiInterfaceEvent_LocoRemove 41
#define HmiInterfaceEvent_WriteCv 50
#define HmiInterfaceEvent_ReadCv 51
struct HmiClient
{
int clientId;
IPAddress ip;
int port;
};
struct Dcc
{
uint16_t addr;
uint8_t speed;
bool forward;
uint8_t function;
bool state;
bool mainTrack;
uint16_t cvAddr;
uint16_t cvValue;
bool success;
};
union HmiInterfaceData
{
char ssid[30];
char name[30];
IPAddress ip;
HmiClient client;
Dcc dcc;
HmiInterfaceData() { ssid[0] = 0; }
~HmiInterfaceData() {}
};
struct HmiInterfaceMessage
{
byte event;
HmiInterfaceData data;
HmiInterfaceMessage() { this->event = 0; }
// ~HmiInterfaceMessage() {}
};
/** This interface established a relation between a User Interface and the DCC++ part of the library.
* If HmiInterface::CurrentInterface is not NULL, each User action will call a HMI routine to eventually
* show something on a screen...
*/
class HmiInterface
{
public:
static HmiInterface* CurrentInterface;
CircularBuffer *pHmiInterfaceEventBuffer;
HmiInterface();
void WifiStartConnection(const char* pSsid);
void WifiConnected(IPAddress ip);
void WifiEndConnection(const char* pSsid);
void NewClient(int clientId, IPAddress ip, int port);
void CloseClient(int clientId);
void ChangeSpeed(uint16_t addr, uint8_t speed);
void ChangeDirection(uint16_t addr, bool forward);
void ChangeFunction(uint16_t addr, uint8_t function, bool state);
void DCCOn();
void DCCOff();
void DCCShort();
void DCCEmergencyStop();
void DCCGeneralStop();
void LocoAdd(const char* name, uint16_t addr);
void LocoRemove(uint16_t addr);
void WriteCV(bool mainTrack, uint16_t cvAddr, byte cvValue, bool success);
void ReadCV(bool mainTrack, uint16_t cvAddr, byte cvValue, bool success);
virtual bool HmiInterfaceLoop() = 0;
virtual void HmiInterfaceUpdateDrawing() = 0;
};
#endif
#endif