Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Better function naming style consistancy
  • Loading branch information
hjd1964 committed Aug 18, 2018
1 parent 1ad4dd7 commit f330d9d
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 138 deletions.
8 changes: 4 additions & 4 deletions Align.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions AlignEq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions AlignHor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -88,15 +88,15 @@ 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;
mount[I-1].dec=mount[I-1].dec/Rad;

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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
48 changes: 24 additions & 24 deletions Astro.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -316,25 +316,25 @@ void SetDeltaTrackingRate() {
}

double _currentRate=1.0;
void SetTrackingRate(double r) {
void setTrackingRate(double r) {
_currentRate=r;
#ifndef MOUNT_TYPE_ALTAZM
_deltaAxis1=r*15.0;
_deltaAxis2=0.0;
#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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit f330d9d

Please sign in to comment.