-
Notifications
You must be signed in to change notification settings - Fork 12
/
WiTcontroller.h
206 lines (170 loc) · 5.54 KB
/
WiTcontroller.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//
// DO NOT alter this file
//
#define maxFoundWitServers 5 // must be 5 for the moment
#define maxFoundSsids 60 // must be a multiple of 5
#define maxRoster 60 // must be a multiple of 10
#define maxTurnoutList 60 // must be a multiple of 10
#define maxRouteList 60 // must be a multiple of 10
extern int keypadUseType;
extern int encoderUseType;
extern bool menuCommandStarted;
extern String menuCommand;
extern bool menuIsShowing;
extern String oledText[];
extern bool oledTextInvert[];
extern int currentSpeed[];
extern Direction currentDirection[];
extern int speedStepCurrentMultiplier;
extern TrackPower trackPower;
extern String turnoutPrefix;
extern String routePrefix;
extern bool circleValues;
extern int encoderValue;
extern int lastEncoderValue;
extern String selectedSsid;
extern String selectedSsidPassword;
extern int ssidConnectionState;
extern String ssidPasswordEntered;
extern bool ssidPasswordChanged;
extern char ssidPasswordCurrentChar;
extern IPAddress selectedWitServerIP;
extern int selectedWitServerPort;
extern String selectedWitServerName;
extern int noOfWitServices;
extern int witConnectionState;
extern IPAddress foundWitServersIPs[];
extern int foundWitServersPorts[];
extern String foundWitServersNames[];
extern int foundWitServersCount;
extern String foundSsids[];
extern long foundSsidRssis[];
extern bool foundSsidsOpen[];
extern int foundSsidsCount;
extern int ssidSelectionSource;
extern String witServerIpAndPortConstructed;
extern String witServerIpAndPortEntered;
extern bool witServerIpAndPortChanged;
extern int rosterSize;
extern int rosterIndex[];
extern String rosterName[];
extern int rosterAddress[];
extern char rosterLength[];
extern int page;
extern int turnoutListSize;
extern int turnoutListIndex[];
extern String turnoutListSysName[];
extern String turnoutListUserName[];
extern int turnoutListState[];
extern int routeListSize;
extern int routeListIndex[];
extern String routeListSysName[];
extern String routeListUserName[];
extern int routeListState[];
extern bool functionStates[][MAX_FUNCTIONS];
extern String functionLabels[][MAX_FUNCTIONS];
extern int functionFollow[][MAX_FUNCTIONS];
extern int currentSpeedStep[];
extern int heartBeatPeriod;
extern long lastServerResponseTime;
extern bool heartbeatCheckEnabled;
extern const char* deviceName;
extern const bool encoderRotationClockwiseIsIncreaseSpeed;
extern const bool toggleDirectionOnEncoderButtonPressWhenStationary;
extern int buttonActions[];
extern const String directCommandText[][3];
extern int additionalButtonActions[];
extern long lastSpeedSentTime;
extern int lastSpeedSent;
// extern int lastDirectionSent;
extern int lastSpeedThrottleIndex;
extern AiEsp32RotaryEncoder rotaryEncoder;
extern int currentThrottleIndex;
// function prototypes
void displayUpdateFromWit(void);
void ssidsLoop(void);
void browseSsids(void);
void selectSsidFromFound(int);
void getSsidPasswordAndWitIpForFound(void);
void enterSsidPassword(void);
void showListOfSsids(void);
void selectSsid(int);
void connectSsid(void);
void witServiceLoop(void);
void browseWitService(void);
void selectWitServer(int);
void connectWitServer(void);
void enterWitServer(void);
void disconnectWitServer(void);
void witEntryAddChar(char);
void witEntryDeleteChar(char);
void ssidPasswordAddChar(char);
void ssidPasswordDeleteChar(char);
void buildWitEntry(void);
void IRAM_ATTR readEncoderISR(void);
void rotary_onButtonClick(void);
void rotary_loop(void);
void encoderSpeedChange(bool, int);
void keypadEvent(KeypadEvent);
void initialiseAdditionalButtons(void);
void additionalButtonLoop(void);
void setup(void);
void loop(void);
void doKeyPress(char, bool);
void doDirectCommand (char, bool);
void doDirectAdditionalButtonCommand (int, bool);
void doDirectAction(int);
void doMenu(void);
void resetMenu(void);
void resetFunctionStates(int);
void resetFunctionLabels(int);
void resetAllFunctionLabels(void);
String getLocoWithLength(String);
void speedEstop(void);
void speedDown(int, int);
void speedUp(int, int);
void speedSet(int, int);
void releaseAllLocos(int);
void toggleAdditionalMultiplier(void);
void toggleHeartbeatCheck(void);
void toggleDirection(int);
void changeDirection(int, Direction);
void doDirectFunction(int, bool);
void doDirectFunction(int, bool, bool force);
void doFunction(int, int, bool);
void doFunction(int, int, bool, bool force);
void doFunctionWhichLocosInConsist(int multiThrottleIndex, int functionNumber, bool pressed);
void doFunctionWhichLocosInConsist(int multiThrottleIndex, int functionNumber, bool pressed, bool force);
void powerOnOff(TrackPower);
void powerToggle(void);
void nextThrottle(void);
void reconnect(void);
void setLastServerResponseTime(bool);
void selectRoster(int);
void selectTurnoutList(int, TurnoutAction);
void selectRouteList(int);
void selectFunctionList(int);
void selectEditConsistList(int);
void setAppnameForOled(void);
void writeOledFoundSSids(String);
void writeOledRoster(String);
void writeOledTurnoutList(String, TurnoutAction);
void writeOledRouteList(String);
void writeOledEnterPassword(void);
void writeOledMenu(String, bool);
// void writeOledExtraSubMenu();
void writeHeartbeatCheck(void);
void writeOledSpeed(void);
void writeOledFunctions(void);
void writeOledFunctionList(String);
void writeOledAllLocos(void);
void writeOledEditConsist();
void writeOledArray(bool, bool);
void writeOledArray(bool, bool, bool);
void writeOledArray(bool, bool, bool, bool);
void clearOledArray(void);
void writeOledDirectCommands(void);
void deepSleepStart();
void deepSleepStart(int);
char getMultiThrottleChar(int);
int getMultiThrottleIndex(char);