Skip to content

Commit f03bbad

Browse files
V1.6.52 - Updates
- Fixed key handling, which was suffering from some race-like conditions.
1 parent d46ba33 commit f03bbad

File tree

12 files changed

+53
-43
lines changed

12 files changed

+53
-43
lines changed

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#include "Globals.h"
1818

19-
String version = "V1.6.51";
19+
String version = "V1.6.52";
2020

2121
///////////////////////////////////////////////////////////////////////////
2222
// Please see the Globals.h file for configuration of the firmware.

Software/Arduino code/OpenAstroTracker/Utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ class LcdButtons {
140140
return _analogKeyValue;
141141
}
142142

143-
bool keyChanged(byte& newKey) {
143+
bool keyChanged(byte* pNewKey) {
144144
checkKey();
145145
if (_newKey != _lastNewKey) {
146-
newKey = _newKey;
146+
*pNewKey = _newKey;
147147
_lastNewKey = _newKey;
148148
return true;
149149
}

Software/Arduino code/OpenAstroTracker/c65_startup.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ void startupIsCompleted() {
2929

3030
bool processStartupKeys() {
3131
byte key;
32-
bool waitForRelease = true;
32+
bool waitForRelease = false;
3333
switch (startupState) {
3434
case StartupIsInHomePosition: {
35-
if (lcdButtons.keyChanged(key))
35+
if (lcdButtons.keyChanged(&key))
3636
{
37+
waitForRelease = true;
3738
if (key == btnLEFT) {
3839
isInHomePosition = adjustWrap(isInHomePosition, 1, YES, CANCEL);
3940
}
@@ -88,7 +89,7 @@ bool processStartupKeys() {
8889
}
8990

9091

91-
void prinStartupMenu() {
92+
void printStartupMenu() {
9293

9394
switch (startupState) {
9495
case StartupIsInHomePosition: {

Software/Arduino code/OpenAstroTracker/c70_menuRA.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#ifndef HEADLESS_CLIENT
22
bool processRAKeys() {
33
byte key;
4-
bool waitForRelease = true;
4+
bool waitForRelease = false;
55
if (lcdButtons.currentState() == btnUP) {
66
if (RAselect == 0) mount.targetRA().addHours(1);
77
if (RAselect == 1) mount.targetRA().addMinutes(1);
88
if (RAselect == 2) mount.targetRA().addSeconds(1);
99

1010
// slow down key repetitions
1111
mount.delay(200);
12-
waitForRelease = false;
1312
}
1413
else if (lcdButtons.currentState() == btnDOWN) {
1514
if (RAselect == 0) mount.targetRA().addHours(-1);
@@ -18,9 +17,9 @@ bool processRAKeys() {
1817

1918
// slow down key repetitions
2019
mount.delay(200);
21-
waitForRelease = false;
2220
}
23-
else if (lcdButtons.keyChanged(key)) {
21+
else if (lcdButtons.keyChanged(&key)) {
22+
waitForRelease = true;
2423
switch (key)
2524
{
2625
case btnLEFT: {

Software/Arduino code/OpenAstroTracker/c71_menuDEC.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
#ifndef HEADLESS_CLIENT
22
bool processDECKeys() {
33
byte key;
4-
bool waitForRelease = true;
4+
bool waitForRelease = false;
55
if (lcdButtons.currentState() == btnUP) {
66
if (DECselect == 0) mount.targetDEC().addDegrees(1);
77
if (DECselect == 1) mount.targetDEC().addMinutes(1);
88
if (DECselect == 2) mount.targetDEC().addSeconds(1);
99
// slow down key repetitions
1010
mount.delay(200);
11-
waitForRelease = false;
1211
}
1312
else if (lcdButtons.currentState() == btnDOWN) {
1413
if (DECselect == 0) mount.targetDEC().addDegrees(-1);
1514
if (DECselect == 1) mount.targetDEC().addMinutes(-1);
1615
if (DECselect == 2) mount.targetDEC().addSeconds(-1);
1716
// slow down key repetitions
1817
mount.delay(200);
19-
waitForRelease = false;
2018
}
21-
else if (lcdButtons.keyChanged(key)) {
19+
else if (lcdButtons.keyChanged(&key)) {
20+
waitForRelease = true;
2221
switch (key)
2322
{
2423
case btnLEFT: {

Software/Arduino code/OpenAstroTracker/c722_menuPOI.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ byte homePOI = sizeof(pointOfInterest) / sizeof(pointOfInterest[0]) - 2;
3333

3434
bool processPOIKeys() {
3535
byte key;
36-
if (lcdButtons.keyChanged(key)) {
36+
bool waitForRelease = false;
37+
if (lcdButtons.keyChanged(&key)) {
38+
waitForRelease = true;
3739
switch (key) {
3840
case btnSELECT: {
3941
mount.stopSlewing(ALL_DIRECTIONS);
@@ -70,7 +72,7 @@ bool processPOIKeys() {
7072
}
7173
}
7274

73-
return true;
75+
return waitForRelease;
7476
}
7577

7678
void printPOISubmenu() {

Software/Arduino code/OpenAstroTracker/c725_menuHOME.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ byte subGoIndex = 0;
33

44
bool processHomeKeys() {
55
byte key;
6-
if (lcdButtons.keyChanged(key)) {
6+
bool waitForRelease = false;
7+
8+
if (lcdButtons.keyChanged(&key)) {
9+
waitForRelease = true;
710
switch (key) {
811
case btnSELECT: {
912
if (subGoIndex == 0) {
@@ -29,7 +32,7 @@ bool processHomeKeys() {
2932
}
3033
}
3134

32-
return true;
35+
return waitForRelease;
3336
}
3437

3538
void printHomeSubmenu() {

Software/Arduino code/OpenAstroTracker/c72_menuHA.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
bool processHAKeys() {
44
byte key;
5-
bool waitForRelease = true;
5+
bool waitForRelease = false;
66
if (lcdButtons.currentState() == btnUP) {
77
DayTime ha(mount.HA());
88
if (HAselect == 0) ha.addHours(1);
@@ -11,7 +11,6 @@ bool processHAKeys() {
1111

1212
// slow down key repetitions
1313
mount.delay(200);
14-
waitForRelease = false;
1514
}
1615
else if (lcdButtons.currentState() == btnDOWN) {
1716
DayTime ha(mount.HA());
@@ -21,9 +20,9 @@ bool processHAKeys() {
2120

2221
// slow down key repetitions
2322
mount.delay(200);
24-
waitForRelease = false;
2523
}
26-
else if (lcdButtons.keyChanged(key)) {
24+
else if (lcdButtons.keyChanged(&key)) {
25+
waitForRelease = true;
2726
switch (key) {
2827
case btnLEFT: {
2928
HAselect = adjustWrap(HAselect, 1, 0, 1);

Software/Arduino code/OpenAstroTracker/c75_menuCTRL.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ bool processKeyStateChanges(int key, int dir)
3434

3535
bool processControlKeys() {
3636
byte key;
37+
bool waitForRelease = false;
3738

3839
// User must use SELECT to enter manual control.
3940
if (!inControlMode) {
40-
if (lcdButtons.keyChanged(key)) {
41+
if (lcdButtons.keyChanged(&key)) {
42+
waitForRelease = true;
4143
if (key == btnSELECT) {
4244
inControlMode = true;
4345
mount.stopSlewing(ALL_DIRECTIONS);
@@ -46,11 +48,12 @@ bool processControlKeys() {
4648
lcdMenu.setNextActive();
4749
}
4850
}
49-
return true;
51+
return waitForRelease;
5052
}
5153

5254
if (confirmZeroPoint) {
53-
if (lcdButtons.keyChanged(key)) {
55+
if (lcdButtons.keyChanged(&key)) {
56+
waitForRelease = true;
5457
if (key == btnSELECT) {
5558
if (setZeroPoint) {
5659
// Leaving Control Menu, so set stepper motor positions to zero.
@@ -79,7 +82,7 @@ bool processControlKeys() {
7982
setZeroPoint = !setZeroPoint;
8083
}
8184
}
82-
return true;
85+
return waitForRelease;
8386
}
8487

8588
mount.loop();

Software/Arduino code/OpenAstroTracker/c76_menuCAL.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ bool processCalibrationKeys() {
151151
calState = HIGHLIGHT_DRIFT;
152152
}
153153

154-
if (checkForKeyChange && lcdButtons.keyChanged(key)) {
154+
if (checkForKeyChange && lcdButtons.keyChanged(&key)) {
155155
waitForRelease = true;
156156

157157
switch (calState) {

0 commit comments

Comments
 (0)