From f330d9d58e478004f1e1f6811a892be034f587a6 Mon Sep 17 00:00:00 2001 From: Howard Dutton Date: Sat, 18 Aug 2018 09:51:15 -0400 Subject: [PATCH] Refactoring Better function naming style consistancy --- Align.h | 8 ++++---- AlignEq.ino | 4 ++-- AlignHor.ino | 10 +++++----- Astro.ino | 48 ++++++++++++++++++++++++------------------------ Command.ino | 42 +++++++++++++++++++++--------------------- Goto.ino | 38 +++++++++++++++++++------------------- Guide.ino | 8 ++++---- Home.ino | 2 +- Initialize.ino | 28 ++++++++++++++-------------- MoveTo.ino | 6 +++--- OnStep.ino | 34 +++++++++++++++++----------------- Park.ino | 8 ++++---- Pec.ino | 8 ++++---- StepMode.ino | 14 +++++++------- Timer.ino | 18 +++++++++--------- 15 files changed, 138 insertions(+), 138 deletions(-) diff --git a/Align.h b/Align.h index 58d413359..ee5dd6b4f 100644 --- a/Align.h +++ b/Align.h @@ -44,8 +44,8 @@ class TGeoAlignH void writeCoe(); bool isReady(); bool addStar(int I, int N, double RA, double Dec); - void HorToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide); - void InstrToHor(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide); + void horToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide); + void instrToHor(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide); void autoModel(int n, bool start); private: @@ -104,8 +104,8 @@ class TGeoAlign void writeCoe(); bool isReady(); bool addStar(int I, int N, double RA, double Dec); - void EquToInstr(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide); - void InstrToEqu(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide); + void equToInstr(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide); + void instrToEqu(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide); void autoModel(int n, bool start); private: diff --git a/AlignEq.ino b/AlignEq.ino index 74d518533..0bb070ba4 100644 --- a/AlignEq.ino +++ b/AlignEq.ino @@ -362,7 +362,7 @@ void TGeoAlign::autoModel(int n, bool start) { } // takes the topocentric refracted coordinates and applies corrections to arrive at instrument equatorial coordinates -void TGeoAlign::EquToInstr(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide) { +void TGeoAlign::equToInstr(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide) { double p=1.0; if (PierSide==PierSideWest) p=-1.0; if (Dec>90.0) Dec=90.0; @@ -427,7 +427,7 @@ void TGeoAlign::EquToInstr(double Lat, double HA, double Dec, double *HA1, doubl } // takes the instrument equatorial coordinates and applies corrections to arrive at topocentric refracted coordinates -void TGeoAlign::InstrToEqu(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide) { +void TGeoAlign::instrToEqu(double Lat, double HA, double Dec, double *HA1, double *Dec1, int PierSide) { double p=1.0; if (PierSide==PierSideWest) p=-1.0; HA =HA +ax1Cor; diff --git a/AlignHor.ino b/AlignHor.ino index 9919e189a..5faed7d68 100644 --- a/AlignHor.ino +++ b/AlignHor.ino @@ -77,7 +77,7 @@ the pdCor term is 100% in HA // RA, Dec (all in degrees) bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) { double a,z; - EquToHor(haRange(LST()*15.0-RA),Dec,&a,&z); + equToHor(haRange(LST()*15.0-RA),Dec,&a,&z); // First star: // Near the celestial equator (Dec=0, HA=0), telescope West of the pier if multi-star align @@ -88,7 +88,7 @@ bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) { mount[I-1].azm=getInstrAxis1(); mount[I-1].alt=getInstrAxis2(); - HorToEqu(mount[I-1].alt,mount[I-1].azm,&mount[I-1].ha,&mount[I-1].dec); + horToEqu(mount[I-1].alt,mount[I-1].azm,&mount[I-1].ha,&mount[I-1].dec); mount[I-1].azm=mount[I-1].azm/Rad; mount[I-1].alt=mount[I-1].alt/Rad; mount[I-1].ha=degRange(mount[I-1].ha)/Rad; @@ -96,7 +96,7 @@ bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) { actual[I-1].ha =haRange(LST()*15.0-RA); actual[I-1].dec=Dec; - EquToHor(actual[I-1].ha,actual[I-1].dec,&actual[I-1].alt,&actual[I-1].azm); + equToHor(actual[I-1].ha,actual[I-1].dec,&actual[I-1].alt,&actual[I-1].azm); actual[I-1].alt=actual[I-1].alt/Rad; actual[I-1].azm=actual[I-1].azm/Rad; actual[I-1].ha =degRange(actual[I-1].ha)/Rad; @@ -375,7 +375,7 @@ void TGeoAlignH::autoModel(int n, bool start) { } } -void TGeoAlignH::HorToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide) { +void TGeoAlignH::horToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide) { double p=1.0; if (PierSide==PierSideWest) p=-1.0; double cosLat=cos(90.0/Rad); double sinLat=sin(90.0/Rad); @@ -442,7 +442,7 @@ void TGeoAlignH::HorToInstr(double Alt, double Azm, double *Alt1, double *Azm1, } // takes the instrument equatorial coordinates and applies corrections to arrive at topocentric refracted coordinates -void TGeoAlignH::InstrToHor(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide) { +void TGeoAlignH::instrToHor(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide) { double p=1.0; if (PierSide==PierSideWest) p=-1.0; double cosLat=cos(90.0/Rad); double sinLat=sin(90.0/Rad); diff --git a/Astro.ino b/Astro.ino index 79b6af091..cd8cb16a9 100644 --- a/Astro.ino +++ b/Astro.ino @@ -215,7 +215,7 @@ double jd2last(double JulianDay, double ut1, bool updateRTC) { } // passes Local Apparent Sidereal Time to stepper timer -void update_lst(double t) { +void updateLST(double t) { long lst1=(t/24.0)*8640000.0; // set the local sidereal time @@ -266,7 +266,7 @@ double encodeTimeZone(double tz) { // convert equatorial coordinates to horizon // this takes approx. 1.4mS on a 16MHz Mega2560 -void EquToHor(double HA, double Dec, double *Alt, double *Azm) { +void equToHor(double HA, double Dec, double *Alt, double *Azm) { while (HA<0.0) HA=HA+360.0; while (HA>=360.0) HA=HA-360.0; HA =HA/Rad; @@ -282,7 +282,7 @@ void EquToHor(double HA, double Dec, double *Alt, double *Azm) { // convert horizon coordinates to equatorial // this takes approx. 1.4mS -void HorToEqu(double Alt, double Azm, double *HA, double *Dec) { +void horToEqu(double Alt, double Azm, double *HA, double *Dec) { while (Azm<0) Azm=Azm+360.0; while (Azm>=360.0) Azm=Azm-360.0; Alt = Alt/Rad; @@ -302,7 +302,7 @@ void HorToEqu(double Alt, double Azm, double *HA, double *Dec) { // _deltaAxis1/2 are in arc-seconds/second double _deltaAxis1=15.0,_deltaAxis2=0.0; -void SetDeltaTrackingRate() { +void setDeltaTrackingRate() { #ifndef MOUNT_TYPE_ALTAZM if ((rateCompensation!=RC_REFR_BOTH) && (rateCompensation!=RC_FULL_BOTH)) _deltaAxis2=0.0; #endif @@ -316,7 +316,7 @@ void SetDeltaTrackingRate() { } double _currentRate=1.0; -void SetTrackingRate(double r) { +void setTrackingRate(double r) { _currentRate=r; #ifndef MOUNT_TYPE_ALTAZM _deltaAxis1=r*15.0; @@ -324,17 +324,17 @@ void SetTrackingRate(double r) { #endif } -double GetTrackingRate() { +double getTrackingRate() { return _currentRate; } -double GetStepsPerSecondAxis1() { +double getStepsPerSecondAxis1() { double s=(((double)StepsPerDegreeAxis1/240.0)*(_deltaAxis1/15.0)); if (s<8.0) s=8.0; return s; } -double GetStepsPerSecondAxis2() { +double getStepsPerSecondAxis2() { double s=(((double)StepsPerDegreeAxis2/240.0)*(_deltaAxis2/15.0)); if (s<8.0) s=8.0; return s; @@ -343,7 +343,7 @@ double GetStepsPerSecondAxis2() { // ----------------------------------------------------------------------------------------------------------------------------- // Low overhead altitude calculation, 16 calls to complete -boolean do_fastalt_calc() { +boolean doFastAltCalc() { boolean done=false; static byte ac_step = 0; @@ -394,16 +394,16 @@ boolean do_fastalt_calc() { // Refraction adjusted tracking // returns the amount of refraction (in arcminutes) at the given true altitude (degrees), pressure (millibars), and temperature (celsius) -double TrueRefrac(double Alt, double Pressure=1010.0, double Temperature=10.0) { +double trueRefrac(double Alt, double Pressure=1010.0, double Temperature=10.0) { double TPC=(Pressure/1010.0) * (283.0/(273.0+Temperature)); double r=( ( 1.02*cot( (Alt+(10.3/(Alt+5.11)))/Rad ) ) ) * TPC; if (r<0.0) r=0.0; return r; } // returns the amount of refraction (in arcminutes) at the given apparent altitude (degrees), pressure (millibars), and temperature (celsius) -double ApparentRefrac(double Alt, double Pressure=1010.0, double Temperature=10.0) { - double r=TrueRefrac(Alt,Pressure,Temperature); - r=TrueRefrac(Alt-(r/60.0),Pressure,Temperature); +double apparentRefrac(double Alt, double Pressure=1010.0, double Temperature=10.0) { + double r=trueRefrac(Alt,Pressure,Temperature); + r=trueRefrac(Alt-(r/60.0),Pressure,Temperature); return r; } @@ -415,8 +415,8 @@ double ztr(double a) { double Alt1=a+0.25; if (Alt1<0.0) Alt1=0.0; double Alt2=a-0.25; if (Alt2<0.0) Alt2=0.0; - double Alt1_ = Alt1 - ( TrueRefrac(Alt1) / 60.0 ); - double Alt2_ = Alt2 - ( TrueRefrac(Alt2) / 60.0 ); + double Alt1_ = Alt1 - ( trueRefrac(Alt1) / 60.0 ); + double Alt2_ = Alt2 - ( trueRefrac(Alt2) / 60.0 ); double x=15.0 * ((double)(( Alt1 - Alt2 ) / ( Alt1_ - Alt2_ ))); if (x>15.0) x=15.0; return x; @@ -431,7 +431,7 @@ double ztr(double a) { #define RefractionRateRange 10 #endif -boolean do_refractionRate_calc() { +boolean doRefractionRateCalc() { boolean done=false; static boolean ot=false; @@ -462,24 +462,24 @@ boolean do_refractionRate_calc() { // get the instrument coordinates if ((rr_step==10) || (rr_step==110)) { if (ot) { - Align.EquToInstr(latitude,rr_HA,rr_Dec,&rr_HA,&rr_Dec,getInstrPierSide()); + Align.equToInstr(latitude,rr_HA,rr_Dec,&rr_HA,&rr_Dec,getInstrPierSide()); rr_HA+=indexAxis1; rr_Dec+=indexAxis2; } } // get the Horizon coords if ((rr_step==15) || (rr_step==115)) { - EquToHor(rr_HA,rr_Dec,&rr_Alt,&rr_Azm); + equToHor(rr_HA,rr_Dec,&rr_Alt,&rr_Azm); } else // apply refraction if ((rr_step==20) || (rr_step==120)) { - rr_Alt+=ApparentRefrac(rr_Alt,ambient.getPressure(),ambient.getTemperature())/60.0; + rr_Alt+=apparentRefrac(rr_Alt,ambient.getPressure(),ambient.getTemperature())/60.0; } else // convert back to the Equtorial coords if ((rr_step==25) || (rr_step==125)) { - HorToEqu(rr_Alt,rr_Azm,&rr_HA1,&rr_Dec1); + horToEqu(rr_Alt,rr_Azm,&rr_HA1,&rr_Dec1); if (rr_HA1>180.0) rr_HA1-=360.0; // HA range +/-180 } else @@ -525,7 +525,7 @@ boolean do_refractionRate_calc() { #define AltAzTrackingRange 10 // distance in arc-min (10) ahead of and behind the current Equ position, used for rate calculation -boolean do_altAzmRate_calc() { +boolean doHorRateCalc() { boolean done=false; static int az_step=0; @@ -560,7 +560,7 @@ boolean do_altAzmRate_calc() { // convert to Equatorial coords if ((az_step==5)) { - HorToEqu(az_Alt,az_Azm,&az_HA1,&az_Dec1); + horToEqu(az_Alt,az_Azm,&az_HA1,&az_Dec1); } else // look ahead of and behind the current position @@ -572,7 +572,7 @@ boolean do_altAzmRate_calc() { // each back to the Horizon coords if ((az_step==15) || (az_step==115)) { - EquToHor(az_HA,az_Dec,&az_Alt,&az_Azm); + equToHor(az_HA,az_Dec,&az_Alt,&az_Azm); if (az_Azm>180.0) az_Azm-=360.0; if (az_Azm<-180.0) az_Azm+=360.0; @@ -660,7 +660,7 @@ double cot(double n) { } // Acceleration rate calculation -void SetAccelerationRates(double maxRate) { +void setAccelerationRates(double maxRate) { // set the new guide acceleration rate slewRateX = (RateToXPerSec/(maxRate/16.0))*5.0; // 5x for exponential factor average rate diff --git a/Command.ino b/Command.ino index e70f18d47..03df87db9 100644 --- a/Command.ino +++ b/Command.ino @@ -148,7 +148,7 @@ void processCommands() { // start tracking trackingState=TrackingSidereal; - EnableStepperDrivers(); + enableStepperDrivers(); // start align... alignNumStars=command[1]-'0'; @@ -535,7 +535,7 @@ void processCommands() { if (command[1]=='T') { if (trackingState==TrackingSidereal) { #ifdef MOUNT_TYPE_ALTAZM - f=GetTrackingRate()*1.00273790935*60.0; + f=getTrackingRate()*1.00273790935*60.0; #else f=(trackingTimerRateAxis1*1.00273790935)*60.0; #endif @@ -829,7 +829,7 @@ void processCommands() { // :hR# Restore parked telescope to operation // Return: 0 on failure // 1 on success - if (command[1]=='R') { if (!unpark()) commandError=true; } + if (command[1]=='R') { if (!unPark()) commandError=true; } else commandError=true; } else @@ -1285,7 +1285,7 @@ void processCommands() { // Change Date to MM/DD/YY // Return: 0 on failure // 1 on success - if (command[1]=='C') { if (dateToDouble(&JD,parameter)) { nv.writeFloat(EE_JD,JD); update_lst(jd2last(JD,UT1,true)); } else commandError=true; } else + if (command[1]=='C') { if (dateToDouble(&JD,parameter)) { nv.writeFloat(EE_JD,JD); updateLST(jd2last(JD,UT1,true)); } else commandError=true; } else // :SdsDD*MM# // Set target object declination to sDD*MM or sDD*MM:SS depending on the current precision setting, automatically detects low/high precision // Return: 0 on failure @@ -1314,7 +1314,7 @@ void processCommands() { nv.writeFloat(EE_sites+(currentSite)*25+4,longitude); } else commandError=true; } - update_lst(jd2last(JD,UT1,false)); + updateLST(jd2last(JD,UT1,false)); highPrecision=i; } else // :SGsHH# @@ -1336,7 +1336,7 @@ void processCommands() { if (i<0) timeZone=i-f; else timeZone=i+f; b=encodeTimeZone(timeZone)+128; nv.update(EE_sites+(currentSite)*25+8,b); - update_lst(jd2last(JD,UT1,true)); + updateLST(jd2last(JD,UT1,true)); } else commandError=true; } else commandError=true; } else @@ -1356,7 +1356,7 @@ void processCommands() { if (!hmsToDouble(&LMT,parameter)) commandError=true; else { nv.writeFloat(EE_LMT,LMT); UT1=LMT+timeZone; - update_lst(jd2last(JD,UT1,true)); + updateLST(jd2last(JD,UT1,true)); } highPrecision=i; } else @@ -1400,7 +1400,7 @@ void processCommands() { // Sets the local (apparent) sideral time to HH:MM:SS // Return: 0 on failure // 1 on success - if (command[1]=='S') { i=highPrecision; highPrecision=true; if (!hmsToDouble(&f,parameter)) commandError=true; else update_lst(f); highPrecision=i; } else + if (command[1]=='S') { i=highPrecision; highPrecision=true; if (!hmsToDouble(&f,parameter)) commandError=true; else updateLST(f); highPrecision=i; } else // :StsDD*MM# // Sets the current site latitude to sDD*MM# // Return: 0 on failure @@ -1431,8 +1431,8 @@ void processCommands() { if (fabs(f)<0.1) { trackingState=TrackingNone; } else { - if (trackingState==TrackingNone) { trackingState=TrackingSidereal; EnableStepperDrivers(); } - SetTrackingRate((f/60.0)/1.00273790935); + if (trackingState==TrackingNone) { trackingState=TrackingSidereal; enableStepperDrivers(); } + setTrackingRate((f/60.0)/1.00273790935); } } else commandError=true; } else commandError=true; @@ -1494,7 +1494,7 @@ void processCommands() { if (maxRate<(MaxRate/2L)*16L) maxRate=(MaxRate/2L)*16L; if (maxRate>(MaxRate*2L)*16L) maxRate=(MaxRate*2L)*16L; nv.writeInt(EE_maxRate,(int)(maxRate/16L)); - SetAccelerationRates(maxRate); + setAccelerationRates(maxRate); } else commandError=true; break; case '3': // acceleration rate preset (returns nothing) @@ -1508,7 +1508,7 @@ void processCommands() { case '1': maxRate=MaxRate*8L; break; // 200% default: maxRate=MaxRate*16L; nv.writeInt(EE_maxRate,(int)(maxRate/16L)); - SetAccelerationRates(maxRate); + setAccelerationRates(maxRate); } } break; @@ -1695,20 +1695,20 @@ void processCommands() { if ((command[0]=='T') && (parameter[0]==0)) { #ifndef MOUNT_TYPE_ALTAZM static bool dualAxis=false; - if (command[1]=='o') { rateCompensation=RC_FULL_RA; SetTrackingRate(default_tracking_rate); } else // turn full compensation on, defaults to base sidereal tracking rate - if (command[1]=='r') { rateCompensation=RC_REFR_RA; SetTrackingRate(default_tracking_rate); } else // turn refraction compensation on, defaults to base sidereal tracking rate - if (command[1]=='n') { rateCompensation=RC_NONE; SetTrackingRate(default_tracking_rate); } else // turn refraction off, sidereal tracking rate resumes + if (command[1]=='o') { rateCompensation=RC_FULL_RA; setTrackingRate(default_tracking_rate); } else // turn full compensation on, defaults to base sidereal tracking rate + if (command[1]=='r') { rateCompensation=RC_REFR_RA; setTrackingRate(default_tracking_rate); } else // turn refraction compensation on, defaults to base sidereal tracking rate + if (command[1]=='n') { rateCompensation=RC_NONE; setTrackingRate(default_tracking_rate); } else // turn refraction off, sidereal tracking rate resumes if (command[1]=='1') { dualAxis=false; } else // turn off dual axis tracking if (command[1]=='2') { dualAxis=true; } else // turn on dual axis tracking #endif if (command[1]=='+') { siderealInterval-=HzCf*(0.02); quietReply=true; } else if (command[1]=='-') { siderealInterval+=HzCf*(0.02); quietReply=true; } else - if (command[1]=='S') { SetTrackingRate(0.99726956632); rateCompensation=RC_NONE; quietReply=true; } else // solar tracking rate 60Hz - if (command[1]=='L') { SetTrackingRate(0.96236513150); rateCompensation=RC_NONE; quietReply=true; } else // lunar tracking rate 57.9Hz - if (command[1]=='Q') { SetTrackingRate(default_tracking_rate); quietReply=true; } else // sidereal tracking rate + if (command[1]=='S') { setTrackingRate(0.99726956632); rateCompensation=RC_NONE; quietReply=true; } else // solar tracking rate 60Hz + if (command[1]=='L') { setTrackingRate(0.96236513150); rateCompensation=RC_NONE; quietReply=true; } else // lunar tracking rate 57.9Hz + if (command[1]=='Q') { setTrackingRate(default_tracking_rate); quietReply=true; } else // sidereal tracking rate if (command[1]=='R') { siderealInterval=15956313L; quietReply=true; } else // reset master sidereal clock interval - if (command[1]=='K') { SetTrackingRate(0.99953004401); rateCompensation=RC_NONE; quietReply=true; } else // king tracking rate 60.136Hz - if ((command[1]=='e') && !isSlewing() && !isHoming() && !isParked() ) { trackingState=TrackingSidereal; EnableStepperDrivers(); } else + if (command[1]=='K') { setTrackingRate(0.99953004401); rateCompensation=RC_NONE; quietReply=true; } else // king tracking rate 60.136Hz + if ((command[1]=='e') && !isSlewing() && !isHoming() && !isParked() ) { trackingState=TrackingSidereal; enableStepperDrivers(); } else if ((command[1]=='d') && !isSlewing() && !isHoming() ) trackingState=TrackingNone; else commandError=true; @@ -1726,7 +1726,7 @@ void processCommands() { cli(); SiderealRate=siderealInterval/StepsPerSecondAxis1; sei(); } - SetDeltaTrackingRate(); + setDeltaTrackingRate(); } else if (command[0]=='T') { diff --git a/Goto.ino b/Goto.ino index 39425397e..03d407a04 100644 --- a/Goto.ino +++ b/Goto.ino @@ -25,7 +25,7 @@ GotoErrors validateGotoCoords(double HA, double Dec, double Alt) { GotoErrors validateGoToEqu(double RA, double Dec) { double a,z; double HA=haRange(LST()*15.0-RA); - EquToHor(HA,Dec,&a,&z); + equToHor(HA,Dec,&a,&z); GotoErrors r=validateGoto(); if (r!=GOTO_ERR_NONE) return r; r=validateGotoCoords(HA,Dec,a); return r; @@ -38,7 +38,7 @@ GotoErrors syncEqu(double RA, double Dec) { // Convert RA into hour angle, get altitude // hour angleTrackingMoveTo double HA=haRange(LST()*15.0-RA); - EquToHor(HA,Dec,&a,&z); + equToHor(HA,Dec,&a,&z); // validate GotoErrors f=validateGoto(); if (f!=GOTO_ERR_NONE) return f; @@ -46,17 +46,17 @@ GotoErrors syncEqu(double RA, double Dec) { double Axis1,Axis2; #ifdef MOUNT_TYPE_ALTAZM - EquToHor(HA,Dec,&Axis2,&Axis1); - Align.HorToInstr(Axis2,Axis1,&Axis2,&Axis1,getInstrPierSide()); + equToHor(HA,Dec,&Axis2,&Axis1); + Align.horToInstr(Axis2,Axis1,&Axis2,&Axis1,getInstrPierSide()); Axis1=haRange(Axis1); #else - Align.EquToInstr(latitude,HA,Dec,&Axis1,&Axis2,getInstrPierSide()); + Align.equToInstr(latitude,HA,Dec,&Axis1,&Axis2,getInstrPierSide()); #endif // just turn on tracking if (atHome) { trackingState=TrackingSidereal; - EnableStepperDrivers(); + enableStepperDrivers(); atHome=false; } @@ -142,13 +142,13 @@ boolean getEqu(double *RA, double *Dec, boolean returnHA) { HA=getInstrAxis1(); *Dec=getInstrAxis2(); // apply pointing model - Align.InstrToEqu(latitude,HA,*Dec,&HA,Dec,getInstrPierSide()); + Align.instrToEqu(latitude,HA,*Dec,&HA,Dec,getInstrPierSide()); #else double Z=getInstrAxis1(); double A=getInstrAxis2(); // apply pointing model - Align.InstrToHor(A,Z,&A,&Z,getInstrPierSide()); - HorToEqu(A,Z,&HA,Dec); + Align.instrToHor(A,Z,&A,&Z,getInstrPierSide()); + horToEqu(A,Z,&HA,Dec); #endif // return either the RA or the HA depending on returnHA @@ -171,7 +171,7 @@ boolean getApproxEqu(double *RA, double *Dec, boolean returnHA) { #else double Z=getInstrAxis1(); double A=getInstrAxis2(); - HorToEqu(A,Z,&HA,Dec); + horToEqu(A,Z,&HA,Dec); #endif HA=haRange(HA); @@ -189,7 +189,7 @@ boolean getApproxEqu(double *RA, double *Dec, boolean returnHA) { boolean getHor(double *Alt, double *Azm) { double h,d; getEqu(&h,&d,true); - EquToHor(h,d,Alt,Azm); + equToHor(h,d,Alt,Azm); return true; } @@ -218,15 +218,15 @@ GotoErrors goToEqu(double RA, double Dec) { // Convert RA into hour angle, get altitude double HA=haRange(LST()*15.0-RA); - EquToHor(HA,Dec,&a,&z); + equToHor(HA,Dec,&a,&z); // validate GotoErrors r=validateGoto(); if (r==GOTO_ERR_GOTO) { if (!abortSlew) abortSlew=StartAbortSlew; } if (r!=GOTO_ERR_NONE) return r; r=validateGotoCoords(HA,Dec,a); if (r!=GOTO_ERR_NONE) return r; #ifdef MOUNT_TYPE_ALTAZM - EquToHor(HA,Dec,&a,&z); - Align.HorToInstr(a,z,&a,&z,getInstrPierSide()); + equToHor(HA,Dec,&a,&z); + Align.horToInstr(a,z,&a,&z,getInstrPierSide()); z=haRange(z); if ((MaxAzm>180) && (MaxAzm<=360)) { @@ -258,11 +258,11 @@ GotoErrors goToEqu(double RA, double Dec) { Axis2Alt=a; #else // correct for polar offset, refraction, coordinate systems, operation past pole, etc. as required - Align.EquToInstr(latitude,HA,Dec,&Axis1,&Axis2,getInstrPierSide()); + Align.equToInstr(latitude,HA,Dec,&Axis1,&Axis2,getInstrPierSide()); // as above... for the opposite pier side just incase we need to do a meridian flip int p=PierSideNone; if (getInstrPierSide()==PierSideEast) p=PierSideWest; else if (getInstrPierSide()==PierSideWest) p=PierSideEast; - Align.EquToInstr(latitude,HA,Dec,&Axis1Alt,&Axis2Alt,p); + Align.equToInstr(latitude,HA,Dec,&Axis1Alt,&Axis2Alt,p); #endif // goto function takes HA and Dec in steps @@ -287,7 +287,7 @@ GotoErrors goToEqu(double RA, double Dec) { GotoErrors goToHor(double *Alt, double *Azm) { double HA,Dec; - HorToEqu(*Alt,*Azm,&HA,&Dec); + horToEqu(*Alt,*Azm,&HA,&Dec); double RA=degRange(LST()*15.0-HA); return goToEqu(RA,Dec); @@ -384,9 +384,9 @@ GotoErrors goTo(double thisTargetAxis1, double thisTargetAxis2, double altTarget D("Goto Axis1, Current "); D(((double)(long)posAxis1)/(double)StepsPerDegreeAxis1); D(" -to-> "); DL(((double)(long)targetAxis1.part.m)/(double)StepsPerDegreeAxis1); D("Goto Axis2, Current "); D(((double)(long)posAxis2)/(double)StepsPerDegreeAxis2); D(" -to-> "); DL(((double)(long)targetAxis2.part.m)/(double)StepsPerDegreeAxis2); DL(""); - DisablePec(); + disablePec(); soundAlert(); - StepperModeGoto(); + stepperModeGoto(); return GOTO_ERR_NONE; } diff --git a/Guide.ino b/Guide.ino index 9ca13d5ca..634be7fed 100644 --- a/Guide.ino +++ b/Guide.ino @@ -22,7 +22,7 @@ long guideTimeRemainingAxis2 = -1; unsigned long guideTimeThisIntervalAxis2 = -1; // initialize guiding -void Init_Guide() { +void initGuide() { guideDirAxis1 = 0; guideTimeRemainingAxis1 = -1; guideTimeThisIntervalAxis1 = -1; @@ -43,7 +43,7 @@ void Init_Guide() { #endif } -void Guide() { +void guide() { // 1/100 second sidereal timer, controls issue of steps at the selected RA and/or Dec rate(s) guideAxis1.fixed=0; cli(); long guideLst=lst; sei(); @@ -269,8 +269,8 @@ void ST4() { soundClick(); } if (st4n.wasPressed() && !st4s.wasPressed()) { - if (trackingState==TrackingSidereal) { trackingState=TrackingNone; DisableStepperDrivers(); soundClick(); } else - if (trackingState==TrackingNone) { trackingState=TrackingSidereal; EnableStepperDrivers(); soundClick(); } + if (trackingState==TrackingSidereal) { trackingState=TrackingNone; disableStepperDrivers(); soundClick(); } else + if (trackingState==TrackingNone) { trackingState=TrackingSidereal; enableStepperDrivers(); soundClick(); } } if (c!=currentGuideRate) { setGuideRate(c); enableGuideRate(c); } } diff --git a/Home.ino b/Home.ino index 01f07b1ee..ffaeaea0a 100644 --- a/Home.ino +++ b/Home.ino @@ -118,7 +118,7 @@ int setHome() { if (guideDirAxis1 || guideDirAxis2) return 8; // fail, already in motion if (trackingState==TrackingMoveTo) return 5; // fail, goto in progress - Init_Startup_Values(); + initStartupValues(); // make sure limits are on safetyLimitsOn=true; diff --git a/Initialize.ino b/Initialize.ino index 79634f087..c3a4a6706 100644 --- a/Initialize.ino +++ b/Initialize.ino @@ -3,19 +3,19 @@ #define DEBUG_AXIS_MODES_OFF -void Init_Startup_Values() { +void initStartupValues() { // Basic stepper driver mode setup // if we made through validation and AXIS1_DRIVER_MODEL exists; AXIS2_DRIVER_MODEL, AXIS1_MICROSTEPS, and AXIS2_MICROSTEPS also exist and passed validation in the pre-processor #ifdef AXIS1_DRIVER_MODEL // translate microsteps to mode bits - Axis1_Microsteps = TranslateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS)|TMC_AXIS1_MODE; // if this isn't a TMC2130 stepper driver TMC_AXISn_MODE, etc. = 0 - Axis2_Microsteps = TranslateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS)|TMC_AXIS2_MODE; + Axis1_Microsteps = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS)|TMC_AXIS1_MODE; // if this isn't a TMC2130 stepper driver TMC_AXISn_MODE, etc. = 0 + Axis2_Microsteps = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS)|TMC_AXIS2_MODE; #ifdef AXIS1_MICROSTEPS_GOTO - Axis1_MicrostepsGoto = TranslateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS_GOTO)|TMC_AXIS1_MODE_GOTO; + Axis1_MicrostepsGoto = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS_GOTO)|TMC_AXIS1_MODE_GOTO; #endif #ifdef AXIS2_MICROSTEPS_GOTO - Axis2_MicrostepsGoto = TranslateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS_GOTO)|TMC_AXIS2_MODE_GOTO; + Axis2_MicrostepsGoto = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS_GOTO)|TMC_AXIS2_MODE_GOTO; #endif #endif @@ -95,7 +95,7 @@ void Init_Startup_Values() { sei(); } -void Init_Pins() { +void initPins() { // ------------------------------------------------------------------ // ESP-01 (ESP8266) firmware flashing control @@ -165,10 +165,10 @@ void Init_Pins() { // Pulse per second #ifdef PPS_SENSE_ON pinMode(PpsPin,INPUT); - attachInterrupt(digitalPinToInterrupt(PpsPin),ClockSync,RISING); + attachInterrupt(digitalPinToInterrupt(PpsPin),clockSync,RISING); #elif defined(PPS_SENSE_PULLUP) pinMode(PpsPin,INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(PpsPin),ClockSync,RISING); + attachInterrupt(digitalPinToInterrupt(PpsPin),clockSync,RISING); #endif // Home position sensing @@ -228,7 +228,7 @@ void Init_Pins() { StepperModeTrackingInit(); } -void Init_ReadNV_Values() { +void initReadNvValues() { // get the site information, if a GPS were attached we would use that here instead currentSite=nv.read(EE_currentSite); if (currentSite>3) currentSite=0; // site index is valid? latitude=nv.readFloat(EE_sites+(currentSite)*25+0); @@ -260,7 +260,7 @@ void Init_ReadNV_Values() { urtc.get(JD,LMT); UT1=LMT+timeZone; - update_lst(jd2last(JD,UT1,false)); + updateLST(jd2last(JD,UT1,false)); // get the minutes past meridian east/west #ifdef MOUNT_TYPE_GEM @@ -310,7 +310,7 @@ void Init_ReadNV_Values() { #if !defined(RememberMaxRate_ON) && !defined(REMEMBER_MAX_RATE_ON) if (maxRate!=MaxRate*16L) { maxRate=MaxRate*16L; nv.writeInt(EE_maxRate,(int)(maxRate/16L)); } #endif - SetAccelerationRates(maxRate); // set the new acceleration rate + setAccelerationRates(maxRate); // set the new acceleration rate // get autoMeridianFlip #if defined(MOUNT_TYPE_GEM) && defined(REMEMBER_AUTO_MERIDIAN_FLIP_ON) @@ -343,7 +343,7 @@ void InitStartPosition() { setIndexAxis2(celestialPoleAxis2,PierSideEast); } -void Init_WriteNV_Values() { +void initWriteNvValues() { // EEPROM automatic initialization long autoInitKey = initKey; long thisAutoInitKey; @@ -417,7 +417,7 @@ void Init_WriteNV_Values() { } } -void Init_Start_Timers() { +void initStartTimers() { // Initialize the timers that handle the sidereal clock, RA, and Dec HAL_Init_Timer_Sidereal(); @@ -433,7 +433,7 @@ void Init_Start_Timers() { // different models of stepper drivers have different bit settings for microsteps // translate the human readable microsteps in the configuration to modebit settings -unsigned int TranslateMicrosteps(int axis, int DriverModel, unsigned int Microsteps) { +unsigned int translateMicrosteps(int axis, int DriverModel, unsigned int Microsteps) { unsigned int Mode; // we search for each model, since they are different diff --git a/MoveTo.ino b/MoveTo.ino index 70e0f3f0d..14b072f36 100644 --- a/MoveTo.ino +++ b/MoveTo.ino @@ -178,7 +178,7 @@ void moveTo() { // in AltAz mode if the end of slew doesn't get close enough within 3 seconds: stop tracking for a moment to allow target/actual position synchronization static bool forceSlewStop=false; static unsigned long slewStopTime=0; - if ( (!forceSlewStop) && (distDestAxis1<=GetStepsPerSecondAxis1()) && (distDestAxis2<=GetStepsPerSecondAxis2()) ) { slewStopTime=millis()+3000L; forceSlewStop=true; } + if ( (!forceSlewStop) && (distDestAxis1<=getStepsPerSecondAxis1()) && (distDestAxis2<=getStepsPerSecondAxis2()) ) { slewStopTime=millis()+3000L; forceSlewStop=true; } if ( (lastTrackingState==TrackingSidereal) && (forceSlewStop && ((long)(millis()-slewStopTime)>0)) ) lastTrackingState=TrackingSiderealDisabled; #endif @@ -233,7 +233,7 @@ void moveTo() { // D("Flp3 Axis2, Current "); D(((long)posAxis2)/StepsPerDegreeAxis2); D(" -to-> "); DL(((long)targetAxis2.part.m)/StepsPerDegreeAxis2); DL(""); } else { - StepperModeTracking(); + stepperModeTracking(); // other special gotos: for parking the mount and homing the mount if (parkStatus==Parking) { @@ -278,7 +278,7 @@ void moveTo() { homeMount=false; atHome=true; - DisableStepperDrivers(); + disableStepperDrivers(); } else { // restore trackingState trackingState=lastTrackingState; lastTrackingState=TrackingNone; diff --git a/OnStep.ino b/OnStep.ino index 39f8d374a..05c33afd3 100644 --- a/OnStep.ino +++ b/OnStep.ino @@ -146,15 +146,16 @@ void setup() { ambient.init(); // set initial values for some variables - Init_Startup_Values(); + initStartupValues(); // set pins for input/output as specified in Config.h and PinMap.h - Init_Pins(); - - Init_Guide(); + initPins(); + + // get guiding ready + initGuide(); // if this is the first startup set EEPROM to defaults - Init_WriteNV_Values(); + initWriteNvValues(); // this sets up the sidereal timer and tracking rates siderealInterval=nv.readLong(EE_siderealInterval); // the number of 16MHz clocks in one sidereal second (this is scaled to actual processor speed) @@ -168,13 +169,12 @@ void setup() { timerRateBacklashAxis2=(SiderealRate/BacklashTakeupRate)*timerRateRatio; // now read any saved values from EEPROM into varaibles to restore our last state - Init_ReadNV_Values(); - - SetTrackingRate(default_tracking_rate); - SetDeltaTrackingRate(); + initReadNvValues(); // starts the hardware timers that keep sidereal time, move the motors, etc. - Init_Start_Timers(); + setTrackingRate(default_tracking_rate); + setDeltaTrackingRate(); + initStartTimers(); SerialA.begin(9600); #ifdef HAL_SERIAL_B_ENABLED @@ -262,14 +262,14 @@ void loop() { // GUIDING ------------------------------------------------------------------------------------------- ST4(); - if ((trackingState!=TrackingMoveTo) && (parkStatus==NotParked)) Guide(); + if ((trackingState!=TrackingMoveTo) && (parkStatus==NotParked)) guide(); #ifndef MOUNT_TYPE_ALTAZM // PERIODIC ERROR CORRECTION ------------------------------------------------------------------------- if ((trackingState==TrackingSidereal) && (parkStatus==NotParked) && (!((guideDirAxis1 || guideDirAxis2) && (activeGuideRate>GuideRate1x)))) { // only active while sidereal tracking with a guide rate that makes sense - Pec(); - } else DisablePec(); + pec(); + } else disablePec(); #endif #ifdef HOME_SENSE_ON @@ -327,13 +327,13 @@ void loop() { #endif // CALCULATE SOME TRACKING RATES, ETC. - if (lst%3==0) do_fastalt_calc(); + if (lst%3==0) doFastAltCalc(); #ifdef MOUNT_TYPE_ALTAZM // figure out the current Alt/Azm tracking rates - if (lst%3!=0) do_altAzmRate_calc(); + if (lst%3!=0) doHorRateCalc(); #else // figure out the current refraction compensated tracking rate - if ((rateCompensation!=RC_NONE) && (lst%3!=0)) do_refractionRate_calc(); + if ((rateCompensation!=RC_NONE) && (lst%3!=0)) doRefractionRateCalc(); #endif // SAFETY CHECKS @@ -427,7 +427,7 @@ void loop() { // adjust tracking rate for Alt/Azm mounts // adjust tracking rate for refraction - SetDeltaTrackingRate(); + setDeltaTrackingRate(); // basic check to see if we're not at home if (trackingState!=TrackingNone) atHome=false; diff --git a/Park.ino b/Park.ino index 363254c42..c5e217b01 100644 --- a/Park.ino +++ b/Park.ino @@ -37,7 +37,7 @@ byte park() { trackingState=TrackingNone; // turn off the PEC while we park - DisablePec(); + disablePec(); pecStatus=IgnorePEC; // save the worm sense position nv.writeLong(EE_wormSensePos,wormSensePos); @@ -75,7 +75,7 @@ void parkFinish() { saveAlignModel(); } - DisableStepperDrivers(); + disableStepperDrivers(); } // adjusts targetAxis1/2 to the nearest park position for micro-step modes up to PARK_MAX_MICROSTEP @@ -157,7 +157,7 @@ int parkClearBacklash() { // returns a parked telescope to operation, you must set date and time before calling this. it also // depends on the latitude, longitude, and timeZone; but those are stored and recalled automatically -boolean unpark() { +boolean unPark() { #ifdef STRICT_PARKING_ON if (parkStatus==Parked) { #else @@ -215,7 +215,7 @@ boolean unpark() { // start tracking trackingState=TrackingSidereal; - EnableStepperDrivers(); + enableStepperDrivers(); // get PEC status pecStatus =nv.read(EE_pecStatus); diff --git a/Pec.ino b/Pec.ino index e61ebe954..80fff3e73 100644 --- a/Pec.ino +++ b/Pec.ino @@ -15,7 +15,7 @@ long pecRecordStopTime = 0; long wormRotationPos = 0; long lastWormRotationPos=-1; -void Pec() { +void pec() { // PEC is only active when we're tracking at the sidereal rate with a guide rate that makes sense // keep track of our current step position, and when the step position on the worm wraps during playback @@ -91,7 +91,7 @@ void Pec() { pecRecorded=true; pecFirstRecord=false; #ifdef PEC_CLEANUP_ON - CleanupPec(); + cleanupPec(); #endif } @@ -134,14 +134,14 @@ void Pec() { } } -void DisablePec() { +void disablePec() { // give up recording if we stop tracking at the sidereal rate if (pecStatus==RecordPEC) { pecStatus=IgnorePEC; pecTimerRateAxis1=0.0; } // don't zero the PEC offset, we don't want things moving and it really doesn't matter // get ready to re-index when tracking comes back if (pecStatus==PlayPEC) { pecStatus=ReadyPlayPEC; pecTimerRateAxis1=0.0; } } -void CleanupPec() { +void cleanupPec() { // low pass filter ---------------------------------------------------------- int j,J1,J4,J9,J17; for (int scc=0+3; scc1000000-20000) && (oneS<1000000+20000)) {