Skip to content

Commit 1bc2e46

Browse files
Merge branch 'oatcontrol' into oatcontrol
2 parents 21c2ea6 + 639f632 commit 1bc2e46

File tree

12 files changed

+371
-86
lines changed

12 files changed

+371
-86
lines changed

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 58 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,11 @@ String DayTime::ToString()
188189
}
189190

190191
*p++ = '0' + (secs % 10);
191-
*p++ = '\0';
192-
return String(achBuf);
192+
*p++ = ' ';
193+
*p++ = '(';
194+
strcpy(p, String(this->getTotalHours(), 4).c_str());
195+
strcat(p, ")");
196+
return achBuf;
193197
}
194198

195199

@@ -209,7 +213,7 @@ int DegreeTime::getDegrees() {
209213
return hours;
210214
}
211215

212-
int DegreeTime::getPrintDegrees() {
216+
int DegreeTime::getPrintDegrees() const {
213217
return NORTHERN_HEMISPHERE ? hours + 90 : hours - 90;
214218
}
215219

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

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)