Skip to content

Commit 78c9e31

Browse files
Merge pull request #106 from OpenAstroTech/status-display
V1.8.43 - Updates
2 parents e3f5cf3 + c6aa01c commit 78c9e31

File tree

4 files changed

+131
-49
lines changed

4 files changed

+131
-49
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define VERSION "V1.8.42"
1+
#define VERSION "V1.8.43"

Software/Arduino code/OpenAstroTracker/src/a_inits.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ bool inStartup = false; // Start with a guided startup
115115
bool inSerialControl = false; // When the serial port is in control
116116
bool quitSerialOnNextButtonRelease = false; // Used to detect SELECT button to quit Serial mode.
117117

118-
//// Variables for use in the CONTROL menu
119-
bool inControlMode = false; // Is manual control enabled
120-
121118
// Global variables
122119
bool isUnreachable = false;
123120

Software/Arduino code/OpenAstroTracker/src/c65_startup.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//////////////////////////////////////////////////////////////
1212
// This file contains the Starup 'wizard' that guides you through initial setup
1313

14+
void setControlMode(bool); // In CTRL menu
15+
1416
#define StartupIsInHomePosition 1
1517
#define StartupSetHATime 4
1618
#define StartupWaitForHACompletion 6
@@ -79,7 +81,7 @@ bool processStartupKeys() {
7981
lcdMenu.setActive(Control_Menu);
8082

8183
// Skip the 'Manual control' prompt
82-
inControlMode = true;
84+
setControlMode(true);
8385
#endif
8486
}
8587
else if (isInHomePosition == CANCEL) {

Software/Arduino code/OpenAstroTracker/src/c75_menuCTRL.hpp

Lines changed: 127 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,190 @@
22

33
#if DISPLAY_TYPE > 0
44
#if SUPPORT_MANUAL_CONTROL == 1
5-
bool confirmZeroPoint = false;
5+
66
bool setZeroPoint = true;
77

8+
#define HIGHLIGHT_MANUAL 1
9+
#define HIGHLIGHT_SERIAL 2
10+
11+
#define MANUAL_CONTROL_MODE 10
12+
#define MANUAL_CONTROL_CONFIRM_HOME 11
13+
#define SERIAL_DISPLAY_MODE 20
14+
15+
int ctrlState = HIGHLIGHT_MANUAL;
816

917
#define LOOPS_TO_CONFIRM_KEY 10
1018
byte loopsWithKeyPressed = 0;
1119
byte keyPressed = btnNONE;
1220

21+
void setControlMode(bool state)
22+
{
23+
ctrlState = state ? MANUAL_CONTROL_MODE : HIGHLIGHT_MANUAL;
24+
}
1325

1426
bool processKeyStateChanges(int key, int dir)
1527
{
1628
bool ret = false;
17-
if (keyPressed != key) {
29+
if (keyPressed != key)
30+
{
1831
loopsWithKeyPressed = 0;
1932
keyPressed = key;
2033
}
21-
else {
22-
if (loopsWithKeyPressed == LOOPS_TO_CONFIRM_KEY) {
34+
else
35+
{
36+
if (loopsWithKeyPressed == LOOPS_TO_CONFIRM_KEY)
37+
{
2338
mount.stopSlewing(ALL_DIRECTIONS);
2439
mount.waitUntilStopped(ALL_DIRECTIONS);
25-
if (dir != 0) {
40+
if (dir != 0)
41+
{
2642
mount.startSlewing(dir);
2743
}
2844
loopsWithKeyPressed++;
2945
ret = true;
3046
}
31-
else if (loopsWithKeyPressed < LOOPS_TO_CONFIRM_KEY) {
47+
else if (loopsWithKeyPressed < LOOPS_TO_CONFIRM_KEY)
48+
{
3249
loopsWithKeyPressed++;
3350
}
3451
}
35-
52+
3653
return ret;
3754
}
3855

39-
bool processControlKeys() {
56+
bool processControlKeys()
57+
{
4058
byte key;
4159
bool waitForRelease = false;
4260

4361
// User must use SELECT to enter manual control.
44-
if (!inControlMode) {
45-
if (lcdButtons.keyChanged(&key)) {
62+
switch (ctrlState)
63+
{
64+
case HIGHLIGHT_MANUAL:
65+
{
66+
if (lcdButtons.keyChanged(&key))
67+
{
4668
waitForRelease = true;
47-
if (key == btnSELECT) {
48-
inControlMode = true;
69+
if (key == btnSELECT)
70+
{
71+
ctrlState = MANUAL_CONTROL_MODE;
4972
mount.stopSlewing(ALL_DIRECTIONS);
5073
}
51-
else if (key == btnRIGHT) {
74+
else if ((key == btnDOWN) || (key == btnUP))
75+
{
76+
ctrlState = HIGHLIGHT_SERIAL;
77+
}
78+
else if (key == btnRIGHT)
79+
{
80+
lcdMenu.setNextActive();
81+
}
82+
}
83+
}
84+
break;
85+
86+
case HIGHLIGHT_SERIAL:
87+
{
88+
if (lcdButtons.keyChanged(&key))
89+
{
90+
waitForRelease = true;
91+
if (key == btnSELECT)
92+
{
93+
inSerialControl = !inSerialControl;
94+
}
95+
else if ((key == btnDOWN) || (key == btnUP))
96+
{
97+
ctrlState = HIGHLIGHT_MANUAL;
98+
}
99+
else if (key == btnRIGHT)
100+
{
101+
inSerialControl = false;
52102
lcdMenu.setNextActive();
53103
}
54104
}
55-
return waitForRelease;
56105
}
106+
break;
57107

58-
if (confirmZeroPoint) {
59-
if (lcdButtons.keyChanged(&key)) {
108+
case MANUAL_CONTROL_CONFIRM_HOME:
109+
{
110+
if (lcdButtons.keyChanged(&key))
111+
{
60112
waitForRelease = true;
61-
if (key == btnSELECT) {
62-
if (setZeroPoint) {
113+
if (key == btnSELECT)
114+
{
115+
if (setZeroPoint)
116+
{
63117
// Leaving Control Menu, so set stepper motor positions to zero.
64118
LOGV1(DEBUG_GENERAL, F("CTRL menu: Calling setHome(true)!"));
65119
mount.setHome(true);
66-
LOGV3(DEBUG_GENERAL, F("CTRL menu: setHome(true) returned: RA Current %s, Target: %f"), mount.RAString(CURRENT_STRING|COMPACT_STRING).c_str(), mount.RAString(TARGET_STRING | COMPACT_STRING).c_str());
120+
LOGV3(DEBUG_GENERAL, F("CTRL menu: setHome(true) returned: RA Current %s, Target: %f"), mount.RAString(CURRENT_STRING | COMPACT_STRING).c_str(), mount.RAString(TARGET_STRING | COMPACT_STRING).c_str());
67121
mount.startSlewing(TRACKING);
68122
}
69123

70124
// Set flag to prevent resetting zero point when moving over the menu items
71-
inControlMode = false;
125+
ctrlState = HIGHLIGHT_MANUAL;
72126

73127
#if SUPPORT_GUIDED_STARTUP == 1
74-
if (startupState == StartupWaitForPoleCompletion) {
128+
if (startupState == StartupWaitForPoleCompletion)
129+
{
75130
startupState = StartupPoleConfirmed;
76131
inStartup = true;
77-
inControlMode = false;
132+
ctrlState = HIGHLIGHT_MANUAL;
78133
}
79134
else
80135
#endif
81136
{
82137
lcdMenu.setNextActive();
83138
}
84139

85-
confirmZeroPoint = false;
140+
ctrlState = HIGHLIGHT_MANUAL;
86141
setZeroPoint = true;
87142
}
88-
else if (key == btnLEFT) {
143+
else if (key == btnLEFT)
144+
{
89145
setZeroPoint = !setZeroPoint;
90146
}
91147
}
92-
return waitForRelease;
93148
}
94-
95-
key = lcdButtons.currentState();
96-
switch (key) {
97-
case btnUP: {
149+
break;
150+
151+
case MANUAL_CONTROL_MODE:
152+
{
153+
key = lcdButtons.currentState();
154+
switch (key)
155+
{
156+
case btnUP:
157+
{
98158
processKeyStateChanges(btnUP, NORTH);
99159
}
100160
break;
101161

102-
case btnDOWN: {
162+
case btnDOWN:
163+
{
103164
processKeyStateChanges(btnDOWN, SOUTH);
104165
}
105166
break;
106167

107-
case btnLEFT: {
168+
case btnLEFT:
169+
{
108170
processKeyStateChanges(btnLEFT, WEST);
109171
}
110172
break;
111173

112-
case btnRIGHT: {
174+
case btnRIGHT:
175+
{
113176
processKeyStateChanges(btnRIGHT, EAST);
114177
}
115178
break;
116179

117-
case btnSELECT: {
180+
case btnSELECT:
181+
{
118182
if (processKeyStateChanges(btnSELECT, 0))
119183
{
120184
#if SUPPORT_GUIDED_STARTUP == 1
121-
if (startupState == StartupWaitForPoleCompletion) {
185+
if (startupState == StartupWaitForPoleCompletion)
186+
{
122187
startupState = StartupPoleConfirmed;
123-
inControlMode = false;
124-
confirmZeroPoint = false;
188+
ctrlState = HIGHLIGHT_MANUAL;
125189
waitForRelease = true;
126190
inStartup = true;
127191
}
@@ -130,36 +194,55 @@ bool processControlKeys() {
130194
{
131195
lcdMenu.setCursor(0, 0);
132196
lcdMenu.printMenu("Set home pos?");
133-
confirmZeroPoint = true;
197+
ctrlState = MANUAL_CONTROL_CONFIRM_HOME;
134198
waitForRelease = true;
135199
}
136200
}
137201
}
138202
break;
139203

140-
case btnNONE: {
204+
case btnNONE:
205+
{
141206
processKeyStateChanges(btnNONE, 0);
142207
}
143208
break;
209+
}
210+
}
211+
break;
144212
}
145213

146214
return waitForRelease;
147215
}
148216

149-
150-
void printControlSubmenu() {
151-
if (!inControlMode) {
152-
lcdMenu.printMenu(">Manual control");
217+
void printControlSubmenu()
218+
{
219+
switch (ctrlState)
220+
{
221+
case HIGHLIGHT_MANUAL:
222+
{
223+
lcdMenu.printMenu(">Manual slewing");
224+
}
225+
break;
226+
case HIGHLIGHT_SERIAL:
227+
{
228+
lcdMenu.printMenu(">Serial display");
153229
}
154-
else if (confirmZeroPoint) {
230+
break;
231+
case MANUAL_CONTROL_CONFIRM_HOME:
232+
{
155233
String disp = " Yes No ";
156234
disp.setCharAt(setZeroPoint ? 0 : 5, '>');
157235
disp.setCharAt(setZeroPoint ? 4 : 8, '<');
158236
lcdMenu.printMenu(disp);
159237
}
160-
else {
238+
break;
239+
default:
240+
{
161241
mount.displayStepperPositionThrottled();
162242
}
243+
break;
244+
}
163245
}
246+
164247
#endif
165248
#endif

0 commit comments

Comments
 (0)