Skip to content

Commit 47f0bc1

Browse files
V1.6.57 - Updates
- Fixed a bug where negative time was displayed incorrectly. - Fixed a bug in Set Home that did not account for current RA position. - Fixed a bug that incorrectly calculated current RA from stepper position. - Added some logging for debugging.
1 parent b2f40eb commit 47f0bc1

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,23 @@ void DayTime::subtractTime(const DayTime& other)
158158
char achBuf[32];
159159

160160
// Convert to a standard string (like 14:45:06)
161-
const char* DayTime::ToString() const
161+
const char* DayTime::ToString() const
162162
{
163163
char* p = achBuf;
164164

165-
if (hours < 10) {
165+
int absHours = hours < 0 ? -hours : hours;
166+
if (hours < 0)
167+
{
168+
*p++ = '-';
169+
}
170+
if (absHours < 10) {
166171
*p++ = '0';
167172
}
168173
else {
169-
*p++ = '0' + (hours / 10);
174+
*p++ = '0' + (absHours / 10);
170175
}
171176

172-
*p++ = '0' + (hours % 10);
177+
*p++ = '0' + (absHours % 10);
173178

174179
*p++ = ':';
175180
if (mins < 10) {
@@ -191,7 +196,7 @@ const char* DayTime::ToString() const
191196
*p++ = '0' + (secs % 10);
192197
*p++ = ' ';
193198
*p++ = '(';
194-
strcpy(p, String(this->getTotalHours(), 4).c_str());
199+
strcpy(p, String(this->getTotalHours(), 5).c_str());
195200
strcat(p, ")");
196201
return achBuf;
197202
}
@@ -263,7 +268,7 @@ const char* DegreeTime::ToString() const
263268
*p++ = '0' + (mins / 10);
264269
}
265270
*p++ = '0' + (mins % 10);
266-
271+
267272
*p++ = ':';
268273
if (secs < 10) {
269274
*p++ = '0';

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,29 @@ DegreeTime& Mount::targetDEC() {
392392
const DayTime Mount::currentRA() const {
393393
// How many steps moves the RA ring one sidereal hour along. One sidereal hour moves just shy of 15 degrees
394394
float stepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
395-
float hourPos = _stepperRA->currentPosition() / stepsPerSiderealHour / 2.0;
395+
float hourPos = 2.0 * -_stepperRA->currentPosition() / stepsPerSiderealHour;
396+
#ifdef DEBUG_MODE
397+
logv("CurrentRA: Steps/h : %s (%d x %s)", String(stepsPerSiderealHour, 2).c_str(), _stepsPerRADegree, String(siderealDegreesInHour, 5).c_str());
398+
logv("CurrentRA: RA Steps : %d", _stepperRA->currentPosition());
399+
logv("CurrentRA: POS : %s", String(hourPos).c_str());
400+
#endif
396401
hourPos += _zeroPosRA.getTotalHours();
402+
#ifdef DEBUG_MODE
403+
logv("CurrentRA: ZeroPos : %s", _zeroPosRA.ToString());
404+
logv("CurrentRA: POS (+zp) : %s", DayTime(hourPos).ToString());
405+
#endif
397406
if (_stepperDEC->currentPosition() > 0)
398407
{
399408
hourPos += 12;
400409
if (hourPos > 24) hourPos -= 24;
410+
#ifdef DEBUG_MODE
411+
logv("CurrentRA: RA (+12h): %s", DayTime(hourPos).ToString());
412+
#endif
401413
}
402414

415+
#ifdef DEBUG_MODE
416+
logv("CurrentRA: RA Pos -> : %s", DayTime(hourPos).ToString());
417+
#endif
403418
return hourPos;
404419
}
405420

@@ -1109,10 +1124,12 @@ void Mount::loop() {
11091124
//
11101125
/////////////////////////////////
11111126
void Mount::setHome() {
1127+
_zeroPosRA = currentRA();
1128+
11121129
_stepperRA->setCurrentPosition(0);
11131130
_stepperDEC->setCurrentPosition(0);
11141131
_stepperTRK->setCurrentPosition(0);
1115-
_zeroPosRA = currentRA();
1132+
11161133
#ifdef DEBUG_MODE
11171134
logv("Mount::setHome: ZeroPosRA set to %s", _zeroPosRA.ToString());
11181135
#endif

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.56";
19+
String version = "V1.6.57";
2020

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

0 commit comments

Comments
 (0)