@@ -196,21 +196,21 @@ void Mount::writePersistentData(int which, int val)
196196#if RA_Stepper_TYPE == 0 // 28BYJ
197197void Mount::configureRAStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
198198{
199- #ifdef NORTHERN_HEMISPHERE
200- _stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
201- #else
199+ #if NORTHERN_HEMISPHERE
202200 _stepperRA = new AccelStepper (stepMode, pin4, pin3, pin2, pin1);
201+ #else
202+ _stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
203203#endif
204204 _stepperRA->setMaxSpeed (maxSpeed);
205205 _stepperRA->setAcceleration (maxAcceleration);
206206 _maxRASpeed = maxSpeed;
207207 _maxRAAcceleration = maxAcceleration;
208208
209209 // Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
210- #ifdef NORTHERN_HEMISPHERE
211- _stepperTRK = new AccelStepper (HALFSTEP, pin1, pin2, pin3, pin4);
212- #else
210+ #if NORTHERN_HEMISPHERE
213211 _stepperTRK = new AccelStepper (HALFSTEP, pin4, pin3, pin2, pin1);
212+ #else
213+ _stepperTRK = new AccelStepper (HALFSTEP, pin1, pin2, pin3, pin4);
214214#endif
215215 _stepperTRK->setMaxSpeed (10 );
216216 _stepperTRK->setAcceleration (2500 );
@@ -241,7 +241,11 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed
241241#if DEC_Stepper_TYPE == 0
242242void Mount::configureDECStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
243243{
244+ #if NORTHERN_HEMISPHERE
245+ _stepperDEC = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
246+ #else
244247 _stepperDEC = new AccelStepper (stepMode, pin4, pin3, pin2, pin1);
248+ #endif
245249 _stepperDEC->setMaxSpeed (maxSpeed);
246250 _stepperDEC->setAcceleration (maxAcceleration);
247251 _maxDECSpeed = maxSpeed;
@@ -408,15 +412,15 @@ void Mount::setLST(const DayTime& lst) {
408412// setLatitude
409413//
410414// ///////////////////////////////
411- void Mount::setLatitude (float lat) {
415+ void Mount::setLatitude (float lat) {
412416 _latitude = lat;
413417}
414418// ///////////////////////////////
415419//
416420// setLongitude
417421//
418422// ///////////////////////////////
419- void Mount::setLongitude (float lon) {
423+ void Mount::setLongitude (float lon) {
420424 _longitude = lon;
421425}
422426
@@ -426,7 +430,7 @@ void Mount::setLongitude(float lon) {
426430//
427431// ///////////////////////////////
428432const float Mount::latitude () const {
429- return _latitude ;
433+ return _latitude;
430434}
431435// ///////////////////////////////
432436//
@@ -478,8 +482,8 @@ const DayTime Mount::currentRA() const {
478482 logv (" CurrentRA: POS (+zp) : %s" , DayTime (hourPos).ToString ());
479483#endif
480484
481- bool flipRA = NORTHERN_HEMISPHERE ?
482- _stepperDEC->currentPosition () < 0
485+ bool flipRA = NORTHERN_HEMISPHERE ?
486+ _stepperDEC->currentPosition () < 0
483487 : _stepperDEC->currentPosition () > 0 ;
484488 if (flipRA)
485489 {
@@ -983,20 +987,21 @@ void Mount::startSlewing(int direction) {
983987 _mountStatus |= STATUS_TRACKING;
984988 }
985989 else {
990+ int sign = NORTHERN_HEMISPHERE ? 1 : -1 ;
986991 if (direction & NORTH) {
987- _stepperDEC->moveTo (30000 );
992+ _stepperDEC->moveTo (sign * 30000 );
988993 _mountStatus |= STATUS_SLEWING;
989994 }
990995 if (direction & SOUTH) {
991- _stepperDEC->moveTo (-30000 );
996+ _stepperDEC->moveTo (-sign * 30000 );
992997 _mountStatus |= STATUS_SLEWING;
993998 }
994999 if (direction & EAST) {
995- _stepperRA->moveTo (-30000 );
1000+ _stepperRA->moveTo (-sign * 30000 );
9961001 _mountStatus |= STATUS_SLEWING;
9971002 }
9981003 if (direction & WEST) {
999- _stepperRA->moveTo (30000 );
1004+ _stepperRA->moveTo (sign * 30000 );
10001005 _mountStatus |= STATUS_SLEWING;
10011006 }
10021007 }
@@ -1084,7 +1089,7 @@ void Mount::loop() {
10841089 bool decStillRunning = false ;
10851090
10861091 unsigned long now = millis ();
1087- #ifdef DEBUG_MODE
1092+ #if defined DEBUG_MODE && defined SEND_PERIODIC_UPDATES
10881093 if (now - _lastMountPrint > 2000 ) {
10891094 Serial.println (getStatusString ());
10901095 _lastMountPrint = now;
@@ -1315,8 +1320,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
13151320#endif
13161321
13171322 float hourPos = raTarget.getTotalHours ();
1323+ if (!NORTHERN_HEMISPHERE) {
1324+ hourPos += 12 ;
1325+ }
13181326 // Map [0 to 24] range to [-12 to +12] range
1319- if (hourPos > 12 ) {
1327+ while (hourPos > 12 ) {
13201328 hourPos = hourPos - 24 ;
13211329#ifdef DEBUG_MODE
13221330 logv (" Mount::CalcSteppersIn: RA>12 so -24. New Target RA: %s, DEC: %s" , DayTime (hourPos).ToString (), _targetDEC.ToString ());
@@ -1509,7 +1517,7 @@ String Mount::DECString(byte type, byte active) {
15091517#ifdef DEBUG_MODE
15101518 logv (" DECString: TARGET!" );
15111519#endif
1512- dec = DegreeTime ( _targetDEC) ;
1520+ dec = _targetDEC;
15131521 }
15141522 else {
15151523#ifdef DEBUG_MODE
0 commit comments