Skip to content

Commit 38586ce

Browse files
V1.12.6 - Southern Hemisphere fixes (#217)
- Fixed all known issues related to running in the southern hemisphere. - Added support for DIR inversion to interrupt stepper library. - Hemisphere no longer needs to be defined in config, firmware determines it automatically from the given Latitude, switching at the equator. - Fixed the logic in Sync call to account for both hemispheres. - Fixed some logic that stopped tracking when setting home position. - Fixed a bug that caused the firmware to fail to recognize the end of very short slews. - Added Meade Extension command to query remaining tracking time - Added Meade Extension command to query the hemisphere that is set.
1 parent f384c2d commit 38586ce

15 files changed

+252
-105
lines changed

Changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
**V1.12.6 - Updates**
2+
- Fixed all known issues related to running in the southern hemisphere.
3+
- Added support for DIR inversion to interrupt stepper library.
4+
- Hemisphere no longer needs to be defined in config, firmware determines it automatically from the given Latitude, switching at the equator.
5+
- Fixed the logic in Sync call to account for both hemispheres.
6+
- Fixed some logic that stopped tracking when setting home position.
7+
- Fixed a bug that caused the firmware to fail to recognize the end of very short slews.
8+
- Added Meade Extension command to query remaining tracking time
9+
- Added Meade Extension command to query the hemisphere that is set.
10+
11+
**V1.12.5 - Updates**
12+
- Bound interrupt stepper library to version 0.0.1.
13+
114
**V1.12.4 - Updates**
215
- Fixed a bug that incorrectly stopped the RA motor after issuing a DEC move.
316

Configuration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#error You have to specify the board
4848
#endif
4949

50-
// Set to 1 for the northern hemisphere, 0 otherwise
50+
// Default to northern hemisphere
5151
#ifndef NORTHERN_HEMISPHERE
5252
#define NORTHERN_HEMISPHERE 1
5353
#endif

Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// Also, numbers are interpreted as simple numbers. _ __ _
44
// So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/
55

6-
#define VERSION "V1.12.4"
6+
#define VERSION "V1.12.6"

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ debug_build_flags =
9292
lib_deps =
9393
${common.lib_deps}
9494
jdolinay/avr-debugger @ 1.2
95-
https://github.com/andre-stefanov/avr-interrupt-stepper
95+
https://github.com/andre-stefanov/avr-interrupt-stepper@0.0.2
9696

9797
[env:mksgenlv21]
9898
extends = env:ramps

src/Declination.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "../Configuration.hpp" // For NORTHERN_HEMISPHERE only
1+
#include "./inc/Globals.hpp"
2+
#include "../Configuration.hpp"
23
#include "Utility.hpp"
34
#include "Declination.hpp"
45

@@ -11,13 +12,13 @@
1112
// Parses the RA or DEC from a string that has an optional sign, a two digit degree, a seperator, a two digit minute, a seperator and a two digit second.
1213
// For example: -45*32:11 or 23:44:22
1314

14-
// In the northern hemisphere, 0 is north pole, 180 and -180 is south pole
15+
// In the NORTHERN hemisphere, 0 is north pole, 180 and -180 is south pole
1516
//------------------ S---------------------------------------- N ---------------------------------- S
1617
// Celestial -90 -60 -30 0 30 60 90 60 30 0 -30 -60 -90
1718
// Celestial = 90 - abs(Declination)
1819
// Declination -180 -150 -120 -90 -60 -30 0 30 60 90 120 150 180
1920

20-
// In the southern hemisphere, 0 is south pole, 180 and -180 is north pole
21+
// In the SOUTHERN hemisphere, 0 is south pole, 180 and -180 is north pole
2122
//------------------ N---------------------------------------- S ---------------------------------- N
2223
// Celestial 90 60 30 0 -30 -60 -90 -60 -30 0 30 60 90
2324
// Celestial = -90 + abs(Declination)
@@ -87,7 +88,9 @@ const char *Declination::ToString() const
8788

8889
*p++ = ' ';
8990
*p++ = '(';
90-
strcpy(p, String(NORTHERN_HEMISPHERE ? 90 - fabsf(getTotalHours()) : -90 + fabsf(getTotalHours()), 4).c_str());
91+
strcpy(p, String(inNorthernHemisphere ? 90 - fabsf(getTotalHours()) : -90 + fabsf(getTotalHours()), 4).c_str());
92+
strcat(p, ", ");
93+
strcat(p, String(getTotalHours(), 4).c_str());
9194
strcat(p, ")");
9295

9396
return achBufDeg;
@@ -96,32 +99,33 @@ const char *Declination::ToString() const
9699
Declination Declination::ParseFromMeade(String const &s)
97100
{
98101
Declination result;
99-
LOG(DEBUG_GENERAL, "[DECLINATION]: Declination.Parse(%s)", s.c_str());
102+
LOG(DEBUG_MEADE, "[DECLINATION]: Declination.Parse(%s) for %s Hemi", s.c_str(), inNorthernHemisphere ? "N" : "S");
100103

101104
// Use the DayTime code to parse it...
102105
DayTime dt = DayTime::ParseFromMeade(s);
106+
LOG(DEBUG_MEADE, "[DECLINATION]: Declination DayTime is %l secs", dt.getTotalSeconds());
103107

104108
// ...and then correct for hemisphere
105-
result.totalSeconds = NORTHERN_HEMISPHERE ? (arcSecondsPerHemisphere / 2) - dt.getTotalSeconds()
106-
: -(arcSecondsPerHemisphere / 2) + dt.getTotalSeconds();
107-
LOG(DEBUG_GENERAL, "[DECLINATION]: Declination.Parse(%s) -> %s (%l)", s.c_str(), result.ToString(), result.totalSeconds);
109+
result.totalSeconds = inNorthernHemisphere ? (arcSecondsPerHemisphere / 2) - labs(dt.getTotalSeconds())
110+
: -(arcSecondsPerHemisphere / 2) + labs(dt.getTotalSeconds());
111+
LOG(DEBUG_MEADE, "[DECLINATION]: Adjust for hemisphere. %s -> %s (%l secs)", s.c_str(), result.ToString(), result.totalSeconds);
108112
return result;
109113
}
110114

111115
Declination Declination::FromSeconds(long seconds)
112116
{
113117
const auto secondsFloat = static_cast<float>(seconds);
114118
const auto arcSecondsPerHemisphereFloat = static_cast<float>(arcSecondsPerHemisphere);
115-
#if NORTHERN_HEMISPHERE == 1
116-
return Declination(((arcSecondsPerHemisphereFloat / 2.0f) - secondsFloat) / 3600.0f);
117-
#else
118-
return Declination(((-arcSecondsPerHemisphereFloat / 2.0f) + secondsFloat) / 3600.0f);
119-
#endif
119+
if (inNorthernHemisphere)
120+
{
121+
return Declination(((arcSecondsPerHemisphereFloat / 2.0f) - secondsFloat) / 3600.0f);
122+
}
123+
return Declination(((arcSecondsPerHemisphereFloat / 2.0f) + secondsFloat) / 3600.0f);
120124
}
121125

122126
const char *Declination::formatString(char *targetBuffer, const char *format, long *) const
123127
{
124128
long secs
125-
= NORTHERN_HEMISPHERE ? (arcSecondsPerHemisphere / 2) - labs(totalSeconds) : -(arcSecondsPerHemisphere / 2) + labs(totalSeconds);
129+
= inNorthernHemisphere ? (arcSecondsPerHemisphere / 2) - labs(totalSeconds) : -(arcSecondsPerHemisphere / 2) + labs(totalSeconds);
126130
return DayTime::formatString(targetBuffer, format, &secs);
127131
}

src/InterruptAccelStepper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ template <typename STEPPER> class InterruptAccelStepper
136136

137137
void setPinsInverted(bool directionInvert = false, bool stepInvert = false, bool enableInvert = false)
138138
{
139-
// STUB
139+
STEPPER::setInverted(directionInvert);
140140
}
141141

142142
bool isRunning()

src/Latitude.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ Latitude Latitude::ParseFromMeade(String const &s)
3535
{
3636
Latitude result(0.0);
3737

38-
LOG(DEBUG_GENERAL, "[LATITUDE]: Latitude.Parse(%s)", s.c_str());
38+
LOG(DEBUG_MEADE, "[LATITUDE]: Latitude.Parse(%s)", s.c_str());
3939
// Use the DayTime code to parse it.
4040
DayTime dt = DayTime::ParseFromMeade(s);
4141
result.totalSeconds = dt.getTotalSeconds();
4242
result.checkHours();
43-
LOG(DEBUG_GENERAL, "[LATITUDE]: Latitude.Parse(%s) -> %s", s.c_str(), result.ToString());
43+
LOG(DEBUG_MEADE, "[LATITUDE]: Latitude.Parse(%s) -> %s", s.c_str(), result.ToString());
4444
return result;
4545
}

src/Longitude.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void Longitude::checkHours()
3535
Longitude Longitude::ParseFromMeade(String const &s)
3636
{
3737
Longitude result(0.0);
38-
LOG(DEBUG_GENERAL, "[LONGITUDE]: Parse(%s)", s.c_str());
38+
LOG(DEBUG_MEADE, "[LONGITUDE]: Parse(%s)", s.c_str());
3939

4040
// Use the DayTime code to parse it.
4141
DayTime dt = DayTime::ParseFromMeade(s);
@@ -52,7 +52,7 @@ Longitude Longitude::ParseFromMeade(String const &s)
5252
}
5353
result.checkHours();
5454

55-
LOG(DEBUG_GENERAL, "[LONGITUDE]: Parse(%s) -> %s = %ls", s.c_str(), result.ToString(), result.getTotalSeconds());
55+
LOG(DEBUG_MEADE, "[LONGITUDE]: Parse(%s) -> %s = %ls", s.c_str(), result.ToString(), result.getTotalSeconds());
5656
return result;
5757
}
5858

src/MeadeCommandProcessor.cpp

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,14 @@ bool gpsAqcuisitionComplete(int &indicator); // defined in c72_menuHA_GPS.hpp
772772
// Returns:
773773
// "float#"
774774
//
775+
// :XGST#
776+
// Description:
777+
// Get Remaining Safe Time
778+
// Information:
779+
// Get the number of hours before the RA ring reaches its end.
780+
// Returns:
781+
// "float#"
782+
//
775783
// :XGT#
776784
// Description:
777785
// Get Tracking speed
@@ -796,6 +804,15 @@ bool gpsAqcuisitionComplete(int &indicator); // defined in c72_menuHA_GPS.hpp
796804
// Returns:
797805
// "n#" - the number of steps from the center of the hall sensor trigger range to the home position.
798806
//
807+
// :XGHS#
808+
// Description:
809+
// Get Hemisphere
810+
// Information:
811+
// Get the hemisphere that the OAT currently assumes it is operating in. This is set via setting Latitude (see ":St" command)
812+
// Returns:
813+
// "N#" - for northern hemisphere
814+
// "S#" - for southern hemisphere
815+
//
799816
// :XGM#
800817
// Description:
801818
// Get Mount configuration settings
@@ -1346,7 +1363,7 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd)
13461363
}
13471364
else if (inCmd[1] == 'P')
13481365
{
1349-
// Set home point
1366+
// Set home point :SHP#
13501367
_mount->setHome(false);
13511368
}
13521369
else
@@ -1685,9 +1702,16 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd)
16851702
return String(_mount->getStepsPerDegree(DEC_STEPS), 1) + "#";
16861703
}
16871704
}
1688-
else if (inCmd[1] == 'S') // :XGS#
1705+
else if (inCmd[1] == 'S')
16891706
{
1690-
return String(_mount->getSpeedCalibration(), 5) + "#";
1707+
if (inCmd.length() == 2) // :XGS#
1708+
{
1709+
return String(_mount->getSpeedCalibration(), 5) + "#";
1710+
}
1711+
else if ((inCmd.length() == 3) && (inCmd[2] == 'T')) // :XGST#
1712+
{
1713+
return String(_mount->checkRALimit(), 7) + "#";
1714+
}
16911715
}
16921716
else if (inCmd[1] == 'T') // :XGT#
16931717
{
@@ -1726,9 +1750,16 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd)
17261750
}
17271751
else if (inCmd[1] == 'H') // :XGH#
17281752
{
1729-
if (inCmd.length() > 2 && inCmd[2] == 'R') // :XGHR#
1753+
if (inCmd.length() > 2)
17301754
{
1731-
return String(_mount->getHomingOffset(StepperAxis::RA_STEPS)) + "#";
1755+
if (inCmd[2] == 'R') // :XGHR#
1756+
{
1757+
return String(_mount->getHomingOffset(StepperAxis::RA_STEPS)) + "#";
1758+
}
1759+
else if (inCmd[2] == 'S') // :XGHS#
1760+
{
1761+
return String(inNorthernHemisphere ? "N#" : "S#");
1762+
}
17321763
}
17331764
else if (inCmd.length() > 2 && inCmd[2] == 'D') // :XGHD#
17341765
{
@@ -1840,12 +1871,14 @@ String MeadeCommandProcessor::handleMeadeExtraCommands(String inCmd)
18401871
{
18411872
_mount->setBacklashCorrection(inCmd.substring(2).toInt());
18421873
}
1843-
18441874
else if (inCmd[1] == 'H') // :XSH
18451875
{
1846-
if (inCmd.length() > 2 && inCmd[2] == 'R') // :XSHR
1876+
if (inCmd.length() > 2)
18471877
{
1848-
_mount->setHomingOffset(StepperAxis::RA_STEPS, inCmd.substring(3).toInt());
1878+
if (inCmd[2] == 'R') // :XSHR
1879+
{
1880+
_mount->setHomingOffset(StepperAxis::RA_STEPS, inCmd.substring(3).toInt());
1881+
}
18491882
}
18501883
else if (inCmd.length() > 2 && inCmd[2] == 'D') // :XSHD
18511884
{

0 commit comments

Comments
 (0)