Skip to content

Commit 0570c5c

Browse files
author
openastrotech
committed
update to .55
1 parent 4241ade commit 0570c5c

File tree

6 files changed

+412
-240
lines changed

6 files changed

+412
-240
lines changed

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ void DayTime::subtractTime(const DayTime& other)
155155
addHours(-other.getHours());
156156
}
157157

158+
char achBuf[32];
159+
158160
// Convert to a standard string (like 14:45:06)
159-
String DayTime::ToString()
161+
const char* DayTime::ToString() const
160162
{
161-
char achBuf[12];
162163
char* p = achBuf;
163164

164165
if (hours < 10) {
@@ -188,8 +189,8 @@ String DayTime::ToString()
188189
}
189190

190191
*p++ = '0' + (secs % 10);
191-
*p++ = '\0';
192-
return String(achBuf);
192+
sprintf(p, " (%.4f)", this->getTotalHours());
193+
return achBuf;
193194
}
194195

195196

@@ -209,7 +210,7 @@ int DegreeTime::getDegrees() {
209210
return hours;
210211
}
211212

212-
int DegreeTime::getPrintDegrees() {
213+
int DegreeTime::getPrintDegrees() const {
213214
return NORTHERN_HEMISPHERE ? hours + 90 : hours - 90;
214215
}
215216

@@ -227,3 +228,49 @@ void DegreeTime::checkHours() {
227228
if (hours < 0) hours = 0;
228229
}
229230
}
231+
232+
char achBufDeg[32];
233+
234+
// Convert to a standard string (like 14:45:06)
235+
const char* DegreeTime::ToString() const
236+
{
237+
char* p = achBufDeg;
238+
int abshours = getPrintDegrees() < 0 ? -getPrintDegrees() : getPrintDegrees();
239+
240+
if (getPrintDegrees() < 0) {
241+
*p++ = '-';
242+
}
243+
else {
244+
*p++ = '+';
245+
}
246+
247+
if (abshours < 10) {
248+
*p++ = '0';
249+
}
250+
else {
251+
*p++ = '0' + (abshours / 10);
252+
}
253+
*p++ = '0' + (abshours % 10);
254+
255+
*p++ = ':';
256+
if (mins < 10) {
257+
*p++ = '0';
258+
}
259+
else {
260+
*p++ = '0' + (mins / 10);
261+
}
262+
*p++ = '0' + (mins % 10);
263+
264+
*p++ = ':';
265+
if (secs < 10) {
266+
*p++ = '0';
267+
}
268+
else {
269+
*p++ = '0' + (secs / 10);
270+
}
271+
272+
*p++ = '0' + (secs % 10);
273+
sprintf(p, " (%.4f)", NORTHERN_HEMISPHERE ? getTotalHours() + 90 : getTotalHours() - 90);
274+
275+
return achBufDeg;
276+
}

Software/Arduino code/OpenAstroTracker/DayTime.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class DayTime {
5656
void subtractTime(const DayTime& other);
5757

5858
// Convert to a standard string (like 14:45:06)
59-
String ToString();
59+
virtual const char* ToString() const;
60+
6061
//protected:
6162
virtual void checkHours();
6263
};
@@ -75,13 +76,16 @@ class DegreeTime : public DayTime {
7576
int getDegrees();
7677

7778
// Get degrees for printing component
78-
int getPrintDegrees();
79+
int getPrintDegrees() const;
7980

8081
// Get total degrees
8182
float getTotalDegrees() const;
8283
//protected:
8384
virtual void checkHours() override;
8485

86+
// Convert to a standard string (like 14:45:06)
87+
virtual const char* ToString() const override;
88+
8589
private:
8690
void clampDegrees();
8791
};

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115
// Where HH is hours, MM is minutes.
116116
// Returns: 1 if successfully set, otherwise 0
117117
//
118+
// :SHLHH:MM#
119+
// Set LST Time
120+
// This sets the scopes LST (and HA).
121+
// Where HH is hours, MM is minutes.
122+
// Returns: 1 if successfully set, otherwise 0
123+
//
118124
// :SYsDD*MM:SS.HH:MM:SS#
119125
// Synchronize Declination and Right Ascension.
120126
// This tells the scope what it is currently pointing at.
@@ -197,6 +203,11 @@
197203
// Where nnn is the number of seconds the entire alignment should take.
198204
// Returns: nothing
199205
//
206+
// :XGB#
207+
// Get Backlash correction steps
208+
// Get the number of steps the RA stepper motor needs to overshoot and backtrack when slewing east.
209+
// Returns: integer
210+
//
200211
// :XGR#
201212
// Get RA steps
202213
// Get the number of steps the RA stepper motor needs to take to rotate by one degree
@@ -222,6 +233,11 @@
222233
// Get the current LST of the mount.
223234
// Returns: HHMMSS
224235
//
236+
// :XSBn#
237+
// Set Backlash correction steps
238+
// Sets the number of steps the RA stepper motor needs to overshoot and backtrack when slewing east.
239+
// Returns: nothing
240+
//
225241
// :XSRn#
226242
// Set RA steps
227243
// Set the number of steps the RA stepper motor needs to take to rotate by one degree
@@ -575,6 +591,9 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd) {
575591
else if (inCmd[1] == 'S') {
576592
return String(_mount->getSpeedCalibration(), 5) + "#";
577593
}
594+
else if (inCmd[1] == 'B') {
595+
return String(_mount->getBacklashCorrection()) + "#";
596+
}
578597
else if (inCmd[1] == 'H') {
579598
char scratchBuffer[10];
580599
sprintf(scratchBuffer, "%02d%02d%02d#", _mount->HA().getHours(), _mount->HA().getMinutes(), _mount->HA().getSeconds());
@@ -605,6 +624,9 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd) {
605624
else if (inCmd[1] == 'Y') {
606625
_mount->setSpeed(DEC_STEPS, inCmd.substring(2).toFloat());
607626
}
627+
else if (inCmd[1] == 'B') {
628+
_mount->setBacklashCorrection(inCmd.substring(2).toInt());
629+
}
608630
}
609631
return "";
610632
}

0 commit comments

Comments
 (0)