diff --git a/Align.h b/Align.h index 374e34c75..f01bfaeed 100644 --- a/Align.h +++ b/Align.h @@ -11,7 +11,7 @@ // ----------------------------------------------------------------------------------- // ADVANCED GEOMETRIC ALIGN FOR ALT/AZM MOUNTS (GOTO ASSIST) -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM typedef struct { double ha; @@ -74,7 +74,7 @@ TGeoAlignH Align; // ----------------------------------------------------------------------------------- // ADVANCED GEOMETRIC ALIGN FOR EQUATORIAL MOUNTS (GOTO ASSIST) -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM typedef struct { double ha; @@ -137,7 +137,7 @@ byte alignThisStar = 0; // checks to see if an alignment is active boolean alignActive() { - return (alignNumStars>0) && (alignThisStar <= alignNumStars); + return (alignNumStars > 0) && (alignThisStar <= alignNumStars); } // adds an alignment star, returns true on success diff --git a/AlignEq.ino b/AlignEq.ino index caa016815..75dcdcc7a 100644 --- a/AlignEq.ino +++ b/AlignEq.ino @@ -9,8 +9,7 @@ // ----------------------------------------------------------------------------------- // ADVANCED GEOMETRIC ALIGN FOR EQUATORIAL MOUNTS (GOTO ASSIST) -#ifndef MOUNT_TYPE_ALTAZM -#define GOTO_ASSIST_DEBUG_OFF +#if MOUNT_TYPE != ALTAZM // Initialize void TGeoAlign::init() { @@ -63,17 +62,17 @@ bool TGeoAlign::isReady() { bool TGeoAlign::addStar(int I, int N, double RA, double Dec) { // First star, just sync - if (I==1) { if (syncEqu(RA,Dec)!=GOTO_ERR_NONE) return false; } + if (I == 1) { if (syncEqu(RA,Dec) != GOTO_ERR_NONE) return false; } mount[I-1].ha=getInstrAxis1()/Rad; mount[I-1].dec=getInstrAxis2()/Rad; actual[I-1].ha=haRange(LST()*15.0-RA)/Rad; actual[I-1].dec=Dec/Rad; - if (getInstrPierSide()==PierSideWest) { actual[I-1].side=-1; mount[I-1].side=-1; } else - if (getInstrPierSide()==PierSideEast) { actual[I-1].side=1; mount[I-1].side=1; } else { actual[I-1].side=0; mount[I-1].side=0; } + if (getInstrPierSide() == PierSideWest) { actual[I-1].side=-1; mount[I-1].side=-1; } else + if (getInstrPierSide() == PierSideEast) { actual[I-1].side=1; mount[I-1].side=1; } else { actual[I-1].side=0; mount[I-1].side=0; } // two or more stars and finished - if ((I>=2) && (I==N)) model(N); + if ((I >= 2) && (I == N)) model(N); return true; } @@ -82,9 +81,9 @@ bool TGeoAlign::addStar(int I, int N, double RA, double Dec) { void TGeoAlign::model(int n) { static bool busy=false; static int numStars=0; - if (busy) return; // busy - if (n>0) { numStars=n; return; } // command - if (numStars>0) { busy=true; autoModel(numStars); busy=false; numStars=0; } // waiting to solve + if (busy) return; // busy + if (n > 0) { numStars=n; return; } // command + if (numStars > 0) { busy=true; autoModel(numStars); busy=false; numStars=0; } // waiting to solve } // returns the correction to be added to the requested RA,Dec to yield the actual RA,Dec that we will arrive at @@ -180,31 +179,31 @@ void TGeoAlign::do_search(double sf, int p1, int p2, int p3, int p4, int p5, int _oh_m =-p9+round(best_ohe/sf); _oh_p=p9+round(best_ohe/sf); double md,mh; - for (_deo=_deo_m; _deo<=_deo_p; _deo++) - for (_pd=_pd_m; _pd<=_pd_p; _pd++) - for (_pz=_pz_m; _pz<=_pz_p; _pz++) - for (_pe=_pe_m; _pe<=_pe_p; _pe++) - for (_df=_df_m; _df<=_df_p; _df++) - for (_ff=_ff_m; _ff<=_ff_p; _ff++) - for (_tf=_tf_m; _tf<=_tf_p; _tf++) - for (_ohe=_oh_m; _ohe<=_oh_p; _ohe++) - for (_ode=_od_m; _ode<=_od_p; _ode++) { + for (_deo=_deo_m; _deo <= _deo_p; _deo++) + for (_pd=_pd_m; _pd <= _pd_p; _pd++) + for (_pz=_pz_m; _pz <= _pz_p; _pz++) + for (_pe=_pe_m; _pe <= _pe_p; _pe++) + for (_df=_df_m; _df <= _df_p; _df++) + for (_ff=_ff_m; _ff <= _ff_p; _ff++) + for (_tf=_tf_m; _tf <= _tf_p; _tf++) + for (_ohe=_oh_m; _ohe <= _oh_p; _ohe++) + for (_ode=_od_m; _ode <= _od_p; _ode++) { ode=((double)_ode)*sf1; odw=-ode; ohe=((double)_ohe)*sf1; ohw=ohe; // check the combinations for all samples - for (l=0; lPI) delta[l].ha=delta[l].ha-PI*2.0; else - if (delta[l].ha<-PI) delta[l].ha=delta[l].ha+PI*2.0; + if (delta[l].ha > PI) delta[l].ha=delta[l].ha-PI*2.0; else + if (delta[l].ha < -PI) delta[l].ha=delta[l].ha+PI*2.0; delta[l].dec=actual[l].dec-(md-d1); delta[l].side=mount[l].side; } // calculate the standard deviations - sum1=0.0; for (l=0; lPI) h1=h1-PI*2.0; - if (h1<-PI) h1=h1+PI*2.0; + if (h1 > PI) h1=h1-PI*2.0; + if (h1 < -PI) h1=h1+PI*2.0; ohe=ohe+h1; } ohe=ohe/num; best_ohe=round(ohe*Rad*3600.0); best_ohw=best_ohe; -#ifdef MOUNT_TYPE_FORK +#if MOUNT_TYPE == FORK Ff=1; Df=0; #else Ff=0; Df=1; #endif // only search for cone error if > 2 stars - int Do=0; if (num>2) Do=1; + int Do=0; if (num > 2) Do=1; // search, this can handle about 9 degrees of polar misalignment, and 4 degrees of cone error // DoPdPzPeTfFf Df OdOh @@ -298,7 +297,7 @@ void TGeoAlign::autoModel(int n) { do_search( 256,Do,0,1,1,0, 0, 0,1,1); do_search( 128,Do,0,1,1,0, 0, 0,1,1); #else - if (num>4) { + if (num > 4) { // DoPdPzPeTfFf Df OdOh do_search( 256,Do,1,1,1,0,Ff,Df,1,1); do_search( 128,Do,1,1,1,1,Ff,Df,1,1); @@ -325,7 +324,7 @@ void TGeoAlign::autoModel(int n) { altCor=best_pe/3600.0; tfCor=best_tf/3600.0; -#if defined(MOUNT_TYPE_FORK) || defined(MOUNT_TYPE_ALTAZM) +#if MOUNT_TYPE == FORK || MOUNT_TYPE == ALTAZM dfCor=best_ff/3600.0; #else dfCor=best_df/3600.0; @@ -339,19 +338,19 @@ void TGeoAlign::autoModel(int n) { // takes the topocentric refracted coordinates and applies corrections to arrive at instrument equatorial coordinates void TGeoAlign::equToInstr(double HA, double Dec, double *HA1, double *Dec1, int PierSide) { - double p=1.0; if (PierSide==PierSideWest) p=-1.0; + double p=1.0; if (PierSide == PierSideWest) p=-1.0; - if (Dec>90.0) Dec=90.0; - if (Dec<-90.0) Dec=-90.0; + if (Dec > 90.0) Dec=90.0; + if (Dec < -90.0) Dec=-90.0; - // breaks-down near the pole (limited to >1' from pole) - if (abs(Dec)<89.9833) { + // breaks-down near the pole (limited to > 1' from pole) + if (abs(Dec) < 89.9833) { // initial rough guess at instrument HA,Dec double h=HA/Rad; double d=Dec/Rad; - for (int pass=0; pass<3; pass++) { + for (int pass=0; pass < 3; pass++) { double sinDec=sin(d); double cosDec=cos(d); double sinHA =sin(h); @@ -369,7 +368,7 @@ void TGeoAlign::equToInstr(double HA, double Dec, double *HA1, double *Dec1, int // misalignment due to Dec axis being perp. to RA axis double PDh=-pdCor*(sinDec/cosDec)*p; - #ifdef MOUNT_TYPE_FORK + #if MOUNT_TYPE == FORK // Fork flex double DFd=dfCor*cosHA; #else @@ -404,15 +403,15 @@ void TGeoAlign::equToInstr(double HA, double Dec, double *HA1, double *Dec1, int // takes the instrument equatorial coordinates and applies corrections to arrive at topocentric refracted coordinates void TGeoAlign::instrToEqu(double HA, double Dec, double *HA1, double *Dec1, int PierSide) { - double p=1.0; if (PierSide==PierSideWest) p=-1.0; + double p=1.0; if (PierSide == PierSideWest) p=-1.0; HA =HA +ax1Cor; Dec=Dec+ax2Cor*-p; - if (Dec>90.0) Dec=90.0; - if (Dec<-90.0) Dec=-90.0; + if (Dec > 90.0) Dec=90.0; + if (Dec < -90.0) Dec=-90.0; - // breaks-down near the pole (limited to >1' from pole) - if (abs(Dec)<89.98333333) { + // breaks-down near the pole (limited to > 1' from pole) + if (abs(Dec) < 89.98333333) { double h=HA/Rad; double d=Dec/Rad; double sinDec=sin(d); @@ -432,7 +431,7 @@ void TGeoAlign::instrToEqu(double HA, double Dec, double *HA1, double *Dec1, int // works on HA instead. meridian flips affect this in HA double PDh=-pdCor*(sinDec/cosDec)*p; -#ifdef MOUNT_TYPE_FORK +#if MOUNT_TYPE == FORK // Fork flex double DFd=dfCor*cosHA; #else @@ -457,10 +456,10 @@ void TGeoAlign::instrToEqu(double HA, double Dec, double *HA1, double *Dec1, int *Dec1=Dec; } - while (*HA1>180.0) *HA1-=360.0; - while (*HA1<-180.0) *HA1+=360.0; - if (*Dec1>90.0) *Dec1=90.0; - if (*Dec1<-90.0) *Dec1=-90.0; + while (*HA1 > 180.0) *HA1-=360.0; + while (*HA1 < -180.0) *HA1+=360.0; + if (*Dec1 > 90.0) *Dec1=90.0; + if (*Dec1 < -90.0) *Dec1=-90.0; } #endif diff --git a/AlignHor.ino b/AlignHor.ino index 0e47187c7..79eada42d 100644 --- a/AlignHor.ino +++ b/AlignHor.ino @@ -9,8 +9,7 @@ // ----------------------------------------------------------------------------------- // ADVANCED GEOMETRIC ALIGN FOR ALT/AZ MOUNTS (GOTO ASSIST) -#ifdef MOUNT_TYPE_ALTAZM -#define GOTO_ASSIST_DEBUG_OFF +#if MOUNT_TYPE == ALTAZM // Initialize void TGeoAlignH::init() { @@ -65,7 +64,7 @@ bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) { equToHor(haRange(LST()*15.0-RA),Dec,&a,&z); // First star, just sync - if (I==1) { if (syncEqu(RA,Dec)!=GOTO_ERR_NONE) return false; } + if (I == 1) { if (syncEqu(RA,Dec) != GOTO_ERR_NONE) return false; } mount[I-1].azm=getInstrAxis1(); mount[I-1].alt=getInstrAxis2(); @@ -83,11 +82,11 @@ bool TGeoAlignH::addStar(int I, int N, double RA, double Dec) { actual[I-1].ha =degRange(actual[I-1].ha)/Rad; actual[I-1].dec=actual[I-1].dec/Rad; - if (getInstrPierSide()==PierSideWest) { actual[I-1].side=-1; mount[I-1].side=-1; } else - if (getInstrPierSide()==PierSideEast) { actual[I-1].side=1; mount[I-1].side=1; } else { actual[I-1].side=0; mount[I-1].side=0; } + if (getInstrPierSide() == PierSideWest) { actual[I-1].side=-1; mount[I-1].side=-1; } else + if (getInstrPierSide() == PierSideEast) { actual[I-1].side=1; mount[I-1].side=1; } else { actual[I-1].side=0; mount[I-1].side=0; } // two or more stars and finished - if ((I>=2) && (I==N)) model(N); + if ((I >= 2) && (I == N)) model(N); return true; } @@ -97,8 +96,8 @@ void TGeoAlignH::model(int n) { static bool busy=false; static int numStars=0; if (busy) return; // busy - if (n>0) { numStars=n; return; } // command - if (numStars>0) { busy=true; autoModel(numStars); busy=false; numStars=0; } // waiting to solve + if (n > 0) { numStars=n; return; } // command + if (numStars > 0) { busy=true; autoModel(numStars); busy=false; numStars=0; } // waiting to solve } // returns the correction to be added to the requested RA,Dec to yield the actual RA,Dec that we will arrive at @@ -194,31 +193,31 @@ void TGeoAlignH::do_search(double sf, int p1, int p2, int p3, int p4, int p5, in _oh_m =-p9+round(best_ohe/sf); _oh_p=p9+round(best_ohe/sf); double ma,mz; - for (_deo=_deo_m; _deo<=_deo_p; _deo++) - for (_pd=_pd_m; _pd<=_pd_p; _pd++) - for (_pz=_pz_m; _pz<=_pz_p; _pz++) - for (_pe=_pe_m; _pe<=_pe_p; _pe++) - for (_df=_df_m; _df<=_df_p; _df++) - for (_ff=_ff_m; _ff<=_ff_p; _ff++) - for (_tf=_tf_m; _tf<=_tf_p; _tf++) - for (_ohe=_oh_m; _ohe<=_oh_p; _ohe++) - for (_ode=_od_m; _ode<=_od_p; _ode++) { + for (_deo=_deo_m; _deo <= _deo_p; _deo++) + for (_pd=_pd_m; _pd <= _pd_p; _pd++) + for (_pz=_pz_m; _pz <= _pz_p; _pz++) + for (_pe=_pe_m; _pe <= _pe_p; _pe++) + for (_df=_df_m; _df <= _df_p; _df++) + for (_ff=_ff_m; _ff <= _ff_p; _ff++) + for (_tf=_tf_m; _tf <= _tf_p; _tf++) + for (_ohe=_oh_m; _ohe <= _oh_p; _ohe++) + for (_ode=_od_m; _ode <= _od_p; _ode++) { ode=((double)_ode)*sf1; odw=-ode; ohe=((double)_ohe)*sf1; ohw=ohe; // check the combinations for all samples - for (l=0; lPI) delta[l].azm=delta[l].azm-PI*2.0; else - if (delta[l].azm<-PI) delta[l].azm=delta[l].azm+PI*2.0; + if (delta[l].azm > PI) delta[l].azm=delta[l].azm-PI*2.0; else + if (delta[l].azm < -PI) delta[l].azm=delta[l].azm+PI*2.0; delta[l].alt=actual[l].alt-(ma-a1); delta[l].side=mount[l].side; } // calculate the standard deviations - sum1=0.0; for (l=0; lPI) z1=z1-PI*2.0; - if (z1<-PI) z1=z1+PI*2.0; + if (z1 > PI) z1=z1-PI*2.0; + if (z1 < -PI) z1=z1+PI*2.0; ohe=ohe+z1; } ohe=ohe/num; best_ohe=round(ohe*Rad*3600.0); best_ohw=best_ohe; @@ -293,7 +292,7 @@ void TGeoAlignH::autoModel(int n) { Ff=0; Df=0; // only search for cone error if > 2 stars - int Do=0; if (num>2) Do=1; + int Do=0; if (num > 2) Do=1; // search, this can handle about 9 degrees of polar misalignment, and 4 degrees of cone error // DoPdPzPeTfFf Df OdOh @@ -308,7 +307,7 @@ void TGeoAlignH::autoModel(int n) { do_search( 256,Do,0,1,1,0, 0, 0,1,1); do_search( 128,Do,0,1,1,0, 0, 0,1,1); #else - if (num>4) { + if (num > 4) { // DoPdPzPeTfFf Df OdOh do_search( 256,Do,1,1,1,0,Ff,Df,1,1); do_search( 128,Do,1,1,1,1,Ff,Df,1,1); @@ -335,7 +334,7 @@ void TGeoAlignH::autoModel(int n) { altCor=best_pe/3600.0; tfCor=best_tf/3600.0; -#if defined(MOUNT_TYPE_FORK) || defined(MOUNT_TYPE_ALTAZM) +#if MOUNT_TYPE == FORK || MOUNT_TYPE == ALTAZM dfCor=best_ff/3600.0; #else dfCor=best_df/3600.0; @@ -348,21 +347,21 @@ void TGeoAlignH::autoModel(int n) { } void TGeoAlignH::horToInstr(double Alt, double Azm, double *Alt1, double *Azm1, int PierSide) { - double p=1.0; if (PierSide==PierSideWest) p=-1.0; + double p=1.0; if (PierSide == PierSideWest) p=-1.0; double cosLat=cos(90.0/Rad); double sinLat=sin(90.0/Rad); - if (Alt>90.0) Alt=90.0; - if (Alt<-90.0) Alt=-90.0; + if (Alt > 90.0) Alt=90.0; + if (Alt < -90.0) Alt=-90.0; - // breaks-down near the Zenith (limited to >1' from Zenith) - if (abs(Alt)<89.98333333) { + // breaks-down near the Zenith (limited to > 1' from Zenith) + if (abs(Alt) < 89.98333333) { // initial rough guess at instrument HA,Dec double z=Azm/Rad; double a=Alt/Rad; - for (int pass=0; pass<3; pass++) { + for (int pass=0; pass < 3; pass++) { double sinAlt=sin(a); double cosAlt=cos(a); double sinAzm=sin(z); @@ -380,7 +379,7 @@ void TGeoAlignH::horToInstr(double Alt, double Azm, double *Alt1, double *Azm1, // misalignment due to Alt axis being perp. to Azm axis double PDh=-pdCor*(sinAlt/cosAlt)*p; - #if defined (MOUNT_TYPE_FORK) || defined(MOUNT_TYPE_ALTAZM) + #if MOUNT_TYPE == FORK || MOUNT_TYPE == ALTAZM // Fork flex double DFd=dfCor*cosAzm; #else @@ -415,18 +414,18 @@ 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) { - double p=1.0; if (PierSide==PierSideWest) p=-1.0; + double p=1.0; if (PierSide == PierSideWest) p=-1.0; double cosLat=cos(90.0/Rad); double sinLat=sin(90.0/Rad); Azm=Azm+ax1Cor; Alt=Alt+ax2Cor*-p; - if (Alt>90.0) Alt=90.0; - if (Alt<-90.0) Alt=-90.0; + if (Alt > 90.0) Alt=90.0; + if (Alt < -90.0) Alt=-90.0; - // breaks-down near the Zenith (limited to >1' from Zenith) - if (abs(Alt)<89.98333333) { + // breaks-down near the Zenith (limited to > 1' from Zenith) + if (abs(Alt) < 89.98333333) { double z=Azm/Rad; double a=Alt/Rad; double sinAlt=sin(a); @@ -446,7 +445,7 @@ void TGeoAlignH::instrToHor(double Alt, double Azm, double *Alt1, double *Azm1, // works on Azm instead. meridian flips affect this in Azm double PDh=-pdCor*(sinAlt/cosAlt)*p; -#ifdef MOUNT_TYPE_FORK +#if MOUNT_TYPE == FORK // Fork flex double DFd=dfCor*cosAzm; #else @@ -471,9 +470,9 @@ void TGeoAlignH::instrToHor(double Alt, double Azm, double *Alt1, double *Azm1, *Alt1=Alt; } - while (*Azm1>360.0) *Azm1-=360.0; - while (*Azm1<-360.0) *Azm1+=360.0; - if (*Alt1>90.0) *Alt1=90.0; - if (*Alt1<-90.0) *Alt1=-90.0; + while (*Azm1 > 360.0) *Azm1-=360.0; + while (*Azm1 < -360.0) *Azm1+=360.0; + if (*Alt1 > 90.0) *Alt1=90.0; + if (*Alt1 < -90.0) *Alt1=-90.0; } #endif diff --git a/Astro.ino b/Astro.ino index 9a7a162b8..bd9a90dfa 100644 --- a/Astro.ino +++ b/Astro.ino @@ -6,13 +6,13 @@ boolean dateToDouble(double *JulianDay, char *date) { char m[3],d[3],y[3]; int m1,d1,y1; - if (strlen(date)!= 8) return false; + if (strlen(date) != 8) return false; m[0]=*date++; m[1]=*date++; m[2]=0; if (!atoi2(m,&m1,false)) return false; - if (*date++!='/') return false; d[0]=*date++; d[1]=*date++; d[2]=0; if (!atoi2(d,&d1,false)) return false; - if (*date++!='/') return false; y[0]=*date++; y[1]=*date++; y[2]=0; if (!atoi2(y,&y1,false)) return false; - if ((m1<1) || (m1>12) || (d1<1) || (d1>31) || (y1<0) || (y1>99)) return false; - if (y1>11) y1=y1+2000; else y1=y1+2100; + if (*date++ != '/') return false; d[0]=*date++; d[1]=*date++; d[2]=0; if (!atoi2(d,&d1,false)) return false; + if (*date++ != '/') return false; y[0]=*date++; y[1]=*date++; y[2]=0; if (!atoi2(y,&y1,false)) return false; + if ((m1 < 1) || (m1 > 12) || (d1 < 1) || (d1 > 31) || (y1 < 0) || (y1 > 99)) return false; + if (y1 > 11) y1=y1+2000; else y1=y1+2100; *JulianDay=julian(y1,m1,d1); return true; @@ -27,23 +27,23 @@ boolean hmsToDouble(double *f, char *hms) { int h1,m1,m2=0; double s1=0; - while (*hms==' ') hms++; // strip prefix white-space + while (*hms == ' ') hms++; // strip prefix white-space int actualLen=strlen(hms); - if (actualLen>13) hms[13]=0; // maximum length + if (actualLen > 13) hms[13]=0; // maximum length - if (highPrecision) { if ((strlen(hms)!=8) && (strlen(hms)<10)) return false; } else if (strlen(hms)!= 7) return false; + if (highPrecision) { if ((strlen(hms) != 8) && (strlen(hms) < 10)) return false; } else if (strlen(hms) != 7) return false; h[0]=*hms++; h[1]=*hms++; h[2]=0; if (!atoi2(h,&h1,false)) return false; if (highPrecision) { - if (*hms++!=':') return false; m[0]=*hms++; m[1]=*hms++; m[2]=0; if (!atoi2(m,&m1,false)) return false; - if (*hms++!=':') return false; + if (*hms++ != ':') return false; m[0]=*hms++; m[1]=*hms++; m[2]=0; if (!atoi2(m,&m1,false)) return false; + if (*hms++ != ':') return false; if (!atof2(hms,&s1,false)) return false; } else { - if (*hms++!=':') return false; m[0]=*hms++; m[1]=*hms++; m[2]=0; if (!atoi2(m,&m1,false)) return false; - if (*hms++!='.') return false; m2=(*hms++)-'0'; + if (*hms++ != ':') return false; m[0]=*hms++; m[1]=*hms++; m[2]=0; if (!atoi2(m,&m1,false)) return false; + if (*hms++ != '.') return false; m2=(*hms++)-'0'; } - if ((h1<0) || (h1>23) || (m1<0) || (m1>59) || (m2<0) || (m2>9) || (s1<0) || (s1>59.9999)) return false; + if ((h1<0) || (h1 > 23) || (m1 < 0) || (m1 > 59) || (m2 < 0) || (m2 > 9) || (s1 < 0) || (s1 > 59.9999)) return false; *f=h1+m1/60.0+m2/600.0+s1/3600.0; return true; @@ -67,7 +67,7 @@ boolean doubleToHms(char *reply, double *f, boolean hp) { s[11]='.'; s[14]='1'; } char sign[2]=""; - if (((s1!=0) || (m1!=0) || (h1!=0)) && (*f<0.0)) strcpy(sign,"-"); + if (((s1 != 0) || (m1 != 0) || (h1 != 0)) && (*f < 0.0)) strcpy(sign,"-"); sprintf(reply,s,sign,(int)h1,(int)m1,(int)s1); return true; @@ -85,7 +85,7 @@ boolean doubleToHmsd(char *reply, double *f) { sd=(s1-floor(s1))*10000; char s[]="%s%02d:%02d:%02d.%04d"; char sign[2]=""; - if (((sd!=0) || (s1!=0) || (m1!=0) || (h1!=0)) && (*f<0.0)) strcpy(sign,"-"); + if (((sd != 0) || (s1 != 0) || (m1 != 0) || (h1 != 0)) && (*f < 0.0)) strcpy(sign,"-"); sprintf(reply,s,sign,(int)h1,(int)m1,(int)s1,(int)sd); return true; @@ -107,8 +107,8 @@ boolean dmsToDouble(double *f, char *dms, boolean sign_present) { double sign = 1.0; boolean secondsOff = false; - while (*dms==' ') dms++; // strip prefix white-space - if (strlen(dms)>13) dms[13]=0; // maximum length + while (*dms == ' ') dms++; // strip prefix white-space + if (strlen(dms) > 13) dms[13]=0; // maximum length actualLen=strlen(dms); @@ -122,31 +122,31 @@ boolean dmsToDouble(double *f, char *dms, boolean sign_present) { } else { checkLen=6; if (actualLen != checkLen) { - if (actualLen==9) { secondsOff=false; checkLen=9; } else return false; + if (actualLen == 9) { secondsOff=false; checkLen=9; } else return false; } else secondsOff = true; } // determine if the sign was used and accept it if so if (sign_present) { - if (*dms=='-') sign=-1.0; else if (*dms=='+') sign=1.0; else return false; + if (*dms == '-') sign=-1.0; else if (*dms == '+') sign=1.0; else return false; dms++; d[0]=*dms++; d[1]=*dms++; d[2]=0; if (!atoi2(d,&d1,false)) return false; } else { d[0]=*dms++; d[1]=*dms++; d[2]=*dms++; d[3]=0; if (!atoi2(d,&d1,false)) return false; } // make sure the seperator is an allowed character - if ((*dms!=':') && (*dms!='*') && (*dms!=char(223))) return false; else dms++; + if ((*dms != ':') && (*dms != '*') && (*dms != char(223))) return false; else dms++; m[0]=*dms++; m[1]=*dms++; m[2]=0; if (!atoi2(m,&m1,false)) return false; if ((highPrecision) && (!secondsOff)) { // make sure the seperator is an allowed character - if (*dms++!=':') return false; + if (*dms++ != ':') return false; if (!atof2(dms,&s1,false)) return false; } if (sign_present) { lowLimit=-90; highLimit=90; } - if ((d1highLimit) || (m1<0) || (m1>59) || (s1<0) || (s1>59.999)) return false; + if ((d1 < lowLimit) || (d1 > highLimit) || (m1 < 0) || (m1 > 59) || (s1 < 0) || (s1 > 59.999)) return false; *f=sign*(d1+m1/60.0+s1/3600.0); return true; @@ -160,7 +160,7 @@ boolean doubleToDms(char *reply, double *f, boolean fullRange, boolean signPrese f1=*f; // setup formatting, handle adding the sign - if (f1<0) { f1=-f1; sign[0]='-'; } + if (f1 < 0) { f1=-f1; sign[0]='-'; } f1=f1+0.000139; // round to 1/2 arc-second d1=floor(f1); @@ -169,7 +169,7 @@ boolean doubleToDms(char *reply, double *f, boolean fullRange, boolean signPrese char s[]="+%02d*%02d:%02d"; if (signPresent) { - if (sign[0]=='-') { s[0]='-'; } o=1; + if (sign[0] == '-') { s[0]='-'; } o=1; } else { strcpy(s,"%02d*%02d:%02d"); } @@ -192,7 +192,7 @@ boolean doubleToDmsd(char *reply, double *f) { f1=*f; // setup formatting, handle adding the sign - if (f1<0) { f1=-f1; sign[0]='-'; } + if (f1 < 0) { f1=-f1; sign[0]='-'; } f1=f1+0.000000139; // round to 0.0005 arc-second d1=floor(f1); @@ -201,7 +201,7 @@ boolean doubleToDmsd(char *reply, double *f) { s2=(s1-floor(s1))*1000.0; char s[]="+%02d*%02d:%02d.%03d"; - if (sign[0]=='-') { s[0]='-'; } + if (sign[0] == '-') { s[0]='-'; } sprintf(reply,s,(int)d1,(int)m1,(int)s1,(int)s2); return true; @@ -212,11 +212,11 @@ void timeZoneToHM(char *reply, double tz) { double f=fabs(frac(tz)); sprintf(reply,"%+03d",(int)tz); // append for :30 - if (fabs(f-0.5)<0.00000001) { + if (fabs(f-0.5) < 0.00000001) { strcat(reply,":30"); } // append for :45 - if (fabs(f-0.75)<0.00000001) { + if (fabs(f-0.75) < 0.00000001) { strcat(reply,":45"); } } @@ -257,8 +257,8 @@ double jd2last(double JulianDay, double ut1, bool updateRTC) { // correct for day moving forward/backward... this works for multipule days of up-time double J=JulianDay; - while (lmt>=24.0) { lmt=lmt-24.0; J=J-1.0; } - if (lmt<0.0) { lmt=lmt+24.0; J=J+1.0; } + while (lmt >= 24.0) { lmt=lmt-24.0; J=J-1.0; } + if (lmt < 0.0) { lmt=lmt+24.0; J=J+1.0; } // set the RTC urtc.set(J,lmt); @@ -285,20 +285,20 @@ void updateLST(double t) { // convert the lst (in 1/100 second units) into floating point hours double LST() { cli(); long tempLst=lst; sei(); - while (tempLst>8640000) tempLst-=8640000; + while (tempLst > 8640000) tempLst-=8640000; return (tempLst/8640000.0)*24.0; } double decodeTimeZone(double tz) { // -100 codes for :30 - if (tz<-24.0) { + if (tz < -24.0) { tz=tz+100.0; - if (tz<0) tz=tz-0.5; else tz=tz+0.5; + if (tz < 0) tz=tz-0.5; else tz=tz+0.5; } // +100 codes for :45 - if (tz>24.0) { + if (tz > 24.0) { tz=tz-100.0; - if (tz<0) tz=tz-0.75; else tz=tz+0.75; + if (tz < 0) tz=tz-0.75; else tz=tz+0.75; } return tz; } @@ -306,11 +306,11 @@ double decodeTimeZone(double tz) { double encodeTimeZone(double tz) { double f=fabs(frac(tz)); // -100 codes for :30 - if (fabs(f-0.5)<0.00000001) { + if (fabs(f-0.5) < 0.00000001) { tz=(long)tz-100.0; } // +100 codes for :45 - if (fabs(f-0.75)<0.00000001) { + if (fabs(f-0.75) < 0.00000001) { tz=(long)tz+100.0; } tz=(long)tz; @@ -353,7 +353,7 @@ void horToEqu(double Alt, double Azm, double *HA, double *Dec) { // 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 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; + double r=( ( 1.02*cot( (Alt+(10.3/(Alt+5.11)))/Rad ) ) ) * TPC; if (r < 0.0) r=0.0; return r; } @@ -370,9 +370,9 @@ void topocentricToObservedPlace(double *RA, double *Dec) { double h=LST()*15.0-*RA; double d=*Dec; // within about 1/20 arc-second of NCP - if (fabs(d-90.0)<0.00001) { Azm=0.0; Alt=latitude; } else + if (fabs(d-90.0) < 0.00001) { Azm=0.0; Alt=latitude; } else // within about 1/20 arc-second of SCP - if (fabs(d+90.0)<0.00001) { Azm=180.0; Alt=-latitude; } else equToHor(h,d,&Alt,&Azm); + if (fabs(d+90.0) < 0.00001) { Azm=180.0; Alt=-latitude; } else equToHor(h,d,&Alt,&Azm); Alt = Alt+trueRefrac(Alt)/60.0; horToEqu(Alt,Azm,&h,&d); *RA=degRange(LST()*15.0-h); *Dec=d; @@ -384,9 +384,9 @@ void observedPlaceToTopocentric(double *RA, double *Dec) { double h=LST()*15.0-*RA; double d=*Dec; // within about 1/20 arc-second of the "refracted" NCP - if (fabs(d-90.0)<0.00001) { Azm=0.0; Alt=latitude; } else + if (fabs(d-90.0) < 0.00001) { Azm=0.0; Alt=latitude; } else // within about 1/20 arc-second of the "refracted" SCP - if (fabs(d+90.0)<0.00001) { Azm=180.0; Alt=-latitude; } else equToHor(h,d,&Alt,&Azm); + if (fabs(d+90.0) < 0.00001) { Azm=180.0; Alt=-latitude; } else equToHor(h,d,&Alt,&Azm); Alt = Alt-apparentRefrac(Alt)/60.0; horToEqu(Alt,Azm,&h,&d); *RA=degRange(LST()*15.0-h); *Dec=d; @@ -401,10 +401,10 @@ double _deltaAxis1=15.0,_deltaAxis2=0.0; boolean trackingSyncInProgress() { static int lastTrackingSyncSeconds=0; - if ((trackingSyncSeconds > 0) && (trackingState!=TrackingSidereal)) trackingSyncSeconds=0; + if ((trackingSyncSeconds > 0) && (trackingState != TrackingSidereal)) trackingSyncSeconds=0; // sound goto done - if ((trackingSyncSeconds==0) and (lastTrackingSyncSeconds!=trackingSyncSeconds)) soundAlert(); + if ((trackingSyncSeconds == 0) and (lastTrackingSyncSeconds != trackingSyncSeconds)) soundAlert(); lastTrackingSyncSeconds=trackingSyncSeconds; @@ -417,7 +417,7 @@ void setDeltaTrackingRate() { if (trackingSyncInProgress()) { trackingSyncSeconds--; - #ifdef MOUNT_TYPE_ALTAZM + #if MOUNT_TYPE == ALTAZM double a,z,d1,d2,newTargetAlt,newTargetAzm; getHor(&a,&z); double newTargetHA=haRange(LST()*15.0-newTargetRA); @@ -429,34 +429,34 @@ void setDeltaTrackingRate() { getEqu(&r,&d,false); d1=r-newTargetRA; d2=d-newTargetDec; - if (getInstrPierSide()==PierSideEast) d2=-d2; + if (getInstrPierSide() == PierSideEast) d2=-d2; #endif - if ((abs(d1)5.0) f1=5.0; - if (abs(d1)5.0) f2=5.0; - if (abs(d2) 5.0) f1=5.0; + if (abs(d1) < ArcSecPerStepAxis1/3600.0) f1=0.0; + f2=(d2*3600.0)/120.0; if (f2 < -5.0) f2=-5.0; if (f2 > 5.0) f2=5.0; + if (abs(d2) < ArcSecPerStepAxis2/3600.0) f2=0.0; } } -#ifndef MOUNT_TYPE_ALTAZM - if ((rateCompensation!=RC_REFR_BOTH) && (rateCompensation!=RC_FULL_BOTH)) _deltaAxis2=0.0; +#if MOUNT_TYPE != ALTAZM + if ((rateCompensation != RC_REFR_BOTH) && (rateCompensation != RC_FULL_BOTH)) _deltaAxis2=0.0; #endif cli(); // trackingTimerRateAxis1/2 are x the sidereal rate - if (trackingState==TrackingSidereal) trackingTimerRateAxis1=(_deltaAxis1/15.0)+f1; else trackingTimerRateAxis1=0.0; - if (trackingState==TrackingSidereal) trackingTimerRateAxis2=(_deltaAxis2/15.0)+f2; else trackingTimerRateAxis2=0.0; + if (trackingState == TrackingSidereal) trackingTimerRateAxis1=(_deltaAxis1/15.0)+f1; else trackingTimerRateAxis1=0.0; + if (trackingState == TrackingSidereal) trackingTimerRateAxis2=(_deltaAxis2/15.0)+f2; else trackingTimerRateAxis2=0.0; sei(); - fstepAxis1.fixed=doubleToFixed( (((double)StepsPerDegreeAxis1/240.0)*(_deltaAxis1/15.0))/100.0 ); - fstepAxis2.fixed=doubleToFixed( (((double)StepsPerDegreeAxis2/240.0)*(_deltaAxis2/15.0))/100.0 ); + fstepAxis1.fixed=doubleToFixed( (((double)AXIS1_STEPS_PER_DEGREE/240.0)*(_deltaAxis1/15.0))/100.0 ); + fstepAxis2.fixed=doubleToFixed( (((double)AXIS2_STEPS_PER_DEGREE/240.0)*(_deltaAxis2/15.0))/100.0 ); } double _currentRate=1.0; void setTrackingRate(double r) { _currentRate=r; -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM _deltaAxis1=r*15.0; _deltaAxis2=0.0; #endif @@ -468,7 +468,7 @@ double getTrackingRate() { double getTrackingRate60Hz() { double f; -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM f=getTrackingRate()*1.00273790935*60.0; #else cli(); f=(trackingTimerRateAxis1*1.00273790935)*60.0; sei(); @@ -477,14 +477,14 @@ double getTrackingRate60Hz() { } double getStepsPerSecondAxis1() { - double s=(((double)StepsPerDegreeAxis1/240.0)*(_deltaAxis1/15.0)); - if (s<8.0) s=8.0; + double s=(((double)AXIS1_STEPS_PER_DEGREE/240.0)*(_deltaAxis1/15.0)); + if (s < 8.0) s=8.0; return s; } double getStepsPerSecondAxis2() { - double s=(((double)StepsPerDegreeAxis2/240.0)*(_deltaAxis2/15.0)); - if (s<8.0) s=8.0; + double s=(((double)AXIS2_STEPS_PER_DEGREE/240.0)*(_deltaAxis2/15.0)); + if (s < 8.0) s=8.0; return s; } @@ -499,41 +499,41 @@ boolean doFastAltCalc(bool recalc) { static double ac_sindec,ac_cosdec,ac_cosha; static double ac_sinalt; - if (recalc==true) { ac_step=0; return false; } + if (recalc == true) { ac_step=0; return false; } ac_step++; // load HA/Dec - if (ac_step==1) { + if (ac_step == 1) { getApproxEqu(&ac_HA,&ac_Dec,true); currentDec=ac_Dec; } else // convert units - if (ac_step==2) { + if (ac_step == 2) { ac_HA =ac_HA/Rad; ac_Dec=ac_Dec/Rad; } else // prep Dec - if (ac_step==3) { + if (ac_step == 3) { ac_sindec=sin(ac_Dec); } else // prep Dec - if (ac_step==4) { + if (ac_step == 4) { ac_cosdec=cos(ac_Dec); } else // prep HA - if (ac_step==5) { + if (ac_step == 5) { ac_cosha=cos(ac_HA); } else // calc Alt, phase 1 - if (ac_step==6) { + if (ac_step == 6) { ac_sinalt = (ac_sindec * sinLat) + (ac_cosdec * cosLat * ac_cosha); } else // calc Alt, phase 2 - if (ac_step==7) { + if (ac_step == 7) { currentAlt=asin(ac_sinalt)*Rad; } else // finish - if (ac_step==8) { + if (ac_step == 8) { ac_step=0; done=true; } @@ -545,20 +545,20 @@ boolean doFastAltCalc(bool recalc) { // Alternate tracking rate calculation method double ztr(double a) { - if (a>89.8) return 14.9998; - if (a>89.5) return 14.9995; + if (a > 89.8) return 14.9998; + if (a > 89.5) return 14.9995; - 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=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 x=15.0 * ((double)(( Alt1 - Alt2 ) / ( Alt1_ - Alt2_ ))); if (x>15.0) x=15.0; + double x=15.0 * ((double)(( Alt1 - Alt2 ) / ( Alt1_ - Alt2_ ))); if (x > 15.0) x=15.0; return x; } -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM // Distance in arc-min ahead of and behind the current Equ position, used for rate calculation #ifdef HAL_NO_DOUBLE_PRECISION @@ -577,77 +577,77 @@ boolean doRefractionRateCalc() { static double rr_Alt,rr_Azm; // turn off if not tracking at sidereal rate - if (trackingState!=TrackingSidereal) { _deltaAxis1=_currentRate*15.0; _deltaAxis2=0.0; return true; } + if (trackingState != TrackingSidereal) { _deltaAxis1=_currentRate*15.0; _deltaAxis2=0.0; return true; } rr_step++; // load HA/Dec - if (rr_step==1) { - if ((rateCompensation==RC_FULL_RA) || (rateCompensation==RC_FULL_BOTH)) getEqu(&rr_Axis1,&rr_Axis2,true); else getApproxEqu(&rr_Axis1,&rr_Axis2,true); + if (rr_step == 1) { + if ((rateCompensation == RC_FULL_RA) || (rateCompensation == RC_FULL_BOTH)) getEqu(&rr_Axis1,&rr_Axis2,true); else getApproxEqu(&rr_Axis1,&rr_Axis2,true); } else // convert units, get ahead of and behind current position - if ((rr_step==5) || (rr_step==105)) { + if ((rr_step == 5) || (rr_step == 105)) { rr_HA =rr_Axis1; rr_Dec=rr_Axis2; - if (rr_step==5) rr_HA =rr_HA-(RefractionRateRange/60.0); - if (rr_step==105) rr_HA =rr_HA+(RefractionRateRange/60.0); + if (rr_step == 5) rr_HA =rr_HA-(RefractionRateRange/60.0); + if (rr_step == 105) rr_HA =rr_HA+(RefractionRateRange/60.0); } else // get the instrument coordinates - if ((rr_step==10) || (rr_step==110)) { - if ((rateCompensation==RC_FULL_RA) || (rateCompensation==RC_FULL_BOTH)) { + if ((rr_step == 10) || (rr_step == 110)) { + if ((rateCompensation == RC_FULL_RA) || (rateCompensation == RC_FULL_BOTH)) { Align.equToInstr(rr_HA,rr_Dec,&rr_HA,&rr_Dec,getInstrPierSide()); } } // get the Horizon coords - if ((rr_step==15) || (rr_step==115)) { + if ((rr_step == 15) || (rr_step == 115)) { equToHor(rr_HA,rr_Dec,&rr_Alt,&rr_Azm); } else // apply refraction - if ((rr_step==20) || (rr_step==120)) { + if ((rr_step == 20) || (rr_step == 120)) { 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)) { + if ((rr_step == 25) || (rr_step == 125)) { horToEqu(rr_Alt,rr_Azm,&rr_HA1,&rr_Dec1); - if (rr_HA1>180.0) rr_HA1-=360.0; // HA range +/-180 + if (rr_HA1 > 180.0) rr_HA1-=360.0; // HA range +/-180 } else // calculate refraction rate deltas' - if ((rr_step==30) || (rr_step==130)) { + if ((rr_step == 30) || (rr_step == 130)) { // store first calc - if (rr_step==30) { rr_HA2=rr_HA1; rr_Dec2=rr_Dec1; } + if (rr_step == 30) { rr_HA2=rr_HA1; rr_Dec2=rr_Dec1; } // we have both -0.5hr and +0.5hr values - if (rr_step==130) { + if (rr_step == 130) { // set rates // handle coordinate wrap - if ((rr_HA1<-90.0) && (rr_HA2>90.0)) rr_HA1+=360.0; - if ((rr_HA2<-90.0) && (rr_HA1>90.0)) rr_HA2+=360.0; + if ((rr_HA1 < -90.0) && (rr_HA2 > 90.0)) rr_HA1+=360.0; + if ((rr_HA2 < -90.0) && (rr_HA1 > 90.0)) rr_HA2+=360.0; // set rates double dax1=(rr_HA1-rr_HA2)*(15.0/(RefractionRateRange/60.0))/2.0; - if (fabs(_deltaAxis1-dax1)>0.005) _deltaAxis1=dax1; else _deltaAxis1=(_deltaAxis1*9.0+dax1)/10.0; + if (fabs(_deltaAxis1-dax1) > 0.005) _deltaAxis1=dax1; else _deltaAxis1=(_deltaAxis1*9.0+dax1)/10.0; double dax2; - if (getInstrPierSide()==PierSideWest) { + if (getInstrPierSide() == PierSideWest) { dax2=(rr_Dec2-rr_Dec1)*(15.0/(RefractionRateRange/60.0))/2.0; } else { dax2=(rr_Dec1-rr_Dec2)*(15.0/(RefractionRateRange/60.0))/2.0; } - if (fabs(_deltaAxis2-dax2)>0.005) _deltaAxis2=dax2; else _deltaAxis2=(_deltaAxis2*9.0+dax2)/10.0; + if (fabs(_deltaAxis2-dax2) > 0.005) _deltaAxis2=dax2; else _deltaAxis2=(_deltaAxis2*9.0+dax2)/10.0; // override for special case of near a celestial pole - if (90.0-fabs(rr_Dec)<(1.0/3600.0)) { _deltaAxis1=_currentRate*15.0; _deltaAxis2=0.0; } + if (90.0-fabs(rr_Dec) < (1.0/3600.0)) { _deltaAxis1=_currentRate*15.0; _deltaAxis2=0.0; } // override for special case of near the zenith - if (currentAlt>85.0) { _deltaAxis1=ztr(currentAlt); _deltaAxis2=0.0; } + if (currentAlt > 85.0) { _deltaAxis1=ztr(currentAlt); _deltaAxis2=0.0; } } } else // finish once every 200 calls - if (rr_step==200) { + if (rr_step == 200) { rr_step=0; done=true; } @@ -659,7 +659,7 @@ boolean doRefractionRateCalc() { // ----------------------------------------------------------------------------------------------------------------------------- // AltAz tracking -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM #define AltAzTrackingRange 10 // distance in arc-min (10) ahead of and behind the current Equ position, used for rate calculation @@ -674,12 +674,12 @@ boolean doHorRateCalc() { static double az_Azm,az_Azm1,az_Azm2; // turn off if not tracking at sidereal rate - if (((trackingState!=TrackingSidereal) && (trackingState!=TrackingMoveTo))) { _deltaAxis1=0.0; _deltaAxis2=0.0; return true; } + if (((trackingState != TrackingSidereal) && (trackingState != TrackingMoveTo))) { _deltaAxis1=0.0; _deltaAxis2=0.0; return true; } az_step++; // convert units, get ahead of and behind current position - if (az_step==1) { - if (trackingState==TrackingMoveTo) { + if (az_step == 1) { + if (trackingState == TrackingMoveTo) { cli(); az_Axis1=targetAxis1.part.m+indexAxis1Steps; az_Axis2=targetAxis2.part.m+indexAxis2Steps; @@ -691,58 +691,58 @@ boolean doHorRateCalc() { sei(); } // get the Azm - az_Azm=(double)az_Axis1/(double)StepsPerDegreeAxis1; + az_Azm=(double)az_Axis1/(double)AXIS1_STEPS_PER_DEGREE; // get the Alt - az_Alt=(double)az_Axis2/(double)StepsPerDegreeAxis2; + az_Alt=(double)az_Axis2/(double)AXIS2_STEPS_PER_DEGREE; } else // convert to Equatorial coords - if ((az_step==5)) { + if ((az_step == 5)) { horToEqu(az_Alt,az_Azm,&az_HA1,&az_Dec1); } else // look ahead of and behind the current position - if ((az_step==10) || (az_step==110)) { - if (az_step==10 ) az_HA =(az_HA1-(AltAzTrackingRange/60.0)); - if (az_step==110) az_HA =(az_HA1+(AltAzTrackingRange/60.0)); + if ((az_step == 10) || (az_step == 110)) { + if (az_step == 10 ) az_HA =(az_HA1-(AltAzTrackingRange/60.0)); + if (az_step == 110) az_HA =(az_HA1+(AltAzTrackingRange/60.0)); az_Dec=az_Dec1; } else // each back to the Horizon coords - if ((az_step==15) || (az_step==115)) { + if ((az_step == 15) || (az_step == 115)) { 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; + if (az_Azm > 180.0) az_Azm-=360.0; + if (az_Azm < -180.0) az_Azm+=360.0; - if (az_step==15) { + if (az_step == 15) { az_Alt2=az_Alt; az_Azm2=az_Azm; } - if (az_step==115) { + if (az_step == 115) { az_Alt1=az_Alt; az_Azm1=az_Azm; } } else // calculate tracking rate deltas' - if ((az_step==20) || (az_step==120)) { + if ((az_step == 20) || (az_step == 120)) { // we have both -0.5hr and +0.5hr values - if (az_step==120) { + if (az_step == 120) { // handle coordinate wrap - if ((az_Azm1<-90.0) && (az_Azm2>90.0)) az_Azm1+=360.0; - if ((az_Azm2<-90.0) && (az_Azm1>90.0)) az_Azm2+=360.0; + if ((az_Azm1 < -90.0) && (az_Azm2 > 90.0)) az_Azm1+=360.0; + if ((az_Azm2 < -90.0) && (az_Azm1 > 90.0)) az_Azm2+=360.0; // set rates _deltaAxis1=((az_Azm1-az_Azm2)*(15.0/(AltAzTrackingRange/60.0))/2.0)*_currentRate; _deltaAxis2=((az_Alt1-az_Alt2)*(15.0/(AltAzTrackingRange/60.0))/2.0)*_currentRate; // override for special case of near a celestial pole - if (90.0-fabs(az_Dec)<=0.5) { _deltaAxis1=0.0; _deltaAxis2=0.0; } + if (90.0-fabs(az_Dec) < =0.5) { _deltaAxis1=0.0; _deltaAxis2=0.0; } } } else // finish once every 200 calls - if (az_step==200) { + if (az_step == 200) { az_step=0; done=true; } @@ -756,17 +756,17 @@ void setAccelerationRates(double maxRate) { // set the new guide acceleration rate slewRateX = (RateToXPerSec/(maxRate/16.0))*5.0; // 5x for exponential factor average rate - slewRateX = slewRateX*((MaxRateDef/2.0)/(maxRate/16.0)); // scale with maxRate so DegreesForAcceleration and DegreesForRapidStop are approximately correct - accXPerSec = slewRateX/DegreesForAcceleration; + slewRateX = slewRateX*((MaxRateDef/2.0)/(maxRate/16.0)); // scale with maxRate so SLEW_ACCELERATION_DIST and SLEW_RAPID_STOP_DIST are approximately correct + accXPerSec = slewRateX/SLEW_ACCELERATION_DIST; guideRates[9]=RateToASPerSec/(maxRate/16.0); guideRates[8]=guideRates[9]/2.0; activeGuideRate=GuideRateNone; // set the new goto acceleration rate cli(); - StepsForRateChangeAxis1= (sqrt((double)DegreesForAcceleration*(double)StepsPerDegreeAxis1))*maxRate; - StepsForRateChangeAxis2= (sqrt((double)DegreesForAcceleration*(double)StepsPerDegreeAxis2))*maxRate; + StepsForRateChangeAxis1= (sqrt((double)SLEW_ACCELERATION_DIST*(double)AXIS1_STEPS_PER_DEGREE))*maxRate; + StepsForRateChangeAxis2= (sqrt((double)SLEW_ACCELERATION_DIST*(double)AXIS2_STEPS_PER_DEGREE))*maxRate; sei(); // slewSpeed is in degrees per second - slewSpeed=(1000000.0/(maxRate/16L))/StepsPerDegreeAxis1; + slewSpeed=(1000000.0/(maxRate/16L))/AXIS1_STEPS_PER_DEGREE; } diff --git a/Command.ino b/Command.ino index a3c51d56a..2226f24ce 100644 --- a/Command.ino +++ b/Command.ino @@ -13,7 +13,7 @@ cb cmdB; #ifdef HAL_SERIAL_C_ENABLED cb cmdC; #endif -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON cb cmdST4; #endif char _replyX[50]=""; cb cmdX; // virtual command channel for internal use @@ -37,23 +37,23 @@ void processCommands() { boolean supress_frame = false; char *conv_end; -#ifdef FOCUSER1_ON +#if FOCUSER1 == ON static char primaryFocuser = 'F'; #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON static char secondaryFocuser = 'f'; #endif // accumulate the command - if ((SerialA.available()>0) && (!cmdA.ready())) cmdA.add(SerialA.read()); + if ((SerialA.available() > 0) && (!cmdA.ready())) cmdA.add(SerialA.read()); #ifdef HAL_SERIAL_B_ENABLED - if ((SerialB.available()>0) && (!cmdB.ready())) cmdB.add(SerialB.read()); + if ((SerialB.available() > 0) && (!cmdB.ready())) cmdB.add(SerialB.read()); #endif #ifdef HAL_SERIAL_C_ENABLED - if ((SerialC.available()>0) && (!cmdC.ready())) cmdC.add(SerialC.read()); + if ((SerialC.available() > 0) && (!cmdC.ready())) cmdC.add(SerialC.read()); #endif -#ifdef ST4_HAND_CONTROL_ON - if ((SerialST4.available()>0) && (!cmdST4.ready())) cmdST4.add(SerialST4.read()); +#if ST4_HAND_CONTROL == ON + if ((SerialST4.available() > 0) && (!cmdST4.ready())) cmdST4.add(SerialST4.read()); #endif // send any reply @@ -76,7 +76,7 @@ void processCommands() { #ifdef HAL_SERIAL_C_ENABLED else if (cmdC.ready()) { strcpy(command,cmdC.getCmd()); strcpy(parameter,cmdC.getParameter()); cmdC.flush(); SerialC.flush(); process_command=COMMAND_SERIAL_C; } #endif -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON else if (cmdST4.ready()) { strcpy(command,cmdST4.getCmd()); strcpy(parameter,cmdST4.getParameter()); cmdST4.flush(); process_command=COMMAND_SERIAL_ST4; } #endif else if (cmdX.ready()) { strcpy(command,cmdX.getCmd()); strcpy(parameter,cmdX.getParameter()); cmdX.flush(); process_command=COMMAND_SERIAL_X; } @@ -89,8 +89,8 @@ void processCommands() { reply[0]=0; reply[1]=0; // (char)6 - Special - if (command[0]==(char)6) { - if (command[1]=='0') { + if (command[0] == (char)6) { + if (command[1] == '0') { reply[0]=command[1]; strcpy(reply,"CK_FAIL"); // last cmd checksum failed } else { reply[0]=command[1]; reply[1]=0; // Equatorial or Horizon mode, A or P @@ -100,10 +100,10 @@ void processCommands() { } else // A - Alignment Commands - if (command[0]=='A') { + if (command[0] == 'A') { // :AW# Align Write to EEPROM // Returns: 1 on success - if (command[1]=='W') { + if (command[1] == 'W') { saveAlignModel(); } else // :A?# Align status @@ -111,7 +111,7 @@ void processCommands() { // where m is the maximum number of alignment stars // n is the current alignment star (0 otherwise) // o is the last required alignment star when an alignment is in progress (0 otherwise) - if (command[1]=='?') { + if (command[1] == '?') { reply[0]=MAX_NUM_ALIGN_STARS; reply[1]='0'+alignThisStar; reply[2]='0'+alignNumStars; @@ -133,7 +133,7 @@ void processCommands() { // 10) Call :A+# command to accept the correction // Return: 0 on failure // 1 on success - if ((command[1]>='1') && (command[1]<=MAX_NUM_ALIGN_STARS) && (parameter[0]==0)) { + if ((command[1] >= '1') && (command[1] <= MAX_NUM_ALIGN_STARS) && (parameter[0] == 0)) { // set current time and date before calling this routine // telescope should be set in the polar home (CWD) for a starting point @@ -154,7 +154,7 @@ void processCommands() { // Returns: // 1: If correction is accepted // 0: Failure, Manual align mode not set or distance too far - if (command[1]=='+') { + if (command[1] == '+') { if (alignActive()) { commandError = !alignStar(); if (commandError) { alignNumStars=0; alignThisStar=0; } @@ -173,17 +173,17 @@ void processCommands() { // Return: 0 on failure // 1 on success // Set the Backlash values. Units are arc-seconds - if ((command[0]=='$') && (command[1]=='B')) { - if ((strlen(parameter)>1) && (strlen(parameter)<5)) { - if ( (atoi2((char*)¶meter[1],&i)) && ((i>=0) && (i<=999))) { - if (parameter[0]=='D') { + if ((command[0] == '$') && (command[1] == 'B')) { + if ((strlen(parameter) > 1) && (strlen(parameter) < 5)) { + if ( (atoi2((char*)¶meter[1],&i)) && ((i >= 0) && (i <= 999))) { + if (parameter[0] == 'D') { reactivateBacklashComp(); - cli(); backlashAxis2=(int)round(((double)i*(double)StepsPerDegreeAxis2)/3600.0); sei(); + cli(); backlashAxis2=(int)round(((double)i*(double)AXIS2_STEPS_PER_DEGREE)/3600.0); sei(); nv.writeInt(EE_backlashAxis2,backlashAxis2); } else - if (parameter[0]=='R') { + if (parameter[0] == 'R') { reactivateBacklashComp(); - cli(); backlashAxis1 =(int)round(((double)i*(double)StepsPerDegreeAxis1)/3600.0); sei(); + cli(); backlashAxis1 =(int)round(((double)i*(double)AXIS1_STEPS_PER_DEGREE)/3600.0); sei(); nv.writeInt(EE_backlashAxis1,backlashAxis1); } else commandError=true; } else commandError=true; @@ -196,18 +196,18 @@ void processCommands() { // :%BR# Get RA Antibacklash // Return: d# // Get the Backlash values. Units are arc-seconds - if ((command[0]=='%') && (command[1]=='B')) { - if (parameter[0]=='D') { + if ((command[0] == '%') && (command[1] == 'B')) { + if (parameter[0] == 'D') { reactivateBacklashComp(); - i=(int)round(((double)backlashAxis2*3600.0)/(double)StepsPerDegreeAxis2); - if (i<0) i=0; if (i>999) i=999; + i=(int)round(((double)backlashAxis2*3600.0)/(double)AXIS2_STEPS_PER_DEGREE); + if (i<0) i=0; if (i > 999) i=999; sprintf(reply,"%d",i); quietReply=true; } else - if (parameter[0]=='R') { + if (parameter[0] == 'R') { reactivateBacklashComp(); - i=(int)round(((double)backlashAxis1*3600.0)/(double)StepsPerDegreeAxis1); - if (i<0) i=0; if (i>999) i=999; + i=(int)round(((double)backlashAxis1*3600.0)/(double)AXIS1_STEPS_PER_DEGREE); + if (i<0) i=0; if (i > 999) i=999; sprintf(reply,"%d",i); quietReply=true; } else commandError=true; @@ -218,16 +218,16 @@ void processCommands() { // Returns: Nothing // :B-# Decrease Reticule Brightness // Returns: Nothing - if ((command[0]=='B') && ((command[1]=='+') || (command[1]=='-'))) { -#ifdef RETICULE_LED_PINS + if ((command[0] == 'B') && ((command[1] == '+') || (command[1] == '-'))) { +#if LED_RETICLE_PIN >= 0 int scale; - if (reticuleBrightness>255-8) scale=1; else - if (reticuleBrightness>255-32) scale=4; else - if (reticuleBrightness>255-64) scale=12; else - if (reticuleBrightness>255-128) scale=32; else scale=64; - if (command[1]=='-') reticuleBrightness+=scale; if (reticuleBrightness>255) reticuleBrightness=255; - if (command[1]=='+') reticuleBrightness-=scale; if (reticuleBrightness<0) reticuleBrightness=0; - analogWrite(ReticulePin,reticuleBrightness); + if (reticuleBrightness > 255-8) scale=1; else + if (reticuleBrightness > 255-32) scale=4; else + if (reticuleBrightness > 255-64) scale=12; else + if (reticuleBrightness > 255-128) scale=32; else scale=64; + if (command[1] == '-') reticuleBrightness+=scale; if (reticuleBrightness > 255) reticuleBrightness=255; + if (command[1] == '+') reticuleBrightness-=scale; if (reticuleBrightness < 0) reticuleBrightness=0; + analogWrite(ReticlePin,reticuleBrightness); #endif quietReply=true; } else @@ -237,11 +237,11 @@ void processCommands() { // Returns: Nothing (Sync's fail silently) // :CM# Synchonize the telescope with the current database object (as above) // Returns: "N/A#" on success, "En#" on failure where n is the error code per the :MS# command - if ((command[0]=='C') && ((command[1]=='S') || command[1]=='M')) { - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo)) { + if ((command[0] == 'C') && ((command[1] == 'S') || command[1] == 'M')) { + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo)) { newTargetRA=origTargetRA; newTargetDec=origTargetDec; -#if TELESCOPE_COORDINATES==TOPOCENTRIC +#if TELESCOPE_COORDINATES == TOPOCENTRIC topocentricToObservedPlace(&newTargetRA,&newTargetDec); #endif @@ -251,9 +251,9 @@ void processCommands() { i=syncEqu(newTargetRA,newTargetDec); } - if (command[1]=='M') { - if (i==0) strcpy(reply,"N/A"); - if (i>0) { reply[0]='E'; reply[1]='0'+i; reply[2]=0; } + if (command[1] == 'M') { + if (i == 0) strcpy(reply,"N/A"); + if (i > 0) { reply[0]='E'; reply[1]='0'+i; reply[2]=0; } } quietReply=true; @@ -262,16 +262,16 @@ void processCommands() { // D - Distance Bars // :D# returns an "\0x7f#" if the mount is moving, otherwise returns "#". - if ((command[0]=='D') && (command[1]==0)) { if (trackingState==TrackingMoveTo) { reply[0]=(char)127; reply[1]=0; } else { reply[0]='#'; reply[1]=0; supress_frame=true; } quietReply=true; } else + if ((command[0] == 'D') && (command[1] == 0)) { if (trackingState == TrackingMoveTo) { reply[0]=(char)127; reply[1]=0; } else { reply[0]='#'; reply[1]=0; supress_frame=true; } quietReply=true; } else -#ifdef ESP8266_CONTROL_ON +#if SERIAL_B_ESP_FLASHING == ON // E - Enter special mode // :ESPFLASH# ESP8266 device flash mode // Returns: Never (infinite loop) // OnStep must be at home and tracking turned off for this command to work. A power cycle is required to resume normal operation. - if (command[0]=='E') { - if ((command[1]=='S') && (parameter[0]=='P') && (parameter[1]=='F') && (parameter[2]=='L') && (parameter[3]=='A') && (parameter[4]=='S') && (parameter[5]=='H')) { - if ((atHome) && (trackingState==TrackingNone)) { + if (command[0] == 'E') { + if ((command[1] == 'S') && (parameter[0] == 'P') && (parameter[1] == 'F') && (parameter[2] == 'L') && (parameter[3] == 'A') && (parameter[4] == 'S') && (parameter[5] == 'H')) { + if ((atHome) && (trackingState == TrackingNone)) { // initialize both serial ports SerialA.println("The ESP8266 will now be placed in flash upload mode (at 115200 Baud.)"); SerialA.println("Waiting for data, you have one minute to start the upload."); @@ -279,7 +279,7 @@ void processCommands() { SerialA.begin(115200); #ifdef ESP32 #if SERIAL_B_BAUD_DEFAULT != 115200 - #error "On the ESP32, when ESP8266_CONTROL_ON is used SERIAL_B_BAUD_DEFAULT must be 115200" + #error "On the ESP32, when SERIAL_B_ESP_FLASHING is used SERIAL_B_BAUD_DEFAULT must be 115200" #endif #else SerialB.begin(115200); @@ -299,10 +299,10 @@ void processCommands() { if (SerialA.available()) { int inByte = SerialA.read(); delayMicroseconds(5); SerialB.write(inByte); delayMicroseconds(5); - if (millis()>lastRead) lastRead=millis(); + if (millis() > lastRead) lastRead=millis(); } yield(); - if ((long)(millis()-lastRead)>5000) break; // wait 5 seconds w/no traffic before resuming normal operation + if ((long)(millis()-lastRead) > 5000) break; // wait 5 seconds w/no traffic before resuming normal operation } SerialA.print("Resetting ESP8266, "); @@ -326,198 +326,198 @@ void processCommands() { } else #endif -#ifdef FOCUSER1_ON +#if FOCUSER1 == ON // F - Focuser1 Commands - if (command[0]==primaryFocuser) { + if (command[0] == primaryFocuser) { // :FA# Active? // Return: 0 on failure // 1 on success // :FAn# Select focuser 1 or 2 // Return: 0 on failure // 1 on success - if (command[1]=='A') { -#ifdef FOCUSER2_ON - if ((parameter[0]=='1') && (parameter[1]==0)) { primaryFocuser='F'; secondaryFocuser='f'; } else - if ((parameter[0]=='2') && (parameter[1]==0)) { primaryFocuser='f'; secondaryFocuser='F'; } else + if (command[1] == 'A') { +#if FOCUSER2 == ON + if ((parameter[0] == '1') && (parameter[1] == 0)) { primaryFocuser='F'; secondaryFocuser='f'; } else + if ((parameter[0] == '2') && (parameter[1] == 0)) { primaryFocuser='f'; secondaryFocuser='F'; } else #endif - if (parameter[0]!=0) commandError=true; + if (parameter[0] != 0) commandError=true; } else // :F+# Move focuser in (toward objective) // Returns: Nothing - if (command[1]=='+') { foc1.startMoveIn(); quietReply=true; } else + if (command[1] == '+') { foc1.startMoveIn(); quietReply=true; } else // :F-# Move focuser out (away from objective) // Returns: Nothing - if (command[1]=='-') { foc1.startMoveOut(); quietReply=true; } else + if (command[1] == '-') { foc1.startMoveOut(); quietReply=true; } else // :FQ# Stop the focuser // Returns: Nothing - if (command[1]=='Q') { foc1.stopMove(); quietReply=true; } else + if (command[1] == 'Q') { foc1.stopMove(); quietReply=true; } else // :FG# Get focuser current position (in microns) // Returns: snnn# - if (command[1]=='G') { sprintf(reply,"%ld",(long)round(foc1.getPosition())); quietReply=true; } else + if (command[1] == 'G') { sprintf(reply,"%ld",(long)round(foc1.getPosition())); quietReply=true; } else // :FI# Get full in position (in microns) // Returns: n# - if (command[1]=='I') { sprintf(reply,"%ld",(long)round(foc1.getMin())); quietReply=true; } else + if (command[1] == 'I') { sprintf(reply,"%ld",(long)round(foc1.getMin())); quietReply=true; } else // :FM# Get max position (in microns) // Returns: n# - if (command[1]=='M') { sprintf(reply,"%ld",(long)round(foc1.getMax())); quietReply=true; } else + if (command[1] == 'M') { sprintf(reply,"%ld",(long)round(foc1.getMax())); quietReply=true; } else // :FT# get status // Returns: M# (for moving) or S# (for stopped) - if (command[1]=='T') { if (foc1.moving()) strcpy(reply,"M"); else strcpy(reply,"S"); quietReply=true; } else + if (command[1] == 'T') { if (foc1.moving()) strcpy(reply,"M"); else strcpy(reply,"S"); quietReply=true; } else // :FZ# Set focuser position as zero // Returns: Nothing - if (command[1]=='Z') { foc1.setPosition(0); quietReply=true; } else + if (command[1] == 'Z') { foc1.setPosition(0); quietReply=true; } else // :FH# Set focuser position as half-travel // Returns: Nothing - if (command[1]=='H') { foc1.setPosition(((MaxAxis4+MinAxis4)/2.0)*1000.0); quietReply=true; } else + if (command[1] == 'H') { foc1.setPosition(((AXIS4_LIMIT_MAX+AXIS4_LIMIT_MIN)/2.0)*1000.0); quietReply=true; } else // :FF# Set focuser for fast motion (1mm/s) // Returns: Nothing - if (command[1]=='F') { foc1.setMoveRate(1000); quietReply=true; } else -#ifdef AXIS4_DC_MODE_ON + if (command[1] == 'F') { foc1.setMoveRate(1000); quietReply=true; } else +#if AXIS4_DRIVER_DC_MODE != OFF // :FP# Get focuser DC Motor Power Level (in %) // Returns: nnn# // :FPnnn# Set focuser DC Motor Power Level (in %) // Return: 0 on failure // 1 on success - if (command[1]=='P') { - if (parameter[0]==0) { + if (command[1] == 'P') { + if (parameter[0] == 0) { sprintf(reply,"%d",(int)dcPwrAxis4); quietReply=true; } else { i=atol(parameter); - if ((i>=0) && (i<=100)) { dcPwrAxis4=i; foc1.setDcPower(dcPwrAxis4); nv.write(EE_dcPwrAxis4,i); } else commandError=true; + if ((i >= 0) && (i <= 100)) { dcPwrAxis4=i; foc1.setDcPower(dcPwrAxis4); nv.write(EE_dcPwrAxis4,i); } else commandError=true; } } else #endif // :Fp# Check for focuser pseudo absolute mode // Return: 0 on failure // 1 on success - if (command[1]>='p') { -#ifndef AXIS4_DC_MODE_ON + if (command[1] >= 'p') { +#if AXIS4_DRIVER_DC_MODE == OFF commandError=true; #endif } else // :FRsnnn# Set focuser target position relative (in microns) // Returns: Nothing - if (command[1]=='R') { foc1.relativeTarget(atol(parameter)); quietReply=true; } else + if (command[1] == 'R') { foc1.relativeTarget(atol(parameter)); quietReply=true; } else // :FS# Set focuser for slow motion (0.01mm/s) // Returns: Nothing // :FSsnnn# Set focuser target position (in microns) // Returns: Nothing - if (command[1]=='S') { if (parameter[0]==0) { foc1.setMoveRate(constrain(1,AXIS4_MIN_MOVE_RATE,1000)); quietReply=true; } else foc1.setTarget(atol(parameter)); } else + if (command[1] == 'S') { if (parameter[0] == 0) { foc1.setMoveRate(constrain(1,AXIS4_LIMIT_MIN_RATE,1000)); quietReply=true; } else foc1.setTarget(atol(parameter)); } else // :Fn# Movement rate, 1=finest, 2=0.01mm/second, 3=0.1mm/second, 4=1mm/second // Returns: Nothing - if ((command[1]>='1') && (command[1]<='4')) { i=command[1]-'1'; int p[] = {1,10,100,1000}; foc1.setMoveRate(constrain(p[i],AXIS4_MIN_MOVE_RATE,1000)); quietReply=true; } else commandError=true; + if ((command[1] >= '1') && (command[1] <= '4')) { i=command[1]-'1'; int p[] = {1,10,100,1000}; foc1.setMoveRate(constrain(p[i],AXIS4_LIMIT_MIN_RATE,1000)); quietReply=true; } else commandError=true; } else #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON // f - Focuser2 Commands - if (command[0]==secondaryFocuser) { + if (command[0] == secondaryFocuser) { // :fA# Active? // Return: 0 on failure // 1 on success // :fAn# Select focuser 1 or 2 // Return: 0 on failure // 1 on success - if (command[1]=='A') { - if ((parameter[0]=='1') && (parameter[1]==0)) { primaryFocuser='F'; secondaryFocuser='f'; } else - if ((parameter[0]=='2') && (parameter[1]==0)) { primaryFocuser='f'; secondaryFocuser='F'; } else - if (parameter[0]!=0) commandError=true; + if (command[1] == 'A') { + if ((parameter[0] == '1') && (parameter[1] == 0)) { primaryFocuser='F'; secondaryFocuser='f'; } else + if ((parameter[0] == '2') && (parameter[1] == 0)) { primaryFocuser='f'; secondaryFocuser='F'; } else + if (parameter[0] != 0) commandError=true; } else // :f+# Move focuser in (toward objective,) default rate = 0.1mm/second // Returns: Nothing - if (command[1]=='+') { foc2.startMoveIn(); quietReply=true; } else + if (command[1] == '+') { foc2.startMoveIn(); quietReply=true; } else // :f-# Move focuser out (away from objective) // Returns: Nothing - if (command[1]=='-') { foc2.startMoveOut(); quietReply=true; } else + if (command[1] == '-') { foc2.startMoveOut(); quietReply=true; } else // :fQ# Stop the focuser // Returns: Nothing - if (command[1]=='Q') { foc2.stopMove(); quietReply=true; } else + if (command[1] == 'Q') { foc2.stopMove(); quietReply=true; } else // :fG# Get focuser current position (in microns) // Returns: snnn# - if (command[1]=='G') { sprintf(reply,"%ld",(long)round(foc2.getPosition())); quietReply=true; } else + if (command[1] == 'G') { sprintf(reply,"%ld",(long)round(foc2.getPosition())); quietReply=true; } else // :fI# Get full in position (in microns) // Returns: n# - if (command[1]=='I') { sprintf(reply,"%ld",(long)round(foc2.getMin())); quietReply=true; } else + if (command[1] == 'I') { sprintf(reply,"%ld",(long)round(foc2.getMin())); quietReply=true; } else // :fM# Get max position (in microns) // Returns: n# - if (command[1]=='M') { sprintf(reply,"%ld",(long)round(foc2.getMax())); quietReply=true; } else + if (command[1] == 'M') { sprintf(reply,"%ld",(long)round(foc2.getMax())); quietReply=true; } else // :fT# get status // Returns: M# (for moving) or S# (for stopped) - if (command[1]=='T') { if (foc2.moving()) strcpy(reply,"M"); else strcpy(reply,"S"); quietReply=true; } else + if (command[1] == 'T') { if (foc2.moving()) strcpy(reply,"M"); else strcpy(reply,"S"); quietReply=true; } else // :fZ# Set focuser position as zero // Returns: Nothing - if (command[1]=='Z') { foc2.setPosition(0); quietReply=true; } else + if (command[1] == 'Z') { foc2.setPosition(0); quietReply=true; } else // :fH# Set focuser position as half-travel // Returns: Nothing - if (command[1]=='H') { foc2.setPosition(((MaxAxis5+MinAxis5)/2.0)*1000.0); quietReply=true; } else + if (command[1] == 'H') { foc2.setPosition(((AXIS5_LIMIT_MAX+AXIS5_LIMIT_MIN)/2.0)*1000.0); quietReply=true; } else // :fF# Set focuser for fast motion (1mm/s) // Returns: Nothing - if (command[1]=='F') { foc2.setMoveRate(1000); quietReply=true; } else -#ifdef AXIS5_DC_MODE_ON + if (command[1] == 'F') { foc2.setMoveRate(1000); quietReply=true; } else +#if AXIS5_DRIVER_DC_MODE != OFF // :fP# Get focuser DC Motor Power Level (in %) // Returns: nnn# // :fPnnn# Set focuser DC Motor Power Level (in %) // Return: 0 on failure // 1 on success - if (command[1]=='p') { - if (parameter[0]==0) { + if (command[1] == 'p') { + if (parameter[0] == 0) { sprintf(reply,"%d",(int)dcPwrAxis5); quietReply=true; } else { i=atol(parameter); - if ((i>=0) && (i<=100)) { dcPwrAxis5=i; foc2.setDcPower(dcPwrAxis5); nv.write(EE_dcPwrAxis5,i); } else commandError=true; + if ((i >= 0) && (i <= 100)) { dcPwrAxis5=i; foc2.setDcPower(dcPwrAxis5); nv.write(EE_dcPwrAxis5,i); } else commandError=true; } } else #endif // :fp# Check for focuser pseudo absolute mode // Return: 0 on failure // 1 on success - if (command[1]>='p') { -#ifndef AXIS5_DC_MODE_ON + if (command[1] >= 'p') { +#if AXIS5_DRIVER_DC_MODE == OFF commandError=true; #endif } else // :fRsnnn# Set focuser target position relative (in microns) // Returns: Nothing - if (command[1]=='R') { foc2.relativeTarget(atol(parameter)); quietReply=true; } else + if (command[1] == 'R') { foc2.relativeTarget(atol(parameter)); quietReply=true; } else // :fS# Set focuser for slow motion (0.01mm/s) // Returns: Nothing // :fSsnnn# Set focuser target position (in microns) // Returns: Nothing - if (command[1]=='S') { if (parameter[0]==0) { foc2.setMoveRate(constrain(1,AXIS5_MIN_MOVE_RATE,1000)); quietReply=true; } else foc2.setTarget(atol(parameter)); } else + if (command[1] == 'S') { if (parameter[0] == 0) { foc2.setMoveRate(constrain(1,AXIS5_LIMIT_MIN_RATE,1000)); quietReply=true; } else foc2.setTarget(atol(parameter)); } else // :fn# Movement rate, 1=finest, 2=0.01mm/second, 3=0.1mm/second, 4=1mm/second // Returns: Nothing - if ((command[1]>='1') && (command[1]<='4')) { i=command[1]-'1'; int p[] = {1,10,100,1000}; foc2.setMoveRate(constrain(p[i],AXIS5_MIN_MOVE_RATE,1000)); quietReply=true; } else commandError=true; + if ((command[1] >= '1') && (command[1] <= '4')) { i=command[1]-'1'; int p[] = {1,10,100,1000}; foc2.setMoveRate(constrain(p[i],AXIS5_LIMIT_MIN_RATE,1000)); quietReply=true; } else commandError=true; } else #endif // G - Get Telescope Information - if (command[0]=='G') { + if (command[0] == 'G') { // :GA# Get Telescope Altitude // Returns: sDD*MM# or sDD*MM'SS# (based on precision setting) // The current scope altitude - if (command[1]=='A') { getHor(&f,&f1); if (!doubleToDms(reply,&f,false,true)) commandError=true; else quietReply=true; } else + if (command[1] == 'A') { getHor(&f,&f1); if (!doubleToDms(reply,&f,false,true)) commandError=true; else quietReply=true; } else // :Ga# Get Local Time in 12 hour format // Returns: HH:MM:SS# - if (command[1]=='a') { LMT=timeRange(UT1-timeZone); if (LMT>12.0) LMT-=12.0; if (!doubleToHms(reply,&LMT,true)) commandError=true; else quietReply=true; } else + if (command[1] == 'a') { LMT=timeRange(UT1-timeZone); if (LMT > 12.0) LMT-=12.0; if (!doubleToHms(reply,&LMT,true)) commandError=true; else quietReply=true; } else // :GC# Get the current date // Returns: MM/DD/YY# // The current local calendar date - if (command[1]=='C') { + if (command[1] == 'C') { LMT=UT1-timeZone; // correct for day moving forward/backward... this works for multipule days of up-time double J=JD; int y,m,d; - while (LMT>=24.0) { LMT=LMT-24.0; J=J-1.0; } + while (LMT >= 24.0) { LMT=LMT-24.0; J=J-1.0; } if (LMT<0.0) { LMT=LMT+24.0; J=J+1.0; } - greg(J,&y,&m,&d); y-=2000; if (y>=100) y-=100; + greg(J,&y,&m,&d); y-=2000; if (y >= 100) y-=100; sprintf(reply,"%02d/%02d/%02d",m,d,y); quietReply=true; } else // :Gc# Get the current time format // Returns: 24# // The current local time format - if (command[1]=='c') { + if (command[1] == 'c') { strcpy(reply,"24"); quietReply=true; } else @@ -525,23 +525,23 @@ void processCommands() { // Returns: sDD*MM# or sDD*MM'SS# (based on precision setting) // :GDe# Get Telescope Declination // Returns: sDD*MM'SS.s# - if (command[1]=='D') { + if (command[1] == 'D') { #ifdef HAL_SLOW_PROCESSOR - if (millis()-_coord_t>500) + if (millis()-_coord_t > 500) #else - if (millis()-_coord_t>50) + if (millis()-_coord_t > 50) #endif { getEqu(&f,&f1,false); -#if TELESCOPE_COORDINATES==TOPOCENTRIC +#if TELESCOPE_COORDINATES == TOPOCENTRIC observedPlaceToTopocentric(&f,&f1); #endif _ra=f/15.0; _dec=f1; _coord_t=millis(); } - if (parameter[0]==0) { + if (parameter[0] == 0) { if (!doubleToDms(reply,&_dec,false,true)) commandError=true; else quietReply=true; } else - if ((parameter[0]=='e') && (parameter[1]==0)) { + if ((parameter[0] == 'e') && (parameter[1] == 0)) { if (!doubleToDmsd(reply,&_dec)) commandError=true; else quietReply=true; } else commandError=true; } else @@ -549,80 +549,80 @@ void processCommands() { // Returns: sDD*MM# or sDD*MM'SS# (based on precision setting) // :Gde# Get Currently Selected Target Declination // Returns: sDD*MM'SS.s# - if (command[1]=='d') { - if (parameter[0]==0) { + if (command[1] == 'd') { + if (parameter[0] == 0) { if (!doubleToDms(reply,&origTargetDec,false,true)) commandError=true; else quietReply=true; } else - if ((parameter[0]=='e') && (parameter[1]==0)) { + if ((parameter[0] == 'e') && (parameter[1] == 0)) { if (!doubleToDmsd(reply,&origTargetDec)) commandError=true; else quietReply=true; } else commandError=true; } else // :GG# Get UTC offset time // Returns: sHH# // The number of decimal hours to add to local time to convert it to UTC - if (command[1]=='G') { + if (command[1] == 'G') { timeZoneToHM(reply,timeZone); quietReply=true; } else // :Gg# Get Current Site Longitude // Returns: sDDD*MM# // The current site Longitude. East Longitudes are negative - if (command[1]=='g') { i=highPrecision; highPrecision=false; if (!doubleToDms(reply,&longitude,true,true)) commandError=true; else quietReply=true; highPrecision=i; } else + if (command[1] == 'g') { i=highPrecision; highPrecision=false; if (!doubleToDms(reply,&longitude,true,true)) commandError=true; else quietReply=true; highPrecision=i; } else // :Gh# Get Horizon Limit // Returns: sDD*# // The minimum elevation of an object above the horizon required for a mount goto - if (command[1]=='h') { sprintf(reply,"%+02d*",minAlt); quietReply=true; } else + if (command[1] == 'h') { sprintf(reply,"%+02d*",minAlt); quietReply=true; } else // :GL# Get Local Time in 24 hour format // Returns: HH:MM:SS# // On devices with single precision fp several days up-time will cause loss of precision as additional mantissa digits are needed to represent hours // Devices with double precision fp are limitated by sidereal clock overflow which takes 249 days - if (command[1]=='L') { LMT=timeRange(UT1-timeZone); if (!doubleToHms(reply,&LMT,true)) commandError=true; else quietReply=true; } else + if (command[1] == 'L') { LMT=timeRange(UT1-timeZone); if (!doubleToHms(reply,&LMT,true)) commandError=true; else quietReply=true; } else // :GM# Get Site 1 Name // :GN# Get Site 2 Name // :GO# Get Site 3 Name // :GP# Get Site 4 Name // Returns: # // A # terminated string with the name of the requested site. - if ((command[1]=='M') || (command[1]=='N') || (command[1]=='O') || (command[1]=='P')) { + if ((command[1] == 'M') || (command[1] == 'N') || (command[1] == 'O') || (command[1] == 'P')) { i=command[1]-'M'; nv.readString(EE_sites+i*25+9,reply); - if (reply[0]==0) { strcat(reply,"None"); } + if (reply[0] == 0) { strcat(reply,"None"); } quietReply=true; } else // :Gm# Gets the meridian pier-side // Returns: E#, W#, N# (none/parked), ?# (Meridian flip in progress) // A # terminated string with the pier side. - if (command[1]=='m') { + if (command[1] == 'm') { reply[0]='?'; reply[1]=0; - if (getInstrPierSide()==PierSideNone) reply[0]='N'; - if (getInstrPierSide()==PierSideEast) reply[0]='E'; - if (getInstrPierSide()==PierSideWest) reply[0]='W'; + if (getInstrPierSide() == PierSideNone) reply[0]='N'; + if (getInstrPierSide() == PierSideEast) reply[0]='E'; + if (getInstrPierSide() == PierSideWest) reply[0]='W'; quietReply=true; } else // :Go# Get Overhead Limit // Returns: DD*# // The highest elevation above the horizon that the telescope will goto - if (command[1]=='o') { sprintf(reply,"%02d*",maxAlt); quietReply=true; } else + if (command[1] == 'o') { sprintf(reply,"%02d*",maxAlt); quietReply=true; } else // :GR# Get Telescope RA // Returns: HH:MM.T# or HH:MM:SS# (based on precision setting) // :GRa# Get Telescope RA // Returns: HH:MM:SS.ss# - if (command[1]=='R') { + if (command[1] == 'R') { #ifdef HAL_SLOW_PROCESSOR - if (millis()-_coord_t>500) + if (millis()-_coord_t > 500) #else - if (millis()-_coord_t>50) + if (millis()-_coord_t > 50) #endif { getEqu(&f,&f1,false); -#if TELESCOPE_COORDINATES==TOPOCENTRIC +#if TELESCOPE_COORDINATES == TOPOCENTRIC observedPlaceToTopocentric(&f,&f1); #endif _ra=f/15.0; _dec=f1; _coord_t=millis(); } - if (parameter[0]==0) { + if (parameter[0] == 0) { if (!doubleToHms(reply,&_ra,highPrecision)) commandError=true; else quietReply=true; } else - if ((parameter[0]=='a') && (parameter[1]==0)) { + if ((parameter[0] == 'a') && (parameter[1] == 0)) { if (!doubleToHmsd(reply,&_ra)) commandError=true; else quietReply=true; } else commandError=true; } else @@ -630,25 +630,25 @@ void processCommands() { // Returns: HH:MM.T# or HH:MM:SS (based on precision setting) // :Gra# Get Telescope RA // Returns: HH:MM:SS.ss# - if (command[1]=='r') { + if (command[1] == 'r') { f=origTargetRA; f/=15.0; - if (parameter[0]==0) { + if (parameter[0] == 0) { if (!doubleToHms(reply,&f,highPrecision)) commandError=true; else quietReply=true; } else - if ((parameter[0]=='a') && (parameter[1]==0)) { + if ((parameter[0] == 'a') && (parameter[1] == 0)) { if (!doubleToHmsd(reply,&f)) commandError=true; else quietReply=true; } else commandError=true; } else // :GS# Get the Sidereal Time // Returns: HH:MM:SS# // The Sidereal Time as an ASCII Sexidecimal value in 24 hour format - if (command[1]=='S') { f=LST(); if (!doubleToHms(reply,&f,true)) commandError=true; else quietReply=true; } else + if (command[1] == 'S') { f=LST(); if (!doubleToHms(reply,&f,true)) commandError=true; else quietReply=true; } else // :GT# Get tracking rate // Returns: dd.ddddd# (OnStep returns more decimal places than LX200 standard) // Returns the tracking rate if siderealTracking, 0.0 otherwise - if (command[1]=='T') { + if (command[1] == 'T') { char temp[10]; - if ((trackingState==TrackingSidereal) && !trackingSyncInProgress()) f=getTrackingRate60Hz(); else f=0.0; + if ((trackingState == TrackingSidereal) && !trackingSyncInProgress()) f=getTrackingRate60Hz(); else f=0.0; dtostrf(f,0,5,temp); strcpy(reply,temp); quietReply=true; @@ -656,47 +656,47 @@ void processCommands() { // :Gt# Get Current Site Latitude // Returns: sDD*MM# // The latitude of the current site. Positive for North latitudes - if (command[1]=='t') { i=highPrecision; highPrecision=false; if (!doubleToDms(reply,&latitude,false,true)) commandError=true; else quietReply=true; highPrecision=i; } else + if (command[1] == 't') { i=highPrecision; highPrecision=false; if (!doubleToDms(reply,&latitude,false,true)) commandError=true; else quietReply=true; highPrecision=i; } else // :GU# Get telescope Status // Returns: SS# - if (command[1]=='U') { + if (command[1] == 'U') { i=0; - if ((trackingState!=TrackingSidereal) || trackingSyncInProgress()) reply[i++]='n'; // [n]ot tracking - if ((trackingState!=TrackingMoveTo) && !trackingSyncInProgress()) reply[i++]='N'; // [N]o goto + if ((trackingState != TrackingSidereal) || trackingSyncInProgress()) reply[i++]='n'; // [n]ot tracking + if ((trackingState != TrackingMoveTo) && !trackingSyncInProgress()) reply[i++]='N'; // [N]o goto const char *parkStatusCh = "pIPF"; reply[i++]=parkStatusCh[parkStatus]; // not [p]arked, parking [I]n-progress, [P]arked, Park [F]ailed if (pecRecorded) reply[i++]='R'; // PEC data has been [R]ecorded if (atHome) reply[i++]='H'; // at [H]ome if (PPSsynced) reply[i++]='S'; // PPS [S]ync if ((guideDirAxis1) || (guideDirAxis2)) reply[i++]='G'; // [G]uide active -#ifndef MOUNT_TYPE_ALTAZM - if (rateCompensation==RC_REFR_RA) { reply[i++]='r'; reply[i++]='s'; } // [r]efr enabled [s]ingle axis - if (rateCompensation==RC_REFR_BOTH) { reply[i++]='r'; } // [r]efr enabled - if (rateCompensation==RC_FULL_RA) { reply[i++]='t'; reply[i++]='s'; } // on[t]rack enabled [s]ingle axis - if (rateCompensation==RC_FULL_BOTH) { reply[i++]='t'; } // on[t]rack enabled +#if MOUNT_TYPE != ALTAZM + if (rateCompensation == RC_REFR_RA) { reply[i++]='r'; reply[i++]='s'; } // [r]efr enabled [s]ingle axis + if (rateCompensation == RC_REFR_BOTH) { reply[i++]='r'; } // [r]efr enabled + if (rateCompensation == RC_FULL_RA) { reply[i++]='t'; reply[i++]='s'; } // on[t]rack enabled [s]ingle axis + if (rateCompensation == RC_FULL_BOTH) { reply[i++]='t'; } // on[t]rack enabled #endif if (waitingHome) reply[i++]='w'; // [w]aiting at home if (pauseHome) reply[i++]='u'; // pa[u]se at home enabled? if (soundEnabled) reply[i++]='z'; // bu[z]zer enabled? -#ifdef MOUNT_TYPE_GEM +#if MOUNT_TYPE == GEM if (autoMeridianFlip) reply[i++]='a'; // [a]uto meridian flip #endif -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM const char *pch = PECStatusStringAlt; reply[i++]=pch[pecStatus]; // PEC Status is one of "/,~;^" (/)gnore, get ready to (,)lay, (~)laying, get ready to (;)ecord, (^)ecording // if (wormSensedAgain) { reply[i++]='.'; wormSensedAgain=false; } // PEC optional (.) to indicate an index detect since last call #endif // provide mount type - #if defined(MOUNT_TYPE_GEM) +#if MOUNT_TYPE == GEM reply[i++]='E'; - #elif defined(MOUNT_TYPE_FORK) +#elif MOUNT_TYPE == FORK reply[i++]='K'; - #elif defined(MOUNT_TYPE_ALTAZM) +#elif MOUNT_TYPE == ALTAZM reply[i++]='A'; - #endif +#endif // provide pier side info. - if (getInstrPierSide()==PierSideNone) reply[i++]='o'; else // pier side n[o]ne - if (getInstrPierSide()==PierSideEast) reply[i++]='T'; else // pier side eas[T] - if (getInstrPierSide()==PierSideWest) reply[i++]='W'; // pier side [W]est + if (getInstrPierSide() == PierSideNone) reply[i++]='o'; else // pier side n[o]ne + if (getInstrPierSide() == PierSideEast) reply[i++]='T'; else // pier side eas[T] + if (getInstrPierSide() == PierSideWest) reply[i++]='W'; // pier side [W]est // provide pulse-guide rate reply[i++]='0'+getPulseGuideRate(); @@ -712,19 +712,19 @@ void processCommands() { } else // :Gu# Get bit packed telescope status // Returns: SS# - if (command[1]=='u') { + if (command[1] == 'u') { memset(reply,(char)0b10000000,9); - if ((trackingState!=TrackingSidereal) || trackingSyncInProgress()) reply[0]|=0b10000001; // Not tracking - if ((trackingState!=TrackingMoveTo) && !trackingSyncInProgress()) reply[0]|=0b10000010; // No goto + if ((trackingState != TrackingSidereal) || trackingSyncInProgress()) reply[0]|=0b10000001; // Not tracking + if ((trackingState != TrackingMoveTo) && !trackingSyncInProgress()) reply[0]|=0b10000010; // No goto if (PPSsynced) reply[0]|=0b10000100; // PPS sync if ((guideDirAxis1) || (guideDirAxis2)) reply[0]|=0b10001000; // Guide active -#ifndef MOUNT_TYPE_ALTAZM - if (rateCompensation==RC_REFR_RA) reply[0]|=0b11010000; // Refr enabled Single axis - if (rateCompensation==RC_REFR_BOTH) reply[0]|=0b10010000; // Refr enabled - if (rateCompensation==RC_FULL_RA) reply[0]|=0b11100000; // OnTrack enabled Single axis - if (rateCompensation==RC_FULL_BOTH) reply[0]|=0b10100000; // OnTrack enabled +#if MOUNT_TYPE != ALTAZM + if (rateCompensation == RC_REFR_RA) reply[0]|=0b11010000; // Refr enabled Single axis + if (rateCompensation == RC_REFR_BOTH) reply[0]|=0b10010000; // Refr enabled + if (rateCompensation == RC_FULL_RA) reply[0]|=0b11100000; // OnTrack enabled Single axis + if (rateCompensation == RC_FULL_BOTH) reply[0]|=0b10100000; // OnTrack enabled #endif - if (rateCompensation==RC_NONE) { + if (rateCompensation == RC_NONE) { double tr=getTrackingRate60Hz(); if (abs(tr-57.900)<0.001) reply[1]|=0b10000001; else // Lunar rate selected if (abs(tr-60.000)<0.001) reply[1]|=0b10000010; else // Solar rate selected @@ -735,26 +735,26 @@ void processCommands() { if (waitingHome) reply[2]|=0b10000010; // Waiting at home if (pauseHome) reply[2]|=0b10000100; // Pause at home enabled? if (soundEnabled) reply[2]|=0b10001000; // Buzzer enabled? -#ifdef MOUNT_TYPE_GEM +#if MOUNT_TYPE == GEM if (autoMeridianFlip) reply[2]|=0b10010000; // Auto meridian flip #endif if (pecRecorded) reply[2]|=0b10100000; // PEC data has been recorded // provide mount type - #if defined(MOUNT_TYPE_GEM) +#if MOUNT_TYPE == GEM reply[3]|=0b10000001; // GEM - #elif defined(MOUNT_TYPE_FORK) +#elif MOUNT_TYPE == FORK reply[3]|=0b10000010; // FORK - #elif defined(MOUNT_TYPE_ALTAZM) +#elif MOUNT_TYPE == ALTAZM reply[3]|=0b10001000; // ALTAZM - #endif +#endif // provide pier side info. - if (getInstrPierSide()==PierSideNone) reply[3]|=0b10010000; else // Pier side none - if (getInstrPierSide()==PierSideEast) reply[3]|=0b10100000; else // Pier side east - if (getInstrPierSide()==PierSideWest) reply[3]|=0b11000000; // Pier side west + if (getInstrPierSide() == PierSideNone) reply[3]|=0b10010000; else // Pier side none + if (getInstrPierSide() == PierSideEast) reply[3]|=0b10100000; else // Pier side east + if (getInstrPierSide() == PierSideWest) reply[3]|=0b11000000; // Pier side west -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM reply[4]=pecStatus|0b10000000; // PEC status: 0 ignore, 1 get ready to play, 2 playing, 3 get ready to record, 4 recording #endif reply[5]=parkStatus|0b10000000; // Park status: 0 not parked, 1 parking in-progress, 2 parked, 3 park failed @@ -774,13 +774,13 @@ void processCommands() { // Returns: # // :GVT# Get Telescope Firmware Time // returns: HH:MM:SS# - if (command[1]=='V') { - if (parameter[1]==(char)0) { - if (parameter[0]=='D') strcpy(reply,FirmwareDate); else - if (parameter[0]=='M') sprintf(reply,"OnStep %i.%i%s",FirmwareVersionMajor,FirmwareVersionMinor,FirmwareVersionPatch); else - if (parameter[0]=='N') sprintf(reply,"%i.%i%s",FirmwareVersionMajor,FirmwareVersionMinor,FirmwareVersionPatch); else - if (parameter[0]=='P') strcpy(reply,FirmwareName); else - if (parameter[0]=='T') strcpy(reply,FirmwareTime); else commandError=true; + if (command[1] == 'V') { + if (parameter[1] == (char)0) { + if (parameter[0] == 'D') strcpy(reply,FirmwareDate); else + if (parameter[0] == 'M') sprintf(reply,"OnStep %i.%i%s",FirmwareVersionMajor,FirmwareVersionMinor,FirmwareVersionPatch); else + if (parameter[0] == 'N') sprintf(reply,"%i.%i%s",FirmwareVersionMajor,FirmwareVersionMinor,FirmwareVersionPatch); else + if (parameter[0] == 'P') strcpy(reply,FirmwareName); else + if (parameter[0] == 'T') strcpy(reply,FirmwareTime); else commandError=true; } else commandError=true; quietReply=true; @@ -790,27 +790,27 @@ void processCommands() { // where mount: A-AltAzm, P-Fork, G-GEM // tracking: T-tracking, N-not tracking // alignment: 0-needs alignment, 1-one star aligned, 2-two star aligned, >= 3-three star aligned - if ((command[1]=='W') && (parameter[0]==0)) { + if ((command[1] == 'W') && (parameter[0] == 0)) { // mount type - #if defined(MOUNT_TYPE_GEM) +#if MOUNT_TYPE == GEM reply[0]='G'; - #elif defined(MOUNT_TYPE_FORK) +#elif MOUNT_TYPE == FORK reply[0]='P'; - #elif defined(MOUNT_TYPE_ALTAZM) +#elif MOUNT_TYPE == ALTAZM reply[0]='A'; - #endif +#endif // tracking - if ((trackingState!=TrackingSidereal) || trackingSyncInProgress()) reply[1]='N'; else reply[1]='T'; + if ((trackingState != TrackingSidereal) || trackingSyncInProgress()) reply[1]='N'; else reply[1]='T'; // align status - i=alignThisStar-1; if (i<0) i=0; if (i>3) i=3; reply[2]='0'+i; + i=alignThisStar-1; if (i<0) i=0; if (i > 3) i=3; reply[2]='0'+i; reply[3]=0; quietReply=true; } else // :GXnn# Get OnStep value // Returns: value - if (command[1]=='X') { - if (parameter[2]==(char)0) { - if (parameter[0]=='0') { // 0n: Align Model + if (command[1] == 'X') { + if (parameter[2] == (char)0) { + if (parameter[0] == '0') { // 0n: Align Model static int star=0; switch (parameter[1]) { case '0': sprintf(reply,"%ld",(long)(Align.ax1Cor*3600.0)); quietReply=true; break; // ax1Cor @@ -819,7 +819,7 @@ void processCommands() { case '3': sprintf(reply,"%ld",(long)(Align.azmCor*3600.0)); quietReply=true; break; // azmCor case '4': sprintf(reply,"%ld",(long)(Align.doCor*3600.0)); quietReply=true; break; // doCor case '5': sprintf(reply,"%ld",(long)(Align.pdCor*3600.0)); quietReply=true; break; // pdCor -#if defined(MOUNT_TYPE_FORK) || defined(MOUNT_TYPE_ALTAZM) +#if MOUNT_TYPE == FORK || MOUNT_TYPE == ALTAZM case '6': sprintf(reply,"%ld",(long)(Align.dfCor*3600.0)); quietReply=true; break; // ffCor case '7': sprintf(reply,"%ld",(long)(0)); quietReply=true; break; // dfCor #else @@ -828,7 +828,7 @@ void processCommands() { #endif case '8': sprintf(reply,"%ld",(long)(Align.tfCor*3600.0)); quietReply=true; break; // tfCor - case '9': { int n=0; if (alignThisStar>alignNumStars) n=alignNumStars; sprintf(reply,"%ld",(long)(n)); star=0; quietReply=true; } break; // Number of stars, reset to first star + case '9': { int n=0; if (alignThisStar > alignNumStars) n=alignNumStars; sprintf(reply,"%ld",(long)(n)); star=0; quietReply=true; } break; // Number of stars, reset to first star case 'A': { double f=(Align.actual[star].ha*Rad)/15.0; doubleToHms(reply,&f,true); quietReply=true; } break; // Star #n HA case 'B': { double f=(Align.actual[star].dec*Rad); doubleToDms(reply,&f,false,true); quietReply=true; } break; // Star #n Dec case 'C': { double f=(Align.mount[star].ha*Rad)/15.0; doubleToHms(reply,&f,true); quietReply=true; } break; // Mount #n HA @@ -837,44 +837,44 @@ void processCommands() { default: commandError=true; } } else - if (parameter[0]=='4') { // 4n: Encoder + if (parameter[0] == '4') { // 4n: Encoder switch (parameter[1]) { - case '0': if (getEnc(&f,&f1)==0) { if (!doubleToDms(reply,&f,true,true)) commandError=true; else quietReply=true; } else commandError=true; break; // Get formatted absolute Axis1 angle - case '1': if (getEnc(&f,&f1)==0) { if (!doubleToDms(reply,&f1,true,true)) commandError=true; else quietReply=true; } else commandError=true; break; // Get formatted absolute Axis2 angle - case '2': if (getEnc(&f,&f1)==0) { dtostrf(f,0,6,reply); quietReply=true; } else commandError=true; break; // Get absolute Axis1 angle in degrees - case '3': if (getEnc(&f,&f1)==0) { dtostrf(f1,0,6,reply); quietReply=true; } else commandError=true; break; // Get absolute Axis2 angle in degrees + case '0': if (getEnc(&f,&f1) == 0) { if (!doubleToDms(reply,&f,true,true)) commandError=true; else quietReply=true; } else commandError=true; break; // Get formatted absolute Axis1 angle + case '1': if (getEnc(&f,&f1) == 0) { if (!doubleToDms(reply,&f1,true,true)) commandError=true; else quietReply=true; } else commandError=true; break; // Get formatted absolute Axis2 angle + case '2': if (getEnc(&f,&f1) == 0) { dtostrf(f,0,6,reply); quietReply=true; } else commandError=true; break; // Get absolute Axis1 angle in degrees + case '3': if (getEnc(&f,&f1) == 0) { dtostrf(f1,0,6,reply); quietReply=true; } else commandError=true; break; // Get absolute Axis2 angle in degrees case '9': cli(); dtostrf(trackingTimerRateAxis1,1,8,reply); sei(); quietReply=true; break; // Get current tracking rate default: commandError=true; } } else - if (parameter[0]=='8') { // 8n: Date/Time + if (parameter[0] == '8') { // 8n: Date/Time switch (parameter[1]) { case '0': f=timeRange(UT1); doubleToHms(reply,&f,true); quietReply=true; break; // UTC time - case '1': f1=JD; f=UT1; while (f>=24.0) { f-=24.0; f1+=1; } while (f<0.0) { f+=24.0; f1-=1; } greg(f1,&i2,&i,&i1); i2=(i2/99.99999-floor(i2/99.99999))*100; sprintf(reply,"%02d/%02d/%02d",i,i1,i2); quietReply=true; break; // UTC date + case '1': f1=JD; f=UT1; while (f >= 24.0) { f-=24.0; f1+=1; } while (f < 0.0) { f+=24.0; f1-=1; } greg(f1,&i2,&i,&i1); i2=(i2/99.99999-floor(i2/99.99999))*100; sprintf(reply,"%02d/%02d/%02d",i,i1,i2); quietReply=true; break; // UTC date case '9': if (dateWasSet && timeWasSet) commandError=true; break; // Get Date/Time status, returns 0=known or 1=unknown default: commandError=true; } } else - if (parameter[0]=='9') { // 9n: Misc. + if (parameter[0] == '9') { // 9n: Misc. switch (parameter[1]) { case '0': dtostrf(guideRates[currentPulseGuideRate]/15.0,2,2,reply); quietReply=true; break; // pulse-guide rate case '1': sprintf(reply,"%i",pecAnalogValue); quietReply=true; break; // pec analog value case '2': dtostrf(maxRate/16.0,3,3,reply); quietReply=true; break; // MaxRate (current) case '3': dtostrf((double)MaxRateDef,3,3,reply); quietReply=true; break; // MaxRateDef (default) - case '4': if (meridianFlip==MeridianFlipNever) { sprintf(reply,"%d N",getInstrPierSide()); } else { sprintf(reply,"%d",getInstrPierSide()); } quietReply=true; break; // pierSide (N if never) + case '4': if (meridianFlip == MeridianFlipNever) { sprintf(reply,"%d N",getInstrPierSide()); } else { sprintf(reply,"%d",getInstrPierSide()); } quietReply=true; break; // pierSide (N if never) case '5': sprintf(reply,"%i",(int)autoMeridianFlip); quietReply=true; break; // autoMeridianFlip case '6': // preferred pier side - if (preferredPierSide==PPS_EAST) strcpy(reply,"E"); else - if (preferredPierSide==PPS_WEST) strcpy(reply,"W"); else strcpy(reply,"B"); + if (preferredPierSide == PPS_EAST) strcpy(reply,"E"); else + if (preferredPierSide == PPS_WEST) strcpy(reply,"W"); else strcpy(reply,"B"); quietReply=true; break; case '7': dtostrf(slewSpeed,3,1,reply); quietReply=true; break; // slew speed case '8': -#ifdef ROTATOR_ON -#ifdef MOUNT_TYPE_ALTAZM +#if ROTATOR == ON + #if MOUNT_TYPE == ALTAZM strcpy(reply,"D"); -#else + #else strcpy(reply,"R"); -#endif + #endif #else strcpy(reply,"N"); #endif @@ -885,12 +885,12 @@ void processCommands() { case 'C': dtostrf(ambient.getHumidity(),3,1,reply); quietReply=true; break; // relative humidity in % case 'D': dtostrf(ambient.getAltitude(),3,1,reply); quietReply=true; break; // altitude in meters case 'E': dtostrf(ambient.getDewPoint(),3,1,reply); quietReply=true; break; // dew point in deg. C - case 'F': { float t=HAL_MCU_Temperature(); if (t>-999) { dtostrf(t,1,0,reply); quietReply=true; } else commandError=true; } break; // internal MCU temperature in deg. C + case 'F': { float t=HAL_MCU_Temperature(); if (t > -999) { dtostrf(t,1,0,reply); quietReply=true; } else commandError=true; } break; // internal MCU temperature in deg. C default: commandError=true; } } else -#if (AXIS1_FAULT==TMC_SPI) && (AXIS2_FAULT==TMC_SPI) - if (parameter[0]=='U') { // Un: Get stepper driver statUs +#if (AXIS1_DRIVER_STATUS == TMC_SPI) && (AXIS2_DRIVER_STATUS == TMC_SPI) + if (parameter[0] == 'U') { // Un: Get stepper driver statUs switch (parameter[1]) { case '1': @@ -919,23 +919,23 @@ void processCommands() { } } else #endif - if (parameter[0]=='E') { // En: Get settings + if (parameter[0] == 'E') { // En: Get settings switch (parameter[1]) { case '1': dtostrf((double)MaxRateDef,3,3,reply); quietReply=true; break; - case '2': dtostrf(DegreesForAcceleration,2,1,reply); quietReply=true; break; - case '3': sprintf(reply,"%ld",(long)round(BacklashTakeupRate)); quietReply=true; break; - case '4': sprintf(reply,"%ld",(long)round(StepsPerDegreeAxis1)); quietReply=true; break; - case '5': sprintf(reply,"%ld",(long)round(StepsPerDegreeAxis2)); quietReply=true; break; + case '2': dtostrf(SLEW_ACCELERATION_DIST,2,1,reply); quietReply=true; break; + case '3': sprintf(reply,"%ld",(long)round(BACKLASH_RATE)); quietReply=true; break; + case '4': sprintf(reply,"%ld",(long)round(AXIS1_STEPS_PER_DEGREE)); quietReply=true; break; + case '5': sprintf(reply,"%ld",(long)round(AXIS2_STEPS_PER_DEGREE)); quietReply=true; break; case '6': dtostrf(StepsPerSecondAxis1,3,6,reply); quietReply=true; break; - case '7': sprintf(reply,"%ld",(long)round(StepsPerWormRotationAxis1)); quietReply=true; break; - case '8': sprintf(reply,"%ld",(long)round(PECBufferSize)); quietReply=true; break; -#ifdef MOUNT_TYPE_GEM - case '9': sprintf(reply,"%ld",(long)round(minutesPastMeridianE)); quietReply=true; break; - case 'A': sprintf(reply,"%ld",(long)round(minutesPastMeridianW)); quietReply=true; break; -#endif - case 'B': sprintf(reply,"%ld",(long)round(UnderPoleLimit)); quietReply=true; break; - case 'C': sprintf(reply,"%ld",(long)round(MinDec)); quietReply=true; break; - case 'D': sprintf(reply,"%ld",(long)round(MaxDec)); quietReply=true; break; + case '7': sprintf(reply,"%ld",(long)round(AXIS1_STEPS_PER_WORMROT)); quietReply=true; break; + case '8': sprintf(reply,"%ld",(long)round(pecBufferSize)); quietReply=true; break; +#if MOUNT_TYPE == GEM + case '9': sprintf(reply,"%ld",(long)round(degreesPastMeridianE*4.0)); quietReply=true; break; // minutes past meridianE + case 'A': sprintf(reply,"%ld",(long)round(degreesPastMeridianW*4.0)); quietReply=true; break; // minutes past meridianW +#endif + case 'B': sprintf(reply,"%ld",(long)round(AXIS1_LIMIT_UNDER_POLE/15.0)); quietReply=true; break; // in hours + case 'C': sprintf(reply,"%ld",(long)round(AXIS2_LIMIT_MIN)); quietReply=true; break; + case 'D': sprintf(reply,"%ld",(long)round(AXIS2_LIMIT_MAX)); quietReply=true; break; case 'E': // coordinate mode for getting and setting RA/Dec // 0 = OBSERVED_PLACE @@ -948,7 +948,7 @@ void processCommands() { default: commandError=true; } } else - if (parameter[0]=='F') { // Fn: Debug + if (parameter[0] == 'F') { // Fn: Debug long temp; switch (parameter[1]) { case '0': cli(); temp=(long)(posAxis1-((long)targetAxis1.part.m)); sei(); sprintf(reply,"%ld",temp); quietReply=true; break; // Debug0, true vs. target RA position @@ -968,82 +968,82 @@ void processCommands() { } } else #ifdef Aux0 - if ((parameter[0]=='G') && (parameter[1]=='0')) { sprintf(reply,"%d",(int)round((float)valueAux0/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '0')) { sprintf(reply,"%d",(int)round((float)valueAux0/2.55)); quietReply=true; } else #endif #ifdef Aux1 - if ((parameter[0]=='G') && (parameter[1]=='1')) { sprintf(reply,"%d",(int)round((float)valueAux1/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '1')) { sprintf(reply,"%d",(int)round((float)valueAux1/2.55)); quietReply=true; } else #endif #ifdef Aux2 - if ((parameter[0]=='G') && (parameter[1]=='2')) { sprintf(reply,"%d",(int)round((float)valueAux2/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '2')) { sprintf(reply,"%d",(int)round((float)valueAux2/2.55)); quietReply=true; } else #endif #ifdef Aux3 - if ((parameter[0]=='G') && (parameter[1]=='3')) { sprintf(reply,"%d",(int)round((float)valueAux3/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '3')) { sprintf(reply,"%d",(int)round((float)valueAux3/2.55)); quietReply=true; } else #endif #ifdef Aux4 - if ((parameter[0]=='G') && (parameter[1]=='4')) { sprintf(reply,"%d",(int)round((float)valueAux4/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '4')) { sprintf(reply,"%d",(int)round((float)valueAux4/2.55)); quietReply=true; } else #endif #ifdef Aux5 - if ((parameter[0]=='G') && (parameter[1]=='5')) { sprintf(reply,"%d",(int)round((float)valueAux5/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '5')) { sprintf(reply,"%d",(int)round((float)valueAux5/2.55)); quietReply=true; } else #endif #ifdef Aux6 - if ((parameter[0]=='G') && (parameter[1]=='6')) { sprintf(reply,"%d",(int)round((float)valueAux6/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '6')) { sprintf(reply,"%d",(int)round((float)valueAux6/2.55)); quietReply=true; } else #endif #ifdef Aux7 - if ((parameter[0]=='G') && (parameter[1]=='7')) { sprintf(reply,"%d",(int)round((float)valueAux7/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '7')) { sprintf(reply,"%d",(int)round((float)valueAux7/2.55)); quietReply=true; } else #endif #ifdef Aux8 - if ((parameter[0]=='G') && (parameter[1]=='8')) { sprintf(reply,"%d",(int)round((float)valueAux8/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '8')) { sprintf(reply,"%d",(int)round((float)valueAux8/2.55)); quietReply=true; } else #endif #ifdef Aux9 - if ((parameter[0]=='G') && (parameter[1]=='9')) { sprintf(reply,"%d",(int)round((float)valueAux9/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == '9')) { sprintf(reply,"%d",(int)round((float)valueAux9/2.55)); quietReply=true; } else #endif #ifdef Aux10 - if ((parameter[0]=='G') && (parameter[1]=='A')) { sprintf(reply,"%d",(int)round((float)valueAux10/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'A')) { sprintf(reply,"%d",(int)round((float)valueAux10/2.55)); quietReply=true; } else #endif #ifdef Aux11 - if ((parameter[0]=='G') && (parameter[1]=='B')) { sprintf(reply,"%d",(int)round((float)valueAux11/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'B')) { sprintf(reply,"%d",(int)round((float)valueAux11/2.55)); quietReply=true; } else #endif #ifdef Aux12 - if ((parameter[0]=='G') && (parameter[1]=='C')) { sprintf(reply,"%d",(int)round((float)valueAux12/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'C')) { sprintf(reply,"%d",(int)round((float)valueAux12/2.55)); quietReply=true; } else #endif #ifdef Aux13 - if ((parameter[0]=='G') && (parameter[1]=='D')) { sprintf(reply,"%d",(int)round((float)valueAux13/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'D')) { sprintf(reply,"%d",(int)round((float)valueAux13/2.55)); quietReply=true; } else #endif #ifdef Aux14 - if ((parameter[0]=='G') && (parameter[1]=='E')) { sprintf(reply,"%d",(int)round((float)valueAux14/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'E')) { sprintf(reply,"%d",(int)round((float)valueAux14/2.55)); quietReply=true; } else #endif #ifdef Aux15 - if ((parameter[0]=='G') && (parameter[1]=='F')) { sprintf(reply,"%d",(int)round((float)valueAux15/2.55)); quietReply=true; } else + if ((parameter[0] == 'G') && (parameter[1] == 'F')) { sprintf(reply,"%d",(int)round((float)valueAux15/2.55)); quietReply=true; } else #endif commandError=true; } else commandError=true; } else // :GZ# Get telescope azimuth // Returns: DDD*MM# or DDD*MM'SS# (based on precision setting) - if (command[1]=='Z') { getHor(&f,&f1); f1=degRange(f1); if (!doubleToDms(reply,&f1,true,false)) commandError=true; else quietReply=true; } else commandError=true; + if (command[1] == 'Z') { getHor(&f,&f1); f1=degRange(f1); if (!doubleToDms(reply,&f1,true,false)) commandError=true; else quietReply=true; } else commandError=true; } else // h - Home Position Commands - if (command[0]=='h') { + if (command[0] == 'h') { // :hF# Reset telescope at the home position. This position is required for a Cold Start. // Point to the celestial pole with the counterweight pointing downwards (CWD position). // Returns: Nothing - if (command[1]=='F') { -#ifdef FOCUSER1_ON + if (command[1] == 'F') { +#if FOCUSER1 == ON foc1.savePosition(); #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON foc2.savePosition(); #endif setHome(); quietReply=true; } else // :hC# Moves telescope to the home position // Returns: Nothing - if (command[1]=='C') { -#ifdef FOCUSER1_ON + if (command[1] == 'C') { +#if FOCUSER1 == ON foc1.savePosition(); #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON foc2.savePosition(); #endif goHome(true); quietReply=true; @@ -1051,11 +1051,11 @@ void processCommands() { // :hP# Goto the Park Position // Return: 0 on failure // 1 on success - if (command[1]=='P') { -#ifdef FOCUSER1_ON + if (command[1] == 'P') { +#if FOCUSER1 == ON foc1.savePosition(); #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON foc2.savePosition(); #endif if (park()) commandError=true; @@ -1063,29 +1063,29 @@ void processCommands() { // :hQ# Set the park position // Return: 0 on failure // 1 on success - if (command[1]=='Q') { if (!setPark()) commandError=true; } else + if (command[1] == 'Q') { if (!setPark()) commandError=true; } else // :hR# Restore parked telescope to operation // Return: 0 on failure // 1 on success - if (command[1]=='R') { if (!unPark(true)) commandError=true; } + if (command[1] == 'R') { if (!unPark(true)) commandError=true; } else commandError=true; } else // L - Object Library Commands - if (command[0]=='L') { + if (command[0] == 'L') { // :LB# Find previous object and set it as the current target object. // Returns: Nothing - if ((command[1]=='B') && (parameter[0]==0)) { + if ((command[1] == 'B') && (parameter[0] == 0)) { Lib.prevRec(); quietReply=true; } else // :LCNNNN# // Set current target object to deep sky catalog object number NNNN // Returns : Nothing - if (command[1]=='C') { - if ( (atoi2((char *)¶meter[0],&i)) && ((i>=0) && (i<=32767))) { + if (command[1] == 'C') { + if ( (atoi2((char *)¶meter[0],&i)) && ((i >= 0) && (i <= 32767))) { Lib.gotoRec(i); quietReply=true; } else commandError=true; } else @@ -1093,7 +1093,7 @@ void processCommands() { // :LI# Get Object Information // Returns: # // Returns a string containing the current target object’s name and object type. - if ((command[1]=='I') && (parameter[0]==0)) { + if ((command[1] == 'I') && (parameter[0] == 0)) { Lib.readVars(reply,&i,&origTargetRA,&origTargetDec); char const * objType=objectStr[i]; @@ -1104,11 +1104,11 @@ void processCommands() { // :LIG# Get Object Information and goto // Returns: Nothing - if ((command[1]=='I') && (parameter[0]=='G') && (parameter[1]==0)) { + if ((command[1] == 'I') && (parameter[0] == 'G') && (parameter[1] == 0)) { Lib.readVars(reply,&i,&origTargetRA,&origTargetDec); newTargetRA=origTargetRA; newTargetDec=origTargetDec; -#if TELESCOPE_COORDINATES==TOPOCENTRIC +#if TELESCOPE_COORDINATES == TOPOCENTRIC topocentricToObservedPlace(&newTargetRA,&newTargetDec); #endif @@ -1119,7 +1119,7 @@ void processCommands() { // :LR# Get Object Information including RA and Dec, with advance to next Record // Returns: # // Returns a string containing the current target object’s name, type, RA, and Dec. - if ((command[1]=='R') && (parameter[0]==0)) { + if ((command[1] == 'R') && (parameter[0] == 0)) { Lib.readVars(reply,&i,&origTargetRA,&origTargetDec); char const * objType=objectStr[i]; @@ -1127,7 +1127,7 @@ void processCommands() { strcat(reply,","); strcat(reply,objType); - if (strcmp(reply,",UNK")!=0) { + if (strcmp(reply,",UNK") != 0) { f=origTargetRA; f/=15.0; doubleToHms(ws,&f,highPrecision); strcat(reply,","); strcat(reply,ws); doubleToDms(ws,&origTargetDec,false,true); strcat(reply,","); strcat(reply,ws); } @@ -1143,7 +1143,7 @@ void processCommands() { // ss is a string of up to eleven chars followed by a comma and a type designation for ex. ":LWM31 AND,GAL#" // Return: 0 on failure (memory full, for example) // 1 on success - if (command[1]=='W') { + if (command[1] == 'W') { char name[12]; char objType[4]; @@ -1152,23 +1152,23 @@ void processCommands() { int l=0; do { name[l]=0; - if (parameter[l]==',') break; + if (parameter[l] == ',') break; name[l]=parameter[l]; name[l+1]=0; l++; } while (l<12); // extract object type - i=0; if (parameter[l]==',') { + i=0; if (parameter[l] == ',') { l++; int m=0; do { objType[m+1]=0; objType[m]=parameter[l]; l++; m++; - } while (parameter[l]!=0); + } while (parameter[l] != 0); // encode // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // "UNK", "OC", "GC", "PN", "DN", "SG", "EG", "IG", "KNT", "SNR", "GAL", "CN", "STR", "PLA", "CMT", "AST" - for (l=0; l<=15; l++) { if (strcmp(objType,objectStr[l])==0) i=l; } + for (l=0; l <= 15; l++) { if (strcmp(objType,objectStr[l]) == 0) i=l; } } if (Lib.firstFreeRec()) Lib.writeVars(name,i,origTargetRA,origTargetDec); else commandError=true; @@ -1176,42 +1176,42 @@ void processCommands() { // :LN# Find next deep sky target object subject to the current constraints. // Returns: Nothing - if ((command[1]=='N') && (parameter[0]==0)) { + if ((command[1] == 'N') && (parameter[0] == 0)) { Lib.nextRec(); quietReply=true; } else // :L$# Move to catalog name record // Returns: 1 - if ((command[1]=='$') && (parameter[0]==0)) { + if ((command[1] == '$') && (parameter[0] == 0)) { Lib.nameRec(); quietReply=false; } else // :LD# Clear current record // Returns: Nothing - if ((command[1]=='D') && (parameter[0]==0)) { + if ((command[1] == 'D') && (parameter[0] == 0)) { Lib.clearCurrentRec(); quietReply=true; } else // :LL# Clear current catalog // Returns: Nothing - if ((command[1]=='L') && (parameter[0]==0)) { + if ((command[1] == 'L') && (parameter[0] == 0)) { Lib.clearLib(); quietReply=true; } else // :L!# Clear library (all catalogs) // Returns: Nothing - if ((command[1]=='!') && (parameter[0]==0)) { + if ((command[1] == '!') && (parameter[0] == 0)) { Lib.clearAll(); quietReply=true; } else // :L?# Get library free records (all catalogs) // Returns: n# - if ((command[1]=='?') && (parameter[0]==0)) { + if ((command[1] == '?') && (parameter[0] == 0)) { sprintf(reply,"%d",Lib.recFreeAll()); quietReply=true; } else @@ -1220,8 +1220,8 @@ void processCommands() { // in OnStep catalog# range from 0-14. Catalogs 0-6 are user defined, the remainder are reserved. // Return: 0 on failure // 1 on success - if (command[1]=='o') { - if ( (atoi2((char *)¶meter[0],&i)) && ((i>=0) && (i<=14))) { + if (command[1] == 'o') { + if ( (atoi2((char *)¶meter[0],&i)) && ((i >= 0) && (i <= 14))) { Lib.setCatalog(i); } else commandError=true; } else commandError=true; @@ -1229,10 +1229,10 @@ void processCommands() { } else // M - Telescope Movement Commands - if (command[0]=='M') { + if (command[0] == 'M') { // :MA# Goto the target Alt and Az // Returns: 0..9, see :MS# - if (command[1]=='A') { + if (command[1] == 'A') { if (axis1Enabled) { i=goToHor(&newTargetAlt, &newTargetAzm); reply[0]=i+'0'; reply[1]=0; @@ -1242,18 +1242,18 @@ void processCommands() { } else // :Mgdnnnn# Pulse guide command // Returns: Nothing - if (command[1]=='g') { - if ( (atoi2((char *)¶meter[1],&i)) && ((i>=0) && (i<=16399)) ) { - if (((parameter[0]=='e') || (parameter[0]=='w')) && (guideDirAxis1==0)) { -#ifdef SEPARATE_PULSE_GUIDE_RATE_ON + if (command[1] == 'g') { + if ( (atoi2((char *)¶meter[1],&i)) && ((i >= 0) && (i <= 16399)) ) { + if (((parameter[0] == 'e') || (parameter[0] == 'w')) && (guideDirAxis1 == 0)) { +#if SEPARATE_PULSE_GUIDE_RATE == ON startGuideAxis1(parameter[0],currentPulseGuideRate,i); #else startGuideAxis1(parameter[0],currentGuideRate,i); #endif quietReply=true; } else - if (((parameter[0]=='n') || (parameter[0]=='s')) && (guideDirAxis2==0)) { -#ifdef SEPARATE_PULSE_GUIDE_RATE_ON + if (((parameter[0] == 'n') || (parameter[0] == 's')) && (guideDirAxis2 == 0)) { +#if SEPARATE_PULSE_GUIDE_RATE == ON startGuideAxis2(parameter[0],currentPulseGuideRate,i); #else startGuideAxis2(parameter[0],currentGuideRate,i); @@ -1264,24 +1264,24 @@ void processCommands() { } else // :Me# & :Mw# Move Telescope East or West at current slew rate // Returns: Nothing - if ( ( (command[1]=='e') || (command[1]=='w') ) && (parameter[0]==0) ) { + if ( ( (command[1] == 'e') || (command[1] == 'w') ) && (parameter[0] == 0) ) { startGuideAxis1(command[1],currentGuideRate,GUIDE_TIME_LIMIT*1000); quietReply=true; } else // :Mn# & :Ms# Move Telescope North or South at current slew rate // Returns: Nothing - if ( ( (command[1]=='n') || (command[1]=='s') ) && (parameter[0]==0) ) { + if ( ( (command[1] == 'n') || (command[1] == 's') ) && (parameter[0] == 0) ) { startGuideAxis2(command[1],currentGuideRate,GUIDE_TIME_LIMIT*1000); quietReply=true; } else // :MP# Goto the Current Position for Polar Align // Returns: 0..9, see :MS# - if (command[1]=='P') { + if (command[1] == 'P') { double r,d; getEqu(&r,&d,false); i=validateGoToEqu(r,d); - if (i==0) { + if (i == 0) { Align.altCor=0.0; Align.azmCor=0.0; i=goToEqu(r,d); @@ -1299,13 +1299,13 @@ void processCommands() { // 3=controller in standby // 4=mount is parked // 5=Goto in progress -// 6=outside limits (MaxDec, MinDec, UnderPoleLimit, MeridianLimit) +// 6=outside limits (AXIS2_LIMIT_MAX, AXIS2_LIMIT_MIN, AXIS1_LIMIT_UNDER_POLE, MERIDIAN_E/W) // 7=hardware fault // 8=already in motion // 9=unspecified error - if (command[1]=='S') { + if (command[1] == 'S') { newTargetRA=origTargetRA; newTargetDec=origTargetDec; -#if TELESCOPE_COORDINATES==TOPOCENTRIC +#if TELESCOPE_COORDINATES == TOPOCENTRIC topocentricToObservedPlace(&newTargetRA,&newTargetDec); #endif i=goToEqu(newTargetRA,newTargetDec); @@ -1316,7 +1316,7 @@ void processCommands() { // :MN# Goto current RA/Dec but East of the Pier (within meridian limit overlap for GEM mounts) // Returns: 0..9, see :MS# - if (command[1]=='N') { + if (command[1] == 'N') { i=goToHere(true); reply[0]=i+'0'; reply[1]=0; quietReply=true; @@ -1337,79 +1337,79 @@ void processCommands() { // Returns: nothing // :$QZ? Get PEC status // Returns: S# - if ((command[0]=='$') && (command[1]=='Q')) { - if ((parameter[2]==0) && (parameter[0]=='Z')) { + if ((command[0] == '$') && (command[1] == 'Q')) { + if ((parameter[2] == 0) && (parameter[0] == 'Z')) { quietReply=true; -#ifndef MOUNT_TYPE_ALTAZM - if (parameter[1]=='+') { if (pecRecorded) pecStatus=ReadyPlayPEC; nv.update(EE_pecStatus,pecStatus); } else - if (parameter[1]=='-') { pecStatus=IgnorePEC; nv.update(EE_pecStatus,pecStatus); } else - if ((parameter[1]=='/') && (trackingState==TrackingSidereal)) { pecStatus=ReadyRecordPEC; nv.update(EE_pecStatus,IgnorePEC); } else - if (parameter[1]=='Z') { - for (i=0; imaxStepsPerSecond/StepsPerDegreeAxis1) f=maxStepsPerSecond/StepsPerDegreeAxis1; + if (¶meter[0] != conv_end) { + if (f < 1.0/60.0/60.0) f=1.0/60.0/60.0; + if (f > maxStepsPerSecond/AXIS1_STEPS_PER_DEGREE) f=maxStepsPerSecond/AXIS1_STEPS_PER_DEGREE; customGuideRateAxis1(f*240.0,GUIDE_TIME_LIMIT*1000); } quietReply=true; } else // :REdd.d# Set Axis2 Guide rate to dd.d degrees per second // Returns: Nothing - if (command[1]=='E') { + if (command[1] == 'E') { f=strtod(parameter,&conv_end); double maxStepsPerSecond=1000000.0/(maxRate/16.0); - if (¶meter[0]!=conv_end) { - if (f<1.0/60.0/60.0) f=1.0/60.0/60.0; - if (f>maxStepsPerSecond/StepsPerDegreeAxis2) f=maxStepsPerSecond/StepsPerDegreeAxis2; + if (¶meter[0] != conv_end) { + if (f < 1.0/60.0/60.0) f=1.0/60.0/60.0; + if (f > maxStepsPerSecond/AXIS2_STEPS_PER_DEGREE) f=maxStepsPerSecond/AXIS2_STEPS_PER_DEGREE; customGuideRateAxis2(f*240.0,GUIDE_TIME_LIMIT*1000); } quietReply=true; @@ -1422,43 +1422,43 @@ void processCommands() { // :RS# Set Slew rate to Half Max (VF) ?X (1/2 of maxRate) // :Rn# Set Slew rate to n, where n=0..9 // Returns: Nothing - if ((command[1]=='G') || (command[1]=='C') || (command[1]=='M') || (command[1]=='S') || ((command[1]>='0') && (command[1]<='9'))) { - if (command[1]=='G') i=2; else // 1x - if (command[1]=='C') i=5; else // 8x - if (command[1]=='M') i=6; else // 20x - if (command[1]=='F') i=7; else // 48x - if (command[1]=='S') i=8; else i=command[1]-'0'; // typically 240x to 480x can be as low as 60x + if ((command[1] == 'G') || (command[1] == 'C') || (command[1] == 'M') || (command[1] == 'S') || ((command[1] >= '0') && (command[1] <= '9'))) { + if (command[1] == 'G') i=2; else // 1x + if (command[1] == 'C') i=5; else // 8x + if (command[1] == 'M') i=6; else // 20x + if (command[1] == 'F') i=7; else // 48x + if (command[1] == 'S') i=8; else i=command[1]-'0'; // typically 240x to 480x can be as low as 60x setGuideRate(i); quietReply=true; } else commandError=true; } else -#ifdef ROTATOR_ON +#if ROTATOR == ON // r - Rotator/De-rotator Commands - if (command[0]=='r') { -#ifdef MOUNT_TYPE_ALTAZM + if (command[0] == 'r') { +#if MOUNT_TYPE == ALTAZM // :r+# Enable derotator // Returns: Nothing - if (command[1]=='+') { rot.enableDR(true); quietReply=true; } else + if (command[1] == '+') { rot.enableDR(true); quietReply=true; } else // :r-# Disable derotator // Returns: Nothing - if (command[1]=='-') { rot.enableDR(false); quietReply=true; } else + if (command[1] == '-') { rot.enableDR(false); quietReply=true; } else // :rP# Move rotator to the parallactic angle // Returns: Nothing - if (command[1]=='P') { double h,d; getApproxEqu(&h,&d,true); rot.setPA(h,d); quietReply=true; } else + if (command[1] == 'P') { double h,d; getApproxEqu(&h,&d,true); rot.setPA(h,d); quietReply=true; } else // :rR# Reverse derotator direction // Returns: Nothing - if (command[1]=='R') { rot.reverseDR(); quietReply=true; } else + if (command[1] == 'R') { rot.reverseDR(); quietReply=true; } else #endif // :rF# Reset rotator at the home position // Returns: Nothing - if (command[1]=='F') { rot.reset(); quietReply=true; } else + if (command[1] == 'F') { rot.reset(); quietReply=true; } else // :rC# Moves rotator to the home position // Returns: Nothing - if (command[1]=='C') { rot.home(); quietReply=true; } else + if (command[1] == 'C') { rot.home(); quietReply=true; } else // :rG# Get rotator current position in degrees // Returns: sDDD*MM# - if (command[1]=='G') { + if (command[1] == 'G') { f1=rot.getPosition(); i=highPrecision; highPrecision=false; if (!doubleToDms(reply,&f1,true,true)) commandError=true; else quietReply=true; @@ -1466,27 +1466,27 @@ void processCommands() { } else // :rc# Set continuous move mode (for next move command) // Returns: Nothing - if (command[1]=='c') { rot.moveContinuous(true); quietReply=true; } else + if (command[1] == 'c') { rot.moveContinuous(true); quietReply=true; } else // :r># Move clockwise as set by :rn# command, default = 1 deg (or 0.1 deg/s in continuous mode) // Returns: Nothing - if (command[1]=='>') { rot.startMoveCW(); quietReply=true; } else + if (command[1] == '>') { rot.startMoveCW(); quietReply=true; } else // :r<# Move counter clockwise as set by :rn# command // Returns: Nothing - if (command[1]=='<') { rot.startMoveCCW(); quietReply=true; } else + if (command[1] == '<') { rot.startMoveCCW(); quietReply=true; } else // :rQ# Stops movement (except derotator) // Returns: Nothing - if (command[1]=='Q') { rot.stopMove(); rot.moveContinuous(false); quietReply=true; } else + if (command[1] == 'Q') { rot.stopMove(); rot.moveContinuous(false); quietReply=true; } else // :rn# Move increment, 1=1 degrees, 2=2 degrees, 3=5 degrees, 4=10 degrees // Move rate , 1=.01 deg/s, 2=0.1 deg/s, 3=1.0 deg/s, 4=5.0 deg/s // Returns: Nothing - if ((command[1]>='1') && (command[1]<='4')) { i=command[1]-'1'; int t[]={1,2,5,10}; double t1[]={0.01,0.1,1.0,5.0}; rot.setIncrement(t[i]); rot.setMoveRate(t1[i]); quietReply=true; } else + if ((command[1] >= '1') && (command[1] <= '4')) { i=command[1]-'1'; int t[]={1,2,5,10}; double t1[]={0.01,0.1,1.0,5.0}; rot.setIncrement(t[i]); rot.setMoveRate(t1[i]); quietReply=true; } else // :rSsDDD*MM'SS# Set position // Return: 0 on failure // 1 on success - if (command[1]=='S') { + if (command[1] == 'S') { i=highPrecision; highPrecision=true; - if (parameter[0]=='-') f=-1.0; else f=1.0; - if ((parameter[0]=='+') || (parameter[0]=='-')) i1=1; else i1=0; + if (parameter[0] == '-') f=-1.0; else f=1.0; + if ((parameter[0] == '+') || (parameter[0] == '-')) i1=1; else i1=0; if (!dmsToDouble(&f1,¶meter[i1],true)) commandError=true; else rot.setTarget(f*f1); highPrecision=i; } else commandError=true; @@ -1494,19 +1494,19 @@ void processCommands() { #endif // S - Telescope Set Commands - if (command[0]=='S') { + if (command[0] == 'S') { // :SasDD*MM# // Set target object altitude to sDD*MM# or sDD*MM'SS# (based on precision setting) // Returns: // 0 if Object is within slew range, 1 otherwise - if (command[1]=='a') { if (!dmsToDouble(&newTargetAlt,parameter,true)) commandError=true; } else + if (command[1] == 'a') { if (!dmsToDouble(&newTargetAlt,parameter,true)) commandError=true; } else // :SBn# Set Baud Rate n for Serial-0, where n is an ASCII digit (1..9) with the following interpertation // 0=115.2K, 1=56.7K, 2=38.4K, 3=28.8K, 4=19.2K, 5=14.4K, 6=9600, 7=4800, 8=2400, 9=1200 // Returns: "1" At the current baud rate and then changes to the new rate for further communication - if (command[1]=='B') { + if (command[1] == 'B') { i=(int)(parameter[0]-'0'); - if ((i>=0) && (i<10)) { - if (process_command==COMMAND_SERIAL_A) { + if ((i >= 0) && (i < 10)) { + if (process_command == COMMAND_SERIAL_A) { SerialA.print("1"); #ifdef HAL_SERIAL_TRANSMIT while (SerialA.transmit()); @@ -1515,7 +1515,7 @@ void processCommands() { quietReply=true; #ifdef HAL_SERIAL_B_ENABLED } else - if (process_command==COMMAND_SERIAL_B) { + if (process_command == COMMAND_SERIAL_B) { SerialB.print("1"); #ifdef HAL_SERIAL_TRANSMIT while (SerialB.transmit()); @@ -1525,7 +1525,7 @@ void processCommands() { #endif #if defined(HAL_SERIAL_C_ENABLED) && !defined(HAL_SERIAL_C_BLUETOOTH) } else - if (process_command==COMMAND_SERIAL_C) { + if (process_command == COMMAND_SERIAL_C) { SerialC.print("1"); #ifdef HAL_SERIAL_TRANSMIT while (SerialC.transmit()); @@ -1540,12 +1540,12 @@ 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); updateLST(jd2last(JD,UT1,true)); dateWasSet=true; } else commandError=true; } else + if (command[1] == 'C') { if (dateToDouble(&JD,parameter)) { nv.writeFloat(EE_JD,JD); updateLST(jd2last(JD,UT1,true)); dateWasSet=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 // 1 on success - if (command[1]=='d') { + if (command[1] == 'd') { if (!dmsToDouble(&origTargetDec,parameter,true)) { i=highPrecision; highPrecision=!highPrecision; if (!dmsToDouble(&origTargetDec,parameter,true)) commandError=true; @@ -1553,19 +1553,19 @@ void processCommands() { } } else // :SgsDDD*MM# or :SgDDD*MM# -// Set current sites longitude to sDDD*MM an ASCII position string, East longitudes can be as negative or >180 degrees +// Set current sites longitude to sDDD*MM an ASCII position string, East longitudes can be as negative or > 180 degrees // Return: 0 on failure // 1 on success - if (command[1]=='g') { + if (command[1] == 'g') { i=highPrecision; highPrecision=false; if ((parameter[0] == '-') || (parameter[0] == '+')) i1=1; else i1=0; if (!dmsToDouble(&longitude,(char *)¶meter[i1],false)) commandError=true; else { - if (parameter[0]=='-') longitude=-longitude; - if ((longitude>=-180.0) && (longitude<=360.0)) { - if (longitude>=180.0) longitude-=360.0; + if (parameter[0] == '-') longitude=-longitude; + if ((longitude >= -180.0) && (longitude <= 360.0)) { + if (longitude >= 180.0) longitude-=360.0; nv.writeFloat(EE_sites+(currentSite)*25+4,longitude); } else commandError=true; } @@ -1577,17 +1577,17 @@ void processCommands() { // Set the number of hours added to local time to yield UTC // Return: 0 on failure // 1 on success - if (command[1]=='G') { - if (strlen(parameter)<7) { + if (command[1] == 'G') { + if (strlen(parameter) < 7) { double f=0.0; char *temp=strchr(parameter,':'); if (temp) { - if ((temp[0]==':') && (temp[1]=='4') && temp[2]=='5') { temp[0]=0; f=0.75; } else - if ((temp[0]==':') && (temp[1]=='3') && temp[2]=='0') { temp[0]=0; f=0.5; } else - if ((temp[0]==':') && (temp[1]=='0') && temp[2]=='0') { temp[0]=0; f=0.0; } else { i=-999; } // force error if not :00 or :30 or :45 + if ((temp[0] == ':') && (temp[1] == '4') && temp[2] == '5') { temp[0]=0; f=0.75; } else + if ((temp[0] == ':') && (temp[1] == '3') && temp[2] == '0') { temp[0]=0; f=0.5; } else + if ((temp[0] == ':') && (temp[1] == '0') && temp[2] == '0') { temp[0]=0; f=0.0; } else { i=-999; } // force error if not :00 or :30 or :45 } - if ( (atoi2(parameter,&i)) && ((i>=-24) && (i<=24))) { + if ( (atoi2(parameter,&i)) && ((i >= -24) && (i <= 24))) { if (i<0) timeZone=i-f; else timeZone=i+f; b=encodeTimeZone(timeZone)+128; nv.update(EE_sites+(currentSite)*25+8,b); @@ -1599,14 +1599,14 @@ void processCommands() { // Set the lowest elevation to which the telescope will goTo // Return: 0 on failure // 1 on success - if (command[1]=='h') { if ((parameter[0]!=0) && (strlen(parameter)<4)) { - if ( (atoi2(parameter,&i)) && ((i>=-30) && (i<=30))) { minAlt=i; nv.update(EE_minAlt,minAlt+128); } else commandError=true; + if (command[1] == 'h') { if ((parameter[0] != 0) && (strlen(parameter)<4)) { + if ( (atoi2(parameter,&i)) && ((i >= -30) && (i <= 30))) { minAlt=i; nv.update(EE_minAlt,minAlt+128); } else commandError=true; } else commandError=true; } else // :SLHH:MM:SS# // Set the local Time // Return: 0 on failure // 1 on success - if (command[1]=='L') { + if (command[1] == 'L') { i=highPrecision; highPrecision=true; if (!hmsToDouble(&LMT,parameter)) commandError=true; else { #ifndef ESP32 @@ -1625,19 +1625,19 @@ void processCommands() { // Set site name to be , up to 15 characters. // Return: 0 on failure // 1 on success - if ((command[1]=='M') || (command[1]=='N') || (command[1]=='O') || (command[1]=='P')) { + if ((command[1] == 'M') || (command[1] == 'N') || (command[1] == 'O') || (command[1] == 'P')) { i=command[1]-'M'; - if (strlen(parameter)>15) commandError=true; else nv.writeString(EE_sites+i*25+9,parameter); + if (strlen(parameter) > 15) commandError=true; else nv.writeString(EE_sites+i*25+9,parameter); } else // :SoDD# // Set the overhead elevation limit to DD# // Return: 0 on failure // 1 on success - if (command[1]=='o') { if ((parameter[0]!=0) && (strlen(parameter)<3)) { - if ( (atoi2(parameter,&i)) && ((i>=60) && (i<=90))) { + if (command[1] == 'o') { if ((parameter[0] != 0) && (strlen(parameter)<3)) { + if ( (atoi2(parameter,&i)) && ((i >= 60) && (i <= 90))) { maxAlt=i; -#ifdef MOUNT_TYPE_ALTAZM - if (maxAlt>87) maxAlt=87; +#if MOUNT_TYPE == ALTAZM + if (maxAlt > 87) maxAlt=87; #endif nv.update(EE_maxAlt,maxAlt); } else commandError=true; @@ -1647,7 +1647,7 @@ void processCommands() { // Set target object RA to HH:MM.T or HH:MM:SS based on precision setting, automatically detects low/high precision // Return: 0 on failure // 1 on success - if (command[1]=='r') { + if (command[1] == 'r') { if (!hmsToDouble(&origTargetRA,parameter)) { i=highPrecision; highPrecision=!highPrecision; if (!hmsToDouble(&origTargetRA,parameter)) commandError=true; else origTargetRA*=15.0; @@ -1658,16 +1658,16 @@ 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 updateLST(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 // 1 on success - if (command[1]=='t') { + if (command[1] == 't') { i=highPrecision; highPrecision=false; if (!dmsToDouble(&latitude,parameter,true)) { commandError=true; } else { nv.writeFloat(100+(currentSite)*25+0,latitude); -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM homePositionAxis2=AltAzmDecStartPos; if (latitude<0) homePositionAxis1=180.0; else homePositionAxis1=0.0; #else @@ -1675,21 +1675,21 @@ void processCommands() { #endif cosLat=cos(latitude/Rad); sinLat=sin(latitude/Rad); - if (latitude>0.0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; + if (latitude > 0.0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; } highPrecision=i; } else // :STdd.ddddd# Set Tracking Rate // Return: 0 on failure // 1 on success - if (command[1]=='T') { - if ((trackingState==TrackingSidereal) || (trackingState==TrackingNone)) { + if (command[1] == 'T') { + if ((trackingState == TrackingSidereal) || (trackingState == TrackingNone)) { f=strtod(parameter,&conv_end); - if ( (¶meter[0]!=conv_end) && (((f>=30.0) && (f<90.0)) || (fabs(f)<0.1))) { - if (fabs(f)<0.1) { + if ( (¶meter[0] != conv_end) && (((f >= 30.0) && (f < 90.0)) || (fabs(f) < 0.1))) { + if (fabs(f) < 0.1) { trackingState=TrackingNone; } else { - if (trackingState==TrackingNone) { trackingState=TrackingSidereal; enableStepperDrivers(); } + if (trackingState == TrackingNone) { trackingState=TrackingSidereal; enableStepperDrivers(); } setTrackingRate((f/60.0)/1.00273790935); } } else commandError=true; @@ -1698,9 +1698,9 @@ void processCommands() { // :SXnn,VVVVVV...# Set OnStep value // Return: 0 on failure // 1 on success - if (command[1]=='X') { - if (parameter[2]!=',') { parameter[0]=0; commandError=true; } // make sure command format is correct - if (parameter[0]=='0') { // 0n: Align Model + if (command[1] == 'X') { + if (parameter[2] != ',') { parameter[0]=0; commandError=true; } // make sure command format is correct + if (parameter[0] == '0') { // 0n: Align Model static int star; switch (parameter[1]) { case '0': Align.ax1Cor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // ax1Cor @@ -1709,7 +1709,7 @@ void processCommands() { case '3': Align.azmCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // azmCor case '4': Align.doCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // doCor case '5': Align.pdCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // pdCor -#ifdef MOUNT_TYPE_FORK +#if MOUNT_TYPE == FORK case '6': Align.dfCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // ffCor case '7': break; // dfCor #else @@ -1717,7 +1717,7 @@ void processCommands() { case '7': Align.dfCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // dfCor #endif case '8': Align.tfCor=(double)strtol(¶meter[3],NULL,10)/3600.0; break; // tfCor - case '9': { i=strtol(¶meter[3],NULL,10); if (i==1) { alignNumStars=star; alignThisStar=star+1; Align.model(star); } else star=0; } break; // use 0 to start upload of stars for align, use 1 to trigger align + case '9': { i=strtol(¶meter[3],NULL,10); if (i == 1) { alignNumStars=star; alignThisStar=star+1; Align.model(star); } else star=0; } break; // use 0 to start upload of stars for align, use 1 to trigger align case 'A': { i=highPrecision; highPrecision=true; if (!hmsToDouble(&Align.actual[star].ha,¶meter[3])) commandError=true; else Align.actual[star].ha=(Align.actual[star].ha*15.0)/Rad; highPrecision=i; } break; // Star #n HA case 'B': { i=highPrecision; highPrecision=true; if (!dmsToDouble(&Align.actual[star].dec,¶meter[3],true)) commandError=true; else Align.actual[star].dec=Align.actual[star].dec/Rad; highPrecision=i; } break; // Star #n Dec case 'C': { i=highPrecision; highPrecision=true; if (!hmsToDouble(&Align.mount[star].ha,¶meter[3])) commandError=true; else Align.mount[star].ha=(Align.mount[star].ha*15.0)/Rad; highPrecision=i; } break; // Mount #n HA @@ -1726,32 +1726,32 @@ void processCommands() { default: commandError=true; } } else - if (parameter[0]=='4') { // 4n: Encoder + if (parameter[0] == '4') { // 4n: Encoder switch (parameter[1]) { static double encoderAxis1=0; static double encoderAxis2=0; case '0': // set encoder Axis1 value f=strtod(¶meter[3],&conv_end); - if ( (¶meter[3]!=conv_end) && (f>=-999.9) && (f<=999.9)) encoderAxis1=f; else commandError=true; + if ( (¶meter[3] != conv_end) && (f >= -999.9) && (f <= 999.9)) encoderAxis1=f; else commandError=true; break; case '1': // set encoder Axis2 value f=strtod(¶meter[3],&conv_end); - if ( (¶meter[3]!=conv_end) && (f>=-999.9) && (f<=999.9)) encoderAxis2=f; else commandError=true; + if ( (¶meter[3] != conv_end) && (f >= -999.9) && (f <= 999.9)) encoderAxis2=f; else commandError=true; break; case '2': // sync encoder to last values - if ( (parameter[3]=='1') && (parameter[4]==0)) if (syncEnc(encoderAxis1,encoderAxis2)) commandError=true; + if ( (parameter[3] == '1') && (parameter[4] == 0)) if (syncEnc(encoderAxis1,encoderAxis2)) commandError=true; break; default: commandError=true; } } else - if (parameter[0]=='9') { // 9n: Misc. + if (parameter[0] == '9') { // 9n: Misc. switch (parameter[1]) { case '2': // set new acceleration rate (returns 1 success or 0 failure) if (!isSlewing()) { maxRate=strtod(¶meter[3],&conv_end)*16.0; - if (maxRate<(double)MaxRateDef*8.0) maxRate=(double)MaxRateDef*8.0; - if (maxRate>(double)MaxRateDef*32.0) maxRate=(double)MaxRateDef*32.0; - if (maxRate (double)MaxRateDef*32.0) maxRate=(double)MaxRateDef*32.0; + if (maxRate < maxRateLowerLimit()) maxRate=maxRateLowerLimit(); nv.writeLong(EE_maxRateL,maxRate); setAccelerationRates(maxRate); } else commandError=true; @@ -1773,9 +1773,9 @@ void processCommands() { setAccelerationRates(maxRate); } break; -#ifdef MOUNT_TYPE_GEM +#if MOUNT_TYPE == GEM case '5': // autoMeridianFlip - if ((parameter[3]=='0') || (parameter[3]=='1')) { i=parameter[3]-'0'; autoMeridianFlip=i; nv.write(EE_autoMeridianFlip,autoMeridianFlip); } else commandError=true; + if ((parameter[3] == '0') || (parameter[3] == '1')) { i=parameter[3]-'0'; autoMeridianFlip=i; nv.write(EE_autoMeridianFlip,autoMeridianFlip); } else commandError=true; break; #endif case '6': // preferred pier side @@ -1787,140 +1787,138 @@ void processCommands() { } break; case '7': // buzzer - if ((parameter[3]=='0') || (parameter[3]=='1')) { soundEnabled=parameter[3]-'0'; } else commandError=true; + if ((parameter[3] == '0') || (parameter[3] == '1')) { soundEnabled=parameter[3]-'0'; } else commandError=true; break; case '8': // pause at home on meridian flip - if ((parameter[3]=='0') || (parameter[3]=='1')) { pauseHome=parameter[3]-'0'; nv.write(EE_pauseHome,pauseHome); } else commandError=true; + if ((parameter[3] == '0') || (parameter[3] == '1')) { pauseHome=parameter[3]-'0'; nv.write(EE_pauseHome,pauseHome); } else commandError=true; break; case '9': // continue if paused at home - if ((parameter[3]=='1')) { if (waitingHome) waitingHomeContinue=true; } commandError=true; + if ((parameter[3] == '1')) { if (waitingHome) waitingHomeContinue=true; } commandError=true; break; case 'A': // temperature in deg. C f=strtod(parameter,&conv_end); - if ( (¶meter[0]!=conv_end) && (f>=-100.0) && (f<100.0)) { + if ( (¶meter[0] != conv_end) && (f >= -100.0) && (f < 100.0)) { ambient.setTemperature(f); } else commandError=true; break; case 'B': // pressure in mb f=strtod(parameter,&conv_end); - if ( (¶meter[0]!=conv_end) && (f>=500.0) && (f<1500.0)) { + if ( (¶meter[0] != conv_end) && (f >= 500.0) && (f < 1500.0)) { ambient.setPressure(f); } else commandError=true; break; case 'C': // relative humidity in % - if ( (¶meter[0]!=conv_end) && (f>=0.0) && (f<100.0)) { + if ( (¶meter[0] != conv_end) && (f >= 0.0) && (f < 100.0)) { ambient.setHumidity(f); } else commandError=true; break; case 'D': // altitude - if ( (¶meter[0]!=conv_end) && (f>=0.0) && (f<100.0)) { + if ( (¶meter[0] != conv_end) && (f >= 0.0) && (f < 100.0)) { ambient.setAltitude(f); } else commandError=true; break; default: commandError=true; } } else -#ifdef MOUNT_TYPE_GEM - if (parameter[0]=='E') { // En: Simple value +#if MOUNT_TYPE == GEM + if (parameter[0] == 'E') { // En: Simple value switch (parameter[1]) { - case '9': // minutesPastMeridianE - minutesPastMeridianE=(double)strtol(¶meter[3],NULL,10); - if (minutesPastMeridianE>180) minutesPastMeridianE=180; - if (minutesPastMeridianE<-180) minutesPastMeridianE=-180; - nv.write(EE_dpmE,round((minutesPastMeridianE*15.0)/60.0)+128); + case '9': // minutes past meridianE + degreesPastMeridianE=(double)strtol(¶meter[3],NULL,10)/4.0; + if (degreesPastMeridianE > 180) degreesPastMeridianE=180; + if (degreesPastMeridianE < -180) degreesPastMeridianE=-180; + nv.write(EE_dpmE,round(degreesPastMeridianE+128)); break; - case 'A': // minutesPastMeridianW - minutesPastMeridianW=(double)strtol(¶meter[3],NULL,10); - if (minutesPastMeridianW>180) minutesPastMeridianW=180; - if (minutesPastMeridianW<-180) minutesPastMeridianW=-180; - nv.write(EE_dpmW,round((minutesPastMeridianW*15.0)/60.0)+128); + case 'A': // minutes past meridianW + degreesPastMeridianW=(double)strtol(¶meter[3],NULL,10)/4.0; + if (degreesPastMeridianW > 180) degreesPastMeridianW=180; + if (degreesPastMeridianW < -180) degreesPastMeridianW=-180; + nv.write(EE_dpmW,round(degreesPastMeridianW+128)); break; default: commandError=true; } } else #endif - if (parameter[0]=='G') { // Gn: General purpose output + if (parameter[0] == 'G') { // Gn: General purpose output long v=(double)strtol(¶meter[3],NULL,10); - if ((v>=0) && (v<=255)) { + if ((v >= 0) && (v <= 255)) { #ifdef Aux0 - if (parameter[1]=='0') { valueAux0=v; static bool init=false; if (!init) { pinMode(Aux0,OUTPUT); init=true; } if (v==0) digitalWrite(Aux0,LOW); else digitalWrite(Aux0,HIGH); } else + if (parameter[1] == '0') { valueAux0=v; static bool init=false; if (!init) { pinMode(Aux0,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux0,LOW); else digitalWrite(Aux0,HIGH); } else #endif -#ifndef MODE_SWITCH_BEFORE_SLEW_SPI #ifdef Aux1 - if (parameter[1]=='1') { valueAux1=v; static bool init=false; if (!init) { pinMode(Aux1,OUTPUT); init=true; } if (v==0) digitalWrite(Aux1,LOW); else digitalWrite(Aux1,HIGH); } else + if (parameter[1] == '1') { valueAux1=v; static bool init=false; if (!init) { pinMode(Aux1,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux1,LOW); else digitalWrite(Aux1,HIGH); } else #endif #ifdef Aux2 - if (parameter[1]=='2') { valueAux2=v; static bool init=false; if (!init) { pinMode(Aux2,OUTPUT); init=true; } if (v==0) digitalWrite(Aux2,LOW); else digitalWrite(Aux2,HIGH); } else -#endif + if (parameter[1] == '2') { valueAux2=v; static bool init=false; if (!init) { pinMode(Aux2,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux2,LOW); else digitalWrite(Aux2,HIGH); } else #endif #ifdef Aux3 - if (parameter[1]=='3') { valueAux3=v; static bool init=false; if (!init) { pinMode(Aux3,OUTPUT); init=true; } + if (parameter[1] == '3') { valueAux3=v; static bool init=false; if (!init) { pinMode(Aux3,OUTPUT); init=true; } #ifdef Aux3_Analog analogWrite(Aux3,v); } else #else - if (v==0) digitalWrite(Aux3,LOW); else digitalWrite(Aux3,HIGH); } else + if (v == 0) digitalWrite(Aux3,LOW); else digitalWrite(Aux3,HIGH); } else #endif #endif #ifdef Aux4 - if (parameter[1]=='4') { valueAux4=v; static bool init=false; if (!init) { pinMode(Aux4,OUTPUT); init=true; } + if (parameter[1] == '4') { valueAux4=v; static bool init=false; if (!init) { pinMode(Aux4,OUTPUT); init=true; } #ifdef Aux4_Analog analogWrite(Aux4,v); } else #else - if (v==0) digitalWrite(Aux4,LOW); else digitalWrite(Aux4,HIGH); } else + if (v == 0) digitalWrite(Aux4,LOW); else digitalWrite(Aux4,HIGH); } else #endif #endif #ifdef Aux5 - if (parameter[1]=='5') { valueAux5=v; static bool init=false; if (!init) { pinMode(Aux5,OUTPUT); init=true; } + if (parameter[1] == '5') { valueAux5=v; static bool init=false; if (!init) { pinMode(Aux5,OUTPUT); init=true; } #ifdef Aux5_Analog analogWrite(Aux5,v); } else #else - if (v==0) digitalWrite(Aux5,LOW); else digitalWrite(Aux5,HIGH); } else + if (v == 0) digitalWrite(Aux5,LOW); else digitalWrite(Aux5,HIGH); } else #endif #endif #ifdef Aux6 - if (parameter[1]=='6') { valueAux6=v; static bool init=false; if (!init) { pinMode(Aux6,OUTPUT); init=true; } + if (parameter[1] == '6') { valueAux6=v; static bool init=false; if (!init) { pinMode(Aux6,OUTPUT); init=true; } #ifdef Aux6_Analog analogWrite(Aux6,v); } else #else - if (v==0) digitalWrite(Aux6,LOW); else digitalWrite(Aux6,HIGH); } else + if (v == 0) digitalWrite(Aux6,LOW); else digitalWrite(Aux6,HIGH); } else #endif #endif #ifdef Aux7 - if (parameter[1]=='7') { valueAux7=v; static bool init=false; if (!init) { pinMode(Aux7,OUTPUT); init=true; } + if (parameter[1] == '7') { valueAux7=v; static bool init=false; if (!init) { pinMode(Aux7,OUTPUT); init=true; } #ifdef Aux7_Analog analogWrite(Aux7,v); } else #else - if (v==0) digitalWrite(Aux7,LOW); else digitalWrite(Aux7,HIGH); } else + if (v == 0) digitalWrite(Aux7,LOW); else digitalWrite(Aux7,HIGH); } else #endif #endif #ifdef Aux8 - if (parameter[1]=='8') { valueAux8=v; static bool init=false; if (!init) { pinMode(Aux8,OUTPUT); init=true; } + if (parameter[1] == '8') { valueAux8=v; static bool init=false; if (!init) { pinMode(Aux8,OUTPUT); init=true; } #ifdef Aux8_Analog analogWrite(Aux8,v); } else #else - if (v==0) digitalWrite(Aux8,LOW); else digitalWrite(Aux8,HIGH); } else + if (v == 0) digitalWrite(Aux8,LOW); else digitalWrite(Aux8,HIGH); } else #endif #endif #ifdef Aux9 - if (parameter[1]=='9') { valueAux9=v; static bool init=false; if (!init) { pinMode(Aux9,OUTPUT); init=true; } if (v==0) digitalWrite(Aux9,LOW); else digitalWrite(Aux9,HIGH); } else + if (parameter[1] == '9') { valueAux9=v; static bool init=false; if (!init) { pinMode(Aux9,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux9,LOW); else digitalWrite(Aux9,HIGH); } else #endif #ifdef Aux10 - if (parameter[1]=='A') { valueAux10=v; static bool init=false; if (!init) { pinMode(Aux10,OUTPUT); init=true; } if (v==0) digitalWrite(Aux10,LOW); else digitalWrite(Aux10,HIGH); } else + if (parameter[1] == 'A') { valueAux10=v; static bool init=false; if (!init) { pinMode(Aux10,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux10,LOW); else digitalWrite(Aux10,HIGH); } else #endif #ifdef Aux11 - if (parameter[1]=='B') { valueAux11=v; static bool init=false; if (!init) { pinMode(Aux11,OUTPUT); init=true; } if (v==0) digitalWrite(Aux11,LOW); else digitalWrite(Aux11,HIGH); } else + if (parameter[1] == 'B') { valueAux11=v; static bool init=false; if (!init) { pinMode(Aux11,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux11,LOW); else digitalWrite(Aux11,HIGH); } else #endif #ifdef Aux12 - if (parameter[1]=='C') { valueAux12=v; static bool init=false; if (!init) { pinMode(Aux12,OUTPUT); init=true; } if (v==0) digitalWrite(Aux12,LOW); else digitalWrite(Aux12,HIGH); } else + if (parameter[1] == 'C') { valueAux12=v; static bool init=false; if (!init) { pinMode(Aux12,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux12,LOW); else digitalWrite(Aux12,HIGH); } else #endif #ifdef Aux13 - if (parameter[1]=='D') { valueAux13=v; static bool init=false; if (!init) { pinMode(Aux13,OUTPUT); init=true; } if (v==0) digitalWrite(Aux13,LOW); else digitalWrite(Aux13,HIGH); } else + if (parameter[1] == 'D') { valueAux13=v; static bool init=false; if (!init) { pinMode(Aux13,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux13,LOW); else digitalWrite(Aux13,HIGH); } else #endif #ifdef Aux14 - if (parameter[1]=='E') { valueAux14=v; static bool init=false; if (!init) { pinMode(Aux14,OUTPUT); init=true; } if (v==0) digitalWrite(Aux14,LOW); else digitalWrite(Aux14,HIGH); } else + if (parameter[1] == 'E') { valueAux14=v; static bool init=false; if (!init) { pinMode(Aux14,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux14,LOW); else digitalWrite(Aux14,HIGH); } else #endif #ifdef Aux15 - if (parameter[1]=='F') { valueAux15=v; static bool init=false; if (!init) { pinMode(Aux15,OUTPUT); init=true; } if (v==0) digitalWrite(Aux15,LOW); else digitalWrite(Aux15,HIGH); } else + if (parameter[1] == 'F') { valueAux15=v; static bool init=false; if (!init) { pinMode(Aux15,OUTPUT); init=true; } if (v == 0) digitalWrite(Aux15,LOW); else digitalWrite(Aux15,HIGH); } else #endif commandError=true; } else commandError=true; @@ -1930,7 +1928,7 @@ void processCommands() { // Sets the target Object Azimuth // Return: 0 on failure // 1 on success - if (command[1]=='z') { if (!dmsToDouble(&newTargetAzm,parameter,false)) commandError=true; } else commandError=true; + if (command[1] == 'z') { if (!dmsToDouble(&newTargetAzm,parameter,false)) commandError=true; } else commandError=true; } else // T - Tracking Commands // @@ -1953,35 +1951,35 @@ void processCommands() { // Return: 0 on failure // 1 on success - if ((command[0]=='T') && (parameter[0]==0)) { -#ifndef MOUNT_TYPE_ALTAZM + if ((command[0] == 'T') && (parameter[0] == 0)) { +#if 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]=='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]=='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() ) { lastError=ERR_NONE; trackingState=TrackingSidereal; enableStepperDrivers(); } else - if ((command[1]=='d') && !isSlewing() && !isHoming() ) trackingState=TrackingNone; else + 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] == '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() ) { lastError=ERR_NONE; trackingState=TrackingSidereal; enableStepperDrivers(); } else + if ((command[1] == 'd') && !isSlewing() && !isHoming() ) trackingState=TrackingNone; else commandError=true; -#ifndef MOUNT_TYPE_ALTAZM - if (dualAxis && (rateCompensation==RC_REFR_RA)) rateCompensation=RC_REFR_BOTH; - if (!dualAxis && (rateCompensation==RC_REFR_BOTH)) rateCompensation=RC_REFR_RA; - if (dualAxis && (rateCompensation==RC_FULL_RA)) rateCompensation=RC_FULL_BOTH; - if (!dualAxis && (rateCompensation==RC_FULL_BOTH)) rateCompensation=RC_FULL_RA; +#if MOUNT_TYPE != ALTAZM + if (dualAxis && (rateCompensation == RC_REFR_RA)) rateCompensation=RC_REFR_BOTH; + if (!dualAxis && (rateCompensation == RC_REFR_BOTH)) rateCompensation=RC_REFR_RA; + if (dualAxis && (rateCompensation == RC_FULL_RA)) rateCompensation=RC_FULL_BOTH; + if (!dualAxis && (rateCompensation == RC_FULL_BOTH)) rateCompensation=RC_FULL_RA; #endif // Only burn the new rate if changing the sidereal interval - if ((!commandError) && ((command[1]=='+') || (command[1]=='-') || (command[1]=='R'))) { + if ((!commandError) && ((command[1] == '+') || (command[1] == '-') || (command[1] == 'R'))) { nv.writeLong(EE_siderealInterval,siderealInterval); SiderealClockSetInterval(siderealInterval); cli(); SiderealRate=siderealInterval/StepsPerSecondAxis1; sei(); @@ -1990,7 +1988,7 @@ void processCommands() { setDeltaTrackingRate(); } else - if (command[0]=='T') { + if (command[0] == 'T') { } else // U - Precision Toggle @@ -1998,21 +1996,21 @@ void processCommands() { // Low - RA/Dec/etc. displays and accepts HH:MM.M sDD*MM // High - RA/Dec/etc. displays and accepts HH:MM:SS sDD*MM:SS // Returns Nothing - if ((command[0]=='U') && (command[1]==0)) { highPrecision=!highPrecision; quietReply=true; } else + if ((command[0] == 'U') && (command[1] == 0)) { highPrecision=!highPrecision; quietReply=true; } else -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM // V - PEC Readout // :VRNNNN# // Read out RA PEC Table Entry // Returns: sDDD# // Rate Adjustment factor for worm segment NNNN. PecRate = Steps +/- for this 1 second segment // If NNNN is omitted, returns the currently playing segment - if ((command[0]=='V') && (command[1]=='R')) { + if ((command[0] == 'V') && (command[1] == 'R')) { boolean conv_result=true; - if (parameter[0]==0) { i=pecIndex1; } else conv_result=atoi2(parameter,&i); - if ((conv_result) && ((i>=0) && (i=SecondsPerWormRotationAxis1) i-=SecondsPerWormRotationAxis1; + if (parameter[0] == 0) { i=pecIndex1; } else conv_result=atoi2(parameter,&i); + if ((conv_result) && ((i >= 0) && (i < pecBufferSize))) { + if (parameter[0] == 0) { + i-=1; if (i < 0) i+=SecondsPerWormRotationAxis1; if (i >= SecondsPerWormRotationAxis1) i-=SecondsPerWormRotationAxis1; i1=pecBuffer[i]-128; sprintf(reply,"%+04i,%03i",i1,i); } else { i1=pecBuffer[i]-128; sprintf(reply,"%+04i",i1); @@ -2025,13 +2023,13 @@ void processCommands() { // Returns: x0x1x2x3x4x5x6x7x8x9# // Rate Adjustment factor for worm segments. PecRate = Steps +/- for each 1 second segment, hex one byte integer (PecRate=b-128) // leave a delay of about 10ms between calls - if ((command[0]=='V') && (command[1]=='r')) { - if ( (atoi2(parameter,&i)) && ((i>=0) && (i= 0) && (i < pecBufferSize))) { int j=0; byte b; char x[3]=" "; - for (j=0; j<10; j++) { - if (i+jSecondsPerWormRotationAxis1) s-=SecondsPerWormRotationAxis1; - while (s<0) s+=SecondsPerWormRotationAxis1; + while (s > SecondsPerWormRotationAxis1) s-=SecondsPerWormRotationAxis1; + while (s < 0) s+=SecondsPerWormRotationAxis1; sprintf(reply,"%05ld",s); // indexWorm_sense quietReply=true; } else // :VI# // Read RA PEC record index start (steps) // Returns: DDDDDD# - if ((command[0]=='V') && (command[1]=='I')) { + if ((command[0] == 'V') && (command[1] == 'I')) { sprintf(reply,"%06ld",0L); // indexWorm_record quietReply=true; } else // :WIDDDDDD# // Write RA PEC index start (steps) - if ((command[0]=='W') && (command[1]=='I')) { + if ((command[0] == 'W') && (command[1] == 'I')) { commandError=true; long l=strtol(parameter,&conv_end,10); // see if it converted and is in range - if ( (¶meter[0]!=conv_end) && ((l>=0) && (l<(long)StepsPerWormRotationAxis1))) { + if ( (¶meter[0] != conv_end) && ((l >= 0) && (l < (long)AXIS1_STEPS_PER_WORMROT))) { // ignored commandError=false; } @@ -2098,16 +2096,16 @@ void processCommands() { // Write RA PEC Table Entry // Returns: Nothing // Rate Adjustment factor for worm segment NNNN. PecRate = Steps +/- for this 1 second segment - if ((command[0]=='W') && (command[1]=='R')) { + if ((command[0] == 'W') && (command[1] == 'R')) { commandError=true; - if (parameter[1]==0) { - if (parameter[0]=='+') { + if (parameter[1] == 0) { + if (parameter[0] == '+') { i=pecBuffer[SecondsPerWormRotationAxis1-1]; memmove((byte *)&pecBuffer[1],(byte *)&pecBuffer[0],SecondsPerWormRotationAxis1-1); pecBuffer[0]=i; commandError=false; } else - if (parameter[0]=='-') { + if (parameter[0] == '-') { i=pecBuffer[0]; memmove((byte *)&pecBuffer[0],(byte *)&pecBuffer[1],SecondsPerWormRotationAxis1-1); pecBuffer[SecondsPerWormRotationAxis1-1]=i; @@ -2117,11 +2115,11 @@ void processCommands() { // it should be an int // see if it converted and is in range i=atoi(parameter); - if ((i>=0) && (i= 0) && (i < pecBufferSize)) { // should be another int here // see if it converted and is in range i2=atoi((char*)¶meter[5]); - if ((i2>=-128) && (i2<=127)) { + if ((i2 >= -128) && (i2 <= 127)) { pecBuffer[i]=i2+128; pecRecorded =true; commandError=false; @@ -2136,23 +2134,23 @@ void processCommands() { // :Wn# // Sets current site to n, 0..3 or queries site with ? // Returns: Nothing or current site ?# - if (command[0]=='W') { - if ((command[1]>='0') && (command[1]<='3')) { + if (command[0] == 'W') { + if ((command[1] >= '0') && (command[1] <= '3')) { currentSite=command[1]-'0'; nv.update(EE_currentSite,currentSite); quietReply=true; latitude=nv.readFloat(EE_sites+(currentSite*25+0)); -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM homePositionAxis2=AltAzmDecStartPos; #else - if (latitude<0.0) homePositionAxis2=-90.0; else homePositionAxis2=90.0; + if (latitude < 0.0) homePositionAxis2=-90.0; else homePositionAxis2=90.0; #endif cosLat=cos(latitude/Rad); sinLat=sin(latitude/Rad); - if (latitude>0.0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; + if (latitude > 0.0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; longitude=nv.readFloat(EE_sites+(currentSite*25+4)); timeZone=nv.read(EE_sites+(currentSite)*25+8)-128; timeZone=decodeTimeZone(timeZone); } else - if (command[1]=='?') { + if (command[1] == '?') { quietReply=true; sprintf(reply,"%i",currentSite); } else @@ -2166,8 +2164,8 @@ void processCommands() { supress_frame=true; } - if ((strlen(reply)>0) || (cmdA.checksum)) { - if (process_command==COMMAND_SERIAL_A) { + if ((strlen(reply) > 0) || (cmdA.checksum)) { + if (process_command == COMMAND_SERIAL_A) { if (cmdA.checksum) { checksum(reply); strcat(reply,cmdA.getSeq()); supress_frame=false; } if (!supress_frame) strcat(reply,"#"); SerialA.print(reply); @@ -2175,8 +2173,8 @@ void processCommands() { } #ifdef HAL_SERIAL_B_ENABLED - if ((strlen(reply)>0) || (cmdB.checksum)) { - if (process_command==COMMAND_SERIAL_B) { + if ((strlen(reply) > 0) || (cmdB.checksum)) { + if (process_command == COMMAND_SERIAL_B) { if (cmdB.checksum) { checksum(reply); strcat(reply,cmdB.getSeq()); supress_frame=false; } if (!supress_frame) strcat(reply,"#"); @@ -2184,7 +2182,7 @@ void processCommands() { // simulate data corruption static int se=0; se++; - if (se==22) { se=0; reply[2]='x'; } + if (se == 22) { se=0; reply[2]='x'; } */ SerialB.print(reply); @@ -2193,8 +2191,8 @@ void processCommands() { #endif #ifdef HAL_SERIAL_C_ENABLED - if ((strlen(reply)>0) || (cmdC.checksum)) { - if (process_command==COMMAND_SERIAL_C) { + if ((strlen(reply) > 0) || (cmdC.checksum)) { + if (process_command == COMMAND_SERIAL_C) { if (cmdC.checksum) { checksum(reply); strcat(reply,cmdC.getSeq()); supress_frame=false; } if (!supress_frame) strcat(reply,"#"); SerialC.print(reply); @@ -2202,9 +2200,9 @@ void processCommands() { } #endif -#ifdef ST4_HAND_CONTROL_ON - if ((strlen(reply)>0) || (cmdST4.checksum)) { - if (process_command==COMMAND_SERIAL_ST4) { +#if ST4_HAND_CONTROL == ON + if ((strlen(reply) > 0) || (cmdST4.checksum)) { + if (process_command == COMMAND_SERIAL_ST4) { if (cmdST4.checksum) { checksum(reply); strcat(reply,cmdST4.getSeq()); supress_frame=false; } if (!supress_frame) strcat(reply,"#"); SerialST4.print(reply); @@ -2212,8 +2210,8 @@ void processCommands() { } #endif - if ((strlen(reply)>0) || (cmdX.checksum)) { - if (process_command==COMMAND_SERIAL_X) { + if ((strlen(reply) > 0) || (cmdX.checksum)) { + if (process_command == COMMAND_SERIAL_X) { if (cmdX.checksum) { checksum(reply); strcat(reply,cmdX.getSeq()); supress_frame=false; } if (!supress_frame) strcat(reply,"#"); strcpy(_replyX,reply); @@ -2224,17 +2222,17 @@ void processCommands() { } void stopMount() { - if ((parkStatus==NotParked) || (parkStatus==Parking)) { + if ((parkStatus == NotParked) || (parkStatus == Parking)) { stopGuideAxis1(); stopGuideAxis2(); - if (trackingState==TrackingMoveTo) if (!abortSlew) abortSlew=StartAbortSlew; + if (trackingState == TrackingMoveTo) if (!abortSlew) abortSlew=StartAbortSlew; } } // calculate the checksum and add to string void checksum(char s[]) { char HEXS[3]=""; - byte cks=0; for (unsigned int cksCount0=0; cksCount0 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_OFF -// ST4_ALTERNATE_PINS_ON moves the interface (Mega2560 only) to pins 43, 45, 47, 49. Pin 43 is Dec- (South), Pin 45 is Dec+ (North), Pin 47 is RA- (West), Pin 49 is RA+ (East.) -// ST4_ALTERNATE_PINS_ON is required for Steve's ST4 board and is also required if the ST4 interface is to be used alongside the SPI interface. -#define ST4_ALTERNATE_PINS_OFF - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// RTC (Real Time Clock) support, default=_OFF. Other options: RTC_DS3234 for a DS3234 on the default SPI interface (and CS on pin 10, optionally wire the SQW output to the PPS pin below.) -#define RTC_OFF -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on pin 21 for optional precision clock source (GPS, for example), default=_OFF (Teensy3.x Pin 23) -#define PPS_SENSE_OFF - -// PEC sense on pin 2 or threshold value on Analog 1 (Analog 14 on Teensy3.x) use _ON or _PULLUP to enable the input and use the built-in pullup resistor, default=_OFF -// analog values range from 0 to 1023 which indicate voltages from 0-5VDC (or 0-3.3VDC) on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 2.92V (or 1.93V) -// with either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge) on pin 2 (ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on pin 3 for optional limit sense (stops gotos and/or tracking), default=_OFF -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground (pin 9) and source +5V (pin 8), default=_ON -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_OFF -// Light 2nd status LED by sink to ground (pin 10), default=_OFF, must be off for Teensy3.x (pin 7) -// _ON sets this to blink at 1 sec intervals when PPS is synced -// n sets this to dimly light a polar finder reticle, for example I use STATUS_LED2_PINS 250 -// The default SPI device CS is at pin 10 also, so if the SPI interface is used this must be _OFF -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground (pin 44), default=_OFF. Defaults to pin 9 on the Teensy3.x (STATUS_LED_PINS must be _ON) -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on pin 42, default=_OFF. (Teensy3.x Pin 29) -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Te# and :Td# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // the EM10b has two spur gears that drive the RA/Dec worms, they give an additional 1.25:1 reduction - // in addition to the 18:1 gear heads on the steppers for a 22.5:1 final ratio before the worm/wheels at 144:1 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 360 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - // Axis3 is optional and for a rotator/de-rotator - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 13,11 = Step,Dir (RA/Azm) (Teensy3.x Pins 12,10) -// Axis2: Pins 6,4 = Step,Dir (Dec/Alt) (Teensy3.x Pins 6,4) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default _OFF. -#define STEP_WAVE_FORM_OFF - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins 25 (Axis1) and 30 (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. (Teensy3.x Pins 16,21) -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 22,23,24 for Axis1 (RA/Azm) (Teensy3.x Pins 13,14,15.) M0, M1, M2 are on Pins 27,28,29 for Axis2 (Dec/Alt) (Teensy3.x Pins 18,19,20.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pins 26 (Aux1) and 31 (Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// other settings are LOW, HIGH, TMC_SPI (if available applies internal pullup if LOW and pulldown if HIGH.) Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// A9,A8 = Step,Dir (Teensy3.x 30,33 choose either this option or the second focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed Axis3 rotator, default = -180 -#define MaxAxis3 180 // maximum allowed Axis3 rotator, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// A11,A10 = Step,Dir (Teensy3.2 pins 31,32) (Teensy3.5/3.6 pins 34,35) -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means -#define MinAxis4 -25.0 // minimum allowed Axis4 position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed Axis4 position in millimeters, default = 25.0 -#define AXIS4_REVERSE_OFF // reverse the direction of Axis4 focuser movement - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// A13,A12 = Step,Dir (Teensy3.x pins 30,33 choose either this option or the rotator, not both) -#define FOCUSER2_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means -#define MinAxis5 -25.0 // minimum allowed Axis5 position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed Axis5 position in millimeters, default = 25.0 -#define AXIS5_REVERSE_OFF // reverse the direction of Axis4 focuser movement - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.Classic.h" -#endif diff --git a/Config.MaxESP.h b/Config.MaxESP.h deleted file mode 100644 index 198f144e8..000000000 --- a/Config.MaxESP.h +++ /dev/null @@ -1,246 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep MaxESP (ESP32S) version 2 - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.MaxESP2.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define MaxESP2_OFF // <- Turn _ON to use this configuration *** NOT for the MaxESP version 1.x (see "~\OnStep\other-configurations") *** - -// ESP32 Release 1.0.0 Notes: -// The stock BluetoothSerial.h library doesn't work: -// Copy the latest BluetoothSerial library (just its folder) from https://github.com/espressif/arduino-esp32 into -// C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries -// The stock Wire.h library doesn't work: -// Copy the latest Wire.h library file (only) from ~\OnStep\src\HAL\HAL_ESP32 into -// C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src - -// ESP32 Release 1.0.1 and 1.0.2 Notes: -// The stock BluetoothSerial.h library doesn't, I know of no solution for this -// The stock Wire.h library appears to work properly - -#ifdef MaxESP2_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial2 com port, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 -// For an ESP32 SerialC is the Bluetooth port so use a name instead of a baud "ONSTEP", etc. -#define SERIAL_C_BAUD_DEFAULT_OFF - -// Mount type, default is _GEM (German Equatorial.) This allows Meridian flips and can be used for other mount types if that behaviour is desired. _FORK switches off Meridian Flips -// but allows travel across the Meridian. _ALTAZM is for Alt/Azm mounted 'scopes. -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on pins 34, 32, 33, 35. Pin 34 is RA- (West), Pin 32 is Dec- (South), Pin 33 is Dec+ (North), Pin 35 is RA+ (East.) -// ST4_ON enables the interface. Internal pullup resistors are not available. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: -// Press and hold [E]+[W] buttons for > 2 seconds for mode A: [E] Decrease [W] increase guide rate (or recticule brightness if at home position.) [S] Sync (or Accept during align.) [N] Tracking on/off. -// Press and hold [N]+[S] buttons for > 2 seconds for mode B: [E] Selects prior and [W] next user catalog item. [N] Do a Goto to the catalog item. [S] Sound on/off. -// The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON -// Press and hold [N]+[S] buttons for > 2 seconds for mode B: [E] Selects focuser 1 [W] selects focuser 2. [N] Moves focuser in and [S] moves focuser out. -#define ST4_HAND_CONTROL_FOCUSER_OFF - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// RTC (Real Time Clock) support, default=_OFF. -// Other options: RTC_DS3231 for a DS3231 on the I2C port Aux3/4 (SCL,SDA.) Choose either I2C OR Home Sense support on Aux3/4. -#define RTC_OFF - -// PEC sense on Pin 36 (A0) use _ON to enable the input. Built-in pullup resistors are not available. Provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 4095? which indicate voltages from 0-3.3VDC? on the analog pin (voltage range not confirmed, be careful!) -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on Aux7 (Pin 39) for optional limit sense (stops gotos and/or tracking), Built-in pullup resistors are not available. Default=_OFF. Choose only one feature on Aux7. -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground Aux8 (Pin 25), default=_OFF. Choose only one feature on Aux8. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash. -#define STATUS_LED_PINS_OFF -// Light 2nd status LED by sink to ground Aux8 (Pin 25), default=_OFF. Choose only one feature on Aux8. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground Aux8 (Pin 25), default=_OFF. Choose only one feature on Aux8. -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on Aux8 (Pin 25), default=_OFF. Choose only one feature on Aux8. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_OFF - -// Set to _ON (or the I2C device address if other than 0x77) and wire in BME280 on the I2C port Aux3/4 (SCL,SDA) for temperature, pressure, humidity. Default=_OFF. Choose either I2C OR Home Sense support on Aux3/4. -#define WEATHER_BME280_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// Automatic homing; switch state changes at the home position (uses Aux3 and Aux4.) For MOUNT_TYPE_GEM only. Choose either I2C OR Home Sense support on Aux3/4. -#define HOME_SENSE_OFF // Default _OFF, use _ON to have OnStep automatically detect and use home switches as follows -#define HOME_AXIS1_REVERSE_OFF // Pin Aux3 state should be HIGH when clockwise of the home position (as seen from front,) LOW otherwise; reverse if necessary -#define HOME_AXIS2_REVERSE_OFF // Pin Aux4 state should be HIGH when clockwise of the home position (as seen from above,) LOW otherwise; reverse if necessary - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 2.5 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 360 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 18,19 = Step,Dir (RA/Azm) -// Axis2: Pins 27,26 = Step,Dir (Dec/Alt) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default SQUARE. -#define STEP_WAVE_FORM SQUARE - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_ON // Dec/Alt axis - -// Stepper driver Enable support, just wire (Axis1 and Axis2) Enable to Pin 4 and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. Both AXIS1 and AXIS must use the same value! -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 15,16,17 for Axis1 (RA/Azm) and Pins 8,7,6 for Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pin 12 (Aux1 and Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// settings are TMC_SPI or Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins 2,15 = Step,Dir (choose either this option or the focuser(s), not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed rotator angle, default = -180 -#define MaxAxis3 180 // maximum allowed rotator angle, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement. -#define AXIS3_DISABLE_OFF // Pin 0 (Aux5.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS3_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins 2,15 = Step,Dir -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means. -#define MinAxis4 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS4_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS4_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS4_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS4_DISABLE HIGH // Pin 0 (Aux5.) Default HIGH for common stepper drivers. -#define AXIS4_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 1 if enabled. Default _OFF. - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// Pins 2,15 = Step,Dir (choose this option ONLY for a second DC focuser) -#define FOCUSER2_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means. -#define MinAxis5 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS5_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS5_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS5_DISABLE HIGH // Pin 0 (Aux5.) Default HIGH for common stepper drivers. -#define AXIS5_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS5_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 2 if enabled. Default _OFF. - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.MaxESP2.h" - -#endif diff --git a/Config.MaxPCB.h b/Config.MaxPCB.h deleted file mode 100644 index a914f7bca..000000000 --- a/Config.MaxPCB.h +++ /dev/null @@ -1,245 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep MaxPCB (Teensy3.5/3.6) - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.MaxPCB.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define MaxPCB_OFF // <- Turn _ON to use this configuration - -#ifdef MaxPCB_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 and Serial4 com ports, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 -#define SERIAL_C_BAUD_DEFAULT 9600 - -// ESP8266 reset and GPIO0 control, this sets run mode for normal operation. Uploading programmer firmware to the OpStep MCU can then enable sending new firmware to the ESP8266-01 -// Pin 18 (Aux1) for GPIO0 and Pin 5 (Aux2) for Rst control. Choose only one feature on Aux1/2. -#define ESP8266_CONTROL_OFF - -#define MOUNT_TYPE_GEM -// Mount type, default is _GEM (German Equatorial.) This allows Meridian flips and can be used for other mount types if that behaviour is desired. _FORK switches off Meridian Flips -// but allows travel across the Meridian. _ALTAZM is for Alt/Azm mounted 'scopes. - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on pins 24, 25, 26, 27. Pin 24 is RA- (West), Pin 25 is Dec- (South), Pin 26 is Dec+ (North), Pin 27 is RA+ (East.) -// ST4_ON enables the interface. ST4_PULLUP enables the interface and any internal pullup resistors. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// RTC (Real Time Clock) support, default=_OFF. -// Other options: RTC_DS3231 for a DS3231 on the default I2C pins (optionally wire the SQW output to the PPS pin below.) -#define RTC_OFF -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on Pin 28 for optional precision clock source (GPS, for example), default=_OFF -#define PPS_SENSE_OFF - -// PEC sense on Pin 23 (A9) use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 1.93V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on Aux7 (Pin 4) for optional limit sense (stops gotos and/or tracking), default=_OFF Choose only one feature on Aux7. -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground (Pin 19), default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash. -#define STATUS_LED_PINS_ON -// Light 2nd status LED by sink to ground Aux8 (Pin 22), default=_OFF. Choose only one feature on Aux8. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground Aux8 (Pin 22), default=_OFF. Choose only one feature on Aux8. -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on Pin 29, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -#define WEATHER_BME280_OFF -// Set to _ON (or the I2C device address if other than 0x77) and wire in BME280 on the I2C port (SCL1,SDA1) for temperature, pressure, humidity. Default=_OFF. - -// External temparature monitoring via DS1820 on ONE WIRE interface (uses Aux4.) Default _OFF. -#define TEMPERATURE_DS1820_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// Automatic homing; switch state changes at the home position (uses Aux3 and Aux4.) For MOUNT_TYPE_GEM only. -#define HOME_SENSE_OFF // Default _OFF, use _ON to have OnStep automatically detect and use home switches as follows -#define HOME_AXIS1_REVERSE_OFF // Pin Aux3 state should be HIGH when clockwise of the home position (as seen from front,) LOW otherwise; reverse if necessary -#define HOME_AXIS2_REVERSE_OFF // Pin Aux4 state should be HIGH when clockwise of the home position (as seen from above,) LOW otherwise; reverse if necessary - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. -// The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! -// If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 180 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 20,21 = Step,Dir (RA/Azm) -// Axis2: Pins 3, 2 = Step,Dir (Dec/Alt) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default SQUARE. -#define STEP_WAVE_FORM SQUARE - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins 14 (Axis1) and 9 (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 15,16,17 for Axis1 (RA/Azm) and Pins 8,7,6 for Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL TMC5160_VQUIET // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS 32 // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL TMC5160_VQUIET // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS 32 // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pins 18 (Aux1) and 5 (Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// other settings are LOW, HIGH, TMC_SPI (if available applies internal pullup if LOW and pulldown if HIGH.) Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins 30,33 = Step,Dir (choose either this option or the second focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed rotator angle, default = -180 -#define MaxAxis3 180 // maximum allowed rotator angle, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement. -#define AXIS3_DISABLE_OFF // Pin A21 (Aux5.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS3_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins 34,35 = Step,Dir -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means. -#define MinAxis4 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS4_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS4_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS4_DISABLE_OFF // Pin A22 (Aux6.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS4_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS4_DC_MODE_ON // enable DC focuser instead of a stepper motor. Automatically uses Phase 1 if enabled. Default _OFF. - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// Pins 30,33 = Step,Dir (choose either this option or the rotator, not both) -#define FOCUSER2_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means. -#define MinAxis5 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS5_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS5_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS5_DISABLE_OFF // Pin A21 (Aux5.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS5_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS5_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 2 if enabled. Default _OFF. - -//#define Axis3_EN 36 // Early version 1.x MaxPCB's had the option of using pin 36 for Axis3 EN -//#define Axis4_EN 39 // Early version 1.x MaxPCB's had the option of using pin 39 for Axis4/Axis5 EN - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 - #include "src/pinmaps/Pins.MaxPCB.h" -#endif diff --git a/Config.MiniPCB.h b/Config.MiniPCB.h deleted file mode 100644 index 2f8607e06..000000000 --- a/Config.MiniPCB.h +++ /dev/null @@ -1,230 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep MiniPCB (Teensy3.0,3.1,3.2,4.0) - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.MiniPCB.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define MiniPCB_OFF // <- Turn _ON to use this configuration - -#ifdef MiniPCB_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 com port, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 - -// ESP8266 reset and GPIO0 control. Sending command :ESPFLASH# to OnStep enables flashing the ESP8266 through OnStep's SERIAL_A port (normally the primary USB port.) -// Pin 18 (Aux1) for GPIO0 and Pin 5 (Aux2) for Rst control. Choose only one feature on Aux1/2. -#define ESP8266_CONTROL_OFF - -// Mount type, default is _GEM (German Equatorial.) This allows Meridian flips and can be used for other mount types if that behaviour is desired. _FORK switches off Meridian Flips -// but allows travel across the Meridian. _ALTAZM is for Alt/Azm mounted 'scopes. -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on pins 10, 11, 12, 13. Pin 10 is RA- (West), Pin 11 is Dec- (South), Pin 12 is Dec+ (North), Pin 13 is RA+ (East.) -// ST4_ON enables the interface, ST4_PULLUP enables the interface and any internal pullup resistors. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. Default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_ON - -// RTC (Real Time Clock) support, default=_OFF. -// Other options: RTC_TEENSY for enabling internal Teensy RTC - a resonator soldered to Teensy board and an external battery are required. -#define RTC_OFF - -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on Pad 28 for optional precision clock source (GPS, for example), default=_OFF [infrequently used option] -#define PPS_SENSE_OFF - -// PEC sense on Pin 23 (A9) use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 1.93V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on Aux3 (Pin 4) for optional limit sense (stops gotos and/or tracking), default=_OFF Choose only one feature on Aux4. -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground (Pin 19), default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_ON -// Light 2nd status LED by sink to ground Aux4 (Pin 22), default=_OFF. Choose only one feature on Aux4. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground Aux4 (Pin 22), default=_OFF. Choose only one feature on Aux4. -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on Pad 29, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// External temparature monitoring via DS1820 on ONE WIRE interface (Pin 24.) Default _OFF. -#define TEMPERATURE_DS1820_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// Automatic homing; switch state changes at the home position, uses Aux3 (Pin 4) and Aux4 (Pin 22). Choose only one feature on Aux3/4. For MOUNT_TYPE_GEM only. -#define HOME_SENSE_OFF // Default _OFF, use _ON to have OnStep automatically detect and use home switches as follows -#define HOME_AXIS1_REVERSE_OFF // Pin Aux3 state should be HIGH when clockwise of the home position (as seen from front,) LOW otherwise; reverse if necessary -#define HOME_AXIS2_REVERSE_OFF // Pin Aux4 state should be HIGH when clockwise of the home position (as seen from above,) LOW otherwise; reverse if necessary - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 360 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 20,21 = Step,Dir (RA/Azm) -// Axis2: Pins 3, 2 = Step,Dir (Dec/Alt) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default SQUARE. -#define STEP_WAVE_FORM SQUARE - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins 14 (Axis1) and 9 (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 15,16,17 for Axis1 (RA/Azm) and Pins 8,7,6 for Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pins 18 (Aux1) and 5 (Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// other settings are LOW, HIGH, TMC_SPI (if available applies internal pullup if LOW and pulldown if HIGH.) Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// THE FOLLOWING ARE INFREQUENTLY USED OPTIONS FOR THE MINIPCB SINCE USING ANY OF THESE WOULD REQUIRE SOLDERING TO THE PCB BACK AND ADDING OFF-PCB CIRCUITRY, MUCH EASIER TO USE A MAXPCB AND TEENSY3.5/3.6 -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pads 30,33 = Step,Dir (choose either this option or the second focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed rotator angle, default = -180 -#define MaxAxis3 180 // maximum allowed rotator angle, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pads 31,32 = Step,Dir -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means. -#define MinAxis4 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS4_REVERSE_OFF // reverse the direction of Axis4 focuser movement. - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// Pads 30,33 = Step,Dir (choose either this option or the rotator, not both) -#define FOCUSER2_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means. -#define MinAxis5 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS5_REVERSE_OFF // reverse the direction of Axis5 focuser movement. - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.MiniPCB.h" -#endif diff --git a/Config.Ramps14.h b/Config.Ramps14.h deleted file mode 100644 index 126773a52..000000000 --- a/Config.Ramps14.h +++ /dev/null @@ -1,244 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep using a RAMPS 1.4/1.5 Shield and Arduino Mega2560 or -// compatible all-in one devices like the recommended "MKS Gen-L" and others - -// **************************************************************************************** -// Be sure to adhere to the design limitations of the RAMPS 1.4 -// with respect to voltage, current, signaling, etc... See http://reprap.org/wiki/RAMPS_1.4 -// **************************************************************************************** - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.Ramps14.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define Ramps14_OFF // <- turn _ON to use this configuration - -#ifdef Ramps14_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 com port (RX1/TX1), Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 -// Default speed for Serial2 com port (RX2/TX2), Default=9600 -#define SERIAL_C_BAUD_DEFAULT 9600 - -// Mount type, default is _GEM (German Equatorial.) This allows Meridian flips and can be used for other mount types if that behaviour is desired. _FORK switches off Meridian Flips -// but allows travel across the Meridian. _ALTAZM is for Alt/Azm mounted 'scopes. -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on pins A9, 40, 42, A11. Pin A9 is RA- (West), Pin 40 is Dec- (South), Pin 42 is Dec+ (North), Pin A11 is RA+ (East.) -// ST4_ON enables the interface. ST4_PULLUP enables the interface and any internal pullup resistors. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// RTC (Real Time Clock) support, default=_OFF. -// Other options: RTC_DS3234 for a DS3234 on the default SPI interface pins (CS on Pin 53) or RTC_DS3231 for a DS3231 on the default I2C port (Pins 20 and 21, choose only one feature on these pins.) -// Optionally wire the SQW output to the PPS pin below. -#define RTC_OFF -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on pin 2 for optional precision clock source (GPS, for example), default=_OFF -#define PPS_SENSE_OFF - -// PEC sense on Pin 2 or threshold value on Analog 1. Use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 2.92V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on Pin 3 for optional limit sense (stops gotos and/or tracking), default=_OFF -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground (Pin 11), default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_ON -// Light 2nd status LED by sink to ground (Pin 6), default=_OFF. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground (pin 5), default=_OFF. -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on pin 4, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// Set WEATHER_BME280 to _ON (or the I2C device address if other than 0x77) and wire in BME280 on the I2C port pins 20 (SDA) and 21 (SCL) for temperature, pressure, humidity. Default=_OFF. -// Other options: Set WEATHER_BME280SPI_ON for a BME280 on the default SPI interface pins (CS on Pin 49, or set WEATHER_BME280SPI to CS pin# instead of using _ON.) -#define WEATHER_BME280_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// Automatic homing; switch state changes at the home position (Pins 20 and 21, choose only one feature on these pins.) For MOUNT_TYPE_GEM only. -#define HOME_SENSE_OFF // Default _OFF, use _ON to have OnStep automatically detect and use home switches as follows -#define HOME_AXIS1_REVERSE_OFF // Pin 20 state should be HIGH when clockwise of the home position (as seen from front,) reverse if necessary -#define HOME_AXIS2_REVERSE_OFF // Pin 21 state should be HIGH when clockwise of the home position (as seen from above,) reverse if necessary - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 360 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins A0,A1 = Step,Dir (RA/Azm) -// Axis2: Pins A6,A7 = Step,Dir (Dec/Alt) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default PULSE. -#define STEP_WAVE_FORM PULSE - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins 38 (Axis1) and A2 (Axis2) and OnStep will pull these HIGH to disable stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 23,25,27 for Axis1 (RA/Azm) and Pins 31,33,35 for Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pins 29 (Aux1) and 37 (Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// other settings are LOW, HIGH, TMC_SPI (if available applies internal pullup if LOW and pulldown if HIGH.) Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins 46,48 = Step,Dir -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed rotator angle, default = -180 -#define MaxAxis3 180 // maximum allowed rotator angle, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement. -#define AXIS3_DISABLE HIGH // Pin A8 (Aux3.) Default HIGH, for common stepper drivers. -#define AXIS3_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins 26,28 = Step,Dir -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means. -#define MinAxis4 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS4_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS4_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS4_DISABLE HIGH // Pin 24 (Aux4.) Default HIGH for common stepper drivers. -#define AXIS4_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS4_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 1 if enabled. Default _OFF. - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// Pins 36,34 = Step,Dir -#define FOCUSER2_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means. -#define MinAxis5 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS5_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS5_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS5_DISABLE HIGH // Pin 30 (Aux5.) Default HIGH for common stepper drivers. -#define AXIS5_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS5_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 2 if enabled. Default _OFF. - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.Ramps14.h" -#endif diff --git a/Config.STM32.h b/Config.STM32.h deleted file mode 100644 index df1e1009c..000000000 --- a/Config.STM32.h +++ /dev/null @@ -1,239 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep STM32 - -// For more information on setting OnStep up see: -// http://www.stellarjourney.com/index.php?r=site/equipment_onstep and -// Join the OnStep Groups.io, and view the Wiki at: https://groups.io/g/onstep -// -// See the appropriate file below for detailed information on this pin map to be -// sure it matches your wiring -// -// *** USE AT YOUR OWN RISK *** - -#define STM32Blue_OFF // <- Turn _ON to use STM32F103C8T6 Blue Pill, or -#define STM32Black_OFF // <- Turn _ON to use STM32F103C8T6 Black Pill, or -#define STM32CZ_OFF // <- Turn _ON to use STM32F103VET6 CZ Mini - -#if defined(STM32Black_ON) || defined(STM32Blue_ON) || defined(STM32CZ_ON) -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial3 com port, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 - -// ESP8266 reset and GPIO0 control, this sets run mode for normal operation. Uploading programmer firmware to the OpStep MCU can then enable sending new firmware to the ESP8266-01 -// Pin (Aux1) for GPIO0 and Pin (Aux2) for Rst control. Choose only one feature on Aux1/2. -#define ESP8266_CONTROL_OFF - -// Mount type, default is _GEM (German Equatorial.) This allows Meridian flips and can be used for other mount types if that behaviour is desired. _FORK switches off Meridian Flips -// but allows travel across the Meridian. _ALTAZM is for Alt/Azm mounted 'scopes. -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on four pins (see pinmap.) Pins are RA- (West), Dec- (South), Dec+ (North), RA+ (East.) -// ST4_ON enables the interface, ST4_PULLUP enables the interface and any internal pullup resistors. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on pin for optional precision clock source (GPS, for example), default=_OFF [infrequently used option] -#define PPS_SENSE_OFF - -// PEC sense use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 1.93V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) for optional limit sense (stops gotos and/or tracking), default=_OFF -#define LIMIT_SENSE_OFF -// Default LOW for NO (normally open) limit switches which close when triggered, change this to HIGH if your switch is NC (normally closed) and only opens when triggered. -#define LIMIT_SENSE_STATE LOW - -// Light status LED by sink to ground, default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_OFF -// Light 2nd status LED by sink to ground, default=_OFF. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground, default=_OFF. (don't use with STATUS_LED2_PINS_ON) -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// Set to _ON (or the I2C device address if other than 0x77) and wire in BME280 on the I2C port (SCL,SDA) for temperature, pressure, humidity. Default=_OFF. -#define WEATHER_BME280_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_ON - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_ON - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_ON - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_SLEW_RATE_OFF // Set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF. -#define DesiredBaseSlewRate 1.0 // Desired slew (goto) rate in degrees/second; also adjustable at run-time from 1/2 to 2x this rate. - // The resulting step rate is automatically reduced if too high for the current hardware/settings. - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 360 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 360. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins (see pinmap) = Step,Dir (RA/Azm) -// Axis2: Pins (see pinmap) = Step,Dir (Dec/Alt) - -// Step signal wave form. Use SQUARE for best compatibility or use PULSE to allow faster step rates. Default SQUARE. -#define STEP_WAVE_FORM SQUARE - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins ? (Axis1) and ? (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on three pins for Axis1 (RA/Azm) and three pins Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130* **, TMC5160* ** -// * = add _QUIET (stealthChop tracking,) _VQUIET (stealthChop tracking & slew,) _LOWPWR for reduced power during tracking (for example: TMC2130_QUIET_LOWPWR) -// ** = for TMC5160 (and optionally TMC2130) program the stepper driver current with #define AXISn_TMC_IRUN current_in_milli-amps (for additional settings see AdvancedDriverSetup.txt) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Aux1 and Aux2, choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) returns status/error info. from TMC2130, TMC5160, etc. -// other settings are LOW, HIGH, TMC_SPI (if available applies internal pullup if LOW and pulldown if HIGH.) Default=_OFF. -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins (see pinmap) = Step,Dir (choose either this option or the focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed rotator angle, default = -180 -#define MaxAxis3 180 // maximum allowed rotator angle, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of rotator movement. -#define AXIS3_DISABLE HIGH // Pin ?. Default HIGH, for common stepper drivers. -#define AXIS3_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins (see pinmap) = Step,Dir -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between micro-steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means -#define MinAxis4 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS4_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS4_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS4_DISABLE HIGH // Pin ?. Default HIGH, for common stepper drivers. -#define AXIS4_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS4_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 1 if enabled. Default _OFF. - -// FOCUSER2 --------------------------------------------------------------------------------------------------------------- -// Pins (see pinmap) = Step,Dir (choose this option ONLY for a second DC focuser) -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis5 8 // this is the minimum number of milli-seconds between micro-steps, default=8. In DC motor mode PWM frequency. -#define StepsPerMicrometerAxis5 0.5 // figure this out by testing or other means -#define MinAxis5 -25.0 // minimum allowed position in millimeters, default = -25.0 -#define MaxAxis5 25.0 // maximum allowed position in millimeters, default = 25.0 -#define AXIS5_MIN_MOVE_RATE 10 // minimum micrometers per second, default=10. In DC motor mode power for slow movement (1-1000 range.) -#define AXIS5_REVERSE_OFF // reverse the direction of focuser movement. -#define AXIS5_DISABLE HIGH // Pin ?. Default HIGH, for common stepper drivers. -#define AXIS5_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. Ignored in DC motor mode. -#define AXIS5_DC_MODE_OFF // enable DC focuser instead of a stepper motor. Automatically uses Phase 2 if enabled. Default _OFF. - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 - -#if defined(STM32Black_ON) || defined(STM32Blue_ON) - #include "src/pinmaps/Pins.STM32B.h" -#elif defined(STM32CZ_ON) - #include "src/pinmaps/Pins.STM32CZ.h" -#endif - -#endif diff --git a/Config.h b/Config.h index aca93d989..4f842533b 100644 --- a/Config.h +++ b/Config.h @@ -1,126 +1,178 @@ // ----------------------------------------------------------------------------------- -// Universal configuration for OnStep - -// ********** this file contains NO user settings, see the Config.xxx.h file appropraite for your hardware ************** -// (though you could replace this file contents w/your settings and remove all of the Config.xxx.h files if you wanted to) - -#pragma once - -#include "Config.Classic.h" -#include "Config.MaxESP.h" -#include "Config.MaxPCB.h" -//#include "Config.Mega2560Alt.h" -#include "Config.MiniPCB.h" -#include "Config.Ramps14.h" -#include "Config.STM32.h" -//#include "Config.TM4C.h" - -#ifdef Classic_ON - #define Configuration_Found -#endif -#ifdef MiniPCB_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef MaxPCB_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef MaxESP_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef MaxESP2_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef MaxESP3_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef Ramps14_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef Mega2560Alt_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef STM32CZ_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef STM32Black_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef STM32Blue_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif -#ifdef TM4C_ON - #ifdef Configuration_Found - #define Configuration_Duplicate - #else - #define Configuration_Found - #endif -#endif - -#ifdef Configuration_Duplicate - #error "You have more than one Config.xxx.h file enabled, ONLY ONE can be enabled with _ON." -#endif - -#ifndef Configuration_Found - #error "Choose ONE Config.xxx.h file and enable it for use by turning it _ON." -#endif - -// configuration file version - -#ifdef FileVersionConfig - #if FileVersionConfig < FirmwareVersionConfig - // firmware version 2 is compatible with file version 1 - #if (FileVersionConfig==1) && (FirmwareVersionConfig==2) - #warning "Configuration: There have been changes to the configuration file format, but OnStep is still backwards compatible for now." - #else - #error "Configuration: There have been changes to the configuration file format. You'll have to make a new Config.xxx.h file." - #endif - #elif FileVersionConfig > FirmwareVersionConfig - #error "Configuration: Configuration file version mismatch." - #endif -#else - #if (FirmwareVersionConfig == 1) || (FirmwareVersionConfig == 2) - #warning "Configuration: Config.xxx.h file version isn't specified (pre-version 1?)" - #else - #error "Configuration: There have been changes to the configuration file format. You'll have to make a new Config.xxx.h file." - #endif -#endif +// Configuration for OnStep + +/* + * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and join the OnStep Groups.io at https://groups.io/g/onstep + * + * *** Read the compiler warnings and errors, they are there to help guard against invalid configurations *** + * +*/ + +// ------------------------------------------------------------------------------------------------------------------------- +// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- + +// PINMAP ------------------------------------------------------------------------------------------------------------------ +// *** See the matching Pins.xxx.h file for your setup (in src/pinmaps/) with detailed information on the pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** *** + +#define PINMAP OFF // Default OFF, Choose from: MiniPCB, MiniEMB, MiniPCB2, MaxPCB, MaxPCB2, MaxTMC, STM32Blue, <- Required. + // Ramps14, MaxESP2, MaxESP3, Classic, Mega2560Alt + +// SERIAL PORTS ------------------------------------------------------------------------------------------------------------ +#define SERIAL_A_BAUD_DEFAULT 9600 // Default 9600, Common rates are 9600,19200,57600,115200. See (src/HAL/) for your MCU Serial port #... Usually not changed. +#define SERIAL_B_BAUD_DEFAULT 9600 // Default 9600, Common rates are 9600,19200,57600,115200. Optional. +#define SERIAL_B_ESP_FLASHING OFF // Default OFF, Enable uploading firmware to ESP8266 WiFi through SERIAL_B port using the :ESPFLASH# command. Optional. +#define SERIAL_C_BAUD_DEFAULT OFF // Default OFF, Common rates are 9600,19200,57600,115200. Bluetooth on ESP32 use "name" instead of rate. Optional. + +// MOUNT TYPE -------------------------------------------------------------------------------------------------------------- +#define MOUNT_TYPE GEM // Default GEM, GEM for German Equatorial, FORK for Equatorial Fork, or ALTAZM for Dobsonian etc. mounts. <- Required. GEM supports meridian flips. + +// USER FEEDBACK ----------------------------------------------------------------------------------------------------------- +#define LED_STATUS_PIN ON // Default ON, Blinks when sidereal tracking otherwise steady on to indicate that the controller is active. Optional. +#define LED_STATUS2_PIN OFF // Default OFF, Blinks at 1 sec intervals when PPS is synced, steady on during gotos, off when tracking stopped. Optional. +#define LED_RETICLE_PIN OFF // Default OFF, n. Where n=0 to 255 (0 to 100%) activates this feature and sets default brightness. Optional. +#define BUZZER OFF // Default OFF, ON for piezo buzzer or specify frequency for a speaker (for example "BUZZER 2000".) Optional. +#define BUZZER_STATE_DEFAULT OFF // Default OFF, Start with piezo buzzer/speaker enabled. Optional. + +// TIME -------------------------------------------------------------------------------------------------------------------- +#define RTC OFF // Default OFF, Select RTC DS3231, DS3234, TEENSY (Teensy3.2 internal.) Provides Date/Time/PPS (if avail.) Optional. + +// SENSORS ----------------------------------------------------------------------------------------------------------------- +// * = also supports ON_PULLUP or ON_PULLDOWN to activate MCU internal resistors if present. +#define WEATHER OFF // Default OFF, BME280 temperature, pressure, humidity on I2C interface (0x77.) Optional. + +#define TELESCOPE_TEMPERATURE OFF // Default OFF, DS1820 for telescope temperature on ONE WIRE interface. Optional. + +#define HOME_SENSE OFF // Default OFF, ON*. Automatically detect and use home switches. Optional, for GEM mounts only. +#define HOME_SENSE_STATE_AXIS1 HIGH // Default HIGH, HIGH signal when clockwise of home position LOW otherwise (as seen from front.) Optional, adjust as needed. +#define HOME_SENSE_STATE_AXIS2 HIGH // Default HIGH, HIGH signal when clockwise of home position LOW otherwise (as seen from front.) Optional, adjust as needed. + +#define LIMIT_SENSE OFF // Default OFF, ON*. Switch close (to ground) for optional limit sense (stops gotos and/or tracking.) Optional. +#define LIMIT_SENSE_STATE LOW // Default LOW, LOW for NO (normally open) switches close w/trigger, use HIGH for NC (normally closed.) Optional, adjust as needed. + +#define PEC_SENSE OFF // Default OFF, ON*, n. Sense digital OR n=0 to 1023 (0 to 3.3 VDC) for analog threshold. Optional, ignored on Alt/Azm mounts. +#define PEC_SENSE_STATE HIGH // Default HIGH, HIGH senses the PEC signal rising edge or use LOW for falling edge. Optional, adjust as needed. + +#define PPS_SENSE OFF // Default OFF, ON*. Enables PPS (pulse per second.) Optional. + +// ST4 INTERFACE ----------------------------------------------------------------------------------------------------------- +// *** It is up to you to verify the interface meets the electrical specifications of any connected device, use at your own risk *** +#define ST4_INTERFACE OFF // Default OFF, ON or ON_PULLUP enables the ST4 interface. Optional. +#define ST4_HAND_CONTROL OFF // Default OFF, Enables special features w/combo button presses & smart hand control (SHC) support. Optional, OFF allows only <= 1X rates on the ST4 port. + +// GUIDING BEHAVIOUR ------------------------------------------------------------------------------------------------------- +#define GUIDE_TIME_LIMIT 0 // Default 0, For no time limit, or specify guide time limit in seconds. Safety feature. Optional, adjust as needed. +#define GUIDE_DISABLE_BACKLASH OFF // Default OFF, Disable backlash takeup during guiding at <= 1X Optional. + +// TRACKING BEHAVIOUR ------------------------------------------------------------------------------------------------------ +#define TRACK_AUTOSTART OFF // Default OFF, Start with tracking enabled. Optional. +#define TRACK_REFRACTION_RATE_DEFAULT OFF // Default OFF, Start with atmospheric refraction compensation enabled (RA axis only.) Optional, ignored on Alt/Azm mounts. + +// SYNCING BEHAVIOUR ------------------------------------------------------------------------------------------------------- +#define SYNC_CURRENT_PIER_SIDE_ONLY ON // Default ON, Disables ability of Sync to change pier side, for GEM mounts. Optional. + +// SLEWING BEHAVIOUR ------------------------------------------------------------------------------------------------------- +#define SLEW_RATE_BASE_DESIRED 1.0 // Default 1.0, Desired slew (goto) rate in degrees/second, adjustable run-time from 1/2 to 2x this rate. <- Required, adjust as needed. Tries to use this rate, if possible. +#define SLEW_RATE_MEMORY OFF // Default OFF, Remember rates set across power cycles. Optional. +#define SLEW_ACCELERATION_DIST 5.0 // Default 5.0, Approx. distance in degrees during which acceleration and deceleration takes place. Adjust as needed. +#define SLEW_RAPID_STOP_DIST 2.0 // Default 2.0, Approx. distance in degrees required to stop when a slew is aborted or limit is exceeded. Adjust as needed. +#define BACKLASH_RATE 25 // Default 25, Speed in x sidereal rate, too fast and motors stall, too slow and sluggish moving in backlash. Usually not changed. +#define MFLIP_SKIP_HOME OFF // Default OFF, Goto directly to the destination without visiting the home position. Optional. +#define MFLIP_PAUSE_HOME_MEMORY OFF // Default OFF, Remember the last meridian flip pause at home setting across power cycles. Optional. +#define MFLIP_AUTOMATIC_MEMORY OFF // Default OFF, Remember the last automatic meridian flip setting. Optional. + +// PARKING BEHAVIOUR ------------------------------------------------------------------------------------------------------- +#define STRICT_PARKING OFF // Default OFF, Enable and un-parking is only allowed if successfully parked. Optional. + +// MOTION CONTROL ---------------------------------------------------------------------------------------------------------- +#define STEP_WAVE_FORM SQUARE // Default SQUARE, Step signal wave form, SQUARE for best compatibility, PULSE to allow faster step rates. Adjust as needed. + +// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2100, TMC2208, TMC2209*, TMC2130**, TMC5160*** +// * = add _QUIET (stealthChop tracking) or _VQUIET (stealthChop tracking & slew.) +// ** = for the SSS TMC2130 you can set the stepper driver current (in milliamps) with #define AXISn_TMC_IRUN (IHOLD, etc.) If you choose to do so set the Vref pot. to 2.5V instead of by motor current as usual. +// *** = for the SSS TMC5160 you must set the stepper driver current (in milliamps) with #define AXISn_TMC_IRUN (IHOLD, etc.) + +// AXIS1 RA/AZM -------------------------- +#define AXIS1_STEPS_PER_DEGREE 12800.0 // Default 12800, Calculated as: (stepper_steps * micro_steps * gear_reduction1 * gear_reduction2)/360.0 <- Required, adjust as needed. +#define AXIS1_STEPS_PER_WORMROT 12800 // Default 12800, Number of steps per worm rotation (PEC,) (AXIS1_STEPS_PER_DEGREE*360)/gear_reduction_final_stage. <- Required, adjust as needed, ignored in Alt/Azm mode. + +#define AXIS1_DRIVER_MODEL OFF // Default OFF, Stepper driver model (see above.) <- Often configured. +#define AXIS1_DRIVER_MICROSTEPS OFF // Default OFF, Microstep mode when tracking (for example: AXIS1_DRIVER_MICROSTEPS 32) <- Often configured. +#define AXIS1_DRIVER_MICROSTEPS_GOTO OFF // Default OFF, Microstep mode used during gotos (for example: AXIS1_DRIVER_MICROSTEPS_GOTO 2) Optional. +#define AXIS1_DRIVER_IHOLD OFF // Default OFF, OFF for IRUN/2.0, or set value for current in milli-amps used during standstill. Optional, TMC2130 & TMC5160 only. +#define AXIS1_DRIVER_IRUN OFF // Default OFF, Current in milli-amps when tracking, set to value appropriate for your stepper/driver rating. Optional, TMC2130 & TMC5160 only. +#define AXIS1_DRIVER_IGOTO OFF // Default OFF, OFF for same as IRUN, or set value for current in milli-amps used during gotos. Optional, TMC2130 & TMC5160 only. +#define AXIS1_DRIVER_REVERSE OFF // Default OFF, Reverses the direction of movement. Reversing wiring instead can also correct this. Optional. +#define AXIS1_DRIVER_STATUS OFF // Default OFF, Polling for stepper driver status info/fault detection. Options are TMC_SPI, HIGH, or LOW. Optional. + +#define AXIS1_LIMIT_UNDER_POLE 180 // Default 180, Degrees +/-, maximum allowed Hour Angle. Allowed range is 150 to 180. Adjust as needed, ignored in Alt/Azm mode. +#define AXIS1_LIMIT_MAXAZM 360 // Default 360, Degrees +/-, maximum allowed Azimuth. Allowed range is 180 to 360. Ignored in Eq modes. Adjust as needed, ignored on Eq mounts. + +// AXIS2 DEC/ALT ------------------------- +#define AXIS2_STEPS_PER_DEGREE 12800.0 // Default 12800, Calculated as: (stepper_steps * micro_steps * gear_reduction1 * gear_reduction2)/360.0 <- Required, adjust as needed. + +#define AXIS2_DRIVER_MODEL OFF // Default OFF, Stepper driver model (see above.) <- Often configured. +#define AXIS2_DRIVER_MICROSTEPS OFF // Default OFF, Microstep mode when tracking (for example: AXIS2_DRIVER_MICROSTEPS 32) <- Often configured. +#define AXIS2_DRIVER_MICROSTEPS_GOTO OFF // Default OFF, Microstep mode used during gotos (for example: AXIS2_DRIVER_MICROSTEPS_GOTO 2) Optional. +#define AXIS2_DRIVER_IHOLD OFF // Default OFF, OFF for IRUN/2.0, current in milli-amps used during standstill. Optional, TMC2130 & TMC5160 only. +#define AXIS2_DRIVER_IRUN OFF // Default OFF, Current in milli-amps when tracking, set to value appropriate for your stepper/driver rating. Optional, TMC2130 & TMC5160 only. +#define AXIS2_DRIVER_IGOTO OFF // Default OFF, OFF for same as IRUN, current in milli-amps used during gotos. Optional, TMC2130 & TMC5160 only. +#define AXIS2_DRIVER_POWER_DOWN OFF // Default OFF, Powers off axis 10 sec. after movement stops or 10 min. after last <= 1x guide. Optional, ignored on Alt/Azm mounts. +#define AXIS2_DRIVER_REVERSE OFF // Default OFF, Reverses the direction of movement. Reversing wiring instead can also correct this. Optional. +#define AXIS2_DRIVER_STATUS OFF // Default OFF, Polling for stepper driver status info/fault detection. Options are TMC_SPI, HIGH, or LOW. Optional. + +#define AXIS2_LIMIT_MIN -91 // Default -91.0, Minimum allowed declination in degrees. Usually not changed. +#define AXIS2_LIMIT_MAX +91 // Default 91.0, Maximum allowed declination in degrees. Usually not changed. + +// AXIS3 ROTATOR ------------------------- +#define ROTATOR OFF // Default OFF, Use ON to enable the rotator (or de-rotator for ALTAZM mounts.) Optional. +#define AXIS3_STEPS_PER_DEGREE 64.0 // Default 64.0, De-rotation Alt/Az resolution: calc. circumference of useful imaging circle (pixels * 2)/360. Adjust as needed. +#define AXIS3_STEP_RATE_MAX 8.0 // Default 8.0, This is the minimum milli-seconds per step. Fastest speed also limited by MCU performace. Adjust as needed. + +#define AXIS3_DRIVER_MODEL OFF // Default OFF, Stepper driver model (TMC2130 or TMC5160 only.) Optional. +#define AXIS3_DRIVER_MICROSTEPS OFF // Default OFF, Microstep mode(for example: AXIS3_DRIVER_MICROSTEPS 1) Optional, for TMC2130 & TMC5160 only. +#define AXIS3_DRIVER_IHOLD OFF // Default OFF, OFF for IRUN/2.0, current in milli-amps used during standstill. Optional, for TMC2130 & TMC5160 only. +#define AXIS3_DRIVER_IRUN OFF // Default OFF, Current in milli-amps, set to value appropriate for your stepper/driver rating. Optional, for TMC2130 & TMC5160 only. +#define AXIS3_DRIVER_POWER_DOWN OFF // Default OFF, Powers off the motor at stand-still. Optional. +#define AXIS3_DRIVER_REVERSE OFF // Default OFF, Reverses the direction of movement. Reversing wiring instead can also correct this. Optional. + +#define AXIS3_LIMIT_MIN -180 // Default -180.0, Minimum allowed rotator angle in degrees. Usually not changed. +#define AXIS3_LIMIT_MAX 180 // Default 180.0, Maximum allowed rotator angle in degrees. Usually not changed. + +// AXIS4 FOCUSER 1 ---------------------- +#define FOCUSER1 OFF // Default OFF, Use ON to enable this focuser. Optional. +#define AXIS4_STEPS_PER_MICRON 0.5 // Default 0.5, Steps per micro-meter. Figure this out by testing or other means. Adjust as needed. +#define AXIS4_STEP_RATE_MAX 8.0 // Default 8.0, This is the milli-seconds per step (lower is faster.) In DC mode PWM frequency. Adjust as needed. + +#define AXIS4_DRIVER_MODEL OFF // Default OFF, Stepper driver model (TMC2130 or TMC5160 only.) Optional. +#define AXIS4_DRIVER_MICROSTEPS OFF // Default OFF, Microstep mode (for example: AXIS4_DRIVER_MICROSTEPS 1) Optional, for TMC2130 & TMC5160 only. +#define AXIS4_DRIVER_IHOLD OFF // Default OFF, OFF for IRUN/2.0, current in milli-amps used during standstill. Optional, for TMC2130 & TMC5160 only. +#define AXIS4_DRIVER_IRUN OFF // Default OFF, Current in milli-amps, set to value appropriate for your stepper/driver rating. Optional, for TMC2130 & TMC5160 only. +#define AXIS4_DRIVER_POWER_DOWN OFF // Default OFF Powers off the motor at stand-still. Optional. +#define AXIS4_DRIVER_REVERSE OFF // Default OFF, Reverses the direction of movement. Reversing wiring instead can also correct this. Optional. +#define AXIS4_DRIVER_DC_MODE OFF // Default OFF, Use DRV8825 for pwm dc motor control on stepper driver outputs. Optional. + +#define AXIS4_LIMIT_MIN_RATE 10 // Default 10, Minimum micrometers per second, default=10. In DC mode power for slowest move (1-1000 range.) Adjust as needed. +#define AXIS4_LIMIT_MIN -25.0 // Default -25.0, Minimum allowed position in millimeters. Adjust as needed. +#define AXIS4_LIMIT_MAX 25.0 // Default 25.0, Maximum allowed position in millimeters. Adjust as needed. + +// AXIS5 FOCUSER 2 ---------------------- +#define FOCUSER2 OFF // Default OFF, Use ON to enable this focuser. Optional. +#define AXIS5_STEPS_PER_MICRON 0.5 // Default 0.5, Steps per micrometer. Figure this out by testing or other means. Adjust as needed. +#define AXIS5_STEP_RATE_MAX 8.0 // Default 8.0, This is the milli-seconds per step (lower is faster.) In DC mode PWM frequency. Adjust as needed. + +#define AXIS5_DRIVER_MODEL OFF // Default OFF, Stepper driver model (TMC2130 or TMC5160 only.) Optional. +#define AXIS5_DRIVER_MICROSTEPS OFF // Default OFF, Microstep mode (for example: AXIS5_DRIVER_MICROSTEPS 1) Optional, for TMC2130 & TMC5160 only. +#define AXIS5_DRIVER_IHOLD OFF // Default OFF, OFF for IRUN/2.0, current in milli-amps used during standstill. Optional, for TMC2130 & TMC5160 only. +#define AXIS5_DRIVER_IRUN OFF // Default OFF, Current in milli-amps, set to value appropriate for your stepper/driver rating. Optional, for TMC2130 & TMC5160 only. +#define AXIS5_DRIVER_POWER_DOWN OFF // Default OFF Powers off the motor at stand-still. Optional. +#define AXIS5_DRIVER_REVERSE OFF // Default OFF, Reverses the direction of movement. Reversing wiring instead can also correct this. Optional. +#define AXIS5_DRIVER_DC_MODE OFF // Default OFF, Use DRV8825 for PWM DC motor control on stepper driver outputs. Optional. + +#define AXIS5_LIMIT_MIN_RATE 10 // Default 10, Minimum micrometers per second, default=10. In DC mode power for slowest move (1-1000 range.) Adjust as needed. +#define AXIS5_LIMIT_MIN -25.0 // Default -25.0, Minimum allowed position in millimeters. Adjust as needed. +#define AXIS5_LIMIT_MAX 25.0 // Default 25.0, Maximum allowed position in millimeters. Adjust as needed. + +// THAT'S IT FOR USER CONFIGURATION! + +// ------------------------------------------------------------------------------------------------------------------------- +#define FileVersionConfig 3 diff --git a/Constants.h b/Constants.h index d2d9fb6b9..950b58972 100644 --- a/Constants.h +++ b/Constants.h @@ -3,6 +3,46 @@ #pragma once +// On/Off, etc. +#define OFF -1 +#define ON -2 +#define ON_PULLUP -3 +#define ON_PULLDOWN -4 +#define XDIRECT -5 + +// Pinmaps +#define PINMAP_FIRST 1 +#define Classic 1 +#define AltMega2560 2 +#define Ramps14 3 +#define MiniPCB 10 +#define MiniEMB 11 +#define MiniPCB2 12 +#define MaxPCB 20 +#define MaxPCB2 21 +#define MaxTMC 22 +#define MaxESP 30 +#define MaxESP2 31 +#define MaxESP3 32 +#define STM32Blue 40 +#define STM32Black 41 +#define PINMAP_LAST 41 + +// mount types +#define GEM 1 // German Equatorial Mount. Meridian flips enabled. +#define FORK 2 // Fork Mount. Meridian flips disabled. +#define ALTAZM 3 // Altitude Azimuth Mount. Dobsonians, etc. + +// various RTC's supported +#define DS3231 1 // DS3231 RTC on I2C +#define DS3234 2 // DS3234 RTC on SPI (default CS) +#define TEENSY 3 // TEENSY3.2 RTC (Built-in) + +// various Weather sensors supported +#define BME280 1 // BME280 on I2C +#define BME280SPI 2 // BME280 on SPI (default CS) +#define DS1820 3 // DS18B20 on OneWire + // coordinate mode for getting and setting RA/Dec #define OBSERVED_PLACE 1 #define TOPOCENTRIC 2 @@ -12,50 +52,50 @@ // EEPROM Info -------------------------------------------------------------------------------------------------------------- // General purpose storage A (100 bytes), 0..99 -#define EE_posAxis1 0 // 4 -#define EE_posAxis2 4 // 4 -#define EE_pierSide 8 // 1 -#define EE_parkStatus 9 // 1 -#define EE_parkSaved 10 // 1 +#define EE_posAxis1 0 // 4 +#define EE_posAxis2 4 // 4 +#define EE_pierSide 8 // 1 +#define EE_parkStatus 9 // 1 +#define EE_parkSaved 10 // 1 -#define EE_currentSite 11 // 1 +#define EE_currentSite 11 // 1 -#define EE_pauseHome 12 // 1 + 1 +#define EE_pauseHome 12 // 1 + 1 -#define EE_LMT 14 // 4 -#define EE_JD 18 // 4 +#define EE_LMT 14 // 4 +#define EE_JD 18 // 4 -#define EE_pulseGuideRate 22 // 1 -#define EE_maxRate 23 // 2 +#define EE_pulseGuideRate 22 // 1 +#define EE_maxRate 23 // 2 -#define EE_autoMeridianFlip 25 // 1 +#define EE_autoMeridianFlip 25 // 1 -#define EE_dfCor 26 // 4 -#define EE_ax1Cor 30 // 4 -#define EE_ax2Cor 34 // 4 +#define EE_dfCor 26 // 4 +#define EE_ax1Cor 30 // 4 +#define EE_ax2Cor 34 // 4 -#define EE_dpmE 38 // 1 -#define EE_dpmW 39 // 1 -#define EE_minAlt 40 // 1 -#define EE_maxAlt 41 // 1 +#define EE_dpmE 38 // 1 +#define EE_dpmW 39 // 1 +#define EE_minAlt 40 // 1 +#define EE_maxAlt 41 // 1 -#define EE_doCor 42 // 4 -#define EE_pdCor 46 // 4 -#define EE_altCor 50 // 4 -#define EE_azmCor 54 // 4 -#define EE_indexAxis1 58 // 4 -#define EE_indexAxis2 62 // 4 -#define EE_tfCor 66 // 4 +#define EE_doCor 42 // 4 +#define EE_pdCor 46 // 4 +#define EE_altCor 50 // 4 +#define EE_azmCor 54 // 4 +#define EE_indexAxis1 58 // 4 +#define EE_indexAxis2 62 // 4 +#define EE_tfCor 66 // 4 -#define EE_pecStatus 70 // 1 -#define EE_pecRecorded 71 // 1 +#define EE_pecStatus 70 // 1 +#define EE_pecRecorded 71 // 1 -#define EE_posAxis4 72 // 4 +#define EE_posAxis4 72 // 4 -#define EE_wormSensePos 76 // 4 +#define EE_wormSensePos 76 // 4 -#define EE_backlashAxis1 80 // 4 -#define EE_backlashAxis2 84 // 4 +#define EE_backlashAxis1 80 // 4 +#define EE_backlashAxis2 84 // 4 #define EE_siderealInterval 88 // 4 #define EE_posAxis5 92 // 4 @@ -84,13 +124,13 @@ #define EE_sites 100 -// PEC table: 200...PECBufferSize+199 -// PECBufferSize table of byte sized integers -128..+127, units are steps +// PEC table: 200...pecBufferSize+199 +// pecBufferSize table of byte sized integers -128..+127, units are steps #define EE_pecTable 200 // Library -// Catalog storage starts at 200+PECBufferSize and ends at E2END-100 +// Catalog storage starts at 200+pecBufferSize and ends at E2END-100 // General purpose storage B (100 bytes), E2END-99..E2END #define GSB (E2END-100) diff --git a/Globals.h b/Globals.h index a1c22e1c6..71f3ced98 100644 --- a/Globals.h +++ b/Globals.h @@ -4,34 +4,34 @@ #pragma once // Time keeping ------------------------------------------------------------------------------------------------------------ -long siderealTimer = 0; // counter to issue steps during tracking -long PecSiderealTimer = 0; // time since worm wheel zero index for PEC -long guideSiderealTimer=0; // counter to issue steps during guiding -boolean dateWasSet=false; // keep track of date/time validity +long siderealTimer = 0; // counter to issue steps during tracking +long PecSiderealTimer = 0; // time since worm wheel zero index for PEC +long guideSiderealTimer=0; // counter to issue steps during guiding +boolean dateWasSet=false; // keep track of date/time validity boolean timeWasSet=false; -double UT1 = 0.0; // the current universal time -double UT1_start = 0.0; // the start of UT1 -double JD = 0.0; // and date, used for computing LST -double LMT = 0.0; // -double timeZone = 0.0; // +double UT1 = 0.0; // the current universal time +double UT1_start = 0.0; // the start of UT1 +double JD = 0.0; // and date, used for computing LST +double LMT = 0.0; // +double timeZone = 0.0; // -long lst_start = 0; // this marks the start lst when UT1 is set -volatile long lst = 0; // this is the local (apparent) sidereal time in 1/100 seconds (23h 56m 4.1s per day = 86400 clock seconds/ - // 86164.09 sidereal seconds = 1.00273 clock seconds per sidereal second.) Takes 249 days to roll over. +long lst_start = 0; // this marks the start lst when UT1 is set +volatile long lst = 0; // this is the local (apparent) sidereal time in 1/100 seconds (23h 56m 4.1s per day = 86400 clock seconds/ + // 86164.09 sidereal seconds = 1.00273 clock seconds per sidereal second.) Takes 249 days to roll over. long siderealInterval = 15956313L; long masterSiderealInterval = siderealInterval; - // default = 15956313 ticks per sidereal second, where a tick is 1/16 uS - // this is stored in EEPROM which is updated/adjusted with the ":T+#" and ":T-#" commands - // a higher number here means a longer count which slows down the sidereal clock + // default = 15956313 ticks per sidereal second, where a tick is 1/16 uS + // this is stored in EEPROM which is updated/adjusted with the ":T+#" and ":T-#" commands + // a higher number here means a longer count which slows down the sidereal clock -double HzCf = 16000000.0/60.0; // conversion factor to go to/from Hz for sidereal interval +double HzCf = 16000000.0/60.0; // conversion factor to go to/from Hz for sidereal interval -volatile long SiderealRate; // based on the siderealInterval, this is the time between steps for sidereal tracking -volatile long TakeupRate; // this is the takeup rate for synchronizing the target and actual positions when needed +volatile long SiderealRate; // based on the siderealInterval, this is the time between steps for sidereal tracking +volatile long TakeupRate; // this is the takeup rate for synchronizing the target and actual positions when needed -long last_loop_micros=0; // workload monitoring +long last_loop_micros=0; // workload monitoring long this_loop_time=0; long loop_time=0; long worst_loop_time=0; @@ -45,9 +45,9 @@ volatile double LastPPSrateRatio = 1.0; volatile boolean PPSsynced = false; // Tracking and rate control ----------------------------------------------------------------------------------------------- -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM enum RateCompensation {RC_NONE, RC_REFR_RA, RC_REFR_BOTH, RC_FULL_RA, RC_FULL_BOTH}; - #ifdef TRACK_REFRACTION_RATE_DEFAULT_ON + #if TRACK_REFRACTION_RATE_DEFAULT == ON RateCompensation rateCompensation=RC_REFR_RA; #else RateCompensation rateCompensation=RC_NONE; @@ -73,37 +73,34 @@ boolean faultAxis2 = false; #define default_tracking_rate 1 volatile double trackingTimerRateAxis1= default_tracking_rate; volatile double trackingTimerRateAxis2= default_tracking_rate; -volatile double timerRateRatio = ((double)StepsPerDegreeAxis1/(double)StepsPerDegreeAxis2); -volatile boolean useTimerRateRatio = (StepsPerDegreeAxis1!=StepsPerDegreeAxis2); -#define StepsPerSecondAxis1 ((double)StepsPerDegreeAxis1/240.0) -#define ArcSecPerStepAxis1 (3600.0/StepsPerDegreeAxis1) -#define StepsPerSecondAxis2 ((double)StepsPerDegreeAxis2/240.0) -#define ArcSecPerStepAxis2 (3600.0/StepsPerDegreeAxis2) +volatile double timerRateRatio = ((double)AXIS1_STEPS_PER_DEGREE/(double)AXIS2_STEPS_PER_DEGREE); +volatile boolean useTimerRateRatio = (AXIS1_STEPS_PER_DEGREE != AXIS2_STEPS_PER_DEGREE); +#define StepsPerSecondAxis1 ((double)AXIS1_STEPS_PER_DEGREE/240.0) +#define ArcSecPerStepAxis1 (3600.0/AXIS1_STEPS_PER_DEGREE) +#define StepsPerSecondAxis2 ((double)AXIS2_STEPS_PER_DEGREE/240.0) +#define ArcSecPerStepAxis2 (3600.0/AXIS2_STEPS_PER_DEGREE) #define BreakDistAxis1 (2L) #define BreakDistAxis2 (2L) -long SecondsPerWormRotationAxis1 = ((long)(StepsPerWormRotationAxis1/StepsPerSecondAxis1)); -volatile double StepsForRateChangeAxis1= (sqrt((double)DegreesForAcceleration*(double)StepsPerDegreeAxis1))*(double)MaxRate*16.0; -volatile double StepsForRateChangeAxis2= (sqrt((double)DegreesForAcceleration*(double)StepsPerDegreeAxis2))*(double)MaxRate*16.0; -#ifndef DegreesForRapidStop -#define DegreesForRapidStop 1.0 -#endif +long SecondsPerWormRotationAxis1 = ((double)AXIS1_STEPS_PER_WORMROT/StepsPerSecondAxis1); +volatile double StepsForRateChangeAxis1= (sqrt((double)SLEW_ACCELERATION_DIST*(double)AXIS1_STEPS_PER_DEGREE))*(double)MaxRate*16.0; +volatile double StepsForRateChangeAxis2= (sqrt((double)SLEW_ACCELERATION_DIST*(double)AXIS2_STEPS_PER_DEGREE))*(double)MaxRate*16.0; // Basic stepper driver mode setup ------------------------------------------------------------------------------------ -#ifdef AXIS1_DRIVER_MODEL +#if AXIS1_DRIVER_MODEL != OFF // Microsteps for each axis volatile uint8_t _axis1_microstep_code; - #define AXIS1_MICROSTEP_CODE _axis1_microstep_code + #define AXIS1_DRIVER_MICROSTEP_CODE _axis1_microstep_code volatile uint8_t _axis2_microstep_code; - #define AXIS2_MICROSTEP_CODE _axis2_microstep_code + #define AXIS2_DRIVER_MICROSTEP_CODE _axis2_microstep_code - #ifdef AXIS1_MICROSTEPS_GOTO + #if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF volatile uint8_t _axis1_microstep_code_goto; - #define AXIS1_MICROSTEP_CODE_GOTO _axis1_microstep_code_goto + #define AXIS1_DRIVER_MICROSTEP_CODE_GOTO _axis1_microstep_code_goto #endif - #ifdef AXIS2_MICROSTEPS_GOTO + #if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF volatile uint8_t _axis2_microstep_code_goto; - #define AXIS2_MICROSTEP_CODE_GOTO _axis2_microstep_code_goto + #define AXIS2_DRIVER_MICROSTEP_CODE_GOTO _axis2_microstep_code_goto #endif #endif @@ -114,57 +111,54 @@ double cosLat = 1.0; double sinLat = 0.0; double longitude = 0.0; -// fix UnderPoleLimit for fork mounts -#ifdef MOUNT_TYPE_FORK -#undef UnderPoleLimit -#define UnderPoleLimit 12 +// fix AXIS1_LIMIT_UNDER_POLE for fork mounts +#if MOUNT_TYPE == FORK + #undef AXIS1_LIMIT_UNDER_POLE + #define AXIS1_LIMIT_UNDER_POLE 12 #endif // Coordinates ------------------------------------------------------------------------------------------------------------- -#ifdef MOUNT_TYPE_GEM -double homePositionAxis1 = 90.0; -#endif -#if defined(MOUNT_TYPE_FORK) || defined(MOUNT_TYPE_ALTAZM) -double homePositionAxis1 = 0.0; +#if MOUNT_TYPE == GEM + double homePositionAxis1 = 90.0; +#else + double homePositionAxis1 = 0.0; #endif double homePositionAxis2 = 90.0; // either 0 or (fabs(latitude)) #define AltAzmDecStartPos (fabs(latitude)) -volatile long posAxis1 = 0; // hour angle position in steps -volatile long startAxis1 = 0; // hour angle of goto start position in steps -volatile fixed_t targetAxis1; // hour angle of goto end position in steps -volatile byte dirAxis1 = 1; // stepping direction + or - -double origTargetRA = 0.0; // holds the RA for gotos before possible conversion to observed place -double newTargetRA = 0.0; // holds the RA for gotos after conversion to observed place +volatile long posAxis1 = 0; // hour angle position in steps +volatile long startAxis1 = 0; // hour angle of goto start position in steps +volatile fixed_t targetAxis1; // hour angle of goto end position in steps +volatile byte dirAxis1 = 1; // stepping direction + or - +double origTargetRA = 0.0; // holds the RA for gotos before possible conversion to observed place +double newTargetRA = 0.0; // holds the RA for gotos after conversion to observed place fixed_t origTargetAxis1; -#if defined(AXIS1_MICROSTEP_CODE) && defined(AXIS1_MICROSTEP_CODE_GOTO) -volatile long stepAxis1=1; +#if defined(AXIS1_DRIVER_MICROSTEP_CODE) && defined(AXIS1_DRIVER_MICROSTEP_CODE_GOTO) + volatile long stepAxis1=1; #else -#define stepAxis1 1 + #define stepAxis1 1 #endif -volatile long posAxis2 = 0; // declination position in steps -volatile long startAxis2 = 0; // declination of goto start position in steps -volatile fixed_t targetAxis2; // declination of goto end position in steps -volatile byte dirAxis2 = 1; // stepping direction + or - -double origTargetDec = 0.0; // holds the Dec for gotos before possible conversion to observed place -double newTargetDec = 0.0; // holds the Dec for gotos after conversion to observed place +volatile long posAxis2 = 0; // declination position in steps +volatile long startAxis2 = 0; // declination of goto start position in steps +volatile fixed_t targetAxis2; // declination of goto end position in steps +volatile byte dirAxis2 = 1; // stepping direction + or - +double origTargetDec = 0.0; // holds the Dec for gotos before possible conversion to observed place +double newTargetDec = 0.0; // holds the Dec for gotos after conversion to observed place long origTargetAxis2 = 0; -#if defined(AXIS2_MICROSTEP_CODE) && defined(AXIS2_MICROSTEP_CODE_GOTO) -volatile long stepAxis2=1; +#if defined(AXIS2_DRIVER_MICROSTEP_CODE) && defined(AXIS2_DRIVER_MICROSTEP_CODE_GOTO) + volatile long stepAxis2=1; #else -#define stepAxis2 1 + #define stepAxis2 1 #endif double newTargetAlt=0.0, newTargetAzm=0.0; // holds the altitude and azmiuth for slews -// for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - one hour of RA is the default = 60. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. -long minutesPastMeridianE = 60L; -// as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. -long minutesPastMeridianW = 60L; +long degreesPastMeridianE = 15; // for goto's, East side of the pier. How far past the meridian to allow before we do a flip. Ignored on Alt/Azm mounts. +long degreesPastMeridianW = 15; // as above, West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Ignored on Alt/Azm mounts. int minAlt; // the minimum altitude, in degrees, for goTo's (so we don't try to point too low) int maxAlt; // the maximum altitude, in degrees, for goTo's (to keep the telescope tube away from the mount/tripod) -bool autoMeridianFlip = false; // automatically do a meridian flip and continue when we hit the MinutesPastMeridianW +bool autoMeridianFlip = false; // automatically do a meridian flip and continue when we hit the AXIS1_LIMIT_MERIDIAN_W double currentAlt = 45.0; // the current altitude double currentDec = 0.0; // the current declination @@ -201,14 +195,14 @@ boolean axis2Enabled = false; #define MeridianFlipNever 0 #define MeridianFlipAlign 1 #define MeridianFlipAlways 2 -#ifdef MOUNT_TYPE_GEM -byte meridianFlip = MeridianFlipAlways; +#if MOUNT_TYPE == GEM + byte meridianFlip = MeridianFlipAlways; #endif -#ifdef MOUNT_TYPE_FORK -byte meridianFlip = MeridianFlipNever; +#if MOUNT_TYPE == FORK + byte meridianFlip = MeridianFlipNever; #endif -#ifdef MOUNT_TYPE_ALTAZM -byte meridianFlip = MeridianFlipNever; +#if MOUNT_TYPE == ALTAZM + byte meridianFlip = MeridianFlipNever; #endif byte pierSideControl = PierSideNone; @@ -233,14 +227,14 @@ unsigned long baudRate[10] = {115200,56700,38400,28800,19200,14400,9600,4800,240 // Guide command ------------------------------------------------------------------------------------------------------------ #define GuideRate1x 2 #ifndef GuideRateDefault -#define GuideRateDefault 6 // 20x + #define GuideRateDefault 6 // 20x #endif #define GuideRateNone 255 -#define RateToDegPerSec (1000000.0/(double)StepsPerDegreeAxis1) +#define RateToDegPerSec (1000000.0/(double)AXIS1_STEPS_PER_DEGREE) #define RateToASPerSec (RateToDegPerSec*3600.0) #define RateToXPerSec (RateToASPerSec/15.0) double slewRateX = (RateToXPerSec/MaxRate)*2.5; // 5x for exponential factor average rate and / 2x for default MaxRate -double accXPerSec = (slewRateX/DegreesForAcceleration); +double accXPerSec = (slewRateX/SLEW_ACCELERATION_DIST); double guideRates[10]={3.75,7.5,15,30,60,120,300,720,(RateToASPerSec/MaxRate)/2.0,RateToASPerSec/MaxRate}; // .25X .5x 1x 2x 4x 8x 20x 48x half-MaxRate MaxRate // 0 1 2 3 4 5 6 7 8 9 @@ -275,20 +269,18 @@ byte pecStatus = IgnorePEC; boolean pecRecorded = false; boolean pecFirstRecord = false; long lastPecIndex = -1; +int pecBufferSize = PEC_BUFFER_SIZE; long pecIndex = 0; long pecIndex1 = 0; int pecAnalogValue = 0; -int pecAutoRecord = 0; // for writing to PEC table to EEPROM -long wormSensePos = 0; // in steps -boolean wormSensedAgain = false; // indicates PEC index was found +int pecAutoRecord = 0; // for writing to PEC table to EEPROM +long wormSensePos = 0; // in steps +boolean wormSensedAgain = false; // indicates PEC index was found int LastPecPinState = PEC_SENSE_STATE; boolean pecBufferStart = false; -fixed_t accPecGuideHA; // for PEC, buffers steps to be recorded +fixed_t accPecGuideHA; // for PEC, buffers steps to be recorded volatile double pecTimerRateAxis1 = 0.0; -// it takes 3.3ms to record a value to EEPROM, this can effect tracking performance since interrupts are disabled during the operation. -// so we store PEC data in RAM while recording. When done, sidereal tracking is turned off and the data is written to EEPROM. -// writing the data can take up to 3 seconds. -byte pecBuffer[PECBufferSize]; +static byte *pecBuffer; // Misc --------------------------------------------------------------------------------------------------------------------- #define Rad 57.29577951 @@ -308,25 +300,25 @@ fixed_t fstepAxis1; fixed_t fstepAxis2; // status state -boolean LED_ON = false; -boolean LED2_ON = false; +boolean ledOn = false; +boolean led2On = false; // sound/buzzer -#ifdef DEFAULT_SOUND_ON -boolean soundEnabled = true; +#if BUZZER_STATE_DEFAULT == ON + boolean soundEnabled = true; #else -boolean soundEnabled = false; + boolean soundEnabled = false; #endif volatile int buzzerDuration = 0; // pause at home on meridian flip -boolean pauseHome = false; // allow pause at home? -boolean waitingHomeContinue = false; // set to true to stop pause -boolean waitingHome = false; // true if waiting at home +boolean pauseHome = false; // allow pause at home? +boolean waitingHomeContinue = false; // set to true to stop pause +boolean waitingHome = false; // true if waiting at home // reticule control -#ifdef RETICULE_LED_PINS -int reticuleBrightness=RETICULE_LED_PINS; +#if LED_RETICLE_PIN >= 0 + int reticuleBrightness=LED_RETICLE_PIN; #endif // backlash control @@ -336,59 +328,59 @@ volatile int blAxis1 = 0; volatile int blAxis2 = 0; // focuser control -#ifdef AXIS4_DC_MODE_ON -byte dcPwrAxis4 = 50; +#if AXIS4_DRIVER_DC_MODE != OFF + byte dcPwrAxis4 = 50; #endif -#ifdef AXIS5_DC_MODE_ON -byte dcPwrAxis5 = 50; +#if AXIS5_DRIVER_DC_MODE != OFF + byte dcPwrAxis5 = 50; #endif // aux pin control #ifdef Aux0 -byte valueAux0 = 0; + byte valueAux0 = 0; #endif #ifdef Aux1 -byte valueAux1 = 0; + byte valueAux1 = 0; #endif #ifdef Aux2 -byte valueAux2 = 0; + byte valueAux2 = 0; #endif #ifdef Aux3 -byte valueAux3 = 0; + byte valueAux3 = 0; #endif #ifdef Aux4 -byte valueAux4 = 0; + byte valueAux4 = 0; #endif #ifdef Aux5 -byte valueAux5 = 0; + byte valueAux5 = 0; #endif #ifdef Aux6 -byte valueAux6 = 0; + byte valueAux6 = 0; #endif #ifdef Aux7 -byte valueAux7 = 0; + byte valueAux7 = 0; #endif #ifdef Aux8 -byte valueAux8 = 0; + byte valueAux8 = 0; #endif #ifdef Aux9 -byte valueAux9 = 0; + byte valueAux9 = 0; #endif #ifdef Aux10 -byte valueAux10 = 0; + byte valueAux10 = 0; #endif #ifdef Aux11 -byte valueAux11 = 0; + byte valueAux11 = 0; #endif #ifdef Aux12 -byte valueAux12 = 0; + byte valueAux12 = 0; #endif #ifdef Aux13 -byte valueAux13 = 0; + byte valueAux13 = 0; #endif #ifdef Aux14 -byte valueAux14 = 0; + byte valueAux14 = 0; #endif #ifdef Aux15 -byte valueAux15 = 0; + byte valueAux15 = 0; #endif diff --git a/Goto.ino b/Goto.ino index 178c556b6..723457a19 100644 --- a/Goto.ino +++ b/Goto.ino @@ -6,20 +6,20 @@ GotoErrors validateGoto() { // Check state if (faultAxis1 || faultAxis2) return GOTO_ERR_HARDWARE_FAULT; if (!axis1Enabled) return GOTO_ERR_STANDBY; - if (parkStatus!=NotParked) return GOTO_ERR_PARK; + if (parkStatus != NotParked) return GOTO_ERR_PARK; if (guideDirAxis1 || guideDirAxis2) return GOTO_ERR_IN_MOTION; if (trackingSyncInProgress()) return GOTO_ERR_GOTO; - if (trackingState==TrackingMoveTo) return GOTO_ERR_GOTO; + if (trackingState == TrackingMoveTo) return GOTO_ERR_GOTO; return GOTO_ERR_NONE; } GotoErrors validateGotoCoords(double HA, double Dec, double Alt) { // Check coordinates - if (AltmaxAlt) return GOTO_ERR_ABOVE_OVERHEAD; - if (Dec>MaxDec) return GOTO_ERR_OUTSIDE_LIMITS; - if (Dec(double)UnderPoleLimit*15.0) ) return GOTO_ERR_OUTSIDE_LIMITS; + if (Alt < minAlt) return GOTO_ERR_BELOW_HORIZON; + if (Alt > maxAlt) return GOTO_ERR_ABOVE_OVERHEAD; + if (Dec < AXIS2_LIMIT_MIN) return GOTO_ERR_OUTSIDE_LIMITS; + if (Dec > AXIS2_LIMIT_MAX) return GOTO_ERR_OUTSIDE_LIMITS; + if ((fabs(HA) > (double)AXIS1_LIMIT_UNDER_POLE*15.0) ) return GOTO_ERR_OUTSIDE_LIMITS; return GOTO_ERR_NONE; } @@ -27,16 +27,16 @@ GotoErrors validateGoToEqu(double RA, double Dec) { double a,z; double HA=haRange(LST()*15.0-RA); equToHor(HA,Dec,&a,&z); - GotoErrors r=validateGoto(); if (r!=GOTO_ERR_NONE) return r; + GotoErrors r=validateGoto(); if (r != GOTO_ERR_NONE) return r; r=validateGotoCoords(HA,Dec,a); return r; } void setLastErrorForGoto(GotoErrors r) { // check to see if lastError was a goto error and clear it if so - if ((lastError>ERR_GOTO_ERR_NONE) && (lastError<=ERR_GOTO_ERR_UNSPECIFIED)) lastError=ERR_NONE; + if ((lastError > ERR_GOTO_ERR_NONE) && (lastError <= ERR_GOTO_ERR_UNSPECIFIED)) lastError=ERR_NONE; // if an goto error exists log it - if (r!=GOTO_ERR_NONE) lastError=(Errors)((int)ERR_GOTO_ERR_NONE+(int)r); + if (r != GOTO_ERR_NONE) lastError=(Errors)((int)ERR_GOTO_ERR_NONE+(int)r); } // syncs the telescope/mount to the sky @@ -50,12 +50,12 @@ GotoErrors syncEqu(double RA, double Dec) { // validate GotoErrors r=validateGoto(); setLastErrorForGoto(r); - if ((r!=GOTO_ERR_NONE) && (r!=GOTO_ERR_STANDBY)) return r; + if ((r != GOTO_ERR_NONE) && (r != GOTO_ERR_STANDBY)) return r; r=validateGotoCoords(HA,Dec,a); setLastErrorForGoto(r); - if (r!=GOTO_ERR_NONE) return r; + if (r != GOTO_ERR_NONE) return r; double Axis1,Axis2; -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM equToHor(HA,Dec,&Axis2,&Axis1); Align.horToInstr(Axis2,Axis1,&Axis2,&Axis1,getInstrPierSide()); Axis1=haRange(Axis1); @@ -69,24 +69,24 @@ GotoErrors syncEqu(double RA, double Dec) { // west side of pier - we're in the eastern sky and the HA's are negative // east side of pier - we're in the western sky and the HA's are positive int newPierSide=getInstrPierSide(); - if (meridianFlip!=MeridianFlipNever) { - if (atHome) { if (Axis1<0) newPierSide=PierSideWest; else newPierSide=PierSideEast; } else // best side of pier decided based on meridian -#if !defined(SYNC_CURRENT_PIER_SIDE_ONLY_ON) - if (preferredPierSide==PPS_WEST) { newPierSide=PierSideWest; if (haRange(Axis1)> minutesPastMeridianW/4.0) newPierSide=PierSideEast; } else - if (preferredPierSide==PPS_EAST) { newPierSide=PierSideEast; if (haRange(Axis1)<-minutesPastMeridianE/4.0) newPierSide=PierSideWest; } else + if (meridianFlip != MeridianFlipNever) { + if (atHome) { if (Axis1 < 0) newPierSide=PierSideWest; else newPierSide=PierSideEast; } else // best side of pier decided based on meridian +#if SYNC_CURRENT_PIER_SIDE_ONLY == OFF + if (preferredPierSide == PPS_WEST) { newPierSide=PierSideWest; if (haRange(Axis1) > degreesPastMeridianW) newPierSide=PierSideEast; } else + if (preferredPierSide == PPS_EAST) { newPierSide=PierSideEast; if (haRange(Axis1) < -degreesPastMeridianE) newPierSide=PierSideWest; } else #endif { - if ((getInstrPierSide()==PierSideWest) && (haRange(Axis1)> minutesPastMeridianW/4.0)) newPierSide=PierSideEast; - if ((getInstrPierSide()==PierSideEast) && (haRange(Axis1)<-minutesPastMeridianE/4.0)) newPierSide=PierSideWest; + if ((getInstrPierSide() == PierSideWest) && (haRange(Axis1) > degreesPastMeridianW)) newPierSide=PierSideEast; + if ((getInstrPierSide() == PierSideEast) && (haRange(Axis1) < -degreesPastMeridianE)) newPierSide=PierSideWest; } -#if defined(SYNC_CURRENT_PIER_SIDE_ONLY_ON) - if ((!atHome) && (newPierSide!=getInstrPierSide())) return GOTO_ERR_OUTSIDE_LIMITS; +#if SYNC_CURRENT_PIER_SIDE_ONLY == ON + if ((!atHome) && (newPierSide != getInstrPierSide())) return GOTO_ERR_OUTSIDE_LIMITS; #endif } else { // always on the "east" side of pier - we're in the western sky and the HA's are positive - // this is the default in the polar-home position and also for MOUNT_TYPE_FORK and MOUNT_TYPE_ALTAZM. + // this is the default in the polar-home position and also for MOUNT_TYPE FORK and MOUNT_TYPE ALTAZM. newPierSide=PierSideEast; } @@ -99,13 +99,13 @@ GotoErrors syncEqu(double RA, double Dec) { // syncs internal counts to shaft encoder position (in degrees) GotoErrors syncEnc(double EncAxis1, double EncAxis2) { // validate - GotoErrors f=validateGoto(); if (f!=GOTO_ERR_NONE) return f; + GotoErrors f=validateGoto(); if (f != GOTO_ERR_NONE) return f; // no sync from encoders during an alignment! if (alignActive()) return GOTO_ERR_NONE; - long e1=EncAxis1*(double)StepsPerDegreeAxis1; - long e2=EncAxis2*(double)StepsPerDegreeAxis2; + long e1=EncAxis1*(double)AXIS1_STEPS_PER_DEGREE; + long e2=EncAxis2*(double)AXIS2_STEPS_PER_DEGREE; long a1,a2; cli(); @@ -119,9 +119,9 @@ GotoErrors syncEnc(double EncAxis1, double EncAxis2) { long delta2=a2-e2; indexAxis1Steps-=delta1; - indexAxis1=(double)indexAxis1Steps/(double)StepsPerDegreeAxis1; + indexAxis1=(double)indexAxis1Steps/(double)AXIS1_STEPS_PER_DEGREE; indexAxis2Steps-=delta2; - indexAxis2=(double)indexAxis2Steps/(double)StepsPerDegreeAxis2; + indexAxis2=(double)indexAxis2Steps/(double)AXIS2_STEPS_PER_DEGREE; return GOTO_ERR_NONE; } @@ -136,8 +136,8 @@ int getEnc(double *EncAxis1, double *EncAxis2) { a1+=indexAxis1Steps; a2+=indexAxis2Steps; - *EncAxis1=(double)a1/(double)StepsPerDegreeAxis1; - *EncAxis2=(double)a2/(double)StepsPerDegreeAxis2; + *EncAxis1=(double)a1/(double)AXIS1_STEPS_PER_DEGREE; + *EncAxis2=(double)a2/(double)AXIS2_STEPS_PER_DEGREE; return 0; } @@ -146,7 +146,7 @@ int getEnc(double *EncAxis1, double *EncAxis2) { boolean getEqu(double *RA, double *Dec, boolean returnHA) { double HA; -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM HA=getInstrAxis1(); *Dec=getInstrAxis2(); // apply pointing model @@ -162,8 +162,8 @@ boolean getEqu(double *RA, double *Dec, boolean returnHA) { // return either the RA or the HA depending on returnHA if (!returnHA) { *RA=(LST()*15.0-HA); - while (*RA>=360.0) *RA-=360.0; - while (*RA<0.0) *RA+=360.0; + while (*RA >= 360.0) *RA-=360.0; + while (*RA < 0.0) *RA+=360.0; } else *RA=HA; return true; @@ -173,7 +173,7 @@ boolean getEqu(double *RA, double *Dec, boolean returnHA) { boolean getApproxEqu(double *RA, double *Dec, boolean returnHA) { double HA; -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM HA=getInstrAxis1(); *Dec=getInstrAxis2(); #else @@ -183,8 +183,8 @@ boolean getApproxEqu(double *RA, double *Dec, boolean returnHA) { #endif HA=haRange(HA); - if (*Dec>90.0) *Dec=+90.0; - if (*Dec<-90.0) *Dec=-90.0; + if (*Dec > 90.0) *Dec=+90.0; + if (*Dec < -90.0) *Dec=-90.0; // return either the RA or the HA depending on returnHA if (!returnHA) { @@ -205,10 +205,10 @@ boolean getHor(double *Alt, double *Azm) { GotoErrors goToHere(bool toEastOnly) { bool verified=false; PreferredPierSide p=preferredPierSide; - if (meridianFlip==MeridianFlipNever) return GOTO_ERR_OUTSIDE_LIMITS; + if (meridianFlip == MeridianFlipNever) return GOTO_ERR_OUTSIDE_LIMITS; cli(); long h=posAxis1+indexAxis1Steps; sei(); - if ((!toEastOnly) && (getInstrPierSide()==PierSideEast) && (h<(minutesPastMeridianW*(long)StepsPerDegreeAxis1/4L))) { verified=true; preferredPierSide=PPS_WEST; } - if ((getInstrPierSide()==PierSideWest) && (h>(-minutesPastMeridianE*(long)StepsPerDegreeAxis1/4L))) { verified=true; preferredPierSide=PPS_EAST; } + if ((!toEastOnly) && (getInstrPierSide() == PierSideEast) && (h < (degreesPastMeridianW*(long)AXIS1_STEPS_PER_DEGREE))) { verified=true; preferredPierSide=PPS_WEST; } + if ((getInstrPierSide() == PierSideWest) && (h > (-degreesPastMeridianE*(long)AXIS1_STEPS_PER_DEGREE))) { verified=true; preferredPierSide=PPS_EAST; } if (verified) { double newRA,newDec; getEqu(&newRA,&newDec,false); @@ -231,36 +231,36 @@ GotoErrors goToEqu(double RA, double Dec) { // validate GotoErrors r=validateGoto(); setLastErrorForGoto(r); #ifndef GOTO_ERR_GOTO_OFF - if (r==GOTO_ERR_GOTO) { if (!abortSlew) abortSlew=StartAbortSlew; } + if (r == GOTO_ERR_GOTO) { if (!abortSlew) abortSlew=StartAbortSlew; } #endif - if (r!=GOTO_ERR_NONE) return r; + if (r != GOTO_ERR_NONE) return r; r=validateGotoCoords(HA,Dec,a); setLastErrorForGoto(r); - if (r!=GOTO_ERR_NONE) return r; + if (r != GOTO_ERR_NONE) return r; -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM equToHor(HA,Dec,&a,&z); Align.horToInstr(a,z,&a,&z,getInstrPierSide()); z=haRange(z); - if ((MaxAzm>180) && (MaxAzm<=360)) { + if ((AXIS1_LIMIT_MAXAZM > 180) && (AXIS1_LIMIT_MAXAZM <= 360)) { // adjust coordinate range to allow going past 180 deg. // position a1 is 0..180 double a1=getInstrAxis1(); - if (a1>=0) { + if (a1 >= 0) { // and goto z is in -0..-180 - if (z<0) { + if (z < 0) { // the alternate z1 is in 180..360 double z1=z+360.0; - if ((z1dist(a1,z1))) z=z1; + if ((z1 < AXIS1_LIMIT_MAXAZM) && (dist(a1,z) > dist(a1,z1))) z=z1; } } // position a1 -0..-180 - if (a1<0) { + if (a1 < 0) { // and goto z is in 0..180 - if (z>0) { + if (z > 0) { // the alternate z1 is in -360..-180 double z1=z-360.0; - if ((z1>-MaxAzm) && (dist(a1,z)>dist(a1,z1))) z=z1; + if ((z1 > -AXIS1_LIMIT_MAXAZM) && (dist(a1,z) > dist(a1,z1))) z=z1; } } } @@ -274,16 +274,16 @@ GotoErrors goToEqu(double RA, double Dec) { Align.equToInstr(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; + int p=PierSideNone; if (getInstrPierSide() == PierSideEast) p=PierSideWest; else if (getInstrPierSide() == PierSideWest) p=PierSideEast; Align.equToInstr(HA,Dec,&Axis1Alt,&Axis2Alt,p); #endif // goto function takes HA and Dec in steps // when in align mode, force pier side byte thisPierSide = PierSideBest; - if (meridianFlip!=MeridianFlipNever) { - if (preferredPierSide==PPS_WEST) thisPierSide=PierSideWest; - if (preferredPierSide==PPS_EAST) thisPierSide=PierSideEast; + if (meridianFlip != MeridianFlipNever) { + if (preferredPierSide == PPS_WEST) thisPierSide=PierSideWest; + if (preferredPierSide == PPS_EAST) thisPierSide=PierSideEast; } return goTo(Axis1,Axis2,Axis1Alt,Axis2Alt,thisPierSide); @@ -304,39 +304,39 @@ GotoErrors goTo(double thisTargetAxis1, double thisTargetAxis2, double altTarget atHome=false; int thisPierSide=getInstrPierSide(); - if (meridianFlip!=MeridianFlipNever) { + if (meridianFlip != MeridianFlipNever) { // where the allowable hour angles are double eastOfPierMaxHA= 180.0; - double eastOfPierMinHA=-minutesPastMeridianE/4.0; - double westOfPierMaxHA= minutesPastMeridianW/4.0; + double eastOfPierMinHA=-degreesPastMeridianE; + double westOfPierMaxHA= degreesPastMeridianW; double westOfPierMinHA=-180.0; // override the defaults and force a flip if near the meridian and possible (for parking and align) - if ((gotoPierSide!=PierSideBest) && (thisPierSide!=gotoPierSide)) { - if (thisPierSide==PierSideEast) eastOfPierMinHA= minutesPastMeridianW/4.0; - if (thisPierSide==PierSideWest) westOfPierMaxHA=-minutesPastMeridianE/4.0; + if ((gotoPierSide != PierSideBest) && (thisPierSide != gotoPierSide)) { + if (thisPierSide == PierSideEast) eastOfPierMinHA= degreesPastMeridianW; + if (thisPierSide == PierSideWest) westOfPierMaxHA=-degreesPastMeridianE; } // if doing a meridian flip, use the opposite pier side coordinates - if (thisPierSide==PierSideEast) { - if ((thisTargetAxis1>eastOfPierMaxHA) || (thisTargetAxis1 eastOfPierMaxHA) || (thisTargetAxis1 < eastOfPierMinHA)) { thisPierSide=PierSideFlipEW1; thisTargetAxis1 =altTargetAxis1; - if (thisTargetAxis1>westOfPierMaxHA) return GOTO_ERR_OUTSIDE_LIMITS; + if (thisTargetAxis1 > westOfPierMaxHA) return GOTO_ERR_OUTSIDE_LIMITS; thisTargetAxis2=altTargetAxis2; } } else - if (thisPierSide==PierSideWest) { - if ((thisTargetAxis1>westOfPierMaxHA) || (thisTargetAxis1 westOfPierMaxHA) || (thisTargetAxis1 < westOfPierMinHA)) { thisPierSide=PierSideFlipWE1; thisTargetAxis1 =altTargetAxis1; - if (thisTargetAxis1MaxAzm) || (thisTargetAxis1<-MaxAzm)) || ((thisTargetAxis2>180.0) || (thisTargetAxis2<-180.0))) return GOTO_ERR_UNSPECIFIED; + if (((thisTargetAxis1 > AXIS1_LIMIT_MAXAZM) || (thisTargetAxis1 < -AXIS1_LIMIT_MAXAZM)) || ((thisTargetAxis2 > 180.0) || (thisTargetAxis2 < -180.0))) return GOTO_ERR_UNSPECIFIED; #else - if (((thisTargetAxis1>180.0) || (thisTargetAxis1<-180.0)) || ((thisTargetAxis2>180.0) || (thisTargetAxis2<-180.0))) return GOTO_ERR_UNSPECIFIED; + if (((thisTargetAxis1 > 180.0) || (thisTargetAxis1 < -180.0)) || ((thisTargetAxis2 > 180.0) || (thisTargetAxis2 < -180.0))) return GOTO_ERR_UNSPECIFIED; #endif lastTrackingState=trackingState; @@ -377,19 +377,17 @@ GotoErrors goTo(double thisTargetAxis1, double thisTargetAxis2, double altTarget setTargetAxis1(thisTargetAxis1,p); setTargetAxis2(thisTargetAxis2,p); - #ifdef MERIDIAN_FLIP_SKIP_HOME_ON +#if (MFLIP_SKIP_HOME == ON) boolean gotoDirect=true; - #else +#else boolean gotoDirect=false; - #endif +#endif + if (!pauseHome && gotoDirect) { - if (thisPierSide==PierSideFlipWE1) pierSideControl=PierSideEast; else - if (thisPierSide==PierSideFlipEW1) pierSideControl=PierSideWest; else pierSideControl=thisPierSide; + if (thisPierSide == PierSideFlipWE1) pierSideControl=PierSideEast; else + if (thisPierSide == PierSideFlipEW1) pierSideControl=PierSideWest; else pierSideControl=thisPierSide; } else pierSideControl=thisPierSide; - 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(""); - reactivateBacklashComp(); disablePec(); soundAlert(); diff --git a/Guide.ino b/Guide.ino index 4ec030f74..070ddde12 100644 --- a/Guide.ino +++ b/Guide.ino @@ -1,10 +1,10 @@ // --------------------------------------------------------------------------------------------------- // Guide, commands to move the mount in any direction at a series of fixed rates -#if defined(ST4_ON) || defined(ST4_PULLUP) +#if ST4_INTERFACE == ON || ST4_INTERFACE == ON_PULLUP #include "src/lib/PushButton.h" -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON #define debounceMs 100 #else #define debounceMs 5 @@ -41,8 +41,8 @@ void initGuide() { guideTimeRemainingAxis2 = -1; guideTimeThisIntervalAxis2 = -1; -#if defined(ST4_ON) || defined(ST4_PULLUP) - #ifdef ST4_ON +#if ST4_INTERFACE == ON || ST4_INTERFACE == ON_PULLUP + #if ST4_INTERFACE == ON boolean pullup=false; #else boolean pullup=true; @@ -58,18 +58,18 @@ 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(); - if (guideLst!=guideSiderealTimer) { + if (guideLst != guideSiderealTimer) { guideSiderealTimer=guideLst; if (guideDirAxis1) { if (!inbacklashAxis1) { // guideAxis1 keeps track of how many steps we've moved for PEC recording - if (guideDirAxis1=='e') guideAxis1.fixed=-amountGuideAxis1.fixed; else if (guideDirAxis1=='w') guideAxis1.fixed=amountGuideAxis1.fixed; + if (guideDirAxis1 == 'e') guideAxis1.fixed=-amountGuideAxis1.fixed; else if (guideDirAxis1 == 'w') guideAxis1.fixed=amountGuideAxis1.fixed; // for pulse guiding, count down the mS and stop when timed out - if (guideTimeRemainingAxis1>0) { + if (guideTimeRemainingAxis1 > 0) { guideTimeRemainingAxis1-=(long)(micros()-guideTimeThisIntervalAxis1); guideTimeThisIntervalAxis1=micros(); - if (guideTimeRemainingAxis1<=0) { guideDirAxis1='b'; } // break + if (guideTimeRemainingAxis1 <= 0) { guideDirAxis1='b'; } // break } } else { // don't count time if in backlash @@ -80,10 +80,10 @@ void guide() { if (guideDirAxis2) { if (!inbacklashAxis2) { // for pulse guiding, count down the mS and stop when timed out - if (guideTimeRemainingAxis2>0) { + if (guideTimeRemainingAxis2 > 0) { guideTimeRemainingAxis2-=(long)(micros()-guideTimeThisIntervalAxis2); guideTimeThisIntervalAxis2=micros(); - if (guideTimeRemainingAxis2<=0) { guideDirAxis2='b'; } // break + if (guideTimeRemainingAxis2 <= 0) { guideDirAxis2='b'; } // break } } else { // don't count time if in backlash @@ -95,7 +95,7 @@ void guide() { // returns true if rapid movement is happening boolean isSlewing() { - return ((guideDirAxis1!=0) && (fabs(guideTimerRateAxis1)>=2)) || ((guideDirAxis2!=0) && (fabs(guideTimerRateAxis2)>=2)) || (trackingState==TrackingMoveTo); + return ((guideDirAxis1 != 0) && (fabs(guideTimerRateAxis1) >= 2)) || ((guideDirAxis2 != 0) && (fabs(guideTimerRateAxis2) >= 2)) || (trackingState == TrackingMoveTo); } // reactivate or deactivate backlash comp. if necessary @@ -103,29 +103,29 @@ int backlashAxis1PriorToGuide=0; int backlashAxis2PriorToGuide=0; void reactivateBacklashComp() { -#ifdef GUIDES_DISABLE_BACKLASH_ON - if (backlashAxis1PriorToGuide>0) { cli(); backlashAxis1=backlashAxis1PriorToGuide; sei(); backlashAxis1PriorToGuide=0; } - if (backlashAxis2PriorToGuide>0) { cli(); backlashAxis2=backlashAxis2PriorToGuide; sei(); backlashAxis2PriorToGuide=0; } +#if GUIDE_DISABLE_BACKLASH == ON + if (backlashAxis1PriorToGuide > 0) { cli(); backlashAxis1=backlashAxis1PriorToGuide; sei(); backlashAxis1PriorToGuide=0; } + if (backlashAxis2PriorToGuide > 0) { cli(); backlashAxis2=backlashAxis2PriorToGuide; sei(); backlashAxis2PriorToGuide=0; } #endif } void deactivateBacklashComp() { -#ifdef GUIDES_DISABLE_BACKLASH_ON - if (backlashAxis1PriorToGuide==0) { backlashAxis1PriorToGuide=backlashAxis1; cli(); backlashAxis1=0; sei(); } - if (backlashAxis2PriorToGuide==0) { backlashAxis2PriorToGuide=backlashAxis2; cli(); backlashAxis2=0; sei(); } +#if GUIDE_DISABLE_BACKLASH == ON + if (backlashAxis1PriorToGuide == 0) { backlashAxis1PriorToGuide=backlashAxis1; cli(); backlashAxis1=0; sei(); } + if (backlashAxis2PriorToGuide == 0) { backlashAxis2PriorToGuide=backlashAxis2; cli(); backlashAxis2=0; sei(); } #endif } // start a guide in RA or Azm, direction must be 'e', 'w', or 'b', guideRate is the rate selection (0 to 9), guideDuration is in ms (0 to ignore) bool startGuideAxis1(char direction, int guideRate, long guideDuration) { - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo) && (!trackingSyncInProgress()) && (direction!=guideDirAxis1) && (axis1Enabled)) { - if (guideRate<3) deactivateBacklashComp(); else reactivateBacklashComp(); + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo) && (!trackingSyncInProgress()) && (direction != guideDirAxis1) && (axis1Enabled)) { + if (guideRate < 3) deactivateBacklashComp(); else reactivateBacklashComp(); enableGuideRate(guideRate); guideDirAxis1=direction; guideTimeThisIntervalAxis1=micros(); guideTimeRemainingAxis1=guideDuration*1000L; cli(); - if (guideDirAxis1=='e') guideTimerRateAxis1=-guideTimerBaseRateAxis1; else guideTimerRateAxis1=guideTimerBaseRateAxis1; + if (guideDirAxis1 == 'e') guideTimerRateAxis1=-guideTimerBaseRateAxis1; else guideTimerRateAxis1=guideTimerBaseRateAxis1; sei(); } else return false; return true; @@ -133,22 +133,22 @@ bool startGuideAxis1(char direction, int guideRate, long guideDuration) { // stops guide in RA or Azm void stopGuideAxis1() { - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo)) { - cli(); if ((guideDirAxis1) && (guideDirAxis1!='b')) { guideDirAxis1='b'; } sei(); + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo)) { + cli(); if ((guideDirAxis1) && (guideDirAxis1 != 'b')) { guideDirAxis1='b'; } sei(); } } // start a guide in Dec or Alt, direction must be 'n', 's', or 'b', guideRate is the rate selection (0 to 9), guideDuration is in ms (0 to ignore) bool startGuideAxis2(char direction, int guideRate, long guideDuration, bool absolute) { - if (((parkStatus==NotParked) && (trackingState!=TrackingMoveTo)) && (!trackingSyncInProgress()) && (direction!=guideDirAxis2) && (axis1Enabled)) { + if (((parkStatus == NotParked) && (trackingState != TrackingMoveTo)) && (!trackingSyncInProgress()) && (direction != guideDirAxis2) && (axis1Enabled)) { enableGuideRate(guideRate); - if (guideRate<3) deactivateBacklashComp(); else reactivateBacklashComp(); + if (guideRate < 3) deactivateBacklashComp(); else reactivateBacklashComp(); guideDirAxis2=direction; guideTimeThisIntervalAxis2=micros(); guideTimeRemainingAxis2=guideDuration*1000L; - if (guideDirAxis2=='s') { cli(); guideTimerRateAxis2=-guideTimerBaseRateAxis2; sei(); } - if (guideDirAxis2=='n') { cli(); guideTimerRateAxis2= guideTimerBaseRateAxis2; sei(); } - if (!absolute && (getInstrPierSide()==PierSideWest)) { cli(); guideTimerRateAxis2=-guideTimerRateAxis2; sei(); } + if (guideDirAxis2 == 's') { cli(); guideTimerRateAxis2=-guideTimerBaseRateAxis2; sei(); } + if (guideDirAxis2 == 'n') { cli(); guideTimerRateAxis2= guideTimerBaseRateAxis2; sei(); } + if (!absolute && (getInstrPierSide() == PierSideWest)) { cli(); guideTimerRateAxis2=-guideTimerRateAxis2; sei(); } } else return false; return true; } @@ -159,8 +159,8 @@ bool startGuideAxis2(char direction, int guideRate, long guideDuration) { // stops guide in Dec or Alt void stopGuideAxis2() { - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo)) { - cli(); if ((guideDirAxis2) && (guideDirAxis2!='b')) { guideDirAxis2='b'; } sei(); + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo)) { + cli(); if ((guideDirAxis2) && (guideDirAxis2 != 'b')) { guideDirAxis2='b'; } sei(); } } @@ -169,12 +169,12 @@ double guideTimerCustomRateAxis1 = 0.0; bool customGuideRateAxis1(double rate, long guideDuration) { guideTimerCustomRateAxis1=rate; enableGuideRate(-1); - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo) && (axis1Enabled) && (guideDirAxis1)) { + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo) && (axis1Enabled) && (guideDirAxis1)) { guideTimeThisIntervalAxis1=micros(); guideTimeRemainingAxis1=guideDuration*1000L; cli(); - if (guideDirAxis1=='e') guideTimerRateAxis1=-guideTimerBaseRateAxis1; - if (guideDirAxis1=='w') guideTimerRateAxis1=guideTimerBaseRateAxis1; + if (guideDirAxis1 == 'e') guideTimerRateAxis1=-guideTimerBaseRateAxis1; + if (guideDirAxis1 == 'w') guideTimerRateAxis1=guideTimerBaseRateAxis1; sei(); } else return false; return true; @@ -185,12 +185,12 @@ double guideTimerCustomRateAxis2 = 0.0; bool customGuideRateAxis2(double rate, long guideDuration) { guideTimerCustomRateAxis2=rate; enableGuideRate(-1); - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo) && (axis2Enabled) && (guideDirAxis2)) { + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo) && (axis2Enabled) && (guideDirAxis2)) { guideTimeThisIntervalAxis2=micros(); guideTimeRemainingAxis2=guideDuration*1000L; - if (guideDirAxis2=='s') { cli(); guideTimerRateAxis2=-guideTimerBaseRateAxis2; sei(); } - if (guideDirAxis2=='n') { cli(); guideTimerRateAxis2= guideTimerBaseRateAxis2; sei(); } - if (getInstrPierSide()==PierSideWest) { cli(); guideTimerRateAxis2=-guideTimerRateAxis2; sei(); } + if (guideDirAxis2 == 's') { cli(); guideTimerRateAxis2=-guideTimerBaseRateAxis2; sei(); } + if (guideDirAxis2 == 'n') { cli(); guideTimerRateAxis2= guideTimerBaseRateAxis2; sei(); } + if (getInstrPierSide() == PierSideWest) { cli(); guideTimerRateAxis2=-guideTimerRateAxis2; sei(); } } else return false; return true; } @@ -198,7 +198,7 @@ bool customGuideRateAxis2(double rate, long guideDuration) { // sets the rates for guide commands void setGuideRate(int g) { currentGuideRate=g; - if ((g<=GuideRate1x) && (currentPulseGuideRate!=g)) { currentPulseGuideRate=g; nv.update(EE_pulseGuideRate,g); } + if ((g <= GuideRate1x) && (currentPulseGuideRate != g)) { currentPulseGuideRate=g; nv.update(EE_pulseGuideRate,g); } guideTimerCustomRateAxis1=0.0; guideTimerCustomRateAxis2=0.0; } @@ -210,7 +210,7 @@ int getGuideRate() { // gets the rate for pulse-guide commands int getPulseGuideRate() { -#ifdef SEPARATE_PULSE_GUIDE_RATE_ON +#if SEPARATE_PULSE_GUIDE_RATE == ON return currentPulseGuideRate; #else return currentGuideRate; @@ -222,17 +222,17 @@ int getPulseGuideRate() { // 0=.25X 1=.5x 2=1x 3=2x 4=4x 5=8x 6=24x 7=48x 8=half-MaxRate 9=MaxRate void enableGuideRate(int g) { // don't do these calculations unless we have to - if (activeGuideRate==g) return; + if (activeGuideRate == g) return; - if (g>=0) activeGuideRate=g; + if (g >= 0) activeGuideRate=g; // this enables the guide rates - if (guideTimerCustomRateAxis1!=0.0) { + if (guideTimerCustomRateAxis1 != 0.0) { guideTimerBaseRateAxis1=guideTimerCustomRateAxis1; } else { guideTimerBaseRateAxis1=(double)(guideRates[g]/15.0); } - if (guideTimerCustomRateAxis2!=0.0) { + if (guideTimerCustomRateAxis2 != 0.0) { guideTimerBaseRateAxis2=guideTimerCustomRateAxis2; } else { guideTimerBaseRateAxis2=(double)(guideRates[g]/15.0); @@ -243,7 +243,7 @@ void enableGuideRate(int g) { // handle the ST4 interface and hand controller features void ST4() { -#if defined(ST4_ON) || defined(ST4_PULLUP) +#if ST4_INTERFACE == ON || ST4_INTERFACE == ON_PULLUP // get ST4 button presses st4e.poll(); static boolean shcActive=false; @@ -253,7 +253,7 @@ void ST4() { st4s.poll(); } -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON // check for smart hand control if (st4e.hasTone()) { @@ -270,21 +270,21 @@ void ST4() { char c=SerialST4.poll(); // process any single byte guide commands - if (c==ccMe) startGuideAxis1('e',currentGuideRate,GUIDE_TIME_LIMIT*1000); - if (c==ccMw) startGuideAxis1('w',currentGuideRate,GUIDE_TIME_LIMIT*1000); - if (c==ccMn) startGuideAxis2('n',currentGuideRate,GUIDE_TIME_LIMIT*1000); - if (c==ccMs) startGuideAxis2('s',currentGuideRate,GUIDE_TIME_LIMIT*1000); - if ((c==ccQe) || (c==ccQw)) stopGuideAxis1(); - if ((c==ccQn) || (c==ccQs)) stopGuideAxis2(); + if (c == ccMe) startGuideAxis1('e',currentGuideRate,GUIDE_TIME_LIMIT*1000); + if (c == ccMw) startGuideAxis1('w',currentGuideRate,GUIDE_TIME_LIMIT*1000); + if (c == ccMn) startGuideAxis2('n',currentGuideRate,GUIDE_TIME_LIMIT*1000); + if (c == ccMs) startGuideAxis2('s',currentGuideRate,GUIDE_TIME_LIMIT*1000); + if ((c == ccQe) || (c == ccQw)) stopGuideAxis1(); + if ((c == ccQn) || (c == ccQs)) stopGuideAxis2(); return; } } else { if (shcActive) { - #ifdef ST4_ON + #if ST4_INTERFACE == ON pinMode(ST4DEs,INPUT); pinMode(ST4DEn,INPUT); - #else + #elif ST4_INTERFACE == ON_PULLUP pinMode(ST4DEs,INPUT_PULLUP); pinMode(ST4DEn,INPUT_PULLUP); #endif @@ -305,38 +305,38 @@ void ST4() { // see if a combination was down for long enough for an alternate mode static bool altModeA=false; static bool altModeB=false; - if ((trackingState!=TrackingMoveTo) && (!waitingHome)) { - if ((st4e.timeDown()>AltMode_ms) && (st4w.timeDown()>AltMode_ms) && (!altModeB)) { if (!altModeA) { altModeA=true; soundBeep(); } } - if ((st4n.timeDown()>AltMode_ms) && (st4s.timeDown()>AltMode_ms) && (!altModeA)) { if (!altModeB) { altModeB=true; soundBeep(); } } + if ((trackingState != TrackingMoveTo) && (!waitingHome)) { + if ((st4e.timeDown() > AltMode_ms) && (st4w.timeDown() > AltMode_ms) && (!altModeB)) { if (!altModeA) { altModeA=true; soundBeep(); } } + if ((st4n.timeDown() > AltMode_ms) && (st4s.timeDown() > AltMode_ms) && (!altModeA)) { if (!altModeB) { altModeB=true; soundBeep(); } } } // if the alternate mode is allowed & selected & hasn't timed out, handle it - if ( (altModeA || altModeB) && ((st4n.timeUp()=7) c=8; else if (c>=5) c=7; else if (c>=2) c=5; else if (c<2) c=2; } + if (trackingState == TrackingNone) cmdSend(":B+#",true); else { if (c >= 7) c=8; else if (c >= 5) c=7; else if (c >= 2) c=5; else if (c < 2) c=2; } soundClick(); } if (st4e.wasPressed() && !st4w.wasPressed()) { - if (trackingState==TrackingNone) cmdSend(":B-#",true); else { if (c<=5) c=2; else if (c<=7) c=5; else if (c<=8) c=7; else if (c>8) c=8; } + if (trackingState == TrackingNone) cmdSend(":B-#",true); else { if (c <= 5) c=2; else if (c <= 7) c=5; else if (c <= 8) c=7; else if (c > 8) c=8; } soundClick(); } if (st4s.wasPressed() && !st4n.wasPressed()) { - if (alignThisStar>alignNumStars) cmdSend(":CS#",true); else cmdSend(":A+#",true); + if (alignThisStar > alignNumStars) cmdSend(":CS#",true); else cmdSend(":A+#",true); 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); } + if (c != currentGuideRate) { setGuideRate(c); enableGuideRate(c); } } if (altModeB) { -#ifdef ST4_HAND_CONTROL_FOCUSER_ON +#if ST4_HAND_CONTROL_FOCUSER == ON static int fs=0; static int fn=0; if (!fn && !fs) { @@ -344,12 +344,12 @@ void ST4() { if (st4e.wasPressed() && !st4w.wasPressed()) { cmdSend(":F1#",true); soundClick(); } } if (!fn) { - if (st4s.isDown() && st4n.isUp()) { if (fs==0) { cmdSend(":FS#",true); fs++; } else if (fs==1) { cmdSend(":F-#",true); fs++; } else if ((st4s.timeDown()>4000) && (fs==2)) { fs++; cmdSend(":FF#",true); } else if (fs==3) { cmdSend(":F-#",true); fs++; } } - if (st4s.isUp()) { if (fs>0) { cmdSend(":FQ#",true); fs=0; } } + if (st4s.isDown() && st4n.isUp()) { if (fs == 0) { cmdSend(":FS#",true); fs++; } else if (fs == 1) { cmdSend(":F-#",true); fs++; } else if ((st4s.timeDown() > 4000) && (fs == 2)) { fs++; cmdSend(":FF#",true); } else if (fs == 3) { cmdSend(":F-#",true); fs++; } } + if (st4s.isUp()) { if (fs > 0) { cmdSend(":FQ#",true); fs=0; } } } if (!fs) { - if (st4n.isDown() && st4s.isUp()) { if (fn==0) { cmdSend(":FS#",true); fn++; } else if (fn==1) { cmdSend(":F+#",true); fn++; } else if ((st4n.timeDown()>4000) && (fn==2)) { fn++; cmdSend(":FF#",true); } else if (fn==3) { cmdSend(":F+#",true); fn++; } } - if (st4n.isUp()) { if (fn>0) { cmdSend(":FQ#",true); fn=0; } } + if (st4n.isDown() && st4s.isUp()) { if (fn == 0) { cmdSend(":FS#",true); fn++; } else if (fn == 1) { cmdSend(":F+#",true); fn++; } else if ((st4n.timeDown() > 4000) && (fn == 2)) { fn++; cmdSend(":FF#",true); } else if (fn == 3) { cmdSend(":F+#",true); fn++; } } + if (st4n.isUp()) { if (fn > 0) { cmdSend(":FQ#",true); fn=0; } } } #else if (st4w.wasPressed() && !st4e.wasPressed()) { cmdSend(":LN#",true); soundClick(); } @@ -361,7 +361,7 @@ void ST4() { } } else { if ((altModeA || altModeB)) { -#ifdef ST4_HAND_CONTROL_FOCUSER_ON +#if ST4_HAND_CONTROL_FOCUSER == ON cmdSend(":FQ#",true); #endif altModeA=false; altModeB=false; soundBeep(); @@ -374,16 +374,16 @@ void ST4() { if (st4w.isDown() && st4e.isUp()) newDirAxis1='w'; if (st4e.isDown() && st4w.isUp()) newDirAxis1='e'; - if (newDirAxis1!=ST4DirAxis1) { + if (newDirAxis1 != ST4DirAxis1) { ST4DirAxis1=newDirAxis1; - if (newDirAxis1!='b') { -#ifdef ST4_HAND_CONTROL_ON + if (newDirAxis1 != 'b') { +#if ST4_HAND_CONTROL == ON if (waitingHome) waitingHomeContinue=true; else - if (trackingState==TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else + if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else #endif { -#if defined(SEPARATE_PULSE_GUIDE_RATE_ON) && !defined(ST4_HAND_CONTROL_ON) - if (trackingState==TrackingSidereal) startGuideAxis1(newDirAxis1,currentPulseGuideRate,GUIDE_TIME_LIMIT*1000); +#if SEPARATE_PULSE_GUIDE_RATE == ON && ST4_HAND_CONTROL != ON + if (trackingState == TrackingSidereal) startGuideAxis1(newDirAxis1,currentPulseGuideRate,GUIDE_TIME_LIMIT*1000); #else startGuideAxis1(newDirAxis1,currentGuideRate,GUIDE_TIME_LIMIT*1000); #endif @@ -396,17 +396,17 @@ void ST4() { if (st4n.isDown() && st4s.isUp()) newDirAxis2='n'; if (st4s.isDown() && st4n.isUp()) newDirAxis2='s'; - if (newDirAxis2!=ST4DirAxis2) { + if (newDirAxis2 != ST4DirAxis2) { ST4DirAxis2=newDirAxis2; - if (newDirAxis2!='b') { -#ifdef ST4_HAND_CONTROL_ON + if (newDirAxis2 != 'b') { +#if ST4_HAND_CONTROL == ON if (waitingHome) waitingHomeContinue=true; else - if (trackingState==TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else + if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else #endif { -#if defined(SEPARATE_PULSE_GUIDE_RATE_ON) && !defined(ST4_HAND_CONTROL_ON) - if (trackingState==TrackingSidereal) startGuideAxis2(newDirAxis2,currentPulseGuideRate,GUIDE_TIME_LIMIT*1000); +#if SEPARATE_PULSE_GUIDE_RATE == ON && ST4_HAND_CONTROL != ON + if (trackingState == TrackingSidereal) startGuideAxis2(newDirAxis2,currentPulseGuideRate,GUIDE_TIME_LIMIT*1000); #else startGuideAxis2(newDirAxis2,currentGuideRate,GUIDE_TIME_LIMIT*1000); #endif @@ -414,7 +414,7 @@ void ST4() { } else stopGuideAxis2(); } } -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON } #endif #endif diff --git a/Home.ino b/Home.ino index ab1426a67..ca87f6107 100644 --- a/Home.ino +++ b/Home.ino @@ -1,7 +1,7 @@ // ----------------------------------------------------------------------------------- // Functions related to Homing the mount -#ifdef HOME_SENSE_ON +#if (HOME_SENSE == ON) enum findHomeModes { FH_OFF,FH_FAST,FH_IDLE,FH_SLOW,FH_DONE }; findHomeModes findHomeMode=FH_OFF; int PierSideStateAxis1=LOW; @@ -10,25 +10,25 @@ unsigned long findHomeTimeout=0L; void checkHome() { // check if find home timed out or stopped - if ((findHomeMode==FH_FAST) || (findHomeMode==FH_SLOW)) { - if (((long)(millis()-findHomeTimeout)>0L) || ((guideDirAxis1==0) && (guideDirAxis2==0))) { - if ((guideDirAxis1=='e') || (guideDirAxis1=='w')) guideDirAxis1='b'; - if ((guideDirAxis2=='n') || (guideDirAxis2=='s')) guideDirAxis2='b'; + if ((findHomeMode == FH_FAST) || (findHomeMode == FH_SLOW)) { + if (((long)(millis()-findHomeTimeout) > 0L) || ((guideDirAxis1 == 0) && (guideDirAxis2 == 0))) { + if ((guideDirAxis1 == 'e') || (guideDirAxis1 == 'w')) guideDirAxis1='b'; + if ((guideDirAxis2 == 'n') || (guideDirAxis2 == 's')) guideDirAxis2='b'; safetyLimitsOn=true; lastError=ERR_LIMIT_SENSE; findHomeMode=FH_OFF; } else { - if ((digitalRead(Axis1_HOME)!=PierSideStateAxis1) && ((guideDirAxis1=='e') || (guideDirAxis1=='w'))) StopAxis1(); - if ((digitalRead(Axis2_HOME)!=PierSideStateAxis2) && ((guideDirAxis2=='n') || (guideDirAxis2=='s'))) StopAxis2(); + if ((digitalRead(Axis1HomePin) != PierSideStateAxis1) && ((guideDirAxis1 == 'e') || (guideDirAxis1 == 'w'))) StopAxis1(); + if ((digitalRead(Axis2HomePin) != PierSideStateAxis2) && ((guideDirAxis2 == 'n') || (guideDirAxis2 == 's'))) StopAxis2(); } } // we are idle and waiting for a fast guide to stop before the final slow guide to refine the home position - if ((findHomeMode==FH_IDLE) && (guideDirAxis1==0) && (guideDirAxis2==0)) { + if ((findHomeMode == FH_IDLE) && (guideDirAxis1 == 0) && (guideDirAxis2 == 0)) { findHomeMode=FH_OFF; goHome(false); } // we are finishing off the find home - if ((findHomeMode==FH_DONE) && (guideDirAxis1==0) && (guideDirAxis2==0)) { + if ((findHomeMode == FH_DONE) && (guideDirAxis1 == 0) && (guideDirAxis2 == 0)) { findHomeMode=FH_OFF; setHome(); } @@ -36,12 +36,12 @@ void checkHome() { void StopAxis1() { guideDirAxis1='b'; - if ((guideDirAxis2!='n') && (guideDirAxis2!='s')) { if (findHomeMode==FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode==FH_FAST) findHomeMode=FH_IDLE; } + if ((guideDirAxis2 != 'n') && (guideDirAxis2 != 's')) { if (findHomeMode == FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode == FH_FAST) findHomeMode=FH_IDLE; } } void StopAxis2() { guideDirAxis2='b'; - if ((guideDirAxis1!='e') && (guideDirAxis1!='w')) { if (findHomeMode==FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode==FH_FAST) findHomeMode=FH_IDLE; } + if ((guideDirAxis1 != 'e') && (guideDirAxis1 != 'w')) { if (findHomeMode == FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode == FH_FAST) findHomeMode=FH_IDLE; } } #endif @@ -50,33 +50,25 @@ GotoErrors goHome(boolean fast) { GotoErrors f=validateGoto(); -#ifdef HOME_SENSE_ON +#if HOME_SENSE == ON // goto allowed? - if ((f!=GOTO_ERR_NONE) && (f!=GOTO_ERR_STANDBY)) return f; + if ((f != GOTO_ERR_NONE) && (f != GOTO_ERR_STANDBY)) return f; - if (findHomeMode!=FH_OFF) return GOTO_ERR_IN_MOTION; // guide allowed? + if (findHomeMode != FH_OFF) return GOTO_ERR_IN_MOTION; // guide allowed? // stop tracking trackingState=TrackingNone; // decide direction to guide -#ifdef HOME_AXIS1_REVERSE_ON - char a1; if (digitalRead(Axis1_HOME)==HIGH) a1='w'; else a1='e'; -#else - char a1; if (digitalRead(Axis1_HOME)==HIGH) a1='e'; else a1='w'; -#endif -#ifdef HOME_AXIS2_REVERSE_ON - char a2; if (digitalRead(Axis2_HOME)==HIGH) a2='n'; else a2='s'; -#else - char a2; if (digitalRead(Axis2_HOME)==HIGH) a2='s'; else a2='n'; -#endif + char a1; if (digitalRead(Axis1HomePin) == HOME_SENSE_STATE_AXIS2) a1='w'; else a1='e'; + char a2; if (digitalRead(Axis2HomePin) == HOME_SENSE_STATE_AXIS2) a2='n'; else a2='s'; - // if (getInstrPierSide()==PierSideWest) { if (a2=='n') a2='s'; else a2='n'; } + // if (getInstrPierSide() == PierSideWest) { if (a2 == 'n') a2='s'; else a2='n'; } // attach interrupts to stop guide - PierSideStateAxis1=digitalRead(Axis1_HOME); - PierSideStateAxis2=digitalRead(Axis2_HOME); + PierSideStateAxis1=digitalRead(Axis1HomePin); + PierSideStateAxis2=digitalRead(Axis2HomePin); // disable limits safetyLimitsOn=false; @@ -104,7 +96,7 @@ GotoErrors goHome(boolean fast) { #else // goto allowed? - if (f!=GOTO_ERR_NONE) return f; + if (f != GOTO_ERR_NONE) return f; goTo(homePositionAxis1,homePositionAxis2,homePositionAxis1,homePositionAxis2,PierSideEast); homeMount=true; @@ -114,8 +106,8 @@ GotoErrors goHome(boolean fast) { } boolean isHoming() { -#ifdef HOME_SENSE_ON - return (homeMount || (findHomeMode!=FH_OFF)); +#if HOME_SENSE == ON + return (homeMount || (findHomeMode != FH_OFF)); #else return homeMount; #endif @@ -127,7 +119,7 @@ GotoErrors setHome() { if (guideDirAxis1 || guideDirAxis2) return GOTO_ERR_IN_MOTION; reactivateBacklashComp(); - if (trackingState==TrackingMoveTo) return GOTO_ERR_GOTO; + if (trackingState == TrackingMoveTo) return GOTO_ERR_GOTO; initStartupValues(); @@ -148,7 +140,7 @@ GotoErrors setHome() { // reset PEC, unless we have an index to recover from this pecRecorded=nv.read(EE_pecRecorded); - #ifdef PEC_SENSE_OFF + #if PEC_SENSE == OFF pecStatus=IgnorePEC; nv.write(EE_pecStatus,pecStatus); #else diff --git a/Initialize.ino b/Initialize.ino index 5d7b27f0b..765ac6821 100644 --- a/Initialize.ino +++ b/Initialize.ino @@ -6,16 +6,16 @@ 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 + // if we made through validation and AXIS1_DRIVER_MODEL exists; AXIS2_DRIVER_MODEL, AXIS1_DRIVER_MICROSTEPS, and AXIS2_DRIVER_MICROSTEPS also exist and passed validation in the pre-processor +#if AXIS1_DRIVER_MODEL != OFF // translate microsteps to microstep bit code - AXIS1_MICROSTEP_CODE = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS); - AXIS2_MICROSTEP_CODE = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS); - #ifdef AXIS1_MICROSTEPS_GOTO - AXIS1_MICROSTEP_CODE_GOTO = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_MICROSTEPS_GOTO); + AXIS1_DRIVER_MICROSTEP_CODE = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_DRIVER_MICROSTEPS); + AXIS2_DRIVER_MICROSTEP_CODE = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_DRIVER_MICROSTEPS); + #if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF + AXIS1_DRIVER_MICROSTEP_CODE_GOTO = translateMicrosteps(1, AXIS1_DRIVER_MODEL, AXIS1_DRIVER_MICROSTEPS_GOTO); #endif - #ifdef AXIS2_MICROSTEPS_GOTO - AXIS2_MICROSTEP_CODE_GOTO = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_MICROSTEPS_GOTO); + #if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF + AXIS2_DRIVER_MICROSTEP_CODE_GOTO = translateMicrosteps(2, AXIS2_DRIVER_MODEL, AXIS2_DRIVER_MICROSTEPS_GOTO); #endif #endif @@ -58,14 +58,14 @@ void initStartupValues() { Align.init(); // reset meridian flip control - #ifdef MOUNT_TYPE_GEM - meridianFlip = MeridianFlipAlways; + #if MOUNT_TYPE == GEM + meridianFlip = MeridianFlipAlways; #endif - #ifdef MOUNT_TYPE_FORK - meridianFlip = MeridianFlipNever; + #if MOUNT_TYPE == FORK + meridianFlip = MeridianFlipNever; #endif - #ifdef MOUNT_TYPE_ALTAZM - meridianFlip = MeridianFlipNever; + #if MOUNT_TYPE == ALTAZM + meridianFlip = MeridianFlipNever; #endif // where we are @@ -76,7 +76,8 @@ void initStartupValues() { waitingHomeContinue = false; // PEC sanity check - if (SecondsPerWormRotationAxis1>PECBufferSize) SecondsPerWormRotationAxis1=PECBufferSize; + if ((pecBufferSize < 0) || (pecBufferSize > 3384)) pecBufferSize=0; + if (SecondsPerWormRotationAxis1>pecBufferSize) SecondsPerWormRotationAxis1=pecBufferSize; // reset tracking and rates cli(); @@ -91,14 +92,14 @@ void initPins() { // ------------------------------------------------------------------ // Pull the Axis1/2 RST Pin HIGH on the MaxESP2 -#ifdef MaxESP2_ON -pinMode(Axis1_Aux,INPUT_PULLUP); +#if PINMAP == MaxESP2 + pinMode(Axis1_M3,INPUT_PULLUP); #endif // ------------------------------------------------------------------ // ESP-01 (ESP8266) firmware flashing control -#ifdef ESP8266_CONTROL_ON +#if SERIAL_B_ESP_FLASHING == ON pinMode(ESP8266Gpio0Pin,OUTPUT); // ESP8266 GPIO0 digitalWrite(ESP8266Gpio0Pin,HIGH); delay(20); // Run mode pinMode(ESP8266RstPin,OUTPUT); // ESP8266 RST @@ -107,73 +108,86 @@ pinMode(Axis1_Aux,INPUT_PULLUP); #endif // ------------------------------------------------------------------ -// LED and audible feedback +// User feedback -#ifdef STATUS_LED_PINS_ON +#if LED_STATUS_PIN == ON pinMode(LEDnegPin,OUTPUT); digitalWrite(LEDnegPin,LOW); // light status LED (provides GND) -#ifdef LEDposPin - pinMode(LEDposPin,OUTPUT); digitalWrite(LEDposPin,HIGH); // sometimes +5v is provided on a pin -#endif - LED_ON=true; + #ifdef LEDposPin + pinMode(LEDposPin,OUTPUT); digitalWrite(LEDposPin,HIGH); // sometimes +5v is provided on a pin + #endif + ledOn=true; #endif -#ifdef STATUS_LED_PINS +#if LED_STATUS_PIN >= 0 pinMode(LEDnegPin,OUTPUT); digitalWrite(LEDnegPin,LOW); // light status LED (provides pwm'd GND for polar reticule) -#ifdef LEDposPin - pinMode(LEDposPin,OUTPUT); digitalWrite(LEDposPin,HIGH); // sometimes +5v is provided on a pin -#endif - analogWrite(LEDnegPin,STATUS_LED_PINS); - LED_ON=true; + #ifdef LEDposPin + pinMode(LEDposPin,OUTPUT); digitalWrite(LEDposPin,HIGH); // sometimes +5v is provided on a pin + #endif + analogWrite(LEDnegPin,LED_STATUS_PIN); + ledOn=true; #endif -#ifdef RETICULE_LED_PINS - pinMode(ReticulePin,OUTPUT); analogWrite(ReticulePin,reticuleBrightness); // light reticule LED +#if LED_RETICLE_PIN >= 0 + pinMode(ReticlePin,OUTPUT); analogWrite(ReticlePin,reticuleBrightness); // light reticule LED #endif -#ifdef STATUS_LED2_PINS_ON +#if LED_STATUS2_PIN == ON pinMode(LEDneg2Pin,OUTPUT); digitalWrite(LEDneg2Pin,HIGH); // light second status LED (provides just GND) - LED2_ON=false; -#elif defined(STATUS_LED2_PINS) + led2On=false; +#elif LED_STATUS2_PIN >= 0 pinMode(LEDneg2Pin,OUTPUT); digitalWrite(LEDneg2Pin,LOW); // light second status LED (provides pwm'd GND for polar reticule) - analogWrite(LEDneg2Pin,STATUS_LED2_PINS); + analogWrite(LEDneg2Pin,LED_STATUS2_PIN); #endif // ready the sound/buzzer pin -#if defined(BUZZER) || defined(BUZZER_ON) +#if BUZZER == ON || BUZZER >= 0 pinMode(TonePin,OUTPUT); digitalWrite(TonePin,LOW); #endif // ------------------------------------------------------------------ -// Misc. devices and sensors +// Sensors -// PEC index sense -#ifdef PEC_SENSE_ON - pinMode(PecPin,INPUT); -#elif defined(PEC_SENSE_PULLUP) - pinMode(PecPin,INPUT_PULLUP); -#elif defined(PEC_SENSE_PULLDOWN) - pinMode(PecPin,INPUT_PULLDOWN); +// Home position sensing +#if HOME_SENSE == ON + pinMode(Axis1HomePin,INPUT); + pinMode(Axis2HomePin,INPUT); +#elif HOME_SENSE == ON_PULLUP + pinMode(Axis1HomePin,INPUT_PULLUP); + pinMode(Axis2HomePin,INPUT_PULLUP); +#elif HOME_SENSE == ON_PULLDOWN + pinMode(Axis1HomePin,INPUT_PULLDOWN); + pinMode(Axis2HomePin,INPUT_PULLDOWN); #endif // limit switch sense -#ifdef LIMIT_SENSE_ON +#if LIMIT_SENSE == ON + pinMode(LimitPin,INPUT); +#elif LIMIT_SENSE == ON_PULLUP pinMode(LimitPin,INPUT_PULLUP); +#elif LIMIT_SENSE == ON_PULLDOWN + pinMode(LimitPin,INPUT_PULLDOWN); +#endif + +// PEC index sense +#if PEC_SENSE == ON + pinMode(PecPin,INPUT); +#elif PEC_SENSE == ON_PULLUP + pinMode(PecPin,INPUT_PULLUP); +#elif PEC_SENSE == ON_PULLDOWN + pinMode(PecPin,INPUT_PULLDOWN); #endif // Pulse per second -#ifdef PPS_SENSE_ON +#if PPS_SENSE == ON pinMode(PpsPin,INPUT); attachInterrupt(digitalPinToInterrupt(PpsPin),clockSync,RISING); -#elif defined(PPS_SENSE_PULLUP) +#elif PPS_SENSE == ON_PULLUP pinMode(PpsPin,INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(PpsPin),clockSync,RISING); -#endif - -// Home position sensing -#ifdef HOME_SENSE_ON - pinMode(Axis1_HOME,INPUT_PULLUP); - pinMode(Axis2_HOME,INPUT_PULLUP); +#elif PPS_SENSE == ON_PULLDOWN + pinMode(PpsPin,INPUT_PULLDOWN); + attachInterrupt(digitalPinToInterrupt(PpsPin),clockSync,RISING); #endif // ------------------------------------------------------------------ @@ -181,67 +195,62 @@ pinMode(Axis1_Aux,INPUT_PULLUP); pinMode(Axis1StepPin,OUTPUT); // Axis1 pinMode(Axis1DirPin,OUTPUT); + pinMode(Axis2StepPin,OUTPUT); // Axis2 + pinMode(Axis2DirPin,OUTPUT); + // provide 5V power to stepper drivers if requested (classic Pin-map) #ifdef POWER_SUPPLY_PINS_ON pinMode(Axis15vPin,OUTPUT); digitalWrite(Axis15vPin,HIGH); - pinMode(Axis25vPin,OUTPUT); // Axis2 + pinMode(Axis25vPin,OUTPUT); digitalWrite(Axis25vPin,HIGH); -#endif - // provide Gnd on next to the Dec stepper pins if requested (classic Pin-map) -#ifdef Axis2GndPin pinMode(Axis2GndPin,OUTPUT); digitalWrite(Axis2GndPin,LOW); #endif - pinMode(Axis2StepPin,OUTPUT); - pinMode(Axis2DirPin,OUTPUT); - // inputs for stepper drivers fault signal -#ifdef AXIS1_FAULT - #if AXIS1_FAULT==LOW - pinMode(Axis1_FAULT,INPUT_PULLUP); - #elif AXIS1_FAULT==HIGH - #ifdef INPUT_PULLDOWN - pinMode(Axis1_FAULT,INPUT_PULLDOWN); - #else - pinMode(Axis1_FAULT,INPUT); - #endif +// inputs for stepper drivers fault signal +#if AXIS1_DRIVER_STATUS == LOW + pinMode(Axis1FaultPin,INPUT_PULLUP); +#elif AXIS1_DRIVER_STATUS == HIGH + #ifdef INPUT_PULLDOWN + pinMode(Axis1FaultPin,INPUT_PULLDOWN); + #else + pinMode(Axis1FaultPin,INPUT); #endif #endif -#ifdef AXIS2_FAULT - #if AXIS2_FAULT==LOW - pinMode(Axis2_FAULT,INPUT_PULLUP); - #elif AXIS1_FAULT==HIGH - #ifdef INPUT_PULLDOWN - pinMode(Axis2_FAULT,INPUT_PULLDOWN); - #else - pinMode(Axis2_FAULT,INPUT); - #endif +#if AXIS2_DRIVER_STATUS == LOW + pinMode(Axis2FaultPin,INPUT_PULLUP); +#elif AXIS1_DRIVER_STATUS == HIGH + #ifdef INPUT_PULLDOWN + pinMode(Axis2FaultPin,INPUT_PULLDOWN); + #else + pinMode(Axis2FaultPin,INPUT); #endif #endif // initialize and disable the main axes stepper drivers pinMode(Axis1_EN,OUTPUT); pinMode(Axis2_EN,OUTPUT); + StepperModeTrackingInit(); } 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? + currentSite=nv.read(EE_currentSite); if (currentSite > 3) currentSite=0; // site index is valid? latitude=nv.readFloat(EE_sites+(currentSite)*25+0); cosLat=cos(latitude/Rad); sinLat=sin(latitude/Rad); - if (latitude>0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; + if (latitude > 0) defaultDirAxis1 = defaultDirAxis1NCPInit; else defaultDirAxis1 = defaultDirAxis1SCPInit; longitude=nv.readFloat(EE_sites+(currentSite)*25+4); // the polar home position -#ifdef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE == ALTAZM homePositionAxis2=AltAzmDecStartPos; - if (latitude<0) homePositionAxis1=180.0; else homePositionAxis1=0.0; + if (latitude < 0) homePositionAxis1=180.0; else homePositionAxis1=0.0; #else - if (latitude<0) homePositionAxis2=-90.0; else homePositionAxis2=90.0; + if (latitude < 0) homePositionAxis2=-90.0; else homePositionAxis2=90.0; #endif InitStartPosition(); @@ -266,23 +275,16 @@ void initReadNvValues() { updateLST(jd2last(JD,UT1,false)); // get the minutes past meridian east/west -#ifdef MOUNT_TYPE_GEM - minutesPastMeridianE=round(((nv.read(EE_dpmE)-128)*60.0)/15.0); if (abs(minutesPastMeridianE)>180) minutesPastMeridianE=60; - minutesPastMeridianW=round(((nv.read(EE_dpmW)-128)*60.0)/15.0); if (abs(minutesPastMeridianW)>180) minutesPastMeridianW=60; -#endif - // override if specified in Config.h -#ifdef MinutesPastMeridianE - minutesPastMeridianE=MinutesPastMeridianE; -#endif -#ifdef MinutesPastMeridianW - minutesPastMeridianW=MinutesPastMeridianW; +#if MOUNT_TYPE == GEM + degreesPastMeridianE=round(nv.read(EE_dpmE)-128); if (abs(degreesPastMeridianE) > 180) degreesPastMeridianE=15; + degreesPastMeridianW=round(nv.read(EE_dpmW)-128); if (abs(degreesPastMeridianW) > 180) degreesPastMeridianW=15; #endif // get the min. and max altitude minAlt=nv.read(EE_minAlt)-128; maxAlt=nv.read(EE_maxAlt); -#ifdef MOUNT_TYPE_ALTAZM - if (maxAlt>87) maxAlt=87; +#if MOUNT_TYPE == ALTAZM + if (maxAlt > 87) maxAlt=87; #endif // get the backlash amounts @@ -292,9 +294,9 @@ void initReadNvValues() { // get the PEC status pecStatus =nv.read(EE_pecStatus); pecRecorded=nv.read(EE_pecRecorded); if (!pecRecorded) pecStatus=IgnorePEC; - for (int i=0; iGuideRate1x) currentPulseGuideRate=GuideRate1x; + currentPulseGuideRate=nv.read(EE_pulseGuideRate); if (currentPulseGuideRate > GuideRate1x) currentPulseGuideRate=GuideRate1x; // set the default MaxRate based on the desired goto speed MaxRateDef=MaxRate; - if (MaxRateDef(double)MaxRateDef*32.0) maxRate=(double)MaxRateDef*32.0; - if (maxRate (double)MaxRateDef*32.0) maxRate=(double)MaxRateDef*32.0; + if (maxRate < maxRateLowerLimit()) maxRate=maxRateLowerLimit(); -#ifndef REMEMBER_SLEW_RATE_ON - if (maxRate!=(long)((double)MaxRateDef*16.0)) { +#if SLEW_RATE_MEMORY == OFF + if (maxRate != (long)((double)MaxRateDef*16.0)) { maxRate=(double)MaxRateDef*16.0; nv.writeLong(EE_maxRateL,maxRate); } @@ -330,12 +332,12 @@ void initReadNvValues() { setAccelerationRates(maxRate); // set the new acceleration rate // get autoMeridianFlip -#if defined(MOUNT_TYPE_GEM) && defined(REMEMBER_AUTO_MERIDIAN_FLIP_ON) +#if MOUNT_TYPE == GEM && MFLIP_AUTOMATIC_MEMORY == ON autoMeridianFlip=nv.read(EE_autoMeridianFlip); #endif // get meridian flip pause at home -#if defined(MOUNT_TYPE_GEM) && defined(REMEMBER_PAUSE_HOME_ON) +#if MOUNT_TYPE == GEM && MFLIP_PAUSE_HOME_MEMORY == ON pauseHome=nv.read(EE_pauseHome); #endif @@ -344,10 +346,10 @@ void initReadNvValues() { enableGuideRate(GuideRateDefault); // for DC focusers read in the % power -#ifdef AXIS4_DC_MODE_ON +#if AXIS4_DRIVER_DC_MODE != OFF dcPwrAxis4=nv.read(EE_dcPwrAxis4); #endif -#ifdef AXIS5_DC_MODE_ON +#if AXIS5_DRIVER_DC_MODE != OFF dcPwrAxis5=nv.read(EE_dcPwrAxis5); #endif @@ -375,11 +377,11 @@ void initWriteNvValues() { long thisAutoInitKey; if (INIT_KEY) nv.writeLong(EE_autoInitKey,autoInitKey); thisAutoInitKey=nv.readLong(EE_autoInitKey); - if (autoInitKey!=thisAutoInitKey) { + if (autoInitKey != thisAutoInitKey) { // init the site information, lat/long/tz/name nv.write(EE_currentSite,0); latitude=0; longitude=0; - for (int l=0; l<4; l++) { + for (int l=0; l < 4; l++) { nv.writeFloat(EE_sites+(l)*25+0,latitude); nv.writeFloat(EE_sites+(l)*25+4,longitude); nv.write(EE_sites+(l)*25+8,128); @@ -392,9 +394,9 @@ void initWriteNvValues() { nv.writeFloat(EE_JD,JD); nv.writeFloat(EE_LMT,LMT); - // init the minutes past meridian east/west - nv.write(EE_dpmE,round((minutesPastMeridianE*15.0)/60.0)+128); - nv.write(EE_dpmW,round((minutesPastMeridianW*15.0)/60.0)+128); + // init the degrees past meridian east/west + nv.write(EE_dpmE,round(AXIS1_LIMIT_MERIDIAN_E+128)); + nv.write(EE_dpmW,round(AXIS1_LIMIT_MERIDIAN_W+128)); // init the min and max altitude minAlt=-10; @@ -409,7 +411,7 @@ void initWriteNvValues() { // init the PEC status, clear the index and buffer nv.write(EE_pecStatus,IgnorePEC); nv.write(EE_pecRecorded,false); - for (int l=0; l10000L*16L) maxRate=10000L*16L; + if (maxRate < 2L*16L) maxRate=2L*16L; + if (maxRate > 10000L*16L) maxRate=10000L*16L; if (maxRate-90.0)) setTargetAxis1(-60.0,PierSideWest); else setTargetAxis1(-homePositionAxis1,PierSideWest); + if (pierSideControl == PierSideFlipWE1) { + if (homePositionAxis1 == 0.0) setTargetAxis1(0.0,PierSideWest); else { + if ((currentAlt < 10.0) && (getStartAxis1() > -90.0)) setTargetAxis1(-60.0,PierSideWest); else setTargetAxis1(-homePositionAxis1,PierSideWest); } setTargetAxis2(homePositionAxis2,PierSideWest); } else { - if (homePositionAxis1==0.0) setTargetAxis1(0.0,PierSideEast); else { - if ((currentAlt<10.0) && (getStartAxis1()<90.0)) setTargetAxis1(60.0,PierSideEast); else setTargetAxis1(homePositionAxis1,PierSideEast); + if (homePositionAxis1 == 0.0) setTargetAxis1(0.0,PierSideEast); else { + if ((currentAlt < 10.0) && (getStartAxis1() < 90.0)) setTargetAxis1(60.0,PierSideEast); else setTargetAxis1(homePositionAxis1,PierSideEast); } setTargetAxis2(homePositionAxis2,PierSideEast); } // first phase, override above for additional waypoints - if (homePositionAxis2>0.0) { - if (getInstrAxis2()>90.0-latitude) { + if (homePositionAxis2 > 0.0) { + if (getInstrAxis2() > 90.0-latitude) { // if Dec is in the general area of the pole, slew both axis back at once - if (pierSideControl==PierSideFlipWE1) setTargetAxis1(-homePositionAxis1,PierSideWest); else setTargetAxis1(homePositionAxis1,PierSideEast); + if (pierSideControl == PierSideFlipWE1) setTargetAxis1(-homePositionAxis1,PierSideWest); else setTargetAxis1(homePositionAxis1,PierSideEast); } else { // if we're at a low latitude and in the opposite sky, |HA|=6 is very low on the horizon in this orientation and we need to delay arriving there during a meridian flip // in the extreme case, where the user is very near the (Earths!) equator an Horizon limit of -10 or -15 may be necessary for proper operation. - if ((currentAlt<20.0) && (abs(latitude)<45.0) && (getInstrAxis2()<0.0)) { - if (pierSideControl==PierSideFlipWE1) setTargetAxis1(-45.0,PierSideWest); else setTargetAxis1(45.0,PierSideEast); + if ((currentAlt < 20.0) && (abs(latitude) < 45.0) && (getInstrAxis2() < 0.0)) { + if (pierSideControl == PierSideFlipWE1) setTargetAxis1(-45.0,PierSideWest); else setTargetAxis1(45.0,PierSideEast); } } } else { - if (getInstrAxis2()<-90.0-latitude) { + if (getInstrAxis2() < -90.0-latitude) { // if Dec is in the general area of the pole, slew both axis back at once - if (pierSideControl==PierSideFlipWE1) setTargetAxis1(-homePositionAxis1,PierSideWest); else setTargetAxis1(homePositionAxis1,PierSideEast); + if (pierSideControl == PierSideFlipWE1) setTargetAxis1(-homePositionAxis1,PierSideWest); else setTargetAxis1(homePositionAxis1,PierSideEast); } else { // if we're at a low latitude and in the opposite sky, |HA|=6 is very low on the horizon in this orientation and we need to delay arriving there during a meridian flip - if ((currentAlt<20.0) && (abs(latitude)<45.0) && (getInstrAxis2()>0.0)) { - if (pierSideControl==PierSideFlipWE1) setTargetAxis1(-45.0,PierSideWest); else setTargetAxis1(45.0,PierSideEast); + if ((currentAlt < 20.0) && (abs(latitude) < 45.0) && (getInstrAxis2() > 0.0)) { + if (pierSideControl == PierSideFlipWE1) setTargetAxis1(-45.0,PierSideWest); else setTargetAxis1(45.0,PierSideEast); } } } -// D("Flp1 Axis1, Current "); D(((double)(long)posAxis1)/(double)StepsPerDegreeAxis1); D(" -to-> "); DL(((double)(long)targetAxis1.part.m)/(double)StepsPerDegreeAxis1); -// D("Flp1 Axis2, Current "); D(((double)(long)posAxis2)/(double)StepsPerDegreeAxis2); D(" -to-> "); DL(((double)(long)targetAxis2.part.m)/(double)StepsPerDegreeAxis2); DL(""); pierSideControl++; forceRefreshGetEqu(); } @@ -66,8 +64,8 @@ void moveTo() { distStartAxis1=abs(posAxis1-startAxis1); // distance from start Axis1 distStartAxis2=abs(posAxis2-startAxis2); // distance from start Axis2 sei(); - if (distStartAxis1<1) distStartAxis1=1; - if (distStartAxis2<1) distStartAxis2=1; + if (distStartAxis1 < 1) distStartAxis1=1; + if (distStartAxis2 < 1) distStartAxis2=1; cli(); distDestAxis1=abs(posAxis1-(long)targetAxis1.part.m); // distance from dest Axis1 @@ -75,41 +73,41 @@ void moveTo() { sei(); // adjust rates near the horizon to help keep from exceeding the minAlt limit - #ifndef MOUNT_TYPE_ALTAZM - long a2=abs(getInstrAxis2()*StepsPerDegreeAxis2); - static long lastPosAxis2=0; - if (((latitude>10) || (latitude<-10)) && (distStartAxis1>((DegreesForAcceleration*StepsPerDegreeAxis1)/16))) { - // if Dec is decreasing, slow down Dec - if (a2 10) || (latitude < -10)) && (distStartAxis1 > ((SLEW_ACCELERATION_DIST*AXIS1_STEPS_PER_DEGREE)/16))) { + // if Dec is decreasing, slow down Dec + if (a2 < lastPosAxis2) { + double minAlt2=minAlt+10.0; + long a=(currentAlt-minAlt2)*AXIS2_STEPS_PER_DEGREE; if (a < ((SLEW_ACCELERATION_DIST*AXIS2_STEPS_PER_DEGREE)/8)) a=((SLEW_ACCELERATION_DIST*AXIS2_STEPS_PER_DEGREE)/8); + if (a < distDestAxis2) distDestAxis2=a; + } else + // if Dec is increasing, slow down HA + { + double minAlt2=minAlt+10.0; + long a=(currentAlt-minAlt2)*AXIS1_STEPS_PER_DEGREE; if (a < ((SLEW_ACCELERATION_DIST*AXIS1_STEPS_PER_DEGREE)/8)) a=((SLEW_ACCELERATION_DIST*AXIS1_STEPS_PER_DEGREE)/8); + if (a < distDestAxis1) distDestAxis1=a; + } } - } - lastPosAxis2=a2; + lastPosAxis2=a2; #endif - if (distDestAxis1<1) distDestAxis1=1; - if (distDestAxis2<1) distDestAxis2=1; + if (distDestAxis1 < 1) distDestAxis1=1; + if (distDestAxis2 < 1) distDestAxis2=1; - // quickly slow the motors and stop in DegreesForRapidStop + // quickly slow the motors and stop in SLEW_RAPID_STOP_DIST static double deaccXPerSec=0; static double a1r=0; static double a2r=0; - if (abortSlew==1) { + if (abortSlew == 1) { // aborts any meridian flip - if ((pierSideControl==PierSideFlipWE1) || (pierSideControl==PierSideFlipWE2) || (pierSideControl==PierSideFlipWE3)) pierSideControl=PierSideWest; - if ((pierSideControl==PierSideFlipEW1) || (pierSideControl==PierSideFlipEW2) || (pierSideControl==PierSideFlipEW3)) pierSideControl=PierSideEast; + if ((pierSideControl == PierSideFlipWE1) || (pierSideControl == PierSideFlipWE2) || (pierSideControl == PierSideFlipWE3)) pierSideControl=PierSideWest; + if ((pierSideControl == PierSideFlipEW1) || (pierSideControl == PierSideFlipEW2) || (pierSideControl == PierSideFlipEW3)) pierSideControl=PierSideEast; if (pauseHome) { waitingHome=false; waitingHomeContinue=false; } // stop parking/homing - if (parkStatus==Parking) { + if (parkStatus == Parking) { lastTrackingState=abortTrackingState; parkStatus=NotParked; nv.write(EE_parkStatus,parkStatus); @@ -121,74 +119,69 @@ void moveTo() { // set rate (in X sidereal) at which we slow down from double rateXPerSec = RateToXPerSec/(maxRate/16.0); - D("rateXPerSec="); DL(rateXPerSec); - double numSecToStop = (DegreesForRapidStop / (rateXPerSec/240.0)); - D("numSecToStop="); DL(numSecToStop); - deaccXPerSec = (DegreesForRapidStop/numSecToStop)*240.0; - D("deaccXPerSec="); DL(deaccXPerSec); + double numSecToStop = (SLEW_RAPID_STOP_DIST/(rateXPerSec/240.0)); + deaccXPerSec = (SLEW_RAPID_STOP_DIST/numSecToStop)*240.0; abortSlew++; } // First, for Right Ascension long temp; - if (distStartAxis1>distDestAxis1) { + if (distStartAxis1 > distDestAxis1) { temp=(StepsForRateChangeAxis1/isqrt32(distDestAxis1)); // slow down (temp gets bigger) } else { temp=(StepsForRateChangeAxis1/isqrt32(distStartAxis1)); // speed up (temp gets smaller) } - if (tempTakeupRate) temp=TakeupRate; // slowest rate - if (abortSlew!=0) { - // 50x= 5000/100 - if (abortSlew==2) { a1r=(double)SiderealRate/(double)temp; } else - if (abortSlew==3) { + if (temp < maxRate) temp=maxRate; // fastest rate + if (temp > TakeupRate) temp=TakeupRate; // slowest rate + if (abortSlew != 0) { + if (abortSlew == 2) { a1r=(double)SiderealRate/(double)temp; } else + if (abortSlew == 3) { double r=1.2-sqrt((abs(a1r)/slewRateX)); - if (r<0.2) r=0.2; if (r>1.2) r=1.2; - a1r-=(deaccXPerSec/100.0)*r; if (a1r<2.0) a1r=2.0; + if (r < 0.2) r=0.2; if (r > 1.2) r=1.2; + a1r-=(deaccXPerSec/100.0)*r; if (a1r < 2.0) a1r=2.0; } - // 100=5000/50 temp=round((double)SiderealRate/a1r); } cli(); timerRateAxis1=temp; sei(); // Now, for Declination - if (distStartAxis2>distDestAxis2) { + if (distStartAxis2 > distDestAxis2) { temp=(StepsForRateChangeAxis2/isqrt32(distDestAxis2)); // slow down } else { temp=(StepsForRateChangeAxis2/isqrt32(distStartAxis2)); // speed up } - if (tempTakeupRate) temp=TakeupRate; // slowest rate - if (abortSlew!=0) { - if (abortSlew==2) { a2r=(double)SiderealRate/(double)temp; abortSlew++; } else - if (abortSlew==3) { + if (temp < maxRate) temp=maxRate; // fastest rate + if (temp > TakeupRate) temp=TakeupRate; // slowest rate + if (abortSlew != 0) { + if (abortSlew == 2) { a2r=(double)SiderealRate/(double)temp; abortSlew++; } else + if (abortSlew == 3) { double r=1.2-sqrt((abs(a2r)/slewRateX)); - if (r<0.2) r=0.2; if (r>1.2) r=1.2; + if (r < 0.2) r=0.2; if (r > 1.2) r=1.2; a2r-=(deaccXPerSec/100.0)*r; - if (a2r<2.00) a2r=2.0; - if ((a1r<2.00001) && (a2r<2.00001)) abortSlew++; + if (a2r < 2.00) a2r=2.0; + if ((a1r < 2.00001) && (a2r < 2.00001)) abortSlew++; } else - if (abortSlew==4) { abortSlew=0; cli(); targetAxis1.part.m=posAxis1; targetAxis2.part.m=posAxis2; sei(); distDestAxis1=0; distDestAxis2=0; } + if (abortSlew == 4) { abortSlew=0; cli(); targetAxis1.part.m=posAxis1; targetAxis2.part.m=posAxis2; sei(); distDestAxis1=0; distDestAxis2=0; } temp=round((double)SiderealRate/a2r); } cli(); timerRateAxis2=temp; sei(); // make sure we're using the tracking mode microstep setting near the end of slew - if ((distDestAxis1<=getStepsPerSecondAxis1()) && (distDestAxis2<=getStepsPerSecondAxis2()) ) stepperModeTracking(false); + if ((distDestAxis1 <= getStepsPerSecondAxis1()) && (distDestAxis2 <= getStepsPerSecondAxis2()) ) stepperModeTracking(false); // the end of slew doesn't get close enough within 4 seconds force the slew to end static unsigned long slewStopTime=0; static bool slewEnding=false; static bool slewForceEnd=false; - if (!slewEnding && (distDestAxis1<=getStepsPerSecondAxis1()*4.0) && (distDestAxis2<=getStepsPerSecondAxis2()*4.0) ) { slewStopTime=millis()+4000L; slewEnding=true; } - if (slewEnding && ((long)(millis()-slewStopTime)>0)) { - if (abortSlew!=0) { cli(); targetAxis1.part.m=posAxis1; targetAxis2.part.m=posAxis2; sei(); } + if (!slewEnding && (distDestAxis1 <= getStepsPerSecondAxis1()*4.0) && (distDestAxis2 <= getStepsPerSecondAxis2()*4.0) ) { slewStopTime=millis()+4000L; slewEnding=true; } + if (slewEnding && ((long)(millis()-slewStopTime) > 0)) { + if (abortSlew != 0) { cli(); targetAxis1.part.m=posAxis1; targetAxis2.part.m=posAxis2; sei(); } lastError=ERR_GOTO_SYNC; slewForceEnd=true; } - if ( ((distDestAxis1<=ceil(abs(fixedToDouble(fstepAxis1)))+1) && (distDestAxis2<=ceil(abs(fixedToDouble(fstepAxis2)))+1) ) || slewForceEnd ) { + if ( ((distDestAxis1 <= ceil(abs(fixedToDouble(fstepAxis1)))+1) && (distDestAxis2 <= ceil(abs(fixedToDouble(fstepAxis2)))+1) ) || slewForceEnd ) { slewEnding=false; slewForceEnd=false; abortSlew=0; @@ -196,7 +189,7 @@ void moveTo() { // assurance that we're really in tracking mode stepperModeTracking(false); - if ((pierSideControl==PierSideFlipEW2) || (pierSideControl==PierSideFlipWE2)) { + if ((pierSideControl == PierSideFlipEW2) || (pierSideControl == PierSideFlipWE2)) { // just wait stop here until we get notification to continue if (pauseHome) { if (!waitingHomeContinue) { waitingHome=true; return; } @@ -208,21 +201,21 @@ void moveTo() { startAxis1=posAxis1; startAxis2=posAxis2; sei(); - if (homePositionAxis1==0.0) { + if (homePositionAxis1 == 0.0) { // for fork mounts - if (pierSideControl==PierSideFlipEW2) setTargetAxis1(180.0,PierSideEast); else setTargetAxis1(-180.0,PierSideWest); + if (pierSideControl == PierSideFlipEW2) setTargetAxis1(180.0,PierSideEast); else setTargetAxis1(-180.0,PierSideWest); } else { // for eq mounts - if (pierSideControl==PierSideFlipEW2) setTargetAxis1(homePositionAxis1,PierSideEast); else setTargetAxis1(-homePositionAxis1,PierSideWest); + if (pierSideControl == PierSideFlipEW2) setTargetAxis1(homePositionAxis1,PierSideEast); else setTargetAxis1(-homePositionAxis1,PierSideWest); } pierSideControl++; stepperModeGoto(); forceRefreshGetEqu(); } else - if ((pierSideControl==PierSideFlipEW3) || (pierSideControl==PierSideFlipWE3)) { + if ((pierSideControl == PierSideFlipEW3) || (pierSideControl == PierSideFlipWE3)) { - if (pierSideControl==PierSideFlipEW3) pierSideControl=PierSideWest; else pierSideControl=PierSideEast; + if (pierSideControl == PierSideFlipEW3) pierSideControl=PierSideWest; else pierSideControl=PierSideEast; // now complete the slew cli(); @@ -237,9 +230,9 @@ void moveTo() { } else { // other special gotos: for parking the mount and homing the mount - if (parkStatus==Parking) { + if (parkStatus == Parking) { // clear the backlash - int i=parkClearBacklash(); if (i==-1) return; // working + int i=parkClearBacklash(); if (i == -1) return; // working // stop the motor timers (except guiding) cli(); trackingTimerRateAxis1=0.0; trackingTimerRateAxis2=0.0; sei(); delay(11); @@ -250,7 +243,7 @@ void moveTo() { // validate location byte parkPierSide=nv.read(EE_pierSide); - if ((blAxis1!=0) || (blAxis2!=0) || (posAxis1!=(long)targetAxis1.part.m) || (posAxis2!=(long)targetAxis2.part.m) || (pierSideControl!=parkPierSide) || (i!=1)) { parkStatus=ParkFailed; nv.write(EE_parkStatus,parkStatus); } + if ((blAxis1 != 0) || (blAxis2 != 0) || (posAxis1 != (long)targetAxis1.part.m) || (posAxis2 != (long)targetAxis2.part.m) || (pierSideControl != parkPierSide) || (i != 1)) { parkStatus=ParkFailed; nv.write(EE_parkStatus,parkStatus); } // sound park done soundAlert(); @@ -269,7 +262,7 @@ void moveTo() { soundAlert(); // clear the backlash - if (parkClearBacklash()==-1) return; // working, no error flagging + if (parkClearBacklash() == -1) return; // working, no error flagging // restore trackingState trackingState=lastTrackingState; lastTrackingState=TrackingNone; @@ -287,7 +280,7 @@ void moveTo() { setDeltaTrackingRate(); // allow 5 seconds for synchronization of coordinates after goto ends - if (trackingState==TrackingSidereal) trackingSyncSeconds=5; + if (trackingState == TrackingSidereal) trackingSyncSeconds=5; } } } @@ -312,7 +305,7 @@ uint32_t isqrt32 (uint32_t n) { } void stopLimit() { - if (trackingState==TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else trackingState=TrackingNone; + if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else trackingState=TrackingNone; } // check for platform rate limit (lowest maxRate) in 1/16us units @@ -320,24 +313,24 @@ long maxRateLowerLimit() { double r_us=HAL_MAXRATE_LOWER_LIMIT; // for example 16us, this basis rate has platform (STM32/Teensy3.2/3.5/3.6/Mega2560), clock rate, and ISR operating mode (Sqw/Pulse/Dedge) factored in (from HAL.) // higher speed ISR code path? - #if STEP_WAVE_FORM==PULSE || STEP_WAVE_FORM==DEDGE + #if STEP_WAVE_FORM == PULSE || STEP_WAVE_FORM == DEDGE r_us=r_us/1.6; // about 1.6x faster than SQW mode in my testing #endif // on-the-fly mode switching used? - #if !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) - if ((AXIS1_STEP_GOTO!=1) || (AXIS2_STEP_GOTO!=1)) r_us=HAL_MAXRATE_LOWER_LIMIT*1.7; // if this code is enabled, 27us + #if MODE_SWITCH_BEFORE_SLEW == OFF + if ((AXIS1_DRIVER_STEP_GOTO != 1) || (AXIS2_DRIVER_STEP_GOTO != 1)) r_us=HAL_MAXRATE_LOWER_LIMIT*1.7; // if this code is enabled, 27us #endif // average required goto us rates for each axis with any micro-step mode switching applied, if tracking in 32X mode using 4X for gotos (32/4 = 8,) that's an 8x lower true rate so 27/8 = 3.4 is allowed - double r_us_axis1=r_us/AXIS1_STEP_GOTO; - double r_us_axis2=r_us/AXIS2_STEP_GOTO; + double r_us_axis1=r_us/AXIS1_DRIVER_STEP_GOTO; + double r_us_axis2=r_us/AXIS2_DRIVER_STEP_GOTO; // average in axis2 step rate scaling for drives where the reduction ratio isn't equal r_us=(r_us_axis1+r_us_axis2/timerRateRatio)/2.0; // if Axis1 is 10000 step/deg & Axis2 is 20000 steps/deg, Axis2 needs to run 2x speed so we must slow down. 3.4 on one axis and 6.8 on the other for an average of 5.1 // the timer granulaity can start to make for some very abrupt rate changes below 0.25us - if (r_us<0.25) r_us=0.25; + if (r_us < 0.25) r_us=0.25; // return rate in 1/16us units return round(r_us*16.0); diff --git a/OnStep.ino b/OnStep.ino index 3e95e7bdc..fec8cf6c7 100644 --- a/OnStep.ino +++ b/OnStep.ino @@ -39,10 +39,10 @@ // firmware info, these are returned by the ":GV?#" commands #define FirmwareDate __DATE__ -#define FirmwareVersionMajor 2 -#define FirmwareVersionMinor 24 // minor version 0 to 99 -#define FirmwareVersionPatch "g" // for example major.minor patch: 1.3c -#define FirmwareVersionConfig 2 // internal, for tracking configuration file changes +#define FirmwareVersionMajor 3 +#define FirmwareVersionMinor 0 // minor version 0 to 99 +#define FirmwareVersionPatch "a" // for example major.minor patch: 1.3c +#define FirmwareVersionConfig 3 // internal, for tracking configuration file changes #define FirmwareName "On-Step" #define FirmwareTime __TIME__ @@ -52,6 +52,7 @@ #include "Constants.h" #include "src/step_dir_drivers/Models.h" #include "Config.h" +#include "src/pinmaps/Models.h" #include "src/HAL/HAL.h" #include "Validate.h" @@ -84,11 +85,28 @@ #include "src/lib/Misc.h" #include "src/lib/Sound.h" -#ifdef MODE_SWITCH_BEFORE_SLEW_SPI -#include "src/lib/TMC_SPI.h" -// SS ,SCK ,MISO ,MOSI -tmcSpiDriver tmcAxis1(Axis1_M2,Axis1_M1,Axis1_Aux,Axis1_M0); -tmcSpiDriver tmcAxis2(Axis2_M2,Axis2_M1,Axis2_Aux,Axis2_M0); +#if MODE_SWITCH_BEFORE_SLEW == TMC_SPI + #include "src/lib/TMC_SPI.h" + #if AXIS1_DRIVER_STATUS == TMC_SPI +// SS ,SCK ,MISO ,MOSI + tmcSpiDriver tmcAxis1(Axis1_M2,Axis1_M1,Axis1_M3,Axis1_M0); + #else + tmcSpiDriver tmcAxis1(Axis1_M2,Axis1_M1, -1,Axis1_M0); + #endif + #if AXIS2_DRIVER_STATUS == TMC_SPI + tmcSpiDriver tmcAxis2(Axis2_M2,Axis2_M1,Axis2_M3,Axis2_M0); + #else + tmcSpiDriver tmcAxis2(Axis2_M2,Axis2_M1, -1,Axis2_M0); + #endif + #if ROTATOR == ON && AXIS3_DRIVER_MODEL == TMC_SPI + tmcSpiDriver tmcAxis3(Axis3_M2,Axis3_M1, -1,Axis3_M0); + #endif + #if FOCUSER1 == ON && AXIS4_DRIVER_MODEL == TMC_SPI + tmcSpiDriver tmcAxis4(Axis4_M2,Axis4_M1, -1,Axis4_M0); + #endif + #if FOCUSER2 == ON && AXIS5_DRIVER_MODEL == TMC_SPI + tmcSpiDriver tmcAxis5(Axis5_M2,Axis5_M1, -1,Axis5_M0); + #endif #endif #include "src/lib/Coord.h" @@ -97,14 +115,14 @@ tmcSpiDriver tmcAxis2(Axis2_M2,Axis2_M1,Axis2_Aux,Axis2_M0); #include "src/lib/Command.h" #include "Align.h" -#ifdef ROTATOR_ON +#if ROTATOR == ON #include "src/lib/Rotator.h" rotator rot; #endif -#if defined(FOCUSER1_ON) || defined(FOCUSER2_ON) - #ifdef FOCUSER1_ON - #ifdef AXIS4_DC_MODE_ON +#if FOCUSER1 == ON || FOCUSER2 == ON + #if FOCUSER1 == ON + #if AXIS4_DRIVER_DC_MODE != OFF #include "src/lib/FocuserDC.h" focuserDC foc1; #else @@ -112,8 +130,8 @@ tmcSpiDriver tmcAxis2(Axis2_M2,Axis2_M1,Axis2_Aux,Axis2_M0); focuser foc1; #endif #endif - #ifdef FOCUSER2_ON - #ifdef AXIS5_DC_MODE_ON + #if FOCUSER2 == ON + #if AXIS5_DRIVER_DC_MODE != OFF #include "src/lib/FocuserDC.h" focuserDC foc2; #else @@ -155,6 +173,11 @@ void setup() { // get weather monitoring ready to go ambient.init(); + + // prepare PEC buffer +#if MOUNT_TYPE != ALTAZM + createPecBuffer(); +#endif // set initial values for some variables initStartupValues(); @@ -175,9 +198,9 @@ void setup() { timerRateAxis2=SiderealRate; // backlash takeup rates - TakeupRate=SiderealRate/BacklashTakeupRate; - timerRateBacklashAxis1=SiderealRate/BacklashTakeupRate; - timerRateBacklashAxis2=(SiderealRate/BacklashTakeupRate)*timerRateRatio; + TakeupRate=SiderealRate/BACKLASH_RATE; + timerRateBacklashAxis1=SiderealRate/BACKLASH_RATE; + timerRateBacklashAxis2=(SiderealRate/BACKLASH_RATE)*timerRateRatio; // now read any saved values from EEPROM into varaibles to restore our last state initReadNvValues(); @@ -187,97 +210,113 @@ void setup() { setDeltaTrackingRate(); initStartTimers(); - SerialA.begin(9600); + SerialA.begin(SERIAL_A_BAUD_DEFAULT); #ifdef HAL_SERIAL_B_ENABLED SerialB.begin(SERIAL_B_BAUD_DEFAULT); #endif #ifdef HAL_SERIAL_C_ENABLED SerialC.begin(SERIAL_C_BAUD_DEFAULT); #endif -#ifdef ST4_HAND_CONTROL_ON +#if ST4_HAND_CONTROL == ON SerialST4.begin(); #endif - // autostart tracking -#if defined(AUTOSTART_TRACKING_ON) - #if !defined(MOUNT_TYPE_ALTAZM) + // tracking autostart +#if TRACK_AUTOSTART == ON + #if MOUNT_TYPE != ALTAZM // tailor behaviour depending on RTC presence if (!urtc.active) { setHome(); safetyLimitsOn=false; } else { - if (parkStatus==Parked) unPark(true); else setHome(); + if (parkStatus == Parked) unPark(true); else setHome(); } // start tracking trackingState=TrackingSidereal; enableStepperDrivers(); #else - #warning "AUTOSTART_TRACKING_ON ignored for MOUNT_TYPE_ALTAZM" + #warning "Tracking autostart ignored for MOUNT_TYPE ALTAZM" #endif #else // unpark without tracking, if parked - if (parkStatus==Parked) unPark(false); + if (parkStatus == Parked) unPark(false); #endif // start rotator if present -#ifdef ROTATOR_ON - rot.init(Axis3StepPin,Axis3DirPin,Axis3_EN,MaxRateAxis3,StepsPerDegreeAxis3); - rot.setMin(MinAxis3); - rot.setMax(MaxAxis3); - #ifdef AXIS3_REVERSE_ON +#if ROTATOR == ON + rot.init(Axis3StepPin,Axis3DirPin,Axis3_EN,AXIS3_STEP_RATE_MAX,AXIS3_STEPS_PER_DEGREE); + rot.setMin(AXIS3_LIMIT_MIN); + rot.setMax(AXIS3_LIMIT_MAX); + #if AXIS3_DRIVER_REVERSE == ON rot.setReverseState(HIGH); #endif - #ifdef AXIS3_DISABLE - rot.setDisableState(AXIS3_DISABLE); - #ifdef AXIS3_AUTO_POWER_DOWN_ON - rot.powerDownActive(true); - #else - rot.powerDownActive(false); - #endif + rot.setDisableState(AXIS3_DRIVER_DISABLE); + + #if MODE_SWITCH_BEFORE_SLEW == TMC_SPI && AXIS3_DRIVER_MODEL == TMC_SPI + tmcAxis3.setup(AXIS3_DRIVER_INTPOL,AXIS3_DRIVER_DECAY_MODE,AXIS3_MICROSTEP_CODE&0b001111,AXIS3_DRIVER_IRUN,AXIS3_DRIVER_IRUN,AXIS3_DRIVER_RSENSE); + delay(150); + tmcAxis3.setup(AXIS3_DRIVER_INTPOL,AXIS3_DRIVER_DECAY_MODE,AXIS3_MICROSTEP_CODE&0b001111,AXIS3_DRIVER_IRUN,AXIS3_DRIVER_IHOLD,AXIS3_DRIVER_RSENSE); + #endif + + #if AXIS3_DRIVER_POWER_DOWN == ON + rot.powerDownActive(true); + #else + rot.powerDownActive(false); #endif #endif // start focusers if present -#ifdef FOCUSER1_ON - foc1.init(Axis4StepPin,Axis4DirPin,Axis4_EN,EE_posAxis4,MaxRateAxis4,StepsPerMicrometerAxis4); - foc1.setMin(MinAxis4*1000.0); - foc1.setMax(MaxAxis4*1000.0); - #ifdef AXIS4_DC_MODE_ON +#if FOCUSER1 == ON + foc1.init(Axis4StepPin,Axis4DirPin,Axis4_EN,EE_posAxis4,AXIS4_STEP_RATE_MAX,AXIS4_STEPS_PER_MICRON); + foc1.setMin(AXIS4_LIMIT_MIN*1000.0); + foc1.setMax(AXIS4_LIMIT_MAX*1000.0); + #if AXIS4_DRIVER_DC_MODE != OFF foc1.setDcPower(dcPwrAxis4); - foc1.setPhase2(); + foc1.setPhase1(); #endif - #ifdef AXIS4_REVERSE_ON + #if AXIS4_DRIVER_REVERSE == ON foc1.setReverseState(HIGH); #endif - #ifdef AXIS4_DISABLE - foc1.setDisableState(AXIS4_DISABLE); - #ifdef AXIS4_AUTO_POWER_DOWN_ON - foc1.powerDownActive(true); - #else - foc1.powerDownActive(false); - #endif + foc1.setDisableState(AXIS4_DRIVER_DISABLE); + + #if MODE_SWITCH_BEFORE_SLEW == TMC_SPI && AXIS3_DRIVER_MODEL == TMC_SPI + tmcAxis4.setup(AXIS4_DRIVER_INTPOL,AXIS4_DRIVER_DECAY_MODE,AXIS4_MICROSTEP_CODE&0b001111,AXIS4_DRIVER_IRUN,AXIS4_DRIVER_IRUN,AXIS4_DRIVER_RSENSE); + delay(150); + tmcAxis4.setup(AXIS4_DRIVER_INTPOL,AXIS4_DRIVER_DECAY_MODE,AXIS4_MICROSTEP_CODE&0b001111,AXIS4_DRIVER_IRUN,AXIS4_DRIVER_IHOLD,AXIS4_DRIVER_RSENSE); + #endif + + #if AXIS4_DRIVER_POWER_DOWN == ON + foc1.powerDownActive(true); + #else + foc1.powerDownActive(false); #endif #endif -#ifdef FOCUSER2_ON - foc2.init(Axis5StepPin,Axis5DirPin,Axis5_EN,EE_posAxis5,MaxRateAxis5,StepsPerMicrometerAxis5); - foc2.setMin(MinAxis5*1000.0); - foc2.setMax(MaxAxis5*1000.0); - #ifdef AXIS5_DC_MODE_ON + +#if FOCUSER2 == ON + foc2.init(Axis5StepPin,Axis5DirPin,Axis5_EN,EE_posAxis5,AXIS5_STEP_RATE_MAX,AXIS5_STEPS_PER_MICRON); + foc2.setMin(AXIS5_LIMIT_MIN*1000.0); + foc2.setMax(AXIS5_LIMIT_MAX*1000.0); + #if AXIS5_DRIVER_DC_MODE == DRV8825 foc2.setDcPower(dcPwrAxis5); - foc2.setPhase1(); + foc2.setPhase2(); #endif - #ifdef AXIS5_REVERSE_ON + #if AXIS5_DRIVER_REVERSE == ON foc2.setReverseState(HIGH); #endif - #ifdef AXIS5_DISABLE - foc2.setDisableState(AXIS5_DISABLE); - #ifdef AXIS5_AUTO_POWER_DOWN_ON - foc2.powerDownActive(true); - #else - foc2.powerDownActive(false); - #endif + foc2.setDisableState(AXIS5_DRIVER_DISABLE); + + #if MODE_SWITCH_BEFORE_SLEW == TMC_SPI && AXIS3_DRIVER_MODEL == TMC_SPI + tmcAxis5.setup(AXIS5_DRIVER_INTPOL,AXIS5_DRIVER_DECAY_MODE,AXIS5_MICROSTEP_CODE&0b001111,AXIS5_DRIVER_IRUN,AXIS5_DRIVER_IRUN,AXIS5_DRIVER_RSENSE); + delay(150); + tmcAxis5.setup(AXIS5_DRIVER_INTPOL,AXIS5_DRIVER_DECAY_MODE,AXIS5_MICROSTEP_CODE&0b001111,AXIS5_DRIVER_IRUN,AXIS5_DRIVER_IHOLD,AXIS5_DRIVER_RSENSE); + #endif + + #if AXIS5_DRIVER_POWER_DOWN == ON + foc2.powerDownActive(true); + #else + foc2.powerDownActive(false); #endif #endif @@ -294,33 +333,33 @@ void loop() { void loop2() { // GUIDING ------------------------------------------------------------------------------------------- ST4(); - if ((trackingState!=TrackingMoveTo) && (parkStatus==NotParked)) guide(); + if ((trackingState != TrackingMoveTo) && (parkStatus == NotParked)) guide(); -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM // PERIODIC ERROR CORRECTION ------------------------------------------------------------------------- - if ((trackingState==TrackingSidereal) && (parkStatus==NotParked) && (!((guideDirAxis1 || guideDirAxis2) && (activeGuideRate>GuideRate1x)))) { + if ((trackingState == TrackingSidereal) && (parkStatus == NotParked) && (!((guideDirAxis1 || guideDirAxis2) && (activeGuideRate > GuideRate1x)))) { // only active while sidereal tracking with a guide rate that makes sense pec(); } else disablePec(); #endif -#ifdef HOME_SENSE_ON +#if HOME_SENSE == ON // AUTOMATIC HOMING ---------------------------------------------------------------------------------- checkHome(); #endif // 1/100 SECOND TIMED -------------------------------------------------------------------------------- cli(); long tempLst=lst; sei(); - if (tempLst!=siderealTimer) { + if (tempLst != siderealTimer) { siderealTimer=tempLst; #ifdef ESP32 timerSupervisor(true); #endif -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM // WRITE PERIODIC ERROR CORRECTION TO EEPROM - if (pecAutoRecord>0) { + if (pecAutoRecord > 0) { // write PEC table to EEPROM, should do several hundred bytes/second pecAutoRecord--; nv.update(EE_pecTable+pecAutoRecord,pecBuffer[pecAutoRecord]); @@ -328,21 +367,21 @@ void loop2() { #endif // FLASH LED DURING SIDEREAL TRACKING - if (trackingState==TrackingSidereal) { -#ifdef STATUS_LED_PINS_ON - if (siderealTimer%20L==0L) { if (LED_ON) { digitalWrite(LEDnegPin,HIGH); LED_ON=false; } else { digitalWrite(LEDnegPin,LOW); LED_ON=true; } } + if (trackingState == TrackingSidereal) { +#if LED_STATUS_PIN == ON + if (siderealTimer%20L == 0L) { if (ledOn) { digitalWrite(LEDnegPin,HIGH); ledOn=false; } else { digitalWrite(LEDnegPin,LOW); ledOn=true; } } #endif } // SIDEREAL TRACKING DURING GOTOS // keeps the target where it's supposed to be while doing gotos - if (trackingState==TrackingMoveTo) { + if (trackingState == TrackingMoveTo) { moveTo(); - if (lastTrackingState==TrackingSidereal) { + if (lastTrackingState == TrackingSidereal) { // origTargetAxisn isn't used in Alt/Azm mode since meridian flips never happen origTargetAxis1.fixed+=fstepAxis1.fixed; // don't advance the target during meridian flips - if ((getInstrPierSide()==PierSideEast) || (getInstrPierSide()==PierSideWest)) { + if ((getInstrPierSide() == PierSideEast) || (getInstrPierSide() == PierSideWest)) { cli(); targetAxis1.fixed+=fstepAxis1.fixed; targetAxis2.fixed+=fstepAxis2.fixed; @@ -352,29 +391,29 @@ void loop2() { } // ROTATOR/FOCUSERS, MOVE THE TARGET -#if defined(ROTATOR_ON) - rot.move(trackingState==TrackingSidereal); +#if ROTATOR == ON + rot.move(trackingState == TrackingSidereal); #endif -#if defined(FOCUSER1_ON) +#if FOCUSER1 == ON foc1.move(); #endif -#if defined(FOCUSER2_ON) +#if FOCUSER2 == ON foc2.move(); #endif // CALCULATE SOME TRACKING RATES, ETC. - if (lst%3==0) doFastAltCalc(false); -#ifdef MOUNT_TYPE_ALTAZM + if (lst%3 == 0) doFastAltCalc(false); +#if MOUNT_TYPE == ALTAZM // figure out the current Alt/Azm tracking rates - if (lst%3!=0) doHorRateCalc(); + if (lst%3 != 0) doHorRateCalc(); #else // figure out the current refraction compensated tracking rate - if ((rateCompensation!=RC_NONE) && (lst%3!=0)) doRefractionRateCalc(); + if ((rateCompensation != RC_NONE) && (lst%3 != 0)) doRefractionRateCalc(); #endif // SAFETY CHECKS +#if LIMIT_SENSE == ON // support for limit switch(es) -#ifdef LIMIT_SENSE_ON byte limit_1st = digitalRead(LimitPin); if (limit_1st == LIMIT_SENSE_STATE) { // Wait for a short while, then read again @@ -389,39 +428,27 @@ void loop2() { #endif // check for fault signal, stop any slew or guide and turn tracking off -#ifdef AXIS1_FAULT - #if AXIS1_FAULT==LOW - faultAxis1=(digitalRead(Axis1_FAULT)==LOW); - #endif - #if AXIS1_FAULT==HIGH - faultAxis1=(digitalRead(Axis1_FAULT)==HIGH); - #endif - #if AXIS1_FAULT==TMC_SPI - if (lst%2==0) faultAxis1=tmcAxis1.error(); - #endif +#if AXIS1_DRIVER_STATUS == LOW || AXIS1_DRIVER_STATUS == HIGH + faultAxis1=(digitalRead(Axis1FaultPin) == AXIS1_DRIVER_STATUS); +#elif AXIS1_DRIVER_STATUS == TMC_SPI + if (lst%2 == 0) faultAxis1=tmcAxis1.error(); #endif -#ifdef AXIS2_FAULT - #if AXIS2_FAULT==LOW - faultAxis2=(digitalRead(Axis2_FAULT)==LOW); - #endif - #if AXIS2_FAULT==HIGH - faultAxis2=(digitalRead(Axis2_FAULT)==HIGH); - #endif - #if AXIS2_FAULT==TMC_SPI - if (lst%2==1) faultAxis2=tmcAxis2.error(); - #endif +#if AXIS2_DRIVER_STATUS == LOW || AXIS2_DRIVER_STATUS == HIGH + faultAxis2=(digitalRead(Axis2FaultPin) == AXIS2_DRIVER_STATUS); +#elif AXIS2_DRIVER_STATUS == TMC_SPI + if (lst%2 == 1) faultAxis2=tmcAxis2.error(); #endif - if (faultAxis1 || faultAxis2) { lastError=ERR_MOTOR_FAULT; if (trackingState==TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else { trackingState=TrackingNone; if (guideDirAxis1) guideDirAxis1='b'; if (guideDirAxis2) guideDirAxis2='b'; } } + if (faultAxis1 || faultAxis2) { lastError=ERR_MOTOR_FAULT; if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; } else { trackingState=TrackingNone; if (guideDirAxis1) guideDirAxis1='b'; if (guideDirAxis2) guideDirAxis2='b'; } } if (safetyLimitsOn) { // check altitude overhead limit and horizon limit - if (currentAltmaxAlt) { lastError=ERR_ALT_MAX; stopLimit(); } + if (currentAlt < minAlt) { lastError=ERR_ALT_MIN; stopLimit(); } + if (currentAlt > maxAlt) { lastError=ERR_ALT_MAX; stopLimit(); } } // OPTION TO POWER DOWN AXIS2 IF NOT MOVING -#if defined(AXIS2_AUTO_POWER_DOWN_ON) && !defined(MOUNT_TYPE_ALTAZM) +#if AXIS2_DRIVER_POWER_DOWN == ON && MOUNT_TYPE != ALTAZM autoPowerDownAxis2(); #endif @@ -433,13 +460,13 @@ void loop2() { } // ROTATOR/DEROTATOR/FOCUSERS ------------------------------------------------------------------------ -#ifdef ROTATOR_ON +#if ROTATOR == ON rot.follow(); #endif -#ifdef FOCUSER1_ON +#if FOCUSER1 == ON foc1.follow(isSlewing()); #endif -#ifdef FOCUSER2_ON +#if FOCUSER2 == ON foc2.follow(isSlewing()); #endif @@ -449,7 +476,7 @@ void loop2() { // WORKLOAD MONITORING ------------------------------------------------------------------------------- long this_loop_micros=micros(); loop_time=this_loop_micros-last_loop_micros; - if (loop_time>worst_loop_time) worst_loop_time=loop_time; + if (loop_time > worst_loop_time) worst_loop_time=loop_time; last_loop_micros=this_loop_micros; average_loop_time=(average_loop_time*49.0+loop_time)/50.0; @@ -457,7 +484,7 @@ void loop2() { // 0.5 SECOND TIMED ---------------------------------------------------------------------------------- static unsigned long debugTimer=0; - if (((long)(tempMs-debugTimer)>0) && (millis()<1200)) { + if (((long)(tempMs-debugTimer) > 0) && (millis() < 1200)) { debugTimer=tempMs+500UL; // DL(((double)SiderealRate/(double)timerRateAxis1)); } @@ -468,13 +495,13 @@ void loop2() { housekeepingTimer = millis(); } - if ((long)(tempMs-housekeepingTimer)>0) { + if ((long)(tempMs-housekeepingTimer) > 0) { housekeepingTimer=tempMs+1000UL; -#if defined(ROTATOR_ON) && defined(MOUNT_TYPE_ALTAZM) +#if ROTATOR == ON && MOUNT_TYPE == ALTAZM // calculate and set the derotation rate as required double h,d; getApproxEqu(&h,&d,true); - if (trackingState==TrackingSidereal) rot.derotate(h,d); + if (trackingState == TrackingSidereal) rot.derotate(h,d); #endif // adjust tracking rate for Alt/Azm mounts @@ -482,47 +509,46 @@ void loop2() { setDeltaTrackingRate(); // basic check to see if we're not at home - if (trackingState!=TrackingNone) atHome=false; + if (trackingState != TrackingNone) atHome=false; -#ifdef PEC_SENSE - // see if we're on the PEC index - if (trackingState==TrackingSidereal) - pecAnalogValue = analogRead(AnalogPecPin); +#if PEC_SENSE >= 0 + // analog mode, see if we're on the PEC index + if (trackingState == TrackingSidereal) pecAnalogValue = analogRead(AnalogPecPin); #endif -#if defined(PPS_SENSE_ON) || defined(PPS_SENSE_PULLUP) +#if PPS_SENSE != OFF // update clock via PPS - if (trackingState==TrackingSidereal) { + if (trackingState == TrackingSidereal) { cli(); PPSrateRatio=((double)1000000.0/(double)(PPSavgMicroS)); - if ((long)(micros()-(PPSlastMicroS+2000000UL))>0) PPSsynced=false; // if more than two seconds has ellapsed without a pulse we've lost sync + if ((long)(micros()-(PPSlastMicroS+2000000UL)) > 0) PPSsynced=false; // if more than two seconds has ellapsed without a pulse we've lost sync sei(); - #ifdef STATUS_LED2_PINS_ON - if (PPSsynced) { if (LED2_ON) { digitalWrite(LEDneg2Pin,HIGH); LED2_ON=false; } else { digitalWrite(LEDneg2Pin,LOW); LED2_ON=true; } } else { digitalWrite(LEDneg2Pin,HIGH); LED2_ON=false; } // indicate PPS + #if LED_STATUS2_PIN == ON + if (PPSsynced) { if (led2On) { digitalWrite(LEDneg2Pin,HIGH); led2On=false; } else { digitalWrite(LEDneg2Pin,LOW); led2On=true; } } else { digitalWrite(LEDneg2Pin,HIGH); led2On=false; } // indicate PPS #endif - if (LastPPSrateRatio!=PPSrateRatio) { SiderealClockSetInterval(siderealInterval); LastPPSrateRatio=PPSrateRatio; } + if (LastPPSrateRatio != PPSrateRatio) { SiderealClockSetInterval(siderealInterval); LastPPSrateRatio=PPSrateRatio; } } #endif -#ifdef STATUS_LED_PINS_ON +#if LED_STATUS_PIN == ON // LED indicate PWR on - if (trackingState!=TrackingSidereal) if (!LED_ON) { digitalWrite(LEDnegPin,LOW); LED_ON=true; } + if (trackingState != TrackingSidereal) if (!ledOn) { digitalWrite(LEDnegPin,LOW); ledOn=true; } #endif -#ifdef STATUS_LED2_PINS_ON +#if LED_STATUS2_PIN == ON // LED indicate STOP and GOTO - if (trackingState==TrackingMoveTo) if (!LED2_ON) { digitalWrite(LEDneg2Pin,LOW); LED2_ON=true; } -#if defined(PPS_SENSE_ON) || defined(PPS_SENSE_PULLUP) - if (trackingState==TrackingNone) if (LED2_ON) { digitalWrite(LEDneg2Pin,HIGH); LED2_ON=false; } -#else - if (trackingState!=TrackingMoveTo) if (LED2_ON) { digitalWrite(LEDneg2Pin,HIGH); LED2_ON=false; } -#endif + if (trackingState == TrackingMoveTo) if (!led2On) { digitalWrite(LEDneg2Pin,LOW); led2On=true; } + #if PPS_SENSE != OFF + if (trackingState == TrackingNone) if (led2On) { digitalWrite(LEDneg2Pin,HIGH); led2On=false; } + #else + if (trackingState != TrackingMoveTo) if (led2On) { digitalWrite(LEDneg2Pin,HIGH); led2On=false; } + #endif #endif - // SAFETY CHECKS, keeps mount from tracking past the meridian limit, past the UnderPoleLimit, or past the Dec limits + // SAFETY CHECKS, keeps mount from tracking past the meridian limit, past the AXIS1_LIMIT_UNDER_POLE, or past the Dec limits if (safetyLimitsOn) { - if (meridianFlip!=MeridianFlipNever) { - if (getInstrPierSide()==PierSideWest) { - if (getInstrAxis1()>minutesPastMeridianW/4.0) { + if (meridianFlip != MeridianFlipNever) { + if (getInstrPierSide() == PierSideWest) { + if (getInstrAxis1() > degreesPastMeridianW) { if (autoMeridianFlip) { if (goToHere(true)) { lastError=ERR_MERIDIAN; trackingState=TrackingNone; } } else { @@ -530,23 +556,23 @@ void loop2() { } } } else - if (getInstrPierSide()==PierSideEast) { - if (getInstrAxis1()<-minutesPastMeridianE/4.0) { lastError=ERR_MERIDIAN; stopLimit(); } - if (getInstrAxis1()>UnderPoleLimit*15.0) { lastError=ERR_UNDER_POLE; stopLimit(); } + if (getInstrPierSide() == PierSideEast) { + if (getInstrAxis1() < -degreesPastMeridianE) { lastError=ERR_MERIDIAN; stopLimit(); } + if (getInstrAxis1() > AXIS1_LIMIT_UNDER_POLE) { lastError=ERR_UNDER_POLE; stopLimit(); } } } else { -#ifndef MOUNT_TYPE_ALTAZM +#if MOUNT_TYPE != ALTAZM // when Fork mounted, ignore pierSide and just stop the mount if it passes the UnderPoleLimit - if (getInstrAxis1()>UnderPoleLimit*15.0) { lastError=ERR_UNDER_POLE; stopLimit(); } + if (getInstrAxis1() > AXIS1_LIMIT_UNDER_POLE) { lastError=ERR_UNDER_POLE; stopLimit(); } #else - // when Alt/Azm mounted, just stop the mount if it passes MaxAzm - if (getInstrAxis1()>MaxAzm) { lastError=ERR_AZM; stopLimit(); } + // when Alt/Azm mounted, just stop the mount if it passes AXIS1_LIMIT_MAXAZM + if (getInstrAxis1() > AXIS1_LIMIT_MAXAZM) { lastError=ERR_AZM; stopLimit(); } #endif } } - // check for exceeding MinDec or MaxDec -#ifndef MOUNT_TYPE_ALTAZM - if ((currentDecMaxDec)) { lastError=ERR_DEC; stopLimit(); } + // check for exceeding AXIS2_LIMIT_MIN or AXIS2_LIMIT_MAX +#if MOUNT_TYPE != ALTAZM + if ((currentDec < AXIS2_LIMIT_MIN) || (currentDec > AXIS2_LIMIT_MAX)) { lastError=ERR_DEC; stopLimit(); } #endif // update weather info diff --git a/Park.ino b/Park.ino index db9dd3bab..f3693068a 100644 --- a/Park.ino +++ b/Park.ino @@ -3,14 +3,14 @@ // sets the park postion as the current position boolean setPark() { - if ((parkStatus==NotParked) && (trackingState!=TrackingMoveTo) && ((getInstrPierSide()==PierSideNone) || (getInstrPierSide()==PierSideEast) || (getInstrPierSide()==PierSideWest))) { + if ((parkStatus == NotParked) && (trackingState != TrackingMoveTo) && ((getInstrPierSide() == PierSideNone) || (getInstrPierSide() == PierSideEast) || (getInstrPierSide() == PierSideWest))) { lastTrackingState=trackingState; trackingState=TrackingNone; // store our position nv.writeFloat(EE_posAxis1,getInstrAxis1()); nv.writeFloat(EE_posAxis2,getInstrAxis2()); - int p=getInstrPierSide(); if (p==PierSideNone) nv.write(EE_pierSide,PierSideEast); else nv.write(EE_pierSide,p); + int p=getInstrPierSide(); if (p == PierSideNone) nv.write(EE_pierSide,PierSideEast); else nv.write(EE_pierSide,p); // record our park status parkSaved=true; nv.write(EE_parkSaved,parkSaved); @@ -26,8 +26,8 @@ boolean setPark() { // moves the telescope to the park position byte park() { - if (parkStatus==Parked) return 0; // already parked - int f=validateGoto(); if (f==5) f=8; if (f!=0) return f; // goto allowed? + if (parkStatus == Parked) return 0; // already parked + int f=validateGoto(); if (f == 5) f=8; if (f != 0) return f; // goto allowed? parkSaved=nv.read(EE_parkSaved); if (parkSaved) { @@ -55,7 +55,7 @@ byte park() { int gotoStatus=goTo(parkTargetAxis1,parkTargetAxis2,parkTargetAxis1,parkTargetAxis2,parkPierSide); // if failure - if (gotoStatus!=0) { + if (gotoStatus != 0) { trackingState=abortTrackingState; // resume tracking state parkStatus=lastParkStatus; // revert the park status nv.write(EE_parkStatus,parkStatus); @@ -67,7 +67,7 @@ byte park() { // records the park position, updates status, shuts down the stepper motors void parkFinish() { - if (parkStatus!=ParkFailed) { + if (parkStatus != ParkFailed) { // success, we're parked parkStatus=Parked; nv.write(EE_parkStatus,parkStatus); @@ -84,13 +84,13 @@ void targetNearestParkPosition() { // once set, parkClearBacklash() will synchronize Pos with Target again along with clearing the backlash cli(); long parkPosAxis1=targetAxis1.part.m; long parkPosAxis2=targetAxis2.part.m; sei(); parkPosAxis1-=((long)PARK_MAX_MICROSTEP*2L); - for (int l=0; l<(PARK_MAX_MICROSTEP*4); l++) { - if ((parkPosAxis1)%((long)PARK_MAX_MICROSTEP*4L)==0) break; + for (int l=0; l < (PARK_MAX_MICROSTEP*4); l++) { + if ((parkPosAxis1)%((long)PARK_MAX_MICROSTEP*4L) == 0) break; parkPosAxis1++; } parkPosAxis2-=((long)PARK_MAX_MICROSTEP*2L); - for (int l=0; l<(PARK_MAX_MICROSTEP*4); l++) { - if ((parkPosAxis2)%((long)PARK_MAX_MICROSTEP*4L)==0) break; + for (int l=0; l < (PARK_MAX_MICROSTEP*4); l++) { + if ((parkPosAxis2)%((long)PARK_MAX_MICROSTEP*4L) == 0) break; parkPosAxis2++; } cli(); targetAxis1.part.m=parkPosAxis1; targetAxis1.part.f=0; targetAxis2.part.m=parkPosAxis2; targetAxis2.part.f=0; sei(); @@ -101,43 +101,43 @@ bool doParkClearBacklash(int phase) { static unsigned long timeout=0; static bool failed=false; - if (phase==1) { + if (phase == 1) { failed=false; targetNearestParkPosition(); timeout=(unsigned long)millis()+10000UL; // set timeout in 10s return true; } // wait until done or timed out - if (phase==2) { - cli(); if ((posAxis1==(long)targetAxis1.part.m) && (posAxis2==(long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); - if ((long)(millis()-timeout)>0) { failed=true; return true; } else return false; + if (phase == 2) { + cli(); if ((posAxis1 == (long)targetAxis1.part.m) && (posAxis2 == (long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); + if ((long)(millis()-timeout) > 0) { failed=true; return true; } else return false; } - if (phase==3) { + if (phase == 3) { // start by moving fully into the backlash cli(); targetAxis1.part.m += 1; targetAxis2.part.m += 1; sei(); timeout=(unsigned long)millis()+10000UL; // set timeout in 10s return true; } // wait until done or timed out - if (phase==4) { - cli(); if ((posAxis1==(long)targetAxis1.part.m) && (posAxis2==(long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); - if ((long)(millis()-timeout)>0) { failed=true; return true; } else return false; + if (phase == 4) { + cli(); if ((posAxis1 == (long)targetAxis1.part.m) && (posAxis2 == (long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); + if ((long)(millis()-timeout) > 0) { failed=true; return true; } else return false; } - if (phase==5) { + if (phase == 5) { // then reverse direction and take it all up cli(); targetAxis1.part.m -= 1; targetAxis2.part.m -= 1; sei(); timeout=(unsigned long)millis()+10000UL; // set timeout in 10s return true; } // wait until done or timed out - if (phase==6) { - cli(); if ((posAxis1==(long)targetAxis1.part.m) && (posAxis2==(long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); - if ((long)(millis()-timeout)>0) { failed=true; return true; } else return false; + if (phase == 6) { + cli(); if ((posAxis1 == (long)targetAxis1.part.m) && (posAxis2 == (long)targetAxis2.part.m) && !inbacklashAxis1 && !inbacklashAxis2) { sei(); return true; } sei(); + if ((long)(millis()-timeout) > 0) { failed=true; return true; } else return false; } // we arrive back at the exact same position so targetAxis1/targetAxis2 don't need to be touched - if (phase==7) { + if (phase == 7) { // return true on success - cli(); if ((blAxis1!=0) || (blAxis2!=0) || (posAxis1!=(long)targetAxis1.part.m) || (posAxis2!=(long)targetAxis2.part.m) || failed) { sei(); return false; } else { sei(); return true; } + cli(); if ((blAxis1 != 0) || (blAxis2 != 0) || (posAxis1 != (long)targetAxis1.part.m) || (posAxis2 != (long)targetAxis2.part.m) || failed) { sei(); return false; } else { sei(); return true; } } return false; } @@ -145,28 +145,28 @@ bool doParkClearBacklash(int phase) { int parkClearBacklash() { static int phase=1; - if (phase==1) { if (doParkClearBacklash(1)) phase++; } else - if (phase==2) { if (doParkClearBacklash(2)) phase++; } else - if (phase==3) { if (doParkClearBacklash(3)) phase++; } else - if (phase==4) { if (doParkClearBacklash(4)) phase++; } else - if (phase==5) { if (doParkClearBacklash(5)) phase++; } else - if (phase==6) { if (doParkClearBacklash(6)) phase++; } else - if (phase==7) { phase=1; if (doParkClearBacklash(7)) return 1; else return 0; } + if (phase == 1) { if (doParkClearBacklash(1)) phase++; } else + if (phase == 2) { if (doParkClearBacklash(2)) phase++; } else + if (phase == 3) { if (doParkClearBacklash(3)) phase++; } else + if (phase == 4) { if (doParkClearBacklash(4)) phase++; } else + if (phase == 5) { if (doParkClearBacklash(5)) phase++; } else + if (phase == 6) { if (doParkClearBacklash(6)) phase++; } else + if (phase == 7) { phase=1; if (doParkClearBacklash(7)) return 1; else return 0; } return -1; } // 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(bool withTrackingOn) { -#ifdef STRICT_PARKING_ON - if (parkStatus==Parked) { +#if STRICT_PARKING == ON + if (parkStatus == Parked) { #else - if ((parkStatus==Parked) || ((atHome) && (parkStatus==NotParked))) { + if ((parkStatus == Parked) || ((atHome) && (parkStatus == NotParked))) { #endif parkStatus=nv.read(EE_parkStatus); parkSaved =nv.read(EE_parkSaved); parkStatus=Parked; - if (parkStatus==Parked) { + if (parkStatus == Parked) { if (parkSaved) { initStartupValues(); @@ -205,10 +205,10 @@ boolean unPark(bool withTrackingOn) { sei(); // set Meridian Flip behaviour to match mount type - #ifdef MOUNT_TYPE_GEM - meridianFlip=MeridianFlipAlways; + #if MOUNT_TYPE == GEM + meridianFlip=MeridianFlipAlways; #else - meridianFlip=MeridianFlipNever; + meridianFlip=MeridianFlipNever; #endif if (withTrackingOn) { @@ -233,7 +233,7 @@ boolean unPark(bool withTrackingOn) { } boolean isParked() { - return (parkStatus==Parked); + return (parkStatus == Parked); } boolean saveAlignModel() { @@ -247,9 +247,9 @@ boolean saveAlignModel() { boolean loadAlignModel() { // get align/corrections indexAxis1=nv.readFloat(EE_indexAxis1); - indexAxis1Steps=(long)(indexAxis1*(double)StepsPerDegreeAxis1); + indexAxis1Steps=(long)(indexAxis1*(double)AXIS1_STEPS_PER_DEGREE); indexAxis2=nv.readFloat(EE_indexAxis2); - indexAxis2Steps=(long)(indexAxis2*(double)StepsPerDegreeAxis2); + indexAxis2Steps=(long)(indexAxis2*(double)AXIS2_STEPS_PER_DEGREE); Align.readCoe(); return true; } diff --git a/Pec.ino b/Pec.ino index 80fff3e73..fe9590078 100644 --- a/Pec.ino +++ b/Pec.ino @@ -2,10 +2,10 @@ // Functions to handle periodic error correction // enables code to clean-up PEC readings after record (use PECprep or a spreadsheet to fix readings otherwise) -// this cleans up any tracking rate variations that would be introduced by recording more guiding corrections to either the east or west, default=_ON -#define PEC_CLEANUP_ON +// this cleans up any tracking rate variations that would be introduced by recording more guiding corrections to either the east or west, default ON +#define PEC_CLEANUP ON -#ifdef PEC_SENSE_OFF +#if PEC_SENSE == OFF boolean wormSensedFirst=true; #else boolean wormSensedFirst=false; @@ -21,23 +21,23 @@ void pec() { // keep track of our current step position, and when the step position on the worm wraps during playback cli(); long pecPos=(long)targetAxis1.part.m; sei(); - #ifdef PEC_SENSE_OFF + #if PEC_SENSE == OFF wormSensedFirst=true; #endif - #ifdef PEC_SENSE + #if PEC_SENSE >= 0 // for analog sense, with 60 second delay before redetect - long dist; if (wormSensePos>pecPos) dist=wormSensePos-pecPos; else dist=pecPos-wormSensePos; - if ((dist>StepsPerSecondAxis1*60.0) && (pecAnalogValue>PEC_SENSE)) { + long dist; if (wormSensePos > pecPos) dist=wormSensePos-pecPos; else dist=pecPos-wormSensePos; + if ((dist > StepsPerSecondAxis1*60.0) && (pecAnalogValue > PEC_SENSE)) { wormSensePos=pecPos; wormSensedAgain=true; wormSensedFirst=true; pecBufferStart=true; } else pecBufferStart=false; #endif - #if defined(PEC_SENSE_ON) || defined(PEC_SENSE_PULLUP) + #if PEC_SENSE == ON || PEC_SENSE == ON_PULLUP || PEC_SENSE == ON_PULLDOWN // for digital sense, with 60 second delay before redetect - long dist; if (wormSensePos>pecPos) dist=wormSensePos-pecPos; else dist=pecPos-wormSensePos; - if ((dist>StepsPerSecondAxis1*60.0) && (digitalRead(PecPin)==PEC_SENSE_STATE)) { + long dist; if (wormSensePos > pecPos) dist=wormSensePos-pecPos; else dist=pecPos-wormSensePos; + if ((dist > StepsPerSecondAxis1*60.0) && (digitalRead(PecPin) == PEC_SENSE_STATE)) { wormSensePos=pecPos; wormSensedAgain=true; wormSensedFirst=true; @@ -45,26 +45,26 @@ void pec() { } else pecBufferStart=false; #endif - if (pecStatus==IgnorePEC) { pecTimerRateAxis1=0.0; return; } + if (pecStatus == IgnorePEC) { pecTimerRateAxis1=0.0; return; } if (!wormSensedFirst) return; // worm step position corrected for any index found lastWormRotationPos=wormRotationPos; wormRotationPos=(pecPos-wormSensePos); - while (wormRotationPos>=(long)StepsPerWormRotationAxis1) wormRotationPos-=(long)StepsPerWormRotationAxis1; - while (wormRotationPos<0) wormRotationPos+=(long)StepsPerWormRotationAxis1; + while (wormRotationPos >= (long)AXIS1_STEPS_PER_WORMROT) wormRotationPos-=(long)AXIS1_STEPS_PER_WORMROT; + while (wormRotationPos < 0) wormRotationPos+=(long)AXIS1_STEPS_PER_WORMROT; // "soft" PEC index sense - #ifdef PEC_SENSE_OFF - if ((wormRotationPos-lastWormRotationPos)<0) pecBufferStart=true; else pecBufferStart=false; + #if PEC_SENSE == OFF + if ((wormRotationPos-lastWormRotationPos) < 0) pecBufferStart=true; else pecBufferStart=false; #endif // handle playing back and recording PEC cli(); long t=lst; sei(); // start playing PEC - if (pecStatus==ReadyPlayPEC) { + if (pecStatus == ReadyPlayPEC) { // makes sure the index is at the start of a second before resuming play - if ((long)fmod(wormRotationPos,StepsPerSecondAxis1)==0) { + if ((long)fmod(wormRotationPos,StepsPerSecondAxis1) == 0) { pecStatus=PlayPEC; pecIndex=wormRotationPos/StepsPerSecondAxis1; @@ -73,8 +73,8 @@ void pec() { } } else // start recording PEC - if (pecStatus==ReadyRecordPEC) { - if ((long)fmod(wormRotationPos,StepsPerSecondAxis1)==0) { + if (pecStatus == ReadyRecordPEC) { + if ((long)fmod(wormRotationPos,StepsPerSecondAxis1) == 0) { pecStatus=RecordPEC; pecIndex=wormRotationPos/StepsPerSecondAxis1; pecRecorded=false; @@ -86,49 +86,49 @@ void pec() { } } else // and once the PEC data is all stored, indicate that it's valid and start using it - if ((pecStatus==RecordPEC) && (t-pecRecordStopTime>0)) { + if ((pecStatus == RecordPEC) && (t-pecRecordStopTime > 0)) { pecStatus=PlayPEC; pecRecorded=true; pecFirstRecord=false; -#ifdef PEC_CLEANUP_ON +#if PEC_CLEANUP == ON cleanupPec(); #endif } // reset the buffer index to match the worm index - if (pecBufferStart && (pecStatus!=RecordPEC)) { pecIndex=0; PecSiderealTimer=t; } + if (pecBufferStart && (pecStatus != RecordPEC)) { pecIndex=0; PecSiderealTimer=t; } // Increment the PEC index once a second and make it go back to zero when the worm finishes a rotation - if (t-PecSiderealTimer>99) { + if (t-PecSiderealTimer > 99) { PecSiderealTimer=t; pecIndex=(pecIndex+1)%SecondsPerWormRotationAxis1; } - pecIndex1=pecIndex; if (pecIndex1<0) pecIndex1+=SecondsPerWormRotationAxis1; if (pecIndex1>=SecondsPerWormRotationAxis1) pecIndex1-=SecondsPerWormRotationAxis1; + pecIndex1=pecIndex; if (pecIndex1 < 0) pecIndex1+=SecondsPerWormRotationAxis1; if (pecIndex1 >= SecondsPerWormRotationAxis1) pecIndex1-=SecondsPerWormRotationAxis1; accPecGuideHA.fixed+=guideAxis1.fixed; // falls in whenever the pecIndex changes, which is once a sidereal second - if (pecIndex1!=lastPecIndex) { + if (pecIndex1 != lastPecIndex) { lastPecIndex=pecIndex1; // assume no change to tracking rate pecTimerRateAxis1=0.0; - if (pecStatus==RecordPEC) { + if (pecStatus == RecordPEC) { // save the correction as 1 of 3 weighted average int l=round(fixedToDouble(accPecGuideHA)); - if (l<-StepsPerSecondAxis1) l=-StepsPerSecondAxis1; if (l>StepsPerSecondAxis1) l=StepsPerSecondAxis1; // +/-1 sidereal rate range for corrections - if (l<-127) l=-127; if (l>127) l=127; // prevent overflow if StepsPerSecondAxis1>127 + if (l < -StepsPerSecondAxis1) l=-StepsPerSecondAxis1; if (l > StepsPerSecondAxis1) l=StepsPerSecondAxis1; // +/-1 sidereal rate range for corrections + if (l < -127) l=-127; if (l > 127) l=127; // prevent overflow if StepsPerSecondAxis1 > 127 if (!pecFirstRecord) l=(l+((int)pecBuffer[pecIndex1]-128)*2)/3; pecBuffer[pecIndex1]=l+128; // save the correction accPecGuideHA.part.m-=l; // remove from the accumulator } - if (pecStatus==PlayPEC) { + if (pecStatus == PlayPEC) { // pecIndex2 adjusts one second before the value was recorded, an estimate of the latency between image acquisition and response // if sending values directly to OnStep from PECprep, etc. be sure to account for this - int pecIndex2=pecIndex1-1; if (pecIndex2<0) pecIndex2+=SecondsPerWormRotationAxis1; + int pecIndex2=pecIndex1-1; if (pecIndex2 < 0) pecIndex2+=SecondsPerWormRotationAxis1; // number of steps ahead or behind for this 1 second slot, up to +/-127 int l=pecBuffer[pecIndex2]-128; - if (l>StepsPerSecondAxis1) l=StepsPerSecondAxis1; if (l<-StepsPerSecondAxis1) l=-StepsPerSecondAxis1; + if (l > StepsPerSecondAxis1) l=StepsPerSecondAxis1; if (l < -StepsPerSecondAxis1) l=-StepsPerSecondAxis1; pecTimerRateAxis1=((double)l/StepsPerSecondAxis1); } } @@ -136,15 +136,15 @@ void pec() { 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 + 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; } + if (pecStatus == PlayPEC) { pecStatus=ReadyPlayPEC; pecTimerRateAxis1=0.0; } } void cleanupPec() { // low pass filter ---------------------------------------------------------- int j,J1,J4,J9,J17; - for (int scc=0+3; scc2) || (sum_pec<-2)) { pecRecorded=false; pecStatus=IgnorePEC; } + if ((sum_pec > 2) || (sum_pec < -2)) { pecRecorded=false; pecStatus=IgnorePEC; } } +// it often takes a couple of ms to record a value to EEPROM, this can effect tracking performance since interrupts are disabled during the operation. +// so we store PEC data in RAM while recording. When done, sidereal tracking is turned off and the data is written to EEPROM. +void createPecBuffer() { + pecBuffer = (byte*)malloc(pecBufferSize * sizeof(*pecBuffer)); + if (!pecBuffer) pecBufferSize=0; +} diff --git a/Pins.Classic.h b/Pins.Classic.h deleted file mode 100644 index 69dbd0f0d..000000000 --- a/Pins.Classic.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for legacy OnStep Classic (Mega2560 or Teensy3.x) - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.Classic.h" - diff --git a/Pins.MaxPCB.h b/Pins.MaxPCB.h deleted file mode 100644 index 59faa0fff..000000000 --- a/Pins.MaxPCB.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep MaxPCB (Teensy3.5/3.6) - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.MaxPCB.h" - diff --git a/Pins.Mega2560Alt.h b/Pins.Mega2560Alt.h deleted file mode 100644 index 18a3c7da2..000000000 --- a/Pins.Mega2560Alt.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for legacy OnStep "Alternate pin-map" (Mega2560) - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.Mega2560Alt.h" - diff --git a/Pins.MiniPCB.h b/Pins.MiniPCB.h deleted file mode 100644 index 05da7e315..000000000 --- a/Pins.MiniPCB.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep MiniPCB (Teensy3.2) - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.MiniPCB.h" - diff --git a/Pins.Ramps14.h b/Pins.Ramps14.h deleted file mode 100644 index e996cf17e..000000000 --- a/Pins.Ramps14.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep using RAMPS 1.4 Shield (Arduino Mega2560 or Arduino DUE) - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.Ramps14.h" - diff --git a/Pins.TM4C.h b/Pins.TM4C.h deleted file mode 100644 index a0607f1ff..000000000 --- a/Pins.TM4C.h +++ /dev/null @@ -1,6 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep Launchpad TM4C varients - -#warning "Pin-maps in OnStep have moved to the src/pinmaps/ directory, your configuration file's second to last line should be updated." -#include "src/pinmaps/Pins.TM4C.h" - diff --git a/StepMode.ino b/StepMode.ino index 97039da6b..2c4a29a1d 100644 --- a/StepMode.ino +++ b/StepMode.ino @@ -15,18 +15,18 @@ void StepperModeTrackingInit() { disableStepperDrivers(); // if the stepper driver mode select pins are wired in, program any requested micro-step mode -#if !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) +#if MODE_SWITCH_BEFORE_SLEW == OFF // automatic mode switching during slews, initialize micro-step mode - #ifdef AXIS1_MICROSTEP_CODE - if ((AXIS1_MICROSTEP_CODE & 0b001000)==0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_MICROSTEP_CODE & 1)); } else { pinMode(Axis1_M0,INPUT); } - if ((AXIS1_MICROSTEP_CODE & 0b010000)==0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } - if ((AXIS1_MICROSTEP_CODE & 0b100000)==0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } + #ifdef AXIS1_DRIVER_MICROSTEP_CODE + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b001000) == 0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_DRIVER_MICROSTEP_CODE & 1)); } else { pinMode(Axis1_M0,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b010000) == 0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_DRIVER_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b100000) == 0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_DRIVER_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } #endif - #ifdef AXIS2_MICROSTEP_CODE - if ((AXIS2_MICROSTEP_CODE & 0b001000)==0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_MICROSTEP_CODE & 1)); } else { pinMode(Axis2_M0,INPUT); } - if ((AXIS2_MICROSTEP_CODE & 0b010000)==0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } - if ((AXIS2_MICROSTEP_CODE & 0b100000)==0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } + #ifdef AXIS2_DRIVER_MICROSTEP_CODE + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b001000) == 0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_DRIVER_MICROSTEP_CODE & 1)); } else { pinMode(Axis2_M0,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b010000) == 0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_DRIVER_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b100000) == 0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_DRIVER_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } #endif #endif } @@ -37,58 +37,58 @@ void stepperModeTracking(boolean init_tmc) { _stepperModeTrack=true; cli(); -#ifdef AXIS1_DECAY_MODE - #if AXIS1_DECAY_MODE==OPEN - pinModeOpen(Axis1_Mode); - #elif AXIS1_DECAY_MODE==LOW - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,LOW); - #elif AXIS1_DECAY_MODE==HIGH - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,HIGH); +#ifdef AXIS1_DRIVER_DECAY_MODE + #if AXIS1_DRIVER_DECAY_MODE == OPEN + pinModeOpen(Axis1ModePin); + #elif AXIS1_DRIVER_DECAY_MODE == LOW + pinMode(Axis1ModePin,OUTPUT); digitalWrite(Axis1ModePin,LOW); + #elif AXIS1_DRIVER_DECAY_MODE == HIGH + pinMode(Axis1ModePin,OUTPUT); digitalWrite(Axis1ModePin,HIGH); #endif #endif -#ifdef AXIS2_DECAY_MODE - #if AXIS2_DECAY_MODE==OPEN - pinModeOpen(Axis1_Mode); - #elif AXIS2_DECAY_MODE==LOW - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,LOW); - #elif AXIS2_DECAY_MODE==HIGH - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,HIGH); +#ifdef AXIS2_DRIVER_DECAY_MODE + #if AXIS2_DRIVER_DECAY_MODE == OPEN + pinModeOpen(Axis1ModePin); + #elif AXIS2_DRIVER_DECAY_MODE == LOW + pinMode(Axis2ModePin,OUTPUT); digitalWrite(Axis2ModePin,LOW); + #elif AXIS2_DRIVER_DECAY_MODE == HIGH + pinMode(Axis2ModePin,OUTPUT); digitalWrite(Axis2ModePin,HIGH); #endif #endif -#if defined(MODE_SWITCH_BEFORE_SLEW_ON) - #ifdef AXIS1_MICROSTEP_CODE - #ifdef AXIS1_MICROSTEP_CODE_GOTO +#if MODE_SWITCH_BEFORE_SLEW == ON + #ifdef AXIS1_DRIVER_MICROSTEP_CODE + #ifdef AXIS1_DRIVER_MICROSTEP_CODE_GOTO stepAxis1=1; #endif - if ((AXIS1_MICROSTEP_CODE & 0b001000)==0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_MICROSTEP_CODE & 1)); } else { pinMode(Axis1_M0,INPUT); } - if ((AXIS1_MICROSTEP_CODE & 0b010000)==0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } - if ((AXIS1_MICROSTEP_CODE & 0b100000)==0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b001000) == 0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_DRIVER_MICROSTEP_CODE & 1)); } else { pinMode(Axis1_M0,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b010000) == 0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_DRIVER_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE & 0b100000) == 0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_DRIVER_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } #endif - #ifdef AXIS2_MICROSTEP_CODE - #ifdef AXIS2_MICROSTEP_CODE_GOTO + #ifdef AXIS2_DRIVER_MICROSTEP_CODE + #ifdef AXIS2_DRIVER_MICROSTEP_CODE_GOTO stepAxis2=1; #endif - if ((AXIS2_MICROSTEP_CODE & 0b001000)==0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_MICROSTEP_CODE & 1)); } else { pinMode(Axis2_M0,INPUT); } - if ((AXIS2_MICROSTEP_CODE & 0b010000)==0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } - if ((AXIS2_MICROSTEP_CODE & 0b100000)==0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b001000) == 0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_DRIVER_MICROSTEP_CODE & 1)); } else { pinMode(Axis2_M0,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b010000) == 0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_DRIVER_MICROSTEP_CODE>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE & 0b100000) == 0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_DRIVER_MICROSTEP_CODE>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } #endif -#elif defined(MODE_SWITCH_BEFORE_SLEW_SPI) +#elif MODE_SWITCH_BEFORE_SLEW == TMC_SPI stepAxis1=1; stepAxis2=1; - #if (AXIS1_TMC_MODE==STEALTHCHOP) || (AXIS2_TMC_MODE==STEALTHCHOP) + #if (AXIS1_DRIVER_DECAY_MODE == STEALTHCHOP) || (AXIS2_DRIVER_DECAY_MODE == STEALTHCHOP) if (init_tmc) { - tmcAxis1.setup(AXIS1_TMC_INTPOL,AXIS1_TMC_MODE,AXIS1_MICROSTEP_CODE&0b001111,AXIS1_TMC_IRUN,AXIS2_TMC_IRUN,AXIS1_TMC_RSENSE); - tmcAxis2.setup(AXIS2_TMC_INTPOL,AXIS2_TMC_MODE,AXIS2_MICROSTEP_CODE&0b001111,AXIS2_TMC_IRUN,AXIS2_TMC_IRUN,AXIS2_TMC_RSENSE); + tmcAxis1.setup(AXIS1_DRIVER_INTPOL,AXIS1_DRIVER_DECAY_MODE,AXIS1_DRIVER_MICROSTEP_CODE&0b001111,AXIS1_DRIVER_IRUN,AXIS1_DRIVER_IRUN,AXIS1_DRIVER_RSENSE); + tmcAxis2.setup(AXIS2_DRIVER_INTPOL,AXIS2_DRIVER_DECAY_MODE,AXIS2_DRIVER_MICROSTEP_CODE&0b001111,AXIS2_DRIVER_IRUN,AXIS2_DRIVER_IRUN,AXIS2_DRIVER_RSENSE); delay(150); } #endif - tmcAxis1.setup(AXIS1_TMC_INTPOL,AXIS1_TMC_MODE,AXIS1_MICROSTEP_CODE&0b001111,AXIS1_TMC_IRUN,AXIS1_TMC_IHOLD,AXIS1_TMC_RSENSE); - tmcAxis2.setup(AXIS2_TMC_INTPOL,AXIS2_TMC_MODE,AXIS2_MICROSTEP_CODE&0b001111,AXIS2_TMC_IRUN,AXIS2_TMC_IHOLD,AXIS2_TMC_RSENSE); + tmcAxis1.setup(AXIS1_DRIVER_INTPOL,AXIS1_DRIVER_DECAY_MODE,AXIS1_DRIVER_MICROSTEP_CODE&0b001111,AXIS1_DRIVER_IRUN,AXIS1_DRIVER_IHOLD,AXIS1_DRIVER_RSENSE); + tmcAxis2.setup(AXIS2_DRIVER_INTPOL,AXIS2_DRIVER_DECAY_MODE,AXIS2_DRIVER_MICROSTEP_CODE&0b001111,AXIS2_DRIVER_IRUN,AXIS2_DRIVER_IHOLD,AXIS2_DRIVER_RSENSE); #endif -#ifdef MODE_SWITCH_SLEEP_ON +#if MODE_SWITCH_SLEEP == ON if (atHome) delay(20); delay(3); #endif @@ -99,36 +99,48 @@ void stepperModeGoto() { if (!_stepperModeTrack) return; _stepperModeTrack=false; cli(); -#if defined(DECAY_MODE_GOTO) && (DECAY_MODE_GOTO==OPEN) - pinModeOpen(Axis1_Mode); - pinModeOpen(Axis2_Mode); -#elif defined(DECAY_MODE_GOTO) && (DECAY_MODE_GOTO==LOW) - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,LOW); - pinMode(Axis2_Mode,OUTPUT); digitalWrite(Axis1_Mode,LOW); -#elif defined(DECAY_MODE_GOTO) && (DECAY_MODE_GOTO==HIGH) - pinMode(Axis1_Mode,OUTPUT); digitalWrite(Axis1_Mode,HIGH); - pinMode(Axis2_Mode,OUTPUT); digitalWrite(Axis2_Mode,HIGH); -#elif defined(MODE_SWITCH_BEFORE_SLEW_ON) - #ifdef AXIS1_MICROSTEP_CODE_GOTO - stepAxis1=AXIS1_STEP_GOTO; - if ((AXIS1_MICROSTEP_CODE_GOTO & 0b001000)==0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_MICROSTEP_CODE_GOTO & 1)); } else { pinMode(Axis1_M0,INPUT); } - if ((AXIS1_MICROSTEP_CODE_GOTO & 0b010000)==0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_MICROSTEP_CODE_GOTO>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } - if ((AXIS1_MICROSTEP_CODE_GOTO & 0b100000)==0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_MICROSTEP_CODE_GOTO>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } + +#ifdef AXIS1_DRIVER_DECAY_MODE_GOTO + #if AXIS1_DECAY_MODE_GOTO == OPEN + pinModeOpen(Axis1ModePin); + #elif AXIS1_DRIVER_DECAY_MODE_GOTO == LOW + pinMode(Axis1ModePin,OUTPUT); digitalWrite(Axis1ModePin,LOW); + #elif AXIS1_DRIVER_DECAY_MODE_GOTO == HIGH + pinMode(Axis1ModePin,OUTPUT); digitalWrite(Axis1ModePin,HIGH); + #endif +#endif + +#ifdef AXIS2_DRIVER_DECAY_MODE_GOTO + #if AXIS2_DRIVER_DECAY_MODE_GOTO == OPEN + pinModeOpen(Axis1ModePin); + #elif AXIS2_DRIVER_DECAY_MODE_GOTO == LOW + pinMode(Axis2ModePin,OUTPUT); digitalWrite(Axis2ModePin,LOW); + #elif AXIS2_DRIVER_DECAY_MODE_GOTO == HIGH + pinMode(Axis2ModePin,OUTPUT); digitalWrite(Axis2ModePin,HIGH); + #endif +#endif + +#if MODE_SWITCH_BEFORE_SLEW == ON + #ifdef AXIS1_DRIVER_MICROSTEP_CODE_GOTO + stepAxis1=AXIS1_DRIVER_STEP_GOTO; + if ((AXIS1_DRIVER_MICROSTEP_CODE_GOTO & 0b001000) == 0) { pinMode(Axis1_M0,OUTPUT); digitalWrite(Axis1_M0,(AXIS1_DRIVER_MICROSTEP_CODE_GOTO & 1)); } else { pinMode(Axis1_M0,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE_GOTO & 0b010000) == 0) { pinMode(Axis1_M1,OUTPUT); digitalWrite(Axis1_M1,(AXIS1_DRIVER_MICROSTEP_CODE_GOTO>>1 & 1)); } else { pinMode(Axis1_M1,INPUT); } + if ((AXIS1_DRIVER_MICROSTEP_CODE_GOTO & 0b100000) == 0) { pinMode(Axis1_M2,OUTPUT); digitalWrite(Axis1_M2,(AXIS1_DRIVER_MICROSTEP_CODE_GOTO>>2 & 1)); } else { pinMode(Axis1_M2,INPUT); } #endif - #ifdef AXIS2_MICROSTEP_CODE_GOTO - stepAxis2=AXIS2_STEP_GOTO; - if ((AXIS2_MICROSTEP_CODE_GOTO & 0b001000)==0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_MICROSTEP_CODE_GOTO & 1)); } else { pinMode(Axis2_M0,INPUT); } - if ((AXIS2_MICROSTEP_CODE_GOTO & 0b010000)==0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_MICROSTEP_CODE_GOTO>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } - if ((AXIS2_MICROSTEP_CODE_GOTO & 0b100000)==0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_MICROSTEP_CODE_GOTO>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } + #ifdef AXIS2_DRIVER_MICROSTEP_CODE_GOTO + stepAxis2=AXIS2_DRIVER_STEP_GOTO; + if ((AXIS2_DRIVER_MICROSTEP_CODE_GOTO & 0b001000) == 0) { pinMode(Axis2_M0,OUTPUT); digitalWrite(Axis2_M0,(AXIS2_DRIVER_MICROSTEP_CODE_GOTO & 1)); } else { pinMode(Axis2_M0,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE_GOTO & 0b010000) == 0) { pinMode(Axis2_M1,OUTPUT); digitalWrite(Axis2_M1,(AXIS2_DRIVER_MICROSTEP_CODE_GOTO>>1 & 1)); } else { pinMode(Axis2_M1,INPUT); } + if ((AXIS2_DRIVER_MICROSTEP_CODE_GOTO & 0b100000) == 0) { pinMode(Axis2_M2,OUTPUT); digitalWrite(Axis2_M2,(AXIS2_DRIVER_MICROSTEP_CODE_GOTO>>2 & 1)); } else { pinMode(Axis2_M2,INPUT); } #endif -#elif defined(MODE_SWITCH_BEFORE_SLEW_SPI) - stepAxis1=AXIS1_STEP_GOTO; - tmcAxis1.setup(AXIS1_TMC_INTPOL,AXIS1_TMC_MODE_GOTO,AXIS1_MICROSTEP_CODE_GOTO&0b001111,AXIS1_TMC_IGOTO,AXIS1_TMC_IHOLD,AXIS1_TMC_RSENSE); - stepAxis2=AXIS2_STEP_GOTO; - tmcAxis2.setup(AXIS2_TMC_INTPOL,AXIS2_TMC_MODE_GOTO,AXIS2_MICROSTEP_CODE_GOTO&0b001111,AXIS2_TMC_IGOTO,AXIS2_TMC_IHOLD,AXIS2_TMC_RSENSE); +#elif MODE_SWITCH_BEFORE_SLEW == TMC_SPI + stepAxis1=AXIS1_DRIVER_STEP_GOTO; + tmcAxis1.setup(AXIS1_DRIVER_INTPOL,AXIS1_DRIVER_DECAY_MODE_GOTO,AXIS1_DRIVER_MICROSTEP_CODE_GOTO&0b001111,AXIS1_DRIVER_IGOTO,AXIS1_DRIVER_IHOLD,AXIS1_DRIVER_RSENSE); + stepAxis2=AXIS2_DRIVER_STEP_GOTO; + tmcAxis2.setup(AXIS2_DRIVER_INTPOL,AXIS2_DRIVER_DECAY_MODE_GOTO,AXIS2_DRIVER_MICROSTEP_CODE_GOTO&0b001111,AXIS2_DRIVER_IGOTO,AXIS2_DRIVER_IHOLD,AXIS2_DRIVER_RSENSE); #endif -#ifdef MODE_SWITCH_SLEEP_ON +#if MODE_SWITCH_SLEEP == ON delay(3); #endif sei(); @@ -136,18 +148,18 @@ void stepperModeGoto() { void enableStepperDrivers() { // enable the stepper drivers - if (axis1Enabled==false) { - digitalWrite(Axis1_EN,AXIS1_ENABLE); axis1Enabled=true; - digitalWrite(Axis2_EN,AXIS2_ENABLE); axis2Enabled=true; - delay(5); // enable or coming out of sleep on DRV8825 or A4988 is done in <2ms + if (axis1Enabled == false) { + digitalWrite(Axis1_EN,AXIS1_DRIVER_ENABLE); axis1Enabled=true; + digitalWrite(Axis2_EN,AXIS2_DRIVER_ENABLE); axis2Enabled=true; + delay(5); // enable or coming out of sleep on DRV8825 or A4988 is done in < 2ms } } void disableStepperDrivers() { // disable the stepper drivers - if (axis1Enabled==true) { - digitalWrite(Axis1_EN,AXIS1_DISABLE); axis1Enabled=false; - digitalWrite(Axis2_EN,AXIS2_DISABLE); axis2Enabled=false; - delay(5); // enable or coming out of sleep on DRV8825 or A4988 is done in <2ms + if (axis1Enabled == true) { + digitalWrite(Axis1_EN,AXIS1_DRIVER_DISABLE); axis1Enabled=false; + digitalWrite(Axis2_EN,AXIS2_DRIVER_DISABLE); axis2Enabled=false; + delay(5); // enable or coming out of sleep on DRV8825 or A4988 is done in < 2ms } } diff --git a/Timer.ino b/Timer.ino index b172cb5b0..30f8cfebf 100644 --- a/Timer.ino +++ b/Timer.ino @@ -1,10 +1,10 @@ // ----------------------------------------------------------------------------------- // Timers and interrupt handling -#if STEP_WAVE_FORM==PULSE +#if STEP_WAVE_FORM == PULSE // motor timers at 1x rate #define TIMER_PULSE_STEP_MULTIPLIER 1 -#elif STEP_WAVE_FORM==DEDGE +#elif STEP_WAVE_FORM == DEDGE // motor timers at 1x rate #define TIMER_PULSE_STEP_MULTIPLIER 1 volatile byte toggleStateAxis1 = 0; @@ -18,13 +18,13 @@ #endif volatile boolean takeStepAxis2 = false; -#if defined(AXIS1_MICROSTEP_CODE) && defined(AXIS1_MICROSTEP_CODE_GOTO) - volatile long AXIS1_MICROSTEP_CODE_NEXT=AXIS1_MICROSTEP_CODE; +#if defined(AXIS1_DRIVER_MICROSTEP_CODE) && defined(AXIS1_DRIVER_MICROSTEP_CODE_GOTO) + volatile long AXIS1_DRIVER_MICROSTEP_CODE_NEXT=AXIS1_DRIVER_MICROSTEP_CODE; volatile boolean gotoModeAxis1=false; #endif -#if defined(AXIS2_MICROSTEP_CODE) && defined(AXIS2_MICROSTEP_CODE_GOTO) - volatile long AXIS2_MICROSTEP_CODE_NEXT=AXIS2_MICROSTEP_CODE; +#if defined(AXIS2_DRIVER_MICROSTEP_CODE) && defined(AXIS2_DRIVER_MICROSTEP_CODE_GOTO) + volatile long AXIS2_DRIVER_MICROSTEP_CODE_NEXT=AXIS2_DRIVER_MICROSTEP_CODE; volatile boolean gotoModeAxis2=false; #endif @@ -52,7 +52,7 @@ volatile long thisTimerRateAxis2 = 10000UL; // set Timer1 master sidereal clock to interval (in microseconds*16) void SiderealClockSetInterval(long iv) { - if (trackingState==TrackingMoveTo) Timer1SetInterval(iv/100,PPSrateRatio); else Timer1SetInterval(iv/300,PPSrateRatio); + if (trackingState == TrackingMoveTo) Timer1SetInterval(iv/100,PPSrateRatio); else Timer1SetInterval(iv/300,PPSrateRatio); isrTimerRateAxis1=0; // also force rate update for Axis1/2 timers so that PPS adjustments take hold immediately isrTimerRateAxis2=0; @@ -82,9 +82,9 @@ IRAM_ATTR ISR(TIMER1_COMPA_vect) // run at 3x the rate, unless a goto is happening bool centiSecond=true; - if (trackingState!=TrackingMoveTo) { + if (trackingState != TrackingMoveTo) { siderealClockCycleCount++; - if (siderealClockCycleCount%3!=0) { + if (siderealClockCycleCount%3 != 0) { centiSecond=false; #ifndef HAL_FAST_PROCESSOR goto done; @@ -95,7 +95,7 @@ IRAM_ATTR ISR(TIMER1_COMPA_vect) if (centiSecond) { lst++; // handle buzzer - if (buzzerDuration>0) { buzzerDuration--; if (buzzerDuration==0) digitalWrite(TonePin,LOW); } + if (buzzerDuration > 0) { buzzerDuration--; if (buzzerDuration == 0) digitalWrite(TonePin,LOW); } } #ifndef ESP32 @@ -112,17 +112,17 @@ done: {} } void timerSupervisor(bool isCentiSecond) { - if (trackingState!=TrackingMoveTo) { + if (trackingState != TrackingMoveTo) { // automatic rate calculation HA long calculatedTimerRateAxis1; // guide rate acceleration/deceleration and control if (guideDirAxis1) { - if ((fabs(guideTimerRateAxis1)<10.0) && (fabs(guideTimerRateAxis1A)<10.0)) { + if ((fabs(guideTimerRateAxis1) < 10.0) && (fabs(guideTimerRateAxis1A) < 10.0)) { // slow speed guiding, no acceleration guideTimerRateAxis1A=guideTimerRateAxis1; // break - if (guideDirAxis1=='b') { guideDirAxis1=0; guideTimerRateAxis1=0.0; guideTimerRateAxis1A=0.0; } + if (guideDirAxis1 == 'b') { guideDirAxis1=0; guideTimerRateAxis1=0.0; guideTimerRateAxis1A=0.0; } } else { if ((isCentiSecond) && (!inbacklashAxis1)) { // high speed guiding @@ -130,21 +130,21 @@ void timerSupervisor(bool isCentiSecond) { // at higher step rates where torque is reduced make smaller rate changes double r=1.2-sqrt((abs(guideTimerRateAxis1A)/slewRateX)); - if (r<0.2) r=0.2; if (r>1.2) r=1.2; + if (r < 0.2) r=0.2; if (r > 1.2) r=1.2; // acceleration/deceleration control - if ((guideDirAxis1!=lastGuideDirAxis1) && (lastGuideDirAxis1!=0)) guideDirChangeTimerAxis1=25; + if ((guideDirAxis1 != lastGuideDirAxis1) && (lastGuideDirAxis1 != 0)) guideDirChangeTimerAxis1=25; lastGuideDirAxis1=guideDirAxis1; - double gtr1=guideTimerRateAxis1; if (guideDirAxis1=='b') gtr1=0.0; - if (guideDirChangeTimerAxis1>0) guideDirChangeTimerAxis1--; else { - if (guideTimerRateAxis1A>gtr1) { guideTimerRateAxis1A-=(accXPerSec/100.0)*r; if (guideTimerRateAxis1Agtr1) guideTimerRateAxis1A=gtr1; } + double gtr1=guideTimerRateAxis1; if (guideDirAxis1 == 'b') gtr1=0.0; + if (guideDirChangeTimerAxis1 > 0) guideDirChangeTimerAxis1--; else { + if (guideTimerRateAxis1A > gtr1) { guideTimerRateAxis1A-=(accXPerSec/100.0)*r; if (guideTimerRateAxis1A < gtr1) guideTimerRateAxis1A=gtr1; } + if (guideTimerRateAxis1A < gtr1) { guideTimerRateAxis1A+=(accXPerSec/100.0)*r; if (guideTimerRateAxis1A > gtr1) guideTimerRateAxis1A=gtr1; } } // stop guiding - if (guideDirAxis1=='b') { - if (abs(guideTimerRateAxis1A)<0.001) { guideDirAxis1=0; lastGuideDirAxis1=0; guideTimerRateAxis1=0.0; guideTimerRateAxis1A=0.0; guideDirChangeTimerAxis1=0; if (!guideDirAxis2) stepperModeTracking(false); } + if (guideDirAxis1 == 'b') { + if (abs(guideTimerRateAxis1A) < 0.001) { guideDirAxis1=0; lastGuideDirAxis1=0; guideTimerRateAxis1=0.0; guideTimerRateAxis1A=0.0; guideDirChangeTimerAxis1=0; if (!guideDirAxis2) stepperModeTracking(false); } } } } @@ -152,22 +152,22 @@ void timerSupervisor(bool isCentiSecond) { double timerRateAxis1A=trackingTimerRateAxis1; double timerRateAxis1B=guideTimerRateAxis1A+pecTimerRateAxis1+timerRateAxis1A; - if (timerRateAxis1B<-0.00001) { timerRateAxis1B=fabs(timerRateAxis1B); cli(); timerDirAxis1=-1; sei(); } else - if (timerRateAxis1B>0.00001) { cli(); timerDirAxis1=1; sei(); } else { cli(); timerDirAxis1=0; sei(); timerRateAxis1B=1.0; } + if (timerRateAxis1B < -0.00001) { timerRateAxis1B=fabs(timerRateAxis1B); cli(); timerDirAxis1=-1; sei(); } else + if (timerRateAxis1B > 0.00001) { cli(); timerDirAxis1=1; sei(); } else { cli(); timerDirAxis1=0; sei(); timerRateAxis1B=1.0; } calculatedTimerRateAxis1=round((double)SiderealRate/timerRateAxis1B); // remember our "running" rate and only update the actual rate when it changes - if (runTimerRateAxis1!=calculatedTimerRateAxis1) { timerRateAxis1=calculatedTimerRateAxis1; runTimerRateAxis1=calculatedTimerRateAxis1; } + if (runTimerRateAxis1 != calculatedTimerRateAxis1) { timerRateAxis1=calculatedTimerRateAxis1; runTimerRateAxis1=calculatedTimerRateAxis1; } // automatic rate calculation Dec long calculatedTimerRateAxis2; // guide rate acceleration/deceleration if (guideDirAxis2) { - if ((fabs(guideTimerRateAxis2)<10.0) && (fabs(guideTimerRateAxis2A)<10.0)) { + if ((fabs(guideTimerRateAxis2) < 10.0) && (fabs(guideTimerRateAxis2A) < 10.0)) { // slow speed guiding, no acceleration guideTimerRateAxis2A=guideTimerRateAxis2; // break mode - if (guideDirAxis2=='b') { guideDirAxis2=0; guideTimerRateAxis2=0.0; guideTimerRateAxis2A=0.0; } + if (guideDirAxis2 == 'b') { guideDirAxis2=0; guideTimerRateAxis2=0.0; guideTimerRateAxis2A=0.0; } } else { if ((isCentiSecond) && (!inbacklashAxis2)) { // use acceleration @@ -175,21 +175,21 @@ void timerSupervisor(bool isCentiSecond) { // at higher step rates where torque is reduced make smaller rate changes double r=1.2-sqrt((abs(guideTimerRateAxis2A)/slewRateX)); - if (r<0.2) r=0.2; if (r>1.2) r=1.2; + if (r < 0.2) r=0.2; if (r > 1.2) r=1.2; // acceleration/deceleration control - if ((guideDirAxis2!=lastGuideDirAxis2) && (lastGuideDirAxis2!=0)) guideDirChangeTimerAxis2=25; + if ((guideDirAxis2 != lastGuideDirAxis2) && (lastGuideDirAxis2 != 0)) guideDirChangeTimerAxis2=25; lastGuideDirAxis2=guideDirAxis2; - double gtr2=guideTimerRateAxis2; if (guideDirAxis2=='b') gtr2=0.0; - if (guideDirChangeTimerAxis2>0) guideDirChangeTimerAxis2--; else { - if (guideTimerRateAxis2A>gtr2) { guideTimerRateAxis2A-=(accXPerSec/100.0)*r; if (guideTimerRateAxis2Agtr2) guideTimerRateAxis2A=gtr2; } + double gtr2=guideTimerRateAxis2; if (guideDirAxis2 == 'b') gtr2=0.0; + if (guideDirChangeTimerAxis2 > 0) guideDirChangeTimerAxis2--; else { + if (guideTimerRateAxis2A > gtr2) { guideTimerRateAxis2A-=(accXPerSec/100.0)*r; if (guideTimerRateAxis2A < gtr2) guideTimerRateAxis2A=gtr2; } + if (guideTimerRateAxis2A < gtr2) { guideTimerRateAxis2A+=(accXPerSec/100.0)*r; if (guideTimerRateAxis2A > gtr2) guideTimerRateAxis2A=gtr2; } } // stop guiding - if (guideDirAxis2=='b') { - if (abs(guideTimerRateAxis2A)<0.001) { guideDirAxis2=0; lastGuideDirAxis2=0; guideTimerRateAxis2=0.0; guideTimerRateAxis2A=0.0; guideDirChangeTimerAxis2=0; if (!guideDirAxis1) stepperModeTracking(false); } + if (guideDirAxis2 == 'b') { + if (abs(guideTimerRateAxis2A) < 0.001) { guideDirAxis2=0; lastGuideDirAxis2=0; guideTimerRateAxis2=0.0; guideTimerRateAxis2A=0.0; guideDirChangeTimerAxis2=0; if (!guideDirAxis1) stepperModeTracking(false); } } } } @@ -197,11 +197,11 @@ void timerSupervisor(bool isCentiSecond) { double timerRateAxis2A=trackingTimerRateAxis2; double timerRateAxis2B=guideTimerRateAxis2A+timerRateAxis2A; - if (timerRateAxis2B<-0.0001) { timerRateAxis2B=fabs(timerRateAxis2B); cli(); timerDirAxis2=-1; sei(); } else - if (timerRateAxis2B>0.0001) { cli(); timerDirAxis2=1; sei(); } else { cli(); timerDirAxis2=0; sei(); timerRateAxis2B=1.0; } + if (timerRateAxis2B < -0.0001) { timerRateAxis2B=fabs(timerRateAxis2B); cli(); timerDirAxis2=-1; sei(); } else + if (timerRateAxis2B > 0.0001) { cli(); timerDirAxis2=1; sei(); } else { cli(); timerDirAxis2=0; sei(); timerRateAxis2B=1.0; } calculatedTimerRateAxis2=round((double)SiderealRate/timerRateAxis2B); // remember our "running" rate and only update the actual rate when it changes - if (runTimerRateAxis2!=calculatedTimerRateAxis2) { timerRateAxis2=calculatedTimerRateAxis2; runTimerRateAxis2=calculatedTimerRateAxis2; } + if (runTimerRateAxis2 != calculatedTimerRateAxis2) { timerRateAxis2=calculatedTimerRateAxis2; runTimerRateAxis2=calculatedTimerRateAxis2; } } thisTimerRateAxis1=timerRateAxis1; @@ -212,22 +212,22 @@ void timerSupervisor(bool isCentiSecond) { // override rate during backlash compensation if (inbacklashAxis2) thisTimerRateAxis2=timerRateBacklashAxis2; - // trigger Goto step mode, rapid acceleration (low DegreesForAcceleration) can leave too little time + // trigger Goto step mode, rapid acceleration (low SLEW_ACCELERATION_DIST) can leave too little time // until the home position arrives to actually switch to tracking micro-step mode. the larger step size // then causes backlash compensation to activate which in-turn keeps goto micro-step mode from turning off - #if defined(AXIS1_MICROSTEP_CODE) && defined(AXIS1_MICROSTEP_CODE_GOTO) && !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) - gotoRateAxis1=(thisTimerRateAxis1<128*16L); // activate <128us rate + #if defined(AXIS1_DRIVER_MICROSTEP_CODE) && defined(AXIS1_DRIVER_MICROSTEP_CODE_GOTO) && MODE_SWITCH_BEFORE_SLEW == OFF + gotoRateAxis1=(thisTimerRateAxis1 < 128*16L); // activate < 128us rate #endif - #if defined(AXIS2_MICROSTEP_CODE) && defined(AXIS2_MICROSTEP_CODE_GOTO) && !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) - gotoRateAxis2=(thisTimerRateAxis2<128*16L); // activate <128us rate + #if defined(AXIS2_DRIVER_MICROSTEP_CODE) && defined(AXIS2_DRIVER_MICROSTEP_CODE_GOTO) && MODE_SWITCH_BEFORE_SLEW == OFF + gotoRateAxis2=(thisTimerRateAxis2 < 128*16L); // activate < 128us rate #endif // set the rates - if (thisTimerRateAxis1!=isrTimerRateAxis1) { + if (thisTimerRateAxis1 != isrTimerRateAxis1) { PresetTimerInterval(thisTimerRateAxis1/PPSrateRatio, TIMER_PULSE_STEP_MULTIPLIER, &nextAxis1Rate, &slowAxis1Rep); isrTimerRateAxis1=thisTimerRateAxis1; } - if (thisTimerRateAxis2!=isrTimerRateAxis2) { + if (thisTimerRateAxis2 != isrTimerRateAxis2) { PresetTimerInterval(thisTimerRateAxis2/PPSrateRatio, TIMER_PULSE_STEP_MULTIPLIER, &nextAxis2Rate, &slowAxis2Rep); isrTimerRateAxis2=thisTimerRateAxis2; } @@ -239,58 +239,58 @@ IRAM_ATTR ISR(TIMER3_COMPA_vect) HAL_TIMER3_PREFIX; #endif - if (slowAxis1Rep>1) { slowAxis1Cnt++; if (slowAxis1Cnt%slowAxis1Rep!=0) goto done; } + if (slowAxis1Rep > 1) { slowAxis1Cnt++; if (slowAxis1Cnt%slowAxis1Rep != 0) goto done; } -#if STEP_WAVE_FORM!=DEDGE +#if STEP_WAVE_FORM != DEDGE StepPinAxis1_LOW; #endif -#if STEP_WAVE_FORM==SQUARE +#if STEP_WAVE_FORM == SQUARE if (clearAxis1) { takeStepAxis1=false; #endif -#if defined(AXIS1_MICROSTEP_CODE) && defined(AXIS1_MICROSTEP_CODE_GOTO) && !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) +#if defined(AXIS1_DRIVER_MICROSTEP_CODE) && defined(AXIS1_DRIVER_MICROSTEP_CODE_GOTO) && MODE_SWITCH_BEFORE_SLEW == OFF // switch micro-step mode - if (gotoModeAxis1!=gotoRateAxis1) { + if (gotoModeAxis1 != gotoRateAxis1) { // only when at an allowed position - if ((gotoModeAxis1) || ((posAxis1+blAxis1)%AXIS1_STEP_GOTO==0)) { + if ((gotoModeAxis1) || ((posAxis1+blAxis1)%AXIS1_DRIVER_STEP_GOTO == 0)) { // switch mode - if (gotoModeAxis1) { stepAxis1=1; AXIS1_MICROSTEP_CODE_NEXT=AXIS1_MICROSTEP_CODE; gotoModeAxis1=false; } else { stepAxis1=AXIS1_STEP_GOTO; AXIS1_MICROSTEP_CODE_NEXT=AXIS1_MICROSTEP_CODE_GOTO; gotoModeAxis1=true; } - digitalWrite(Axis1_M0,(AXIS1_MICROSTEP_CODE_NEXT & 1)); - digitalWrite(Axis1_M1,(AXIS1_MICROSTEP_CODE_NEXT>>1 & 1)); - #ifndef AXIS1_DISABLE_M2 - digitalWrite(Axis1_M2,(AXIS1_MICROSTEP_CODE_NEXT>>2 & 1)); + if (gotoModeAxis1) { stepAxis1=1; AXIS1_DRIVER_MICROSTEP_CODE_NEXT=AXIS1_DRIVER_MICROSTEP_CODE; gotoModeAxis1=false; } else { stepAxis1=AXIS1_DRIVER_STEP_GOTO; AXIS1_DRIVER_MICROSTEP_CODE_NEXT=AXIS1_DRIVER_MICROSTEP_CODE_GOTO; gotoModeAxis1=true; } + digitalWrite(Axis1_M0,(AXIS1_DRIVER_MICROSTEP_CODE_NEXT & 1)); + digitalWrite(Axis1_M1,(AXIS1_DRIVER_MICROSTEP_CODE_NEXT>>1 & 1)); + #ifndef AXIS1_DRIVER_DISABLE_M2 + digitalWrite(Axis1_M2,(AXIS1_DRIVER_MICROSTEP_CODE_NEXT>>2 & 1)); #endif } } #endif -#if STEP_WAVE_FORM!=SQUARE +#if STEP_WAVE_FORM != SQUARE QuickSetIntervalAxis1(nextAxis1Rate*stepAxis1); #endif - if ((trackingState!=TrackingMoveTo) && (!inbacklashAxis1)) targetAxis1.part.m+=timerDirAxis1*stepAxis1; + if ((trackingState != TrackingMoveTo) && (!inbacklashAxis1)) targetAxis1.part.m+=timerDirAxis1*stepAxis1; // move the RA/Azm stepper to the target - if ((posAxis1!=(long)targetAxis1.part.m) || inbacklashAxis1) { + if ((posAxis1 != (long)targetAxis1.part.m) || inbacklashAxis1) { // set direction - if (posAxis1<(long)targetAxis1.part.m) dirAxis1=1; else dirAxis1=0; - #ifdef AXIS1_REVERSE_ON - if (defaultDirAxis1==dirAxis1) DirPinAxis1_LOW; else DirPinAxis1_HIGH; + if (posAxis1 < (long)targetAxis1.part.m) dirAxis1=1; else dirAxis1=0; + #if AXIS1_DRIVER_REVERSE == ON + if (defaultDirAxis1 == dirAxis1) DirPinAxis1_LOW; else DirPinAxis1_HIGH; #else - if (defaultDirAxis1==dirAxis1) DirPinAxis1_HIGH; else DirPinAxis1_LOW; + if (defaultDirAxis1 == dirAxis1) DirPinAxis1_HIGH; else DirPinAxis1_LOW; #endif // telescope moves WEST with the sky, blAxis1 is the amount of EAST backlash - if (dirAxis1==1) { - if (blAxis10) { blAxis1-=stepAxis1; inbacklashAxis1=true; } else { inbacklashAxis1=false; posAxis1-=stepAxis1; } + if (blAxis1 > 0) { blAxis1-=stepAxis1; inbacklashAxis1=true; } else { inbacklashAxis1=false; posAxis1-=stepAxis1; } } -#if STEP_WAVE_FORM==SQUARE +#if STEP_WAVE_FORM == SQUARE takeStepAxis1=true; } clearAxis1=false; @@ -301,9 +301,9 @@ IRAM_ATTR ISR(TIMER3_COMPA_vect) QuickSetIntervalAxis1(nextAxis1Rate*stepAxis1); } #else -#if STEP_WAVE_FORM==DEDGE +#if STEP_WAVE_FORM == DEDGE toggleStateAxis1++; - if (toggleStateAxis1%2==0) StepPinAxis1_LOW; else StepPinAxis1_HIGH; + if (toggleStateAxis1%2 == 0) StepPinAxis1_LOW; else StepPinAxis1_HIGH; #else StepPinAxis1_HIGH; #endif @@ -322,58 +322,58 @@ IRAM_ATTR ISR(TIMER4_COMPA_vect) HAL_TIMER4_PREFIX; #endif - if (slowAxis2Rep>1) { slowAxis2Cnt++; if (slowAxis2Cnt%slowAxis2Rep!=0) goto done; } + if (slowAxis2Rep > 1) { slowAxis2Cnt++; if (slowAxis2Cnt%slowAxis2Rep != 0) goto done; } -#if STEP_WAVE_FORM!=DEDGE +#if STEP_WAVE_FORM != DEDGE StepPinAxis2_LOW; #endif -#if STEP_WAVE_FORM==SQUARE +#if STEP_WAVE_FORM == SQUARE if (clearAxis2) { takeStepAxis2=false; #endif -#if defined(AXIS2_MICROSTEP_CODE) && defined(AXIS2_MICROSTEP_CODE_GOTO) && !defined(MODE_SWITCH_BEFORE_SLEW_ON) && !defined(MODE_SWITCH_BEFORE_SLEW_SPI) +#if defined(AXIS2_DRIVER_MICROSTEP_CODE) && defined(AXIS2_DRIVER_MICROSTEP_CODE_GOTO) && MODE_SWITCH_BEFORE_SLEW == OFF // switch micro-step mode - if (gotoModeAxis2!=gotoRateAxis2) { + if (gotoModeAxis2 != gotoRateAxis2) { // only when at an allowed position - if ((gotoModeAxis2) || ((posAxis2+blAxis2)%AXIS2_STEP_GOTO==0)) { + if ((gotoModeAxis2) || ((posAxis2+blAxis2)%AXIS2_DRIVER_STEP_GOTO == 0)) { // switch mode - if (gotoModeAxis2) { stepAxis2=1; AXIS2_MICROSTEP_CODE_NEXT=AXIS2_MICROSTEP_CODE; gotoModeAxis2=false; } else { stepAxis2=AXIS2_STEP_GOTO; AXIS2_MICROSTEP_CODE_NEXT=AXIS2_MICROSTEP_CODE_GOTO; gotoModeAxis2=true; } - digitalWrite(Axis2_M0,(AXIS2_MICROSTEP_CODE_NEXT & 1)); - digitalWrite(Axis2_M1,(AXIS2_MICROSTEP_CODE_NEXT>>1 & 1)); - #ifndef AXIS2_DISABLE_M2 - digitalWrite(Axis2_M2,(AXIS2_MICROSTEP_CODE_NEXT>>2 & 1)); + if (gotoModeAxis2) { stepAxis2=1; AXIS2_DRIVER_MICROSTEP_CODE_NEXT=AXIS2_DRIVER_MICROSTEP_CODE; gotoModeAxis2=false; } else { stepAxis2=AXIS2_DRIVER_STEP_GOTO; AXIS2_DRIVER_MICROSTEP_CODE_NEXT=AXIS2_DRIVER_MICROSTEP_CODE_GOTO; gotoModeAxis2=true; } + digitalWrite(Axis2_M0,(AXIS2_DRIVER_MICROSTEP_CODE_NEXT & 1)); + digitalWrite(Axis2_M1,(AXIS2_DRIVER_MICROSTEP_CODE_NEXT>>1 & 1)); + #ifndef AXIS2_DRIVER_DISABLE_M2 + digitalWrite(Axis2_M2,(AXIS2_DRIVER_MICROSTEP_CODE_NEXT>>2 & 1)); #endif } } #endif -#if STEP_WAVE_FORM!=SQUARE +#if STEP_WAVE_FORM != SQUARE QuickSetIntervalAxis2(nextAxis2Rate*stepAxis2); #endif - if ((trackingState!=TrackingMoveTo) && (!inbacklashAxis2)) targetAxis2.part.m+=timerDirAxis2*stepAxis2; + if ((trackingState != TrackingMoveTo) && (!inbacklashAxis2)) targetAxis2.part.m+=timerDirAxis2*stepAxis2; // move the Dec/Alt stepper to the target - if (axis2Powered && ((posAxis2!=(long)targetAxis2.part.m) || inbacklashAxis2)) { + if (axis2Powered && ((posAxis2 != (long)targetAxis2.part.m) || inbacklashAxis2)) { // set direction - if (posAxis2<(long)targetAxis2.part.m) dirAxis2=1; else dirAxis2=0; - #ifdef AXIS2_REVERSE_ON - if (defaultDirAxis2==dirAxis2) DirPinAxis2_LOW; else DirPinAxis2_HIGH; + if (posAxis2 < (long)targetAxis2.part.m) dirAxis2=1; else dirAxis2=0; + #if AXIS2_DRIVER_REVERSE == ON + if (defaultDirAxis2 == dirAxis2) DirPinAxis2_LOW; else DirPinAxis2_HIGH; #else - if (defaultDirAxis2==dirAxis2) DirPinAxis2_HIGH; else DirPinAxis2_LOW; + if (defaultDirAxis2 == dirAxis2) DirPinAxis2_HIGH; else DirPinAxis2_LOW; #endif // telescope moving toward celestial pole in the sky, blAxis2 is the amount of opposite backlash - if (dirAxis2==1) { - if (blAxis20) { blAxis2-=stepAxis2; inbacklashAxis2=true; } else { inbacklashAxis2=false; posAxis2-=stepAxis2; } + if (blAxis2 > 0) { blAxis2-=stepAxis2; inbacklashAxis2=true; } else { inbacklashAxis2=false; posAxis2-=stepAxis2; } } -#if STEP_WAVE_FORM==SQUARE +#if STEP_WAVE_FORM == SQUARE takeStepAxis2=true; } clearAxis2=false; @@ -384,9 +384,9 @@ IRAM_ATTR ISR(TIMER4_COMPA_vect) QuickSetIntervalAxis2(nextAxis2Rate*stepAxis2); } #else -#if STEP_WAVE_FORM==DEDGE +#if STEP_WAVE_FORM == DEDGE toggleStateAxis2++; - if (toggleStateAxis2%2==0) StepPinAxis2_LOW; else StepPinAxis2_HIGH; + if (toggleStateAxis2%2 == 0) StepPinAxis2_LOW; else StepPinAxis2_HIGH; #else StepPinAxis2_HIGH; #endif @@ -400,8 +400,8 @@ done: {} } double getFrequencyHzAxis1() { - if (trackingState==TrackingMoveTo) { - if (posAxis1==(long)targetAxis1.part.m) { + if (trackingState == TrackingMoveTo) { + if (posAxis1 == (long)targetAxis1.part.m) { return getStepsPerSecondAxis1()*1.00273790935; } else return 16000000.0/(double)isrTimerRateAxis1; @@ -410,8 +410,8 @@ double getFrequencyHzAxis1() { } double getFrequencyHzAxis2() { - if (trackingState==TrackingMoveTo) { - if (posAxis2==(long)targetAxis2.part.m) + if (trackingState == TrackingMoveTo) { + if (posAxis2 == (long)targetAxis2.part.m) return getStepsPerSecondAxis2()*1.00273790935; else return 16000000.0/(double)isrTimerRateAxis2; @@ -419,40 +419,40 @@ double getFrequencyHzAxis2() { return (16000000.0/(double)isrTimerRateAxis2)*(double)timerDirAxis2; } -#if defined(AXIS2_AUTO_POWER_DOWN_ON) && !defined(MOUNT_TYPE_ALTAZM) -// Auto power down the Dec motor -void autoPowerDownAxis2() { - static long Axis2PowerOffTimer = 0; - static long timerLastPosAxis2 = 0; - if (axis2Enabled) { - // timer count down - if (Axis2PowerOffTimer>0) Axis2PowerOffTimer--; - - // if the guide rate <= 1x and we're guiding on either axis set the timer to 10 minutes - if ((fabs(guideTimerBaseRateAxis1)<=1.000001) && (guideDirAxis2 || guideDirAxis1)) Axis2PowerOffTimer=10L*60L*100L; - - // if Axis2 isn't stationary, or needs to move, set the timer to a minimum of 10 seconds - cli(); - if (((posAxis2!=timerLastPosAxis2) || (posAxis2!=(long)targetAxis2.part.m)) && (Axis2PowerOffTimer<10*100)) { timerLastPosAxis2=posAxis2; Axis2PowerOffTimer=10*100; } - - // enable/disable Axis2 - if (Axis2PowerOffTimer==0) { - if (axis2Powered && !takeStepAxis2) { axis2Powered=false; digitalWrite(Axis2_EN,AXIS2_DISABLE); } - } else { - if (!axis2Powered) { digitalWrite(Axis2_EN,AXIS2_ENABLE); axis2Powered=true; delayMicroseconds(10); } - } - sei(); - } else { Axis2PowerOffTimer=0; axis2Powered=true; } -} +#if AXIS2_DRIVER_POWER_DOWN == ON && MOUNT_TYPE != ALTAZM + // Auto power down the Dec motor + void autoPowerDownAxis2() { + static long Axis2PowerOffTimer = 0; + static long timerLastPosAxis2 = 0; + if (axis2Enabled) { + // timer count down + if (Axis2PowerOffTimer > 0) Axis2PowerOffTimer--; + + // if the guide rate <= 1x and we're guiding on either axis set the timer to 10 minutes + if ((fabs(guideTimerBaseRateAxis1) <= 1.000001) && (guideDirAxis2 || guideDirAxis1)) Axis2PowerOffTimer=10L*60L*100L; + + // if Axis2 isn't stationary, or needs to move, set the timer to a minimum of 10 seconds + cli(); + if (((posAxis2 != timerLastPosAxis2) || (posAxis2 != (long)targetAxis2.part.m)) && (Axis2PowerOffTimer < 10*100)) { timerLastPosAxis2=posAxis2; Axis2PowerOffTimer=10*100; } + + // enable/disable Axis2 + if (Axis2PowerOffTimer == 0) { + if (axis2Powered && !takeStepAxis2) { axis2Powered=false; digitalWrite(Axis2_EN,AXIS2_DRIVER_DISABLE); } + } else { + if (!axis2Powered) { digitalWrite(Axis2_EN,AXIS2_DRIVER_ENABLE); axis2Powered=true; delayMicroseconds(10); } + } + sei(); + } else { Axis2PowerOffTimer=0; axis2Powered=true; } + } #endif -#if defined(PPS_SENSE_ON) || defined(PPS_SENSE_PULLUP) +#if PPS_SENSE != OFF // PPS interrupt void clockSync() { #define NUM_SECS_TO_AVERAGE 40 unsigned long t=micros(); unsigned long oneS=(t-PPSlastMicroS); - if ((oneS>1000000-20000) && (oneS<1000000+20000)) { + if ((oneS > 1000000-20000) && (oneS < 1000000+20000)) { PPSavgMicroS=(PPSavgMicroS*(NUM_SECS_TO_AVERAGE-1)+oneS)/NUM_SECS_TO_AVERAGE; PPSsynced=true; } else PPSsynced=false; diff --git a/Validate.h b/Validate.h index 5398dfaa6..f19a767f4 100644 --- a/Validate.h +++ b/Validate.h @@ -7,171 +7,27 @@ // ----------------------------------------------------------------------------------- // correct for configuration backwards compatability -// support for old decay mode settings -#ifdef DECAY_MODE - #define AXIS1_DECAY_MODE DECAY_MODE - #define AXIS2_DECAY_MODE DECAY_MODE -#endif -#ifdef DECAY_MODE_GOTO - #define AXIS1_DECAY_MODE_GOTO DECAY_MODE_GOTO - #define AXIS2_DECAY_MODE_GOTO DECAY_MODE_GOTO -#endif - -// automatically set minimum move rates for focusers if they aren't defined -#ifndef AXIS4_MIN_MOVE_RATE - #define AXIS4_MIN_MOVE_RATE 10 -#endif -#ifndef AXIS5_MIN_MOVE_RATE - #define AXIS5_MIN_MOVE_RATE 10 -#endif - -// the mount type FORK with Meridian flips enabled for align (only) is not-longer required use _FORK instead -#ifdef MOUNT_TYPE_FORK_ALT - #define MOUNT_TYPE_FORK -#endif - -// automatically set MaxRate if DefaultSlewRate is present -#if !defined(MaxRate) && defined(DesiredBaseSlewRate) - #define MaxRate ((1000000.0/DesiredBaseSlewRate)/StepsPerDegreeAxis1) -#endif - -// replace REMEMBER_MAX_RATE_ON or RememberMaxRate_ON with REMEMBER_SLEW_RATE_ON -#if defined(RememberMaxRate_ON) || defined(REMEMBER_MAX_RATE_ON) - #ifndef REMEMBER_SLEW_RATE_ON - #define REMEMBER_SLEW_RATE_ON - #endif -#endif - -// set serial port baud rate the old way -#ifdef SERIAL1_BAUD_DEFAULT - #define SERIAL_B_BAUD_DEFAULT SERIAL1_BAUD_DEFAULT -#endif -#ifdef SERIAL4_BAUD_DEFAULT - #define SERIAL_C_BAUD_DEFAULT SERIAL4_BAUD_DEFAULT -#endif - -// config pre-version 1 -#ifdef SEPERATE_PULSE_GUIDE_RATE_ON - #define SEPARATE_PULSE_GUIDE_RATE_ON -#endif -#ifndef MaxRot - #define MaxRot MaxAxis3 -#endif -#ifndef MinRot - #define MinRot MinAxis3 -#endif - -// config version 1 -#ifdef REVERSE_AXIS1_ON - #define AXIS1_REVERSE_ON -#endif -#ifdef REVERSE_AXIS2_ON - #define AXIS2_REVERSE_ON -#endif -#ifdef REVERSE_AXIS3_ON - #define AXIS3_REVERSE_ON -#endif -#ifdef REVERSE_AXIS4_ON - #define AXIS4_REVERSE_ON -#endif -#ifdef REVERSE_AXIS5_ON - #define AXIS5_REVERSE_ON -#endif -#ifndef AXIS1_DISABLE - #if defined(AXIS1_DISABLED_HIGH) - #define AXIS1_DISABLE HIGH - #endif - #if defined(AXIS1_DISABLED_LOW) - #define AXIS1_DISABLE LOW - #endif -#endif -#ifndef AXIS2_DISABLE - #if defined(AXIS2_DISABLED_HIGH) - #define AXIS2_DISABLE HIGH - #endif - #if defined(AXIS2_DISABLED_LOW) - #define AXIS2_DISABLE LOW - #endif -#endif -#ifdef DISABLE_AXIS3 - #define AXIS3_DISABLE DISABLE_AXIS3 -#endif -#ifdef DISABLE_AXIS4 - #define AXIS3_DISABLE DISABLE_AXIS4 -#endif -#ifdef DISABLE_AXIS5 - #define AXIS3_DISABLE DISABLE_AXIS5 -#endif -#ifdef AXIS1_FAULT_LOW - #define AXIS1_FAULT LOW -#endif -#ifdef AXIS1_FAULT_HIGH - #define AXIS1_FAULT HIGH -#endif -#ifdef AXIS1_FAULT_SPI - #define AXIS1_FAULT TMC_SPI -#endif -#if AXIS1_FAULT==TMC2130 - #undef AXIS1_FAULT - #define AXIS1_FAULT TMC_SPI -#endif -#ifdef AXIS2_FAULT_LOW - #define AXIS2_FAULT LOW -#endif -#ifdef AXIS2_FAULT_HIGH - #define AXIS2_FAULT HIGH -#endif -#ifdef AXIS2_FAULT_SPI - #define AXIS2_FAULT TMC_SPI -#endif -#if AXIS2_FAULT==TMC2130 - #undef AXIS2_FAULT - #define AXIS2_FAULT TMC_SPI -#endif -#ifdef AUTO_POWER_DOWN_AXIS2_ON - #define AXIS2_AUTO_POWER_DOWN_ON -#endif -#ifdef DECAY_MODE_LOW - #define DECAY_MODE LOW -#endif -#ifdef DECAY_MODE_HIGH - #define DECAY_MODE HIGH -#endif -#ifdef DECAY_MODE_OPEN - #define DECAY_MODE OPEN -#endif -#ifdef DECAY_MODE_GOTO_LOW - #define DECAY_MODE_GOTO LOW -#endif -#ifdef DECAY_MODE_GOTO_HIGH - #define DECAY_MODE_GOTO HIGH -#endif -#ifdef DECAY_MODE_GOTO_OPEN - #define DECAY_MODE_GOTO OPEN -#endif - // ----------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------- // setup defaults -// Set timer wave mode -#ifndef STEP_WAVE_FORM - #define STEP_WAVE_FORM SQUARE -#endif -#if STEP_WAVE_FORM!=PULSE && STEP_WAVE_FORM!=SQUARE && STEP_WAVE_FORM!=DEDGE - #error "Configuration: STEP_WAVE_FORM; Unknown value, please correct your configuration." -#endif -#if STEP_WAVE_FORM != PULSE - #undef HAL_PULSE_WIDTH - // Set pulse width in SQW and DEDGE mode well above triggering PULSE check code - #define HAL_PULSE_WIDTH 10000 -#endif +// initial allowed degrees past the meridian on the East and West sides of the pier +#define AXIS1_LIMIT_MERIDIAN_E 7.5 +#define AXIS1_LIMIT_MERIDIAN_W 7.5 -#ifndef GUIDE_TIME_LIMIT - #define GUIDE_TIME_LIMIT 0 -#endif +// automatically set MaxRate from SLEW_RATE_BASE_DESIRED +#define MaxRate ((1000000.0/SLEW_RATE_BASE_DESIRED)/AXIS1_STEPS_PER_DEGREE) + +// automatically calculate the pecBufferSize +#define PEC_BUFFER_SIZE ceil(AXIS1_STEPS_PER_WORMROT/(AXIS1_STEPS_PER_DEGREE/240.0)) + +// always enable the separate pulse guide rate +#define SEPARATE_PULSE_GUIDE_RATE ON // set serial port baud rate if not done so already +#ifndef SERIAL_A_BAUD_DEFAULT + #define SERIAL_A_BAUD_DEFAULT 9600 +#endif #ifndef SERIAL_B_BAUD_DEFAULT #define SERIAL_B_BAUD_DEFAULT 9600 #endif @@ -194,48 +50,81 @@ #endif #endif -// make both enable and disable values -#if AXIS1_DISABLE==LOW - #define AXIS1_ENABLE HIGH +// Set disable state from EN state for stepper drivers +#if AXIS1_DRIVER_ENABLE == LOW + #define AXIS1_DRIVER_DISABLE HIGH #endif -#if AXIS1_DISABLE==HIGH - #define AXIS1_ENABLE LOW +#if AXIS1_DRIVER_ENABLE == HIGH + #define AXIS1_DRIVER_DISABLE LOW #endif -#if AXIS2_DISABLE==LOW - #define AXIS2_ENABLE HIGH + +#if AXIS2_DRIVER_ENABLE == LOW + #define AXIS2_DRIVER_DISABLE HIGH #endif -#if AXIS2_DISABLE==HIGH - #define AXIS2_ENABLE LOW +#if AXIS2_DRIVER_ENABLE == HIGH + #define AXIS2_DRIVER_DISABLE LOW +#endif + +#if AXIS3_DRIVER_ENABLE == LOW + #define AXIS3_DRIVER_DISABLE HIGH +#endif +#if AXIS3_DRIVER_ENABLE == HIGH + #define AXIS3_DRIVER_DISABLE LOW +#endif + +#if AXIS4_DRIVER_ENABLE == LOW + #define AXIS4_DRIVER_DISABLE HIGH +#endif +#if AXIS4_DRIVER_ENABLE == HIGH + #define AXIS4_DRIVER_DISABLE LOW +#endif + +#if AXIS5_DRIVER_ENABLE == LOW + #define AXIS5_DRIVER_DISABLE HIGH +#endif +#if AXIS5_DRIVER_ENABLE == HIGH + #define AXIS5_DRIVER_DISABLE LOW #endif // ----------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------- // stepper driver mode setup validation -#if (defined(AXIS1_DRIVER_MODEL) && !defined(AXIS2_DRIVER_MODEL)) || (defined(AXIS2_DRIVER_MODEL) && !defined(AXIS1_DRIVER_MODEL)) - #error "AXISn_DRIVER_MODEL; If using the basic driver mode setup you must use it for both AXIS1 and AXIS2." + +// check timer wave mode +#if STEP_WAVE_FORM != PULSE && STEP_WAVE_FORM != SQUARE && STEP_WAVE_FORM != DEDGE + #error "Configuration: STEP_WAVE_FORM; Unknown value, please correct your configuration." +#endif +#if STEP_WAVE_FORM != PULSE + #undef HAL_PULSE_WIDTH + // set pulse width in SQW and DEDGE mode well above triggering PULSE check code + #define HAL_PULSE_WIDTH 10000 +#endif + +// check model +#if (AXIS1_DRIVER_MODEL != OFF && AXIS2_DRIVER_MODEL == OFF) || (AXIS2_DRIVER_MODEL != OFF && AXIS1_DRIVER_MODEL == OFF) + #error "AXISn_DRIVER_MODEL; If using the driver mode control you must use it for both AXIS1 and AXIS2." #endif -#if defined(AXIS1_DRIVER_MODEL) - // attempting to use the basic (simplified) stepper driver mode setup +#if AXIS1_DRIVER_MODEL != OFF // validate tracking and goto micro-step modes - #ifndef AXIS1_MICROSTEPS - #error "AXIS1_MICROSTEPS must be defined in your Config.xxx.h file if using AXIS1_DRIVER_MODEL!" + #if AXIS1_DRIVER_MICROSTEPS == OFF + #error "AXIS1_DRIVER_MICROSTEPS must be defined in your Config.xxx.h file if using AXIS1_DRIVER_MODEL!" #endif - #ifndef AXIS2_MICROSTEPS - #error "AXIS2_MICROSTEPS must be defined in your Config.xxx.h file if using AXIS2_DRIVER_MODEL!" + #if AXIS2_DRIVER_MICROSTEPS == OFF + #error "AXIS2_DRIVER_MICROSTEPS must be defined in your Config.xxx.h file if using AXIS2_DRIVER_MODEL!" #endif - #ifdef AXIS1_MICROSTEPS_GOTO - #if (AXIS1_MICROSTEPS <= AXIS1_MICROSTEPS_GOTO) && (!((defined(MODE_SWITCH_BEFORE_SLEW_ON) || defined(MODE_SWITCH_BEFORE_SLEW_SPI)) && (AXIS1_MICROSTEPS == AXIS1_MICROSTEPS_GOTO))) - #error "Configuration: AXIS1_MICROSTEPS_GOTO should be less than AXIS1_MICROSTEPS or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF + #if (AXIS1_DRIVER_MICROSTEPS <= AXIS1_DRIVER_MICROSTEPS_GOTO) && (!(MODE_SWITCH_BEFORE_SLEW != OFF && AXIS1_DRIVER_MICROSTEPS == AXIS1_DRIVER_MICROSTEPS_GOTO)) + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO should be less than AXIS1_DRIVER_MICROSTEPS or OFF" #endif - #define AXIS1_STEP_GOTO (AXIS1_MICROSTEPS/AXIS1_MICROSTEPS_GOTO) + #define AXIS1_DRIVER_STEP_GOTO (AXIS1_DRIVER_MICROSTEPS/AXIS1_DRIVER_MICROSTEPS_GOTO) #endif - #ifdef AXIS2_MICROSTEPS_GOTO - #if (AXIS2_MICROSTEPS <= AXIS2_MICROSTEPS_GOTO) && (!((defined(MODE_SWITCH_BEFORE_SLEW_ON) || defined(MODE_SWITCH_BEFORE_SLEW_SPI)) && (AXIS2_MICROSTEPS == AXIS2_MICROSTEPS_GOTO))) - #error "Configuration: AXIS2_MICROSTEPS_GOTO should be less than AXIS2_MICROSTEPS or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF + #if (AXIS2_DRIVER_MICROSTEPS <= AXIS2_DRIVER_MICROSTEPS_GOTO) && (!(MODE_SWITCH_BEFORE_SLEW != OFF && AXIS2_DRIVER_MICROSTEPS == AXIS2_DRIVER_MICROSTEPS_GOTO)) + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO should be less than AXIS2_DRIVER_MICROSTEPS or OFF" #endif - #define AXIS2_STEP_GOTO (AXIS2_MICROSTEPS/AXIS2_MICROSTEPS_GOTO) + #define AXIS2_DRIVER_STEP_GOTO (AXIS2_DRIVER_MICROSTEPS/AXIS2_DRIVER_MICROSTEPS_GOTO) #endif // initialize custom stepper driver values @@ -252,6 +141,15 @@ #if (AXIS2_DRIVER_MODEL < DRIVER_MODEL_FIRST) || (AXIS2_DRIVER_MODEL > DRIVER_MODEL_LAST) #error "AXIS2_DRIVER_MODEL; Unknown stepper driver specified, check your configuration file." #endif + #if ROTATOR == ON && (AXIS3_DRIVER_MODEL != OFF) && (AXIS3_DRIVER_MODEL != TMC_SPI) + #error "AXIS3_DRIVER_MODEL; Unknown stepper driver specified, check your configuration file." + #endif + #if FOCUSER1 == ON && (AXIS4_DRIVER_MODEL != OFF) && (AXIS4_DRIVER_MODEL != TMC_SPI) + #error "AXIS4_DRIVER_MODEL; Unknown stepper driver specified, check your configuration file." + #endif + #if FOCUSER2 == ON && (AXIS5_DRIVER_MODEL != OFF) && (AXIS5_DRIVER_MODEL != TMC_SPI) + #error "AXIS5_DRIVER_MODEL; Unknown stepper driver specified, check your configuration file." + #endif // validate stepper driver setup #include "src/step_dir_drivers/A4988_Validate.h" @@ -266,89 +164,418 @@ #include "src/step_dir_drivers/TMC_SPI_Validate.h" // for stepper drivers where AXISn_MICROSTEPS_GOTO must be defined - #if defined(MODE_SWITCH_BEFORE_SLEW_ON) || defined(MODE_SWITCH_BEFORE_SLEW_SPI) - #if defined(AXIS1_MICROSTEPS) && !defined(AXIS1_MICROSTEPS_GOTO) - #define AXIS1_MICROSTEPS_GOTO AXIS1_MICROSTEPS + #if MODE_SWITCH_BEFORE_SLEW != OFF + #if AXIS1_DRIVER_MICROSTEPS != OFF && AXIS1_DRIVER_MICROSTEPS_GOTO == OFF + #undef AXIS1_DRIVER_MICROSTEPS_GOTO + #define AXIS1_DRIVER_MICROSTEPS_GOTO AXIS1_DRIVER_MICROSTEPS #endif - #if defined(AXIS2_MICROSTEPS) && !defined(AXIS2_MICROSTEPS_GOTO) - #define AXIS2_MICROSTEPS_GOTO AXIS2_MICROSTEPS + #if AXIS2_DRIVER_MICROSTEPS != OFF && AXIS2_DRIVER_MICROSTEPS_GOTO == OFF + #undef AXIS2_DRIVER_MICROSTEPS_GOTO + #define AXIS2_DRIVER_MICROSTEPS_GOTO AXIS2_DRIVER_MICROSTEPS #endif #endif #else - // attempting to use the advanced stepper driver mode setup + #warning "Configuration: Stepper drivers for Axis1 and Axis2 are not defined. Be sure to properly configure micro-step mode, Vref/current, etc. manually with shunts, dip-switches, as required." +#endif + +// if AXISn_DRIVER_STEP_GOTO isn't defined, do so +#ifndef AXIS1_DRIVER_STEP_GOTO + #define AXIS1_DRIVER_STEP_GOTO 1 +#endif +#ifndef AXIS2_DRIVER_STEP_GOTO + #define AXIS2_DRIVER_STEP_GOTO 1 +#endif - #if defined(MODE_SWITCH_BEFORE_SLEW_ON) || defined(MODE_SWITCH_BEFORE_SLEW_SPI) - #if !defined(AXIS1_MODE) || !defined(AXIS1_MODE_GOTO) - #error "Configuration: AXIS1_MODE and AXIS1_MODE_GOTO must be set to a valid value." +// ----------------------------------------------------------------------------------- +// ----------------------------------------------------------------------------------- +// misc. validation + +// check for conflicted pin use, dedicated pins are ignored + +// PINMAPS ----------------------------------------------------------------------------------------------------------------- +#if PINMAP < PINMAP_FIRST || PINMAP > PINMAP_LAST + #error "Configuration: You must specify a PINMAP, etc. in the Config.h file" +#endif + +// SERIAL PORTS ------------------------------------------------------------------------------------------------------------ +#if SERIAL_B_ESP_FLASHING == ON + #if PINMAP == MiniPCB || PINMAP == MiniPCB2 || PINMAP == MaxPCB || PINMAP == Ramps14 || PINMAP == STM32B + #ifndef USES_AUX1 + #define USES_AUX1 false + #else + #error "Configuration: SERIAL_B_ESP_FLASHING enabled but Aux1 is already in use, choose one feature on Aux1" #endif - #if !defined(AXIS2_MODE) || !defined(AXIS2_MODE_GOTO) - #error "Configuration: AXIS2_MODE and AXIS2_MODE_GOTO must be set to a valid value." + #endif + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 || PINMAP == MaxPCB || PINMAP == MaxTMC || PINMAP == Ramps14 || PINMAP == STM32B + #ifndef USES_AUX2 + #define USES_AUX2 + #else + #error "Configuration: SERIAL_B_ESP_FLASHING enabled but Aux2 is already in use, choose one feature on Aux2" #endif #endif + #if PINMAP == Classic || PINMAP == Mega2560Alt || PINMAP == MiniPCB2 || PINMAP == MaxPCB2 + #error "Configuration: SERIAL_B_ESP_FLASHING not supported on this PINMAP" + #endif +#endif - #ifdef AXIS1_MODE - #define AXIS1_MICROSTEP_CODE AXIS1_MODE +// USER FEEDBACK ---------------------------- +#if LED_STATUS_PIN == ON + #if PINMAP == MaxESP || PINMAP == MaxPCB || PINMAP == MaxPCB2|| PINMAP == MaxTMC || PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 || PINMAP == Ramps14 || PINMAP == STM32B + #ifndef USES_AUX0 + #define USES_AUX0 false // false means the AUX0 doesn't have I2C sharing + #else + #error "Configuration: LED_STATUS_PIN enabled but Aux0 is already in use, choose one feature on Aux0" + #endif #endif - #ifdef AXIS2_MODE - #define AXIS2_MICROSTEP_CODE AXIS2_MODE + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 + #ifndef USES_AUX8 + #define USES_AUX8 + #else + #error "Configuration: LED_STATUS_PIN enabled but Aux8 is already in use, choose one feature on Aux8" + #endif #endif - #ifdef AXIS1_MODE_GOTO - #define AXIS1_MICROSTEP_CODE_GOTO AXIS1_MODE_GOTO +#endif +#if LED_STATUS2_PIN == ON + #if PINMAP == MaxESP || PINMAP == MaxESP2 || PINMAP == MaxESP3 || PINMAP == MaxPCB || PINMAP == MaxPCB2|| PINMAP == MaxTMC + #ifndef USES_AUX8 + #define USES_AUX8 + #else + #error "Configuration: LED_STATUS2_PIN enabled but Aux8 is already in use, choose one feature on Aux8" + #endif #endif - #ifdef AXIS2_MODE_GOTO - #define AXIS2_MICROSTEP_CODE_GOTO AXIS2_MODE_GOTO + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #ifndef USES_AUX4 + #define USES_AUX4 + #else + #error "Configuration: LED_STATUS2_PIN enabled but Aux4 is already in use, choose one feature on Aux4" + #endif + #endif +#endif +#if LED_RETICLE_PIN == ON + #if PINMAP == MaxESP || PINMAP == MaxESP2 || PINMAP == MaxESP3 || PINMAP == MaxPCB || PINMAP == MaxPCB2|| PINMAP == MaxTMC + #ifndef USES_AUX8 + #define USES_AUX8 + #else + #error "Configuration: LED_RETICLE_PIN enabled but Aux8 is already in use, choose one feature on Aux8" + #endif #endif + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #ifndef USES_AUX4 + #define USES_AUX4 + #else + #error "Configuration: LED_RETICLE_PIN enabled but Aux4 is already in use, choose one feature on Aux4" + #endif + #endif +#endif +#if BUZZER == ON + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 + #ifndef USES_AUX8 + #define USES_AUX8 + #else + #error "Configuration: BUZZER enabled but Aux8 is already in use, choose one feature on Aux8" + #endif + #endif +#endif +// TIME ------------------------------------- +#if RTC == DS3231 + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #ifndef USES_AUX0 + #define USES_AUX0 true // true means the AUX0 has I2C sharing + #else + #if USES_AUX0 != true + #error "Configuration: RTC DS3231 I2C enabled but Aux0 is already in use, choose one feature on Aux0" + #endif + #endif + #ifndef USES_AUX1 + #define USES_AUX1 true // true means the AUX1 has I2C sharing + #else + #if USES_AUX1 != true + #error "Configuration: RTC DS3231 I2C enabled but Aux1 is already in use, choose one feature on Aux1" + #endif + #endif + #endif +#endif +#if PPS_SENSE == ON + #if PINMAP == MaxESP + #ifndef USES_AUX0 + #define USES_AUX0 + #else + #error "Configuration: PPS_SENSE enabled but Aux0 is already in use, choose one feature on Aux0" + #endif + #endif + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 + #ifndef USES_AUX7 + #define USES_AUX7 + #else + #error "Configuration: PPS_SENSE enabled but Aux7 is already in use, choose one feature on Aux7" + #endif + #endif #endif -// if AXISn_STEP_GOTO isn't defined, do so -#ifndef AXIS1_STEP_GOTO - #define AXIS1_STEP_GOTO 1 +// SENSORS ---------------------------------- +#if WEATHER == BME280 + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #ifndef USES_AUX0 + #define USES_AUX0 true // true means the AUX0 has I2C sharing + #else + #if USES_AUX0 != true + #error "Configuration: RTC DS3231 I2C enabled but Aux0 is already in use, choose one feature on Aux0" + #endif + #endif + #ifndef USES_AUX1 + #define USES_AUX1 true // true means the AUX1 has I2C sharing + #else + #if USES_AUX1 != true + #error "Configuration: RTC DS3231 I2C enabled but Aux1 is already in use, choose one feature on Aux1" + #endif + #endif + #endif +#endif +#if TELESCOPE_TEMPERATURE == DS1820 + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 + #ifndef USES_AUX8 + #define USES_AUX8 + #else + #error "Configuration: RTC DS1820 OneWire interface enabled but Aux8 is already in use, choose one feature on Aux8" + #endif + #endif + #if PINMAP == MaxPCB || PINMAP == MaxTMC + #ifndef USES_AUX4 + #define USES_AUX4 + #else + #error "Configuration: RTC DS1820 OneWire interface enabled but Aux4 is already in use, choose one feature on Aux4" + #endif + #endif #endif -#ifndef AXIS2_STEP_GOTO - #define AXIS2_STEP_GOTO 1 +#if PEC_SENSE == ON || PEC_SENSE == ON_PULLUP || PEC_SENSE == ON_PULLDOWN +#endif +#if LIMIT_SENSE != OFF + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 || PINMAP == MaxPCB || PINMAP == MaxPCB2|| PINMAP == MaxTMC + #ifndef USES_AUX7 + #define USES_AUX7 + #else + #error "Configuration: LIMIT_SENSE enabled but Aux7 is already in use, choose one feature on Aux7" + #endif + #endif + #if PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #ifndef USES_AUX3 + #define USES_AUX3 + #else + #error "Configuration: LIMIT_SENSE enabled but Aux3 is already in use, choose one feature on Aux3" + #endif + #endif +#endif +#if HOME_SENSE != OFF + #if PINMAP == MaxESP2 || PINMAP == MaxESP3 || PINMAP == MaxPCB || PINMAP == MaxPCB2|| PINMAP == MaxTMC || PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 || PINMAP == Ramps14 + #ifndef USES_AUX3 + #define USES_AUX3 + #else + #error "Configuration: HOME_SENSE enabled but Aux3 is already in use, choose one feature on Aux3" + #endif + #ifndef USES_AUX4 + #define USES_AUX4 + #else + #error "Configuration: HOME_SENSE enabled but Aux4 is already in use, choose one feature on Aux4" + #endif + #endif #endif -// ----------------------------------------------------------------------------------- -// ----------------------------------------------------------------------------------- -// misc. validation +// MOTION CONTROL AXIS1/2 ----------------- +#if AXIS1_DRIVER_STATUS != OFF + #if PINMAP == MaxESP2 || PINMAP == MaxPCB || PINMAP == MaxPCB2 || PINMAP == MaxTMC || PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 || PINMAP == STM32Blue + #ifndef USES_AUX1 + #define USES_AUX1 + #else + #error "Configuration: AXIS1_DRIVER_STATUS enabled but Aux1 is already in use, choose one feature on Aux1" + #endif + #endif + #if PINMAP == MaxTMC || PINMAP == MiniEMB + #if AXIS1_DRIVER_STATUS == HIGH || AXIS1_DRIVER_STATUS == LOW + #error "Configuration: AXIS2_DRIVER_STATUS allows Aux1 use in TMC_SPI mode only" + #endif + #endif +#endif -// validate: warn the user not to have MISO wired up and try to use ESP8266 control too -#if defined(ESP8266_CONTROL_ON) && defined(MODE_SWITCH_BEFORE_SLEW_SPI) - #warning "Configuration: be sure the Aux1 and Aux2 pins are wired into the ESP8266 GPIO0 and RST pins and **NOT** the TMC SPI stepper driver SDO pins" - #if (AXIS1_FAULT==TMC_SPI) || (AXIS2_FAULT==TMC_SPI) - #error "Configuration: Fault detection across SPI conflicts with ESP8266 control, choose one feature and wire for it correctly" +#if AXIS2_DRIVER_STATUS != OFF + #if PINMAP == MaxPCB || PINMAP == MaxPCB2 || PINMAP == MiniPCB || PINMAP == MiniPCB2 || PINMAP == STM32Blue + #ifndef USES_AUX2 + #define USES_AUX2 + #else + #error "Configuration: AXIS2_DRIVER_STATUS enabled but Aux2 is already in use, choose one feature on Aux2" + #endif #endif #endif -// validate: to make sure the PEC buffer size isn't too large -#if PECBufferSize > 3384 - #error "PECBufferSize cannot be greater than 3384. Please use the spreadsheet to calculate your correct value" +#if AXIS2_DRIVER_POWER_DOWN == ON + #if PINMAP == MaxESP3 || PINMAP == MaxESP2 || PINMAP == MaxTMC + #error "Configuration: AXIS2_DRIVER_POWER_DOWN not supported on this PINMAP" + #endif #endif -// validate: block this old pin-map configuration option since it's been replaced with other functionality -#if defined(ALTERNATE_PINMAP_ON) - #error "ALTERNATE_PINMAP_ON is an obsolete option, you can't use this configuration." +// MOTION CONTROL FOCUSERS/ROTATOR ---------- + +// focusers/rotator allowed? +#if ROTATOR == ON + #if Axis3StepPin == -1 || Axis3DirPin == -1 + #error "Configuration: AXIS3 step/dir interface is not supported on this PINMAP" + #endif +#endif +#if FOCUSER1 == ON + #if Axis4StepPin == -1 || Axis4DirPin == -1 + #error "Configuration: AXIS4 step/dir interface is not supported on this PINMAP" + #endif +#endif +#if FOCUSER2 == ON + #if (Axis5StepPin == -1 || Axis5DirPin == -1) && AXIS5_DRIVER_DC_MODE == OFF + #error "Configuration: AXIS5 step/dir interface is not supported on this PINMAP" + #endif #endif -// validate: focuser configuration -#if !defined(FOCUSER1_ON) && defined(FOCUSER2_ON) - #error "Focuser2 can't be enabled without first enabling Focuser1" +// focuser/rotators any invalid combinations? +#if FOCUSER1 == ON && ROTATOR == ON + #if PINMAP == MaxESP2 || PINMAP == STM32Blue + #error "Configuration: AXIS3 and AXIS4 step/dir interface is shared, so enabling both is not supported on this PINMAP" + #endif +#endif +#if FOCUSER2 == ON && ROTATOR == ON + #if PINMAP == Classic || PINMAP == MaxESP3 || PINMAP == MaxPCB || PINMAP == MaxPCB2 || PINMAP == MaxTMC || PINMAP == MiniPCB || PINMAP == MiniEMB || PINMAP == MiniPCB2 + #error "Configuration: AXIS3 and AXIS5 step/dir interface is shared, so enabling both is not supported on this PINMAP" + #endif #endif -// validate: reticule and status LED configuration -#if defined(MaxPCB_ON) || defined(MaxESP2_ON) || defined(MiniPCB_ON) - #if defined(RETICULE_LED_PINS) && defined(STATUS_LED_PINS2_ON) - #error "You can't have the Illuminated Reticule and Status2 LEDs both enabled in this configuration." +// focuser/rotators any invalid EN pin use? +#if ROTATOR == ON && AXIS3_DRIVER_POWER_DOWN == ON + #if Axis3_EN == -1 + #error "Configuration: AXIS3_DRIVER_POWER_DOWN enabled but not supported with this PINMAP" + #endif + #if PINMAP == MaxPCB || PINMAP == MaxPCB2 + #if PINMAP == MaxPCB + #warning "Configuration: AXIS3_DRIVER_POWER_DOWN early v1.x MaxPCB boards had the option to use Aux3 for EN control, this is no longer supported (now uses Aux5.)" + #endif + #ifndef USES_AUX5 + #warning "Configuration: AXIS3_DRIVER_POWER_DOWN using Aux5." + #define USES_AUX5 + #else + #error "Configuration: AXIS3_DRIVER_POWER_DOWN enabled but Aux5 is already in use, choose one feature on Aux5" + #endif + #endif +#endif +#if FOCUSER1 == ON && (AXIS4_DRIVER_POWER_DOWN == ON || AXIS4_DRIVER_DC_MODE != OFF) + #if AXIS4_DRIVER_POWER_DOWN == ON && AXIS4_DRIVER_DC_MODE != OFF + #error "Configuration: AXIS4_DRIVER_POWER_DOWN and AXIS4_DRIVER_DC_MODE can't be used at the same time" + #endif + #if Axis4_EN == -1 + #error "Configuration: AXIS4_DRIVER_POWER_DOWN and AXIS4_DRIVER_DC_MODE require ENable signal support which this PINMAP doesn't have" + #endif + #if PINMAP == MaxESP3 + #ifndef USES_AUX2 + #define USES_AUX2 + #else + #error "Configuration: AXIS4_DRIVER_POWER_DOWN and AXIS4_DRIVER_DC_MODE require ENable signal support but Aux2 is already in use, choose one feature on Aux2" + #endif + #endif + #if PINMAP == MaxPCB || PINMAP == MaxPCB2 + #if PINMAP == MaxPCB + #warning "Configuration: AXIS4_DRIVER_POWER_DOWN and AXIS4_DRIVER_DC_MODE require ENable signal support, early v1.x MaxPCB boards had the option to use Aux4 for EN control but this is no longer supported." + #endif + #ifndef USES_AUX6 + #define USES_AUX6 + #else + #error "Configuration: AXIS4_DRIVER_POWER_DOWN and AXIS4_DRIVER_DC_MODE require ENable signal support but Aux6 is already in use, choose one feature on Aux6" + #endif + #endif +#endif +#if FOCUSER2 == ON && AXIS5_DRIVER_POWER_DOWN == ON + #if AXIS5_DRIVER_POWER_DOWN == ON && AXIS5_DRIVER_DC_MODE != OFF + #error "Configuration: AXIS5_DRIVER_POWER_DOWN and AXIS5_DRIVER_DC_MODE can't be used at the same time" + #endif + #if Axis5_EN == -1 + #error "Configuration: AXIS5_DRIVER_POWER_DOWN requires ENable signal support which this PINMAP doesn't have" + #endif + #if PINMAP == MaxPCB || PINMAP == MaxPCB2 + #if PINMAP == MaxPCB + #warning "Configuration: AXIS5_DRIVER_POWER_DOWN early v1.x MaxPCB boards had the option to use Aux3 for EN control, this is no longer supported (now uses Aux5.)" + #endif + #ifndef USES_AUX5 + #define USES_AUX5 + #else + #error "Configuration: AXIS5_DRIVER_POWER_DOWN enabled but Aux5 is already in use, choose one feature on Aux5" + #endif #endif #endif -// validate: limit sense state -#ifdef LIMIT_SENSE_STATE - #if LIMIT_SENSE_STATE != LOW && LIMIT_SENSE_STATE != HIGH - #error "LIMIT_SENSE_STATE must be either HIGH or LOW" +// focuser/rotators any invalid focuser DC modes? +#if !(FOCUSER1 == ON && AXIS4_DRIVER_DC_MODE != OFF) + #if AXIS4_DRIVER_DC_MODE == XDIRECT && AXIS4_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS4_DRIVER_DC_MODE error XDIRECT is for TMC stepper drivers only." + #endif +#endif +#if FOCUSER2 == ON && AXIS5_DRIVER_DC_MODE != OFF + #if !(FOCUSER1 == ON && AXIS4_DRIVER_DC_MODE != OFF) + #error "Configuration: AXIS5_DRIVER_DC_MODE requires enabling FOCUSER1 in AXIS4_DRIVER_DC_MODE. In this mode FOCUSER2 USES the FOCUSER1 stepper driver" + #endif +#endif + +// PINMAP SPECIFIC VALIDATION ---------------------- + +#if PINMAP == Ramps14 + #if SERIAL_B_ESP_FLASHING == ON + #error "Configuration: SERIAL_B_ESP_FLASHING not supported for this PINMAP" + #endif +#endif + +#if PINMAP == MaxTMC + // special checks for MaxTMC to ensure all enabled stepper drivers are TMC2130 or TMC5160 in SPI mode + #if AXIS1_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS1_DRIVER_MODEL must be a TMC2130 or TMC5160 for this PINMAP" + #endif + #if AXIS2_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS2_DRIVER_MODEL must be a TMC2130 or TMC5160 for this PINMAP" + #endif + #if ROTATOR == ON + #if AXIS3_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS3_DRIVER_MODEL must be a TMC2130 or TMC5160 for this PINMAP" + #endif + #endif + #if FOCUSER1 == ON + #if AXIS4_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS4_DRIVER_MODEL must be a TMC2130 or TMC5160 for this PINMAP" + #endif + #endif + #if FOCUSER2 == ON + #if AXIS5_DRIVER_MODEL != TMC_SPI + #error "Configuration: AXIS5_DRIVER_MODEL must be a TMC2130 or TMC5160 for this PINMAP" + #endif #endif #else - #define LIMIT_SENSE_STATE LOW // Default to low + // and when not MaxTMC to ensure all focuser/rotator stepper drivers off (manual configuration only.) + #if ROTATOR == ON && AXIS3_DRIVER_MODEL != OFF + #error "Configuration: AXIS3_DRIVER_MODEL must be OFF for this PINMAP" + #endif + #if FOCUSER1 == ON && AXIS4_DRIVER_MODEL != OFF + #error "Configuration: AXIS4_DRIVER_MODEL must be OFF for this PINMAP" + #endif + #if FOCUSER2 == ON && AXIS5_DRIVER_MODEL != OFF + #error "Configuration: AXIS5_DRIVER_MODEL must be OFF for this PINMAP" + #endif +#endif + +// GENERAL PURPOSE VALIDATION ---------------------- + +#if LED_STATUS_PIN != OFF && LEDnegPin == -1 + #error "Configuration: LED_STATUS_PIN not supported for this PINMAP, must be OFF" +#endif + +#if LED_STATUS2_PIN != OFF && LEDneg2Pin == -1 + #error "Configuration: LED_STATUS2_PIN not supported for this PINMAP, must be OFF" +#endif + +#if LED_RETICLE_PIN != OFF && ReticlePin == -1 + #error "Configuration: LED_RETICLE_PIN not supported for this PINMAP, must be OFF" +#endif + +#if PEC_SENSE > 0 && AnalogPecPin == -1 + #error "Configuration: PEC_SENSE in ANALOG mode not supported for this PINMAP, use ON, etc. NOT a threshold value" #endif diff --git a/other-configurations/Config.MaxESP.h b/other-configurations/Config.MaxESP.h deleted file mode 100644 index fccf1f47b..000000000 --- a/other-configurations/Config.MaxESP.h +++ /dev/null @@ -1,216 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep MaxESP (ESP32S) - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.MaxESP.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define MaxESP_OFF // <- Turn _ON to use this configuration - -// Notes: - -// The stock ESP32 Release 1.0.0 BluetoothSerial.h library doesn't work -// Copy the latest BluetoothSerial library (just it's folder) from https://github.com/espressif/arduino-esp32 into -// C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Bluetooth - -// The stock ESP32 Release 1.0.0 Wire.h library doesn't work -// Copy the latest Wire.h library file (only) from ~\OnStep\src\HAL\HAL_ESP32 into -// C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src - -#ifdef MaxESP_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 and Serial4 com ports, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 -// For an ESP32 SerialC is the Bluetooth port so use a name instead of a baud "ONSTEP", etc. -//#define SERIAL_C_BAUD_DEFAULT "OnStep" - -// Mount type, default is _GEM (German Equatorial) other options are _FORK, _FORK_ALT. _FORK switches off Meridian Flips after (1, 2 or 3 star) alignment is done. _FORK_ALT disables Meridian Flips (1 star align.) -// _ALTAZM is for Alt/Azm mounted 'scopes (1 star align only.) -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on pins 34, 32, 33, 35. Pin 34 is RA- (West), Pin 32 is Dec- (South), Pin 33 is Dec+ (North), Pin 35 is RA+ (East.) -// ST4_ON enables the interface. Internal pullup resistors are not available. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_ON -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: -// Press and hold [E]+[W] buttons for > 2 seconds for mode A: [E] Decrease [W] increase guide rate (or recticule brightness if at home position.) [S] Sync (or Accept during align.) [N] Tracking on/off. -// Press and hold [N]+[S] buttons for > 2 seconds for mode B: [E] Selects prior and [W] next user catalog item. [N] Do a Goto to the catalog item. [S] Sound on/off. -// The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON -// Press and hold [N]+[S] buttons for > 2 seconds for mode B: [E] Selects focuser 1 [W] selects focuser 2. [N] Moves focuser in and [S] moves focuser out. -#define ST4_HAND_CONTROL_FOCUSER_OFF - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// RTC (Real Time Clock) support, default=_OFF. -// Other options: RTC_DS3231 for a DS3231 on the default I2C pins -#define RTC_OFF - -// PEC sense on Pin 36 (A0) use _ON to enable the input. Built-in pullup resistors are not available. Provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 4095? which indicate voltages from 0-3.3VDC? on the analog pin (voltage range not confirmed, be careful!) -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) on Pin 39 for optional limit sense (stops gotos and/or tracking), Built-in pullup resistors are not available. Default=_OFF -#define LIMIT_SENSE_OFF - -// Light status LED by sink to ground (Pin 25), default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash. -#define STATUS_LED_PINS_ON -// Light 2nd status LED by sink to ground (Pin 23), default=_ON. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_ON -// Light reticule LED by sink to ground (Pin 23), default=_OFF. (don't use with STATUS_LED2_PINS_ON) -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on Pin 13, default=_ON. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_ON -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_OFF - -// Set to _ON and wire in BME280 on the I2C port (SCL1,SDA1) for temperature, pressure, humidity. Default=_OFF. -#define WEATHER_BME280_OFF - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// Automatic homing; switch state changes at the home position (uses Aux3 and Aux4.) For MOUNT_TYPE_GEM only. -#define HOME_SENSE_OFF // Default _OFF, use _ON to have OnStep automatically detect and use home switches as follows -#define HOME_AXIS1_REVERSE_OFF // Pin Aux3 state should be HIGH when clockwise of the home position (as seen from front,) LOW otherwise; reverse if necessary -#define HOME_AXIS2_REVERSE_OFF // Pin Aux4 state should be HIGH when clockwise of the home position (as seen from above,) LOW otherwise; reverse if necessary - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_MAX_RATE_ON // set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF -#define MaxRate 64 // microseconds per microstep default setting for gotos, can be adjusted for two times lower or higher at run-time - // minimum* (fastest goto) is around 16, default=96 higher is ok - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 2.5 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define GUIDES_DISABLE_BACKLASH_OFF // Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 32178.285// calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // LXD75 : 200 * 8 * 18:1 * 37:35 * 144/360 = 12178 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 32178.285// calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // LXD75 : 200 * 8 * 18:1 * 37:35 * 360/360 = 12178 - // the LXD75 has two spur gears that drive the RA/Dec worms, they give an additional 1.057:1 reduction - // in addition to the 18:1 gear heads on the steppers for a 19.028:1 final ratio before the worm/wheels at 144:1 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 30446L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 180 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 180. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 18,19 = Step,Dir (RA/Azm) -// Axis2: Pins 27,26 = Step,Dir (Dec/Alt) - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_ON // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins 4 (Axis1) and 12 (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Stepper driver Fault detection on Pins 5 (Aux3) and 14 (Aux4,) choose only one feature to use on Aux3/4. -// other settings are LOW, HIGH (if available applies internal pullup if LOW and pulldown if HIGH.) -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins 2,15 = Step,Dir (choose either this option or the second focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed Axis3 rotator, default = -180 -#define MaxAxis3 180 // maximum allowed Axis3 rotator, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement -#define AXIS3_DISABLE_OFF // Pin 0 (Aux5.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS3_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins 34,35 = Step,Dir -#define FOCUSER1_ON // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means -#define MinAxis4 -25.0 // minimum allowed Axis4 position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed Axis4 position in millimeters, default = 25.0 -#define AXIS4_REVERSE_OFF // reverse the direction of Axis4 focuser movement -#define AXIS4_DISABLE_OFF // Pin 0 (Aux5.) Default _OFF, use HIGH for common stepper drivers. -#define AXIS4_AUTO_POWER_DOWN_OFF // use _ON if you want to power down the motor at stand-still. Default _OFF. - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.MaxESP.h" - -#endif - diff --git a/other-configurations/Config.Mega2560Alt.h b/other-configurations/Config.Mega2560Alt.h deleted file mode 100644 index a45eda006..000000000 --- a/other-configurations/Config.Mega2560Alt.h +++ /dev/null @@ -1,177 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for legacy OnStep "Alternate pin-map" (Mega2560) -// *** this is for backwards compatability with older OnStep systems *** - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * See the Pins.Mega2560Alt.h file for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * -*/ - -#define Mega2560Alt_OFF // <- Turn _ON to use this configuration - -#ifdef Mega2560Alt_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 com port, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 - -// Mount type, default is _GEM (German Equatorial) other options are _FORK, _FORK_ALT. _FORK switches off Meridian Flips after (1, 2 or 3 star) alignment is done. _FORK_ALT disables Meridian Flips (1 star align.) -// _ALTAZM is for Alt/Azm mounted 'scopes (1 star align only.) -#define MOUNT_TYPE_GEM - -// ST4 interface on Pins 47, 43, 45, 49. Pin 47 is RA- (West), Pin 43 is Dec- (South), Pin 45 is Dec+ (North), Pin 49 is RA+ (East.) -// ST4_ON enables the interface. ST4_PULLUP enables the interface and any internal pullup resistors. default=_OFF -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// use separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// Set to _ON to disable backlash takeup during guiding at <= 1X, default=_OFF -#define GUIDES_DISABLE_BACKLASH_OFF - -// RTC (Real Time Clock) support, default=_OFF. Other options: RTC_DS3234 for a DS3234 on the default SPI interface pins (and CS on pin 10, optionally wire the SQW output to the PPS pin below.) -#define RTC_OFF -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on pin 21 for optional precision clock source (GPS, for example), default=_OFF -#define PPS_SENSE_OFF - -// PEC sense on Pin 2 use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for Analog operation (on Pin A1,) default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 2.92V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// switch close (to ground) on Pin 3 for optional limit sense (stops gotos and/or tracking), default=_OFF -#define LIMIT_SENSE_OFF - -// light status LED by sink to ground (Pin 9) and source +5V (Pin 8), default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_ON -// lights 2nd status LED by sink to ground (Pin 7), default=_OFF. -// _ON sets this to blink at 1 sec intervals when PPS is synced -#define STATUS_LED2_PINS_OFF -// lights reticule LED by sink to ground (Pin 44), default=_OFF. -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer on Pin 42, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF (limited testing done) -// can be turned on/off with the :Te# and :Td# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_OFF - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_OFF - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_OFF - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_MAX_RATE_OFF // set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF -#define MaxRate 96 // microseconds per microstep default setting for gotos, can be adjusted for two times lower or higher at run-time - // minimum* (fastest goto) is around 32 (Mega2560,) default=96 higher is ok - // * = minimum can be lower, when both AXIS1/AXIS2_MICROSTEPS are used the compiler will warn you if it's too low - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. OnStep will flip the mount and move the Dec. >90 degrees (+/-) once past this limit. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 7 to 11 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 180 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 180. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins 35,37 = Step,Dir (RA/Azm) -// Axis2: Pins 24,22 = Step,Dir (Dec/Alt) - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support is always on, just wire Enable to Pins 23 (Axis1) and 36 (Axis2) and OnStep will pull these HIGH -// to disable stepper drivers on startup and when Parked or Homed. An Align or UnPark will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on Pins 29,27,25 for Axis1 (RA/Azm) and Pins 30,32,34 for Axis2 (Dec/Alt). -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, S109, ST820, TMC2208, TMC2130 (spreadCycle,) -// TMC2130_QUIET (stealthChop tracking,) TMC2130_VQUIET (full stealthChop mode,) add _LOWPWR for 50% power during tracking (for example: TMC2130_QUIET_LOWPWR) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection, just wire the driver Fault signal to Pins 39 (Axis1) and 38 (Axis2), default=_OFF. The SPI interface (on M0/M1/M2/Aux) can be used to detect errors on the TMC2130. -// other settings are LOW, HIGH, TMC2130 (if available applies internal pullup if LOW and pulldown if HIGH.) -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// THAT'S IT FOR USER CONFIGURATION! - -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.Mega2560Alt.h" -#endif diff --git a/other-configurations/Config.TM4C.h b/other-configurations/Config.TM4C.h deleted file mode 100644 index 3641e15d7..000000000 --- a/other-configurations/Config.TM4C.h +++ /dev/null @@ -1,203 +0,0 @@ -// ----------------------------------------------------------------------------------- -// Configuration for OnStep Launchpad TM4C varients - -/* - * For more information on setting OnStep up see http://www.stellarjourney.com/index.php?r=site/equipment_onstep and - * join the OnStep Groups.io at https://groups.io/g/onstep - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * See the appropriate file below for detailed information on this pin map to be sure it matches your wiring *** USE AT YOUR OWN RISK *** - * ~/OnStep/src/pinmaps/Pins.TM4C.h * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -*/ - -#define TM4C_OFF // <- Turn _ON to use this configuration - -#ifdef TM4C_ON -// ------------------------------------------------------------------------------------------------------------------------- -// ADJUST THE FOLLOWING TO CONFIGURE YOUR CONTROLLER FEATURES -------------------------------------------------------------- - -// Default speed for Serial1 and Serial4 com ports, Default=9600 -#define SERIAL_B_BAUD_DEFAULT 9600 -#define SERIAL_C_BAUD_DEFAULT 9600 - -// ESP8266 reset and GPIO0 control, this sets run mode for normal operation. Uploading programmer firmware to the OpStep MCU can then enable sending new firmware to the ESP8266-01 -// Pin (Aux1) for GPIO0 and Pin (Aux2) for Rst control. Choose only one feature on Aux1/2. -#define ESP8266_CONTROL_OFF - -// Mount type, default is _GEM (German Equatorial) other options are _FORK, _FORK_ALT. _FORK switches off Meridian Flips after (1, 2 or 3 star) alignment is done. _FORK_ALT disables Meridian Flips (1 star align.) -// _ALTAZM is for Alt/Azm mounted 'scopes (1 star align only.) -#define MOUNT_TYPE_GEM - -// Strict parking, default=_OFF. Set to _ON and unparking is only allowed if successfully parked. Otherwise unparking is allowed if at home and not parked (the Home/Reset command ":hF#" sets this state.) -#define STRICT_PARKING_OFF - -// ST4 interface on four pins (see pinmap.) Pins are RA- (West), Dec- (South), Dec+ (North), RA+ (East.) -// ST4_ON enables the interface, ST4_PULLUP enables the interface and any internal pullup resistors. -// It is up to you to create an interface that meets the electrical specifications of any connected device, use at your own risk. default=_OFF -#define ST4_OFF -// If SEPARATE_PULSE_GUIDE_RATE_ON is used the ST4 port is limited to guide rates <= 1X except when ST4_HAND_CONTROL_ON is used. -// Additionally, ST4_HAND_CONTROL_ON enables special features: Press and hold [E]+[W] buttons for > 2 seconds... In this mode [E] decreases and [W] increases guide rates (or if tracking isn't on yet adjusts illuminated recticule brightness.) -// [S] for Sync (or Accept if in align mode.) [N] for Tracking on/off. -OR- Press and hold [N]+[S] buttons for > 2 seconds... In this mode [E] selects prior and [W] next user catalog item. -// [N] to do a Goto to the catalog item. [S] for Sound on/off. The keypad returns to normal operation after 4 seconds of inactivity. ST4_HAND_CONTROL_ON also adds a 100ms de-bounce to all button presses. -// Finally, during a goto pressing any button aborts the slew. If meridian flip paused at home, pressing any button continues. default=_ON -#define ST4_HAND_CONTROL_ON - -// Separate pulse-guide rate so centering and guiding don't disturb each other, default=_ON -#define SEPARATE_PULSE_GUIDE_RATE_ON - -// Guide time limit (in seconds,) default=0 (no limit.) A safety feature, some guides are started with one command and stopped with another. -// If the stop command is never received the guide will continue forever unless this is enabled. -#define GUIDE_TIME_LIMIT 0 - -// PPS use _ON or _PULLUP to enable the input and use the built-in pullup resistor. Sense rising edge on pin for optional precision clock source (GPS, for example), default=_OFF [infrequently used option] -#define PPS_SENSE_OFF - -// PEC sense use _ON or _PULLUP to enable the input/use the built-in pullup resistor (digital input) or provide a comparison value (see below) for analog operation, default=_OFF -// Analog values range from 0 to 1023 which indicate voltages from 0-3.3VDC on the analog pin, for example "PEC_SENSE 600" would detect an index when the voltage exceeds 1.93V -// With either index detection method, once triggered 60s must expire before another detection can happen. This gives time for the index magnet to pass by the detector before another cycle begins. -// Ignored on Alt/Azm mounts. -#define PEC_SENSE_OFF -// PEC sense, rising edge (default with PEC_SENSE_STATE HIGH, use LOW for falling edge, ex. PEC_SENSE_ON) ; for optional PEC index -#define PEC_SENSE_STATE HIGH - -// Switch close (to ground) for optional limit sense (stops gotos and/or tracking), default=_OFF -#define LIMIT_SENSE_OFF - -// Light status LED by sink to ground, default=_ON. -// _ON and OnStep keeps this illuminated to indicate that the controller is active. When sidereal tracking this LED will rapidly flash -#define STATUS_LED_PINS_OFF -// Light 2nd status LED by sink to ground, default=_OFF. -// _ON sets this to blink at 1 sec intervals when PPS is synced. Turns off if tracking is stopped. Turns on during gotos. -#define STATUS_LED2_PINS_OFF -// Light reticule LED by sink to ground, default=_OFF. (don't use with STATUS_LED2_PINS_ON) -// RETICULE_LED_PINS n, where n=0 to 255 activates this feature and sets default brightness -#define RETICULE_LED_PINS_OFF - -// Sound/buzzer, default=_OFF. -// Specify frequency for a piezo speaker (for example "BUZZER 2000") or use BUZZER_ON for a piezo buzzer. -#define BUZZER_OFF -// Sound state at startup, default=_ON. -#define DEFAULT_SOUND_ON - -// Optionally adjust tracking rate to compensate for atmospheric refraction, default=_OFF -// can be turned on/off with the :Tr# and :Tn# commands regardless of this setting -#define TRACK_REFRACTION_RATE_DEFAULT_ON - -// Set to _OFF and OnStep will allow Syncs to change pier side for GEM mounts (on/off), default=_ON -#define SYNC_CURRENT_PIER_SIDE_ONLY_ON - -// Set to _ON and OnStep will remember the last auto meridian flip setting (on/off), default=_OFF -#define REMEMBER_AUTO_MERIDIAN_FLIP_ON - -// Set to _ON and OnStep will travel directly across a meridian flip without visiting the home position (on/off), default=_OFF (only applies if pause at home is disabled) -#define MERIDIAN_FLIP_SKIP_HOME_OFF - -// Set to _ON and OnStep will remember the last meridian flip pause at home setting (on/off), default=_OFF -#define REMEMBER_PAUSE_HOME_ON - -// ADJUST THE FOLLOWING TO MATCH YOUR MOUNT -------------------------------------------------------------------------------- -#define REMEMBER_MAX_RATE_OFF // set to _ON and OnStep will remember rates set in the ASCOM driver, Android App, etc. default=_OFF -#define MaxRate 96 // microseconds per microstep default setting for gotos, can be adjusted for two times lower or higher at run-time - // minimum* (fastest goto) is around 8 (give or take depending on the TIVA-C model,) default=96 higher is ok - // * = minimum can be lower, when both AXIS1/AXIS2_MICROSTEPS are used the compiler will warn you if it's too low - -#define DegreesForAcceleration 5.0 // approximate number of degrees for full acceleration or deceleration: higher values=longer acceleration/deceleration - // Default=5.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. -#define DegreesForRapidStop 1.0 // approximate number of degrees required to stop when requested or if limit is exceeded during a slew: higher values=longer deceleration - // Default=1.0, too low (about <1) can cause gotos to never end if micro-step mode switching is enabled. - -#define BacklashTakeupRate 25 // backlash takeup rate (in multipules of the sidereal rate): too fast and your motors will stall, - // too slow and the mount will be sluggish while it moves through the backlash - // for the most part this doesn't need to be changed, but adjust when needed. Default=25 - - // Axis1 is for RA/Az -#define StepsPerDegreeAxis1 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - // Axis2 is for Dec/Alt -#define StepsPerDegreeAxis2 12800.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // G11 : 400 * 32 * 1 * 360/360 = 12800 - - // PEC, number of steps for a complete worm rotation (in RA), (StepsPerDegreeAxis1*360)/gear_reduction2. Ignored on Alt/Azm mounts. -#define StepsPerWormRotationAxis1 12800L - // G11 : (12800*360)/360 = 12800 - -#define PECBufferSize 824 // PEC, buffer size, max should be no more than 3384, your required buffer size >= StepsPerAxis1WormRotation/(StepsPerDegeeAxis1/240) - // for the most part this doesn't need to be changed, but adjust when needed. 824 seconds is the default. Ignored on Alt/Azm mounts. - -#define MinutesPastMeridianE 30 // for goto's, how far past the meridian to allow before we do a flip (if on the East side of the pier) - a half hour of RA is the default = 30. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. -#define MinutesPastMeridianW 30 // as above, if on the West side of the pier. If left alone, the mount will stop tracking when it hits the this limit. Sometimes used for Fork mounts in Align mode. Ignored on Alt/Azm mounts. - // The above two lines can be removed and settings in EEPROM will be used instead, be sure to set the Meridian limits in control software if you do this! - // If you don't remove these lines Meridian limits will return to these defaults on power up. -#define UnderPoleLimit 12 // maximum allowed hour angle (+/-) under the celestial pole. Default=12. Ignored on Alt/Azm mounts. - // If left alone, the mount will stop tracking when it hits this limit. Valid range is 10 to 12 hours. -#define MinDec -91 // minimum allowed declination, default = -91 (off) Ignored on Alt/Azm mounts. -#define MaxDec +91 // maximum allowed declination, default = 91 (off) Ignored on Alt/Azm mounts. - // For example, a value of +80 would stop gotos/tracking near the north celestial pole. - // For a Northern Hemisphere user, this would stop tracking when the mount is in the polar home position but - // that can be easily worked around by doing an alignment once and saving a park position (assuming a - // fork/yoke mount with meridian flips turned off by setting the minutesPastMeridian values to cover the whole sky) -#define MaxAzm 180 // Alt/Az mounts only. +/- maximum allowed Azimuth, default = 180. Allowed range is 180 to 360 - -// AXIS1/2 STEPPER DRIVER CONTROL ------------------------------------------------------------------------------------------ -// Axis1: Pins (see pinmap) = Step,Dir (RA/Azm) -// Axis2: Pins (see pinmap) = Step,Dir (Dec/Alt) - -// Reverse the direction of movement. Adjust as needed or reverse your wiring so things move in the right direction -#define AXIS1_REVERSE_OFF // RA/Azm axis -#define AXIS2_REVERSE_OFF // Dec/Alt axis - -// Stepper driver Enable support, just wire Enable to Pins ? (Axis1) and ? (Axis2) and OnStep will pull these HIGH to disable the stepper drivers on startup and when Parked or Homed. -// An Align, Sync, or Un-Park will enable the drivers. Adjust below if you need these pulled LOW to disable the drivers. -#define AXIS1_DISABLE HIGH -#define AXIS2_DISABLE HIGH - -// For equatorial mounts, _ON powers down the Declination axis when it's not being used to help lower power use. During low rate guiding (<=1x) the axis stays enabled -// for 10 minutes after any guide on either axis. Otherwise, the Dec axis is disabled (powered off) 10 seconds after movement stops. -#define AXIS2_AUTO_POWER_DOWN_OFF - -// Basic stepper driver mode setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -// If used, this requires connections M0, M1, and M2 on three pins for Axis1 (RA/Azm) and three pins Axis2 (Dec/Alt.) -// Stepper driver models are as follows: (for example AXIS1_DRIVER_MODEL DRV8825,) A4988, LV8729, RAPS128, TMC2208, TMC2130 (spreadCycle,) -// TMC2130_QUIET (stealthChop tracking,) TMC2130_VQUIET (full stealthChop mode,) add _LOWPWR for 50% power during tracking (for example: TMC2130_QUIET_LOWPWR) -#define AXIS1_DRIVER_MODEL_OFF // Axis1 (RA/Azm): Default _OFF, Stepper driver model (see above) -#define AXIS1_MICROSTEPS_OFF // Axis1 (RA/Azm): Default _OFF, Microstep mode when the scope is doing sidereal tracking (for example: AXIS1_MICROSTEPS 32) -#define AXIS1_MICROSTEPS_GOTO_OFF // Axis1 (RA/Azm): Default _OFF, Optional microstep mode used during gotos (for example: AXIS1_MICROSTEPS_GOTO 2) -#define AXIS2_DRIVER_MODEL_OFF // Axis2 (Dec/Alt): Default _OFF, Stepper driver model (see above) -#define AXIS2_MICROSTEPS_OFF // Axis2 (Dec/Alt): Default _OFF, Microstep mode when the scope is doing sidereal tracking -#define AXIS2_MICROSTEPS_GOTO_OFF // Axis2 (Dec/Alt): Default _OFF, Optional microstep mode used during gotos -// Note: you can replace this section with the contents of "AdvancedStepperSetup.txt" . . . . . . . . . . . . . . . . . . . - -// Stepper driver Fault detection on Pins (Aux1) and (Aux2,) choose only one feature to use on Aux1/2. The SPI interface (on M0/M1/M2/Aux) can be used to detect errors on the TMC2130. -// other settings are LOW, HIGH, TMC2130 (if available applies internal pullup if LOW and pulldown if HIGH.) -#define AXIS1_FAULT_OFF -#define AXIS2_FAULT_OFF - -// ------------------------------------------------------------------------------------------------------------------------ -// CAMERA ROTATOR OR ALT/AZ DE-ROTATION ----------------------------------------------------------------------------------- -// Pins (see pinmap) = Step,Dir (choose either this option or the first focuser, not both) -#define ROTATOR_OFF // use _ON to enable the rotator (for any mount type,) default=_OFF (this is also a de-rotator for MOUNT_TYPE_ALTAZM mounts.) -#define MaxRateAxis3 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerDegreeAxis3 64.0 // calculated as : stepper_steps * micro_steps * gear_reduction1 * (gear_reduction2/360) - // Rotator : 24 * 8 * 20 * 6/360 = 64 - // For de-rotation of Alt/Az mounts a quick estimate of the required resolution (in StepsPerDegree) - // would be an estimate of the circumference of the useful imaging circle in (pixels * 2)/360 -#define MinAxis3 -180 // minimum allowed Axis3 rotator, default = -180 -#define MaxAxis3 180 // maximum allowed Axis3 rotator, default = 180 -#define AXIS3_REVERSE_OFF // reverse the direction of Axis3 rotator movement - -// FOCUSER1 --------------------------------------------------------------------------------------------------------------- -// Pins (see pinmap) = Step,Dir (choose either this option or the rotator, not both) -#define FOCUSER1_OFF // use _ON to enable this focuser, default=_OFF -#define MaxRateAxis4 8 // this is the minimum number of milli-seconds between micro-steps, default=8 -#define StepsPerMicrometerAxis4 0.5 // figure this out by testing or other means -#define MinAxis4 -25.0 // minimum allowed Axis4 position in millimeters, default = -25.0 -#define MaxAxis4 25.0 // maximum allowed Axis4 position in millimeters, default = 25.0 -#define AXIS4_REVERSE_OFF // reverse the direction of Axis4 focuser movement - -// THAT'S IT FOR USER CONFIGURATION! -// ------------------------------------------------------------------------------------------------------------------------- -#define FileVersionConfig 2 -#include "src/pinmaps/Pins.TM4C.h" -#endif - diff --git a/other-configurations/README.md b/other-configurations/README.md deleted file mode 100644 index 64ca4a457..000000000 --- a/other-configurations/README.md +++ /dev/null @@ -1,9 +0,0 @@ -OnStep Telescope Controller -=========================== - -# Other configuration files - -These are less frequently used configurations. - -To activate one of these I recommend opening the file (you can use the Arduino IDE to do this if you like) and copy it's contents over the contents of Config.Classic.h (copy/paste.) -Then follow the directions to enable the configuration as you would any other (OnStep Wiki.) diff --git a/other-configurations/other configurations.ino b/other-configurations/other configurations.ino deleted file mode 100644 index 7db41f0ef..000000000 --- a/other-configurations/other configurations.ino +++ /dev/null @@ -1,5 +0,0 @@ -// Placeholder file -// Nothing to see here ... -// -// This file is only present so the Arduino IDE can edit the .h file(s) - diff --git a/src/HAL/HAL_ESP32/Analog.h b/src/HAL/HAL_ESP32/Analog.h new file mode 100644 index 000000000..3af8b5f35 --- /dev/null +++ b/src/HAL/HAL_ESP32/Analog.h @@ -0,0 +1,92 @@ +// ----------------------------------------------------------------------------------- +// ******* Arduino compatible analogWrite() and tone() functions for the ESP32 ******* +// Takes over 8 of the 16 PWM channels (default, uses channel# 8 to 15) so only channel#'s < 8 can be used elsewhere. +// The 8 PWM channels are shared between the non-blocking tone() and analogWrite() functions and are automatically allocated as required. + +portMUX_TYPE __analogOutMux = portMUX_INITIALIZER_UNLOCKED; + +#define __ANALOG_PWM_CHANNEL_START 8 // set aside 8 channels for use elsewhere, use 0 to dedicate all 16 channels here + +volatile uint8_t __tone_p = 0; +volatile unsigned int __tone_f = 0; +volatile unsigned long __tone_d = 0; +volatile int __channelMap[16] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; +TaskHandle_t __toneTask; + +// find and disable any PWM already on this pin +void __pwmDeallocateChannel(int pin) { + for (int channel=__ANALOG_PWM_CHANNEL_START; channel<15; channel++) { + if (__channelMap[channel]==pin) { ledcDetachPin(pin); ledcWrite(channel,0); __channelMap[channel]=-1; break; } + } +} + +// find a PWM channel for this pin, returns -1 if no channel is available +int __pwmAllocateChannel(int pin, boolean clearExisting=false) { + if (clearExisting) __pwmDeallocateChannel(pin); + for (int channel=__ANALOG_PWM_CHANNEL_START; channel<15; channel++) { + if (__channelMap[channel]==-1) { __channelMap[channel]=pin; return channel; } + } + log_e("PWM, no channels available."); + return -1; +} + +int __pwmGetChannel(int pin) { + for (int channel=__ANALOG_PWM_CHANNEL_START; channel<15; channel++) { if (__channelMap[channel]==pin) return channel; } + return -1; +} + +void __toneStop(void * pvParameters) +{ + delay(__tone_d); + + portENTER_CRITICAL(&__analogOutMux); + int channel=__pwmGetChannel(__tone_p); + if (channel>=0) { + ledcDetachPin(__tone_p); + ledcWrite(channel,0); + __pwmDeallocateChannel(__tone_p); + } + portEXIT_CRITICAL(&__analogOutMux); + + vTaskDelete(NULL); +} + +void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0) +{ + portENTER_CRITICAL(&__analogOutMux); + int channel=__pwmAllocateChannel(pin); + if (channel>=0) { + __tone_p=pin; __tone_f=frequency; __tone_d=duration; + ledcAttachPin(pin,channel); + ledcWriteTone(channel,frequency); + if (duration) xTaskCreatePinnedToCore(__toneStop,"__toneStop",10000,NULL,1,&__toneTask,0); + } else log_e("Tone, PWM channel in use or unavailable."); + portEXIT_CRITICAL(&__analogOutMux); +} + +void noTone(uint8_t pin) +{ + portENTER_CRITICAL(&__analogOutMux); + int channel=__pwmGetChannel(pin); + if (channel>=0) { + ledcDetachPin(pin); + ledcWrite(channel,0); + __pwmDeallocateChannel(pin); + } else log_e("noTone, no PWM channel?"); + portEXIT_CRITICAL(&__analogOutMux); +} + +__attribute__ ((weak)) void analogWrite(uint8_t pin, int value) { + Serial.println("Setting the reticule"); + portENTER_CRITICAL(&__analogOutMux); + int channel=__pwmAllocateChannel(pin,true); // using option to clear/detach any existing channel for this pin + if (channel>=0) { + ledcSetup(channel,1000,8); // 1000Hz, 8 bit + ledcAttachPin(pin,channel); + ledcWrite(channel,value); + // just disconnect and go digital if value is 0 or 255 + if (value==0) { noTone(pin); digitalWrite(pin,LOW); } + if (value==255) { noTone(pin); digitalWrite(pin,HIGH); } + } + portEXIT_CRITICAL(&__analogOutMux); +} diff --git a/src/HAL/HAL_ESP32/HAL_ESP32.h b/src/HAL/HAL_ESP32/HAL_ESP32.h index ec23a973c..641756a59 100644 --- a/src/HAL/HAL_ESP32/HAL_ESP32.h +++ b/src/HAL/HAL_ESP32/HAL_ESP32.h @@ -21,7 +21,11 @@ // The stock ESP32 Release 1.0.0 BluetoothSerial.h library doesn't work // Copy the latest BluetoothSerial library (just its folder) from https://github.com/espressif/arduino-esp32 into // C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries -#ifdef SERIAL_C_BAUD_DEFAULT +#if SERIAL_C_BAUD_DEFAULT != OFF + #if SERIAL_C_BAUD_DEFAULT > 0 + #error "Bluetooth on ESP32 SERIAL_C_BAUD_DEFAULT gets set to a own device NAME STRING instead of the typical baud rate." + #endif + #include BluetoothSerial SerialC; #define HAL_SERIAL_C_ENABLED @@ -50,6 +54,8 @@ void analogWrite(int pin, int value) { void HAL_Init(void) { } +#include "Analog.h" + //-------------------------------------------------------------------------------------------------- // Internal MCU temperature (in degrees C) diff --git a/src/HAL/drivers/HAL_24LC.h b/src/HAL/drivers/HAL_24LC.h index 51fa1dfab..c35344ca5 100644 --- a/src/HAL/drivers/HAL_24LC.h +++ b/src/HAL/drivers/HAL_24LC.h @@ -22,7 +22,7 @@ class _eeprom { { if (!__firstCall) { // wait for any prior write to complete - while ((int32_t)(millis()-lastWrite)<5) {}; + while ((int32_t)(millis()-lastWrite) < 5) {}; } else { __firstCall=false; } @@ -38,7 +38,7 @@ class _eeprom { void update(uint16_t address, uint8_t data) { - if (data!=read(address)) write(address,data); + if (data != read(address)) write(address,data); } uint8_t read(uint16_t address) @@ -47,7 +47,7 @@ class _eeprom { if (!__firstCall) { // wait for any prior write to complete - while ((int32_t)(millis()-lastWrite)<5) {}; + while ((int32_t)(millis()-lastWrite) < 5) {}; } else { __firstCall=false; } @@ -68,5 +68,3 @@ class _eeprom { }; _eeprom EEPROM; - - diff --git a/src/HAL/drivers/NV_EEPROM.h b/src/HAL/drivers/NV_EEPROM.h index 99b27aa44..bfe4f12c0 100644 --- a/src/HAL/drivers/NV_EEPROM.h +++ b/src/HAL/drivers/NV_EEPROM.h @@ -97,7 +97,7 @@ class nvs { // read count bytes from EEPROM starting at position i void readBytes(uint16_t i, byte *v, uint8_t count) { - for (int j=0; j5000)) { + if (_dirtyPool && ((long)(millis()-_lastWrite) > 5000)) { timerAlarmsDisable(); EEPROM.commit(); timerAlarmsEnable(); @@ -29,7 +29,7 @@ class nvs { } void update(int i, byte j) { - if (EEPROM.read(i)!=j) { + if (EEPROM.read(i) != j) { EEPROM.write(i, j); _lastWrite=millis(); _dirtyPool=true; @@ -112,7 +112,7 @@ class nvs { // read count bytes from EEPROM starting at position i void readBytes(uint16_t i, byte *v, uint8_t count) { - for (int j=0; j4095) i=0; + for (int j=0; j < 20; j++) { + i++; if (i > 4095) i=0; dirtyW=bitRead(cacheWriteState[i/8],i%8); dirtyR=bitRead(cacheReadState[i/8],i%8); if (dirtyW || dirtyR) break; @@ -76,7 +76,7 @@ class nvs { void update(int i, byte j) { uint8_t k; k=read(i); - if (j!=k) { + if (j != k) { // store cache[i]=j; @@ -164,7 +164,7 @@ class nvs { // read count bytes from EEPROM starting at position i void readBytes(uint16_t i, byte *v, uint8_t count) { - for (int j=0; j4095) i=0; + for (int j=0; j < 20; j++) { + i++; if (i > 4095) i=0; dirtyW=bitRead(cacheWriteState[i/8],i%8); dirtyR=bitRead(cacheReadState[i/8],i%8); if (dirtyW || dirtyR) break; @@ -66,7 +66,7 @@ class nvs { } uint8_t read(int i) { - if (i>E2END2) { + if (i > E2END2) { i=i-(E2END2+1); int dirty=bitRead(cacheReadState[i/8],i%8); if (dirty) { @@ -85,10 +85,10 @@ class nvs { } void update(int i, byte j) { - if (i>E2END2) { + if (i > E2END2) { uint8_t k=read(i); i=i-(E2END2+1); - if (j!=k) { + if (j != k) { // store cache[i]=j; @@ -179,7 +179,7 @@ class nvs { // read count bytes from EEPROM starting at position i void readBytes(uint16_t i, byte *v, uint8_t count) { - for (int j=0; j=100) y-=100; + greg(JD,&y,&mo,&d); y-=2000; if (y >= 100) y-=100; double f1=fabs(LMT)+0.000139; h=floor(f1); @@ -38,8 +38,8 @@ class rtcw { // get the RTC's time (local standard time) void get(double &JD, double &LMT) { - if ((rtc.year()>=0) && (rtc.year()<=99) && (rtc.month()>=1) && (rtc.month()<=12) && (rtc.date()>=1) && (rtc.date()<=31) && - (rtc.hour()>=0) && (rtc.hour()<=23) && (rtc.minute()>=0) && (rtc.minute()<=59) && (rtc.second()>=0) && (rtc.second()<=59)) { + if ((rtc.year() >= 0) && (rtc.year() <= 99) && (rtc.month() >= 1) && (rtc.month() <= 12) && (rtc.date() >= 1) && (rtc.date() <= 31) && + (rtc.hour() >= 0) && (rtc.hour() <= 23) && (rtc.minute() >= 0) && (rtc.minute() <= 59) && (rtc.second() >= 0) && (rtc.second() <= 59)) { int y1=rtc.year(); if (y1>11) y1=y1+2000; else y1=y1+2100; JD=julian(y1,rtc.month(),rtc.date()); LMT=(rtc.hour()+(rtc.minute()/60.0)+(rtc.second()/3600.0)); @@ -49,7 +49,7 @@ class rtcw { bool active=false; }; -#elif defined(RTC_DS3231) +#elif RTC == DS3231 // ----------------------------------------------------------------------------------- // DS3231 RTC support // uses the default I2C port in most cases; though HAL_Wire can redirect to another port (as is done for the Teensy3.5/3.6) @@ -84,7 +84,7 @@ class rtcw { int yy,y,mo,d,h; double m,s; - greg(JD,&y,&mo,&d); yy=y; y-=2000; if (y>=100) y-=100; + greg(JD,&y,&mo,&d); yy=y; y-=2000; if (y >= 100) y-=100; double f1=fabs(LMT)+0.000139; h=floor(f1); @@ -107,8 +107,8 @@ class rtcw { #endif RtcDateTime now = _Rtc.GetDateTime(); - if ((now.Year()>=2018) && (now.Year()<=3000) && (now.Month()>=1) && (now.Month()<=12) && (now.Day()>=1) && (now.Day()<=31) && - (now.Hour()>=0) && (now.Hour()<=23) && (now.Minute()>=0) && (now.Minute()<=59) && (now.Second()>=0) && (now.Second()<=59)) { + if ((now.Year() >= 2018) && (now.Year() <= 3000) && (now.Month() >= 1) && (now.Month() <= 12) && (now.Day() >= 1) && (now.Day() <= 31) && + (now.Hour() >= 0) && (now.Hour() <= 23) && (now.Minute() >= 0) && (now.Minute() <= 59) && (now.Second() >= 0) && (now.Second() <= 59)) { JD=julian(now.Year(),now.Month(),now.Day()); LMT=(now.Hour()+(now.Minute()/60.0)+(now.Second()/3600.0)); } @@ -119,7 +119,7 @@ class rtcw { } }; -#elif defined(RTC_TEENSY) +#elif RTC == TEENSY // ----------------------------------------------------------------------------------- // TEENSY 3.2 RTC support @@ -140,7 +140,7 @@ class rtcw { int y,mo,d,h; double m,s; - greg(JD,&y,&mo,&d); y-=2000; if (y>=100) y-=100; + greg(JD,&y,&mo,&d); y-=2000; if (y >= 100) y-=100; double f1=fabs(LMT)+0.000139; h=floor(f1); @@ -162,8 +162,8 @@ class rtcw { TeensyTime = Teensy3Clock.get(); //get time from Teensy RTC setTime(TeensyTime); //set system time - if ((year()>=0) && (year()<=3000) && (month()>=1) && (month()<=12) && (day()>=1) && (day()<=31) && - (hour()>=0) && (hour()<=23) && (minute()>=0) && (minute()<=59) && (second()>=0) && (second()<=59)) + if ((year() >= 0) && (year() <= 3000) && (month() >= 1) && (month() <= 12) && (day() >= 1) && (day() <= 31) && + (hour() >= 0) && (hour() <= 23) && (minute() >= 0) && (minute() <= 59) && (second() >= 0) && (second() <= 59)) { int y1=year(); JD=julian(y1,month(),day()); diff --git a/src/lib/Command.h b/src/lib/Command.h index fd0581aab..c80b91703 100644 --- a/src/lib/Command.h +++ b/src/lib/Command.h @@ -8,7 +8,7 @@ class cb { bool checksum = false; bool add(char c) { // (chr)6 is a special status command for the LX200 protocol - if ((c==(char)6) && (cbp==0)) { + if ((c == (char)6) && (cbp == 0)) { #ifdef MOUNT_TYPE_ALTAZM cb[0]=':'; cb[1]=(char)6; cb[2]='A'; cb[3]=0; cbp=3; c='#'; #else @@ -18,30 +18,30 @@ class cb { // ignore spaces/lf/cr if ((c!=(char)32) && (c!=(char)10) && (c!=(char)13) && (c!=(char)6)) { - if (cbp>bufferSize-2) cbp=bufferSize-2; + if (cbp > bufferSize-2) cbp=bufferSize-2; cb[cbp]=c; cbp++; cb[cbp]=(char)0; } - if (c=='#') { + if (c == '#') { // validate the command frame, normal command - if (!(cbp>1) && ((cb[0]==':') || (cb[0]==';')) && (cb[cbp-1]=='#')) { flush(); return false; } - if (((cb[0]==':') || (cb[0]==';')) && (cb[1]=='#') && (cb[2]==0)) { flush(); return false; } + if (!(cbp > 1) && ((cb[0] == ':') || (cb[0] == ';')) && (cb[cbp-1] == '#')) { flush(); return false; } + if (((cb[0] == ':') || (cb[0] == ';')) && (cb[1] == '#') && (cb[2] == 0)) { flush(); return false; } - checksum=(cb[0]==';'); + checksum=(cb[0] == ';'); if (checksum) { byte len=strlen(cb)-1; // Minimum length for a valid command is 5 ';CCS#' - if (len<5) { + if (len < 5) { flush(); cb[0]=':'; cb[1]=(char)6; cb[2]='0'; cb[3]='#'; cb[4]=0; cbp=4; return true; } // checksum the data, for example ";111111CCS#". I don't include the command frame in the checksum. The error response is a checksumed string "CK_FAILS#" to request re-transmit. - byte cks=0; for (int cksCount0=1; cksCount04) memmove(pb,(char *)&cb[3],cbp-4); pb[cbp-4]=0; + if (cbp > 4) memmove(pb,(char *)&cb[3],cbp-4); pb[cbp-4]=0; return pb; } char* getSeq() { @@ -75,8 +75,8 @@ class cb { } bool ready() { if (!cbp) return false; - if ((cb[cbp-1]=='#') && (cbp==1)) flush(); - return (cb[cbp-1]=='#'); + if ((cb[cbp-1] == '#') && (cbp == 1)) flush(); + return (cb[cbp-1] == '#'); } bool flush() { cbp=0; @@ -91,4 +91,3 @@ class cb { int cbp=0; char seq=0; }; - diff --git a/src/lib/Coord.h b/src/lib/Coord.h index 58faf7cd4..de6e8bd61 100644 --- a/src/lib/Coord.h +++ b/src/lib/Coord.h @@ -1,70 +1,69 @@ double getInstrAxis1() { - cli(); long p1=posAxis1; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)StepsPerDegreeAxis1; - cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) p=p+180.0-360.0; + cli(); long p1=posAxis1; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)AXIS1_STEPS_PER_DEGREE; + cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) p=p+180.0-360.0; return p; } double getInstrAxis2() { - cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) q=180.0-q; if (q>180.0) q-=360.0; if (q<-180.0) q+=360.0; + cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) q=180.0-q; if (q > 180.0) q-=360.0; if (q < -180.0) q+=360.0; return q; } int getInstrPierSide() { if (atHome) return PierSideNone; - cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) return PierSideWest; else return PierSideEast; + cli(); long p2=posAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) return PierSideWest; else return PierSideEast; } void setIndexAxis1(double axis1, int newPierSide) { // sky=pos+index, index=sky-pos - if (newPierSide==PierSideWest) axis1=axis1+180.0; - cli(); long p1=posAxis1; sei(); indexAxis1=axis1-(double)p1/(double)StepsPerDegreeAxis1; - indexAxis1Steps=(long)(indexAxis1*(double)StepsPerDegreeAxis1); + if (newPierSide == PierSideWest) axis1=axis1+180.0; + cli(); long p1=posAxis1; sei(); indexAxis1=axis1-(double)p1/(double)AXIS1_STEPS_PER_DEGREE; + indexAxis1Steps=(long)(indexAxis1*(double)AXIS1_STEPS_PER_DEGREE); } void setIndexAxis2(double axis2, int newPierSide) { - if (latitude>=0) { if (newPierSide==PierSideWest) axis2=180.0-axis2; } else { if (newPierSide==PierSideWest) axis2=-180.0-axis2; } - if (axis2>360.0) axis2-=360.0; if (axis2<-360.0) axis2+=360.0; - cli(); long p2=posAxis2; sei(); indexAxis2=axis2-(double)p2/(double)StepsPerDegreeAxis2; - indexAxis2Steps=(long)(indexAxis2*(double)StepsPerDegreeAxis2); + if (latitude >= 0) { if (newPierSide == PierSideWest) axis2=180.0-axis2; } else { if (newPierSide == PierSideWest) axis2=-180.0-axis2; } + if (axis2 > 360.0) axis2-=360.0; if (axis2 < -360.0) axis2+=360.0; + cli(); long p2=posAxis2; sei(); indexAxis2=axis2-(double)p2/(double)AXIS2_STEPS_PER_DEGREE; + indexAxis2Steps=(long)(indexAxis2*(double)AXIS2_STEPS_PER_DEGREE); } void setTargetAxis1(double axis1, int newPierSide) { - if (newPierSide==PierSideWest) axis1=axis1+180.0; - long p1=(double)(axis1-indexAxis1)*(double)StepsPerDegreeAxis1; cli(); targetAxis1.part.m=p1; targetAxis2.part.f=0; sei(); + if (newPierSide == PierSideWest) axis1=axis1+180.0; + long p1=(double)(axis1-indexAxis1)*(double)AXIS1_STEPS_PER_DEGREE; cli(); targetAxis1.part.m=p1; targetAxis2.part.f=0; sei(); } void setTargetAxis2(double axis2, int newPierSide) { - if (latitude>=0) { if (newPierSide==PierSideWest) axis2=180.0-axis2; } else { if (newPierSide==PierSideWest) axis2=-180.0-axis2; } - if (axis2>360.0) axis2-=360.0; if (axis2<-360.0) axis2+=360.0; - long p2=(double)(axis2-indexAxis2)*(double)StepsPerDegreeAxis2; cli(); targetAxis2.part.m=p2; targetAxis2.part.f=0; sei(); + if (latitude >= 0) { if (newPierSide == PierSideWest) axis2=180.0-axis2; } else { if (newPierSide == PierSideWest) axis2=-180.0-axis2; } + if (axis2 > 360.0) axis2-=360.0; if (axis2 < -360.0) axis2+=360.0; + long p2=(double)(axis2-indexAxis2)*(double)AXIS2_STEPS_PER_DEGREE; cli(); targetAxis2.part.m=p2; targetAxis2.part.f=0; sei(); } double getTargetAxis1() { - cli(); long p1=targetAxis1.part.m; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)StepsPerDegreeAxis1; - cli(); long p2=targetAxis2.part.m; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) p=p+180.0-360.0; + cli(); long p1=targetAxis1.part.m; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)AXIS1_STEPS_PER_DEGREE; + cli(); long p2=targetAxis2.part.m; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) p=p+180.0-360.0; return p; } double getTargetAxis2() { - cli(); long p2=targetAxis2.part.m; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) q=180.0-q; if (q>180.0) q-=360.0; if (q<-180.0) q+=360.0; + cli(); long p2=targetAxis2.part.m; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) q=180.0-q; if (q > 180.0) q-=360.0; if (q < -180.0) q+=360.0; return q; } double getStartAxis1() { - cli(); long p1=startAxis1; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)StepsPerDegreeAxis1; - cli(); long p2=startAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) p=p+180.0-360.0; + cli(); long p1=startAxis1; sei(); double p=(double)((long)p1+indexAxis1Steps)/(double)AXIS1_STEPS_PER_DEGREE; + cli(); long p2=startAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) p=p+180.0-360.0; return p; } double getStartAxis2() { - cli(); long p2=startAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)StepsPerDegreeAxis2; - if ((q<-90.0) || (q>90.0)) q=180.0-q; if (q>180.0) q-=360.0; if (q<-180.0) q+=360.0; + cli(); long p2=startAxis2; sei(); double q=(double)((long)p2+indexAxis2Steps)/(double)AXIS2_STEPS_PER_DEGREE; + if ((q < -90.0) || (q > 90.0)) q=180.0-q; if (q > 180.0) q-=360.0; if (q < -180.0) q+=360.0; return q; } - diff --git a/src/lib/Focuser.h b/src/lib/Focuser.h index f82744755..f6adf948a 100644 --- a/src/lib/Focuser.h +++ b/src/lib/Focuser.h @@ -59,19 +59,19 @@ class focuser { // sets logic state for reverse motion void setReverseState(int reverseState) { this->reverseState=reverseState; - if (reverseState==LOW) forwardState=HIGH; else forwardState=LOW; + if (reverseState == LOW) forwardState=HIGH; else forwardState=LOW; } // sets logic state for disabling stepper driver void setDisableState(boolean disableState) { this->disableState=disableState; - if (disableState==LOW) enableState=HIGH; else enableState=LOW; + if (disableState == LOW) enableState=HIGH; else enableState=LOW; if (enPin!=-1) { pinMode(enPin,OUTPUT); enableDriver(); currentlyDisabled=false; } } // allows enabling/disabling stepper driver void powerDownActive(boolean active) { - if (enPin==-1) { pda=false; return; } + if (enPin == -1) { pda=false; return; } pda=active; if (pda) { pinMode(enPin,OUTPUT); disableDriver(); currentlyDisabled=true; } } @@ -79,7 +79,7 @@ class focuser { // set movement rate in microns/second void setMoveRate(double rate) { moveRate=rate*spm; // in steps per second - if (moveRate>spsMax) moveRate=spsMax; // limit to maxRate + if (moveRate > spsMax) moveRate=spsMax; // limit to maxRate } // check if moving @@ -111,54 +111,54 @@ class focuser { // sets current position in microns void setPosition(double pos) { spos=round(pos*spm); - if (spossmax) spos=smax; + if (spos < smin) spos=smin; if (spos > smax) spos=smax; target.part.m=spos; target.part.f=0; } // sets target position in microns void setTarget(double pos) { target.part.m=round(pos*spm); target.part.f=0; - if ((long)target.part.msmax) target.part.m=smax; + if ((long)target.part.m < smin) target.part.m=smin; if ((long)target.part.m > smax) target.part.m=smax; } // sets target relative position in microns void relativeTarget(double pos) { target.part.m+=round(pos*spm); target.part.f=0; - if ((long)target.part.msmax) target.part.m=smax; + if ((long)target.part.m < smin) target.part.m=smin; if ((long)target.part.m > smax) target.part.m=smax; } // do automatic movement void move() { target.fixed+=delta.fixed; // stop at limits - if (((long)target.part.msmax)) delta.fixed=0; + if (((long)target.part.m < smin) || ((long)target.part.m > smax)) delta.fixed=0; } - // follow( (trackingState==TrackingMoveTo) || guideDirAxis1 || guideDirAxis2) ); + // follow( (trackingState == TrackingMoveTo) || guideDirAxis1 || guideDirAxis2) ); void follow(boolean slewing) { // if enabled and the timeout has elapsed, disable the stepper driver - if (pda && !currentlyDisabled && ((micros()-lastPhysicalMove)>10000000L)) { disableDriver(); currentlyDisabled=true; } + if (pda && !currentlyDisabled && ((micros()-lastPhysicalMove) > 10000000L)) { disableDriver(); currentlyDisabled=true; } // write position to non-volatile storage if not moving for FOCUSER_WRITE_DELAY milliseconds if ((spos!=lastPos)) { lastMove=millis(); lastPos=spos; } if (!slewing && (spos!=readPos())) { // needs updating and enough time has passed? - if ((long)(millis()-lastMove)>FOCUSER_WRITE_DELAY) writePos(spos); + if ((long)(millis()-lastMove) > FOCUSER_WRITE_DELAY) writePos(spos); } unsigned long microsNow=micros(); - if ((long)(microsNow-nextPhysicalMove)>0) { + if ((long)(microsNow-nextPhysicalMove) > 0) { nextPhysicalMove=microsNow+(unsigned long)(maxRate*1000.0); - if ((spos<(long)target.part.m) && (spos(long)target.part.m) && (spos>smin)) { + if ((spos > (long)target.part.m) && (spos > smin)) { if (pda && currentlyDisabled) { enableDriver(); currentlyDisabled=false; delayMicroseconds(5); } digitalWrite(stepPin,LOW); delayMicroseconds(5); digitalWrite(dirPin,reverseState); delayMicroseconds(5); @@ -182,15 +182,15 @@ class focuser { } void enableDriver() { - if (enPin==-1) return; + if (enPin == -1) return; // for Aux5/Aux6 (DAC) support for stepper driver EN control on MaxPCB Aux5=A21=66 Aux6=A22=67 - if ((enPin==66) || (enPin==67)) { if (enableState==HIGH) analogWrite(enPin,255); else analogWrite(enPin,0); delayMicroseconds(30); } else + if ((enPin == 66) || (enPin == 67)) { if (enableState == HIGH) analogWrite(enPin,255); else analogWrite(enPin,0); delayMicroseconds(30); } else { digitalWrite(enPin,enableState); delayMicroseconds(5); } } void disableDriver() { - if (enPin==-1) return; - if ((enPin==66) || (enPin==67)) { if (disableState==HIGH) analogWrite(enPin,255); else analogWrite(enPin,0); delayMicroseconds(30); } else + if (enPin == -1) return; + if ((enPin == 66) || (enPin == 67)) { if (disableState == HIGH) analogWrite(enPin,255); else analogWrite(enPin,0); delayMicroseconds(30); } else { digitalWrite(enPin,disableState); delayMicroseconds(5); } } diff --git a/src/lib/FocuserDC.h b/src/lib/FocuserDC.h index 8a17b446c..1dadefb07 100644 --- a/src/lib/FocuserDC.h +++ b/src/lib/FocuserDC.h @@ -69,7 +69,7 @@ class focuserDC { // sets logic state for reverse motion void setReverseState(int reverseState) { - if (reverseState==HIGH) reverse=true; else reverse=false; + if (reverseState == HIGH) reverse=true; else reverse=false; } // sets logic state for disabling stepper driver @@ -85,7 +85,7 @@ class focuserDC { void setMoveRate(double rate) { // a rate of 1000 gives 1mm/second (fastest) moveRate=rate*spm; // in steps per second, for a DC motor a step is 1 micron. - if (moveRate>spsMax) moveRate=spsMax; // limit to maxRate + if (moveRate > spsMax) moveRate=spsMax; // limit to maxRate } // check if moving @@ -120,7 +120,7 @@ class focuserDC { // sets current position in microns void setPosition(double pos) { spos=round(pos*spm); - if (spossmax) spos=smax; + if (spos < smin) spos=smin; if (spos > smax) spos=smax; target.part.m=spos; target.part.f=0; } @@ -128,43 +128,43 @@ class focuserDC { void setTarget(double pos) { dcMotor.setPower((moveRate/1000.0)*powerFor1mmSec); target.part.m=round(pos*spm); target.part.f=0; - if ((long)target.part.msmax) target.part.m=smax; + if ((long)target.part.m < smin) target.part.m=smin; if ((long)target.part.m > smax) target.part.m=smax; } // sets target relative position in microns void relativeTarget(double pos) { dcMotor.setPower((moveRate/1000.0)*powerFor1mmSec); target.part.m+=round(pos*spm); target.part.f=0; - if ((long)target.part.msmax) target.part.m=smax; + if ((long)target.part.m < smin) target.part.m=smin; if ((long)target.part.m > smax) target.part.m=smax; } // do automatic movement void move() { target.fixed+=delta.fixed; // stop at limits - if (((long)target.part.msmax)) delta.fixed=0; + if (((long)target.part.m < smin) || ((long)target.part.m > smax)) delta.fixed=0; } - // follow( (trackingState==TrackingMoveTo) || guideDirAxis1 || guideDirAxis2) ); + // follow( (trackingState == TrackingMoveTo) || guideDirAxis1 || guideDirAxis2) ); void follow(boolean slewing) { // write position to non-volatile storage if not moving for FOCUSER_WRITE_DELAY milliseconds if ((spos!=lastPos)) { lastMove=millis(); lastPos=spos; } if (!slewing && (spos!=readPos())) { // needs updating and enough time has passed? - if ((long)(millis()-lastMove)>FOCUSER_WRITE_DELAY) writePos(spos); + if ((long)(millis()-lastMove) > FOCUSER_WRITE_DELAY) writePos(spos); } unsigned long tempMs=millis(); - if ((long)(tempMs-nextPhysicalMove)>0) { + if ((long)(tempMs-nextPhysicalMove) > 0) { nextPhysicalMove=tempMs+(unsigned long)maxRate; if (moving()) { - if ((spos<(long)target.part.m) && (spos(long)target.part.m) && (spos>smin)) { + if ((spos > (long)target.part.m) && (spos > smin)) { if (reverse) dcMotor.setDirectionOut(); else dcMotor.setDirectionIn(); spos--; lastPhysicalMove=millis(); diff --git a/src/lib/Julian.h b/src/lib/Julian.h index caca39245..08daa729d 100644 --- a/src/lib/Julian.h +++ b/src/lib/Julian.h @@ -4,7 +4,7 @@ // Convert Gregorian date (Y,M,D) to Julian day number double julian(int Year, int Month, int Day) { - if ((Month==1) || (Month==2)) { Year--; Month=Month+12; } + if ((Month == 1) || (Month == 2)) { Year--; Month=Month+12; } double B=2.0-floor(Year/100.0)+floor(Year/400.0); return (B+floor(365.25*Year)+floor(30.6001*(Month+1.0))+Day+1720994.5); //+(Time/24.0); } @@ -17,7 +17,7 @@ void greg(double JulianDay, int *Year, int *Month, int *Day) { I=floor(JulianDay); F=0.0; // JD-I; - if (I>2299160.0) { + if (I > 2299160.0) { A=int((I-1867216.25)/36524.25); B=I+1.0+A-floor(A/4.0); } else B=I; @@ -29,8 +29,8 @@ void greg(double JulianDay, int *Year, int *Month, int *Day) { D1=C-E+F-floor(30.6001*G); *Day=floor(D1); - if (G<13.5) *Month=floor(G-1.0); else *Month=floor(G-13.0); - if (*Month>2.5) *Year=floor(D-4716.0); else *Year=floor(D-4715.0); + if (G < 13.5) *Month=floor(G-1.0); else *Month=floor(G-13.0); + if (*Month > 2.5) *Year=floor(D-4716.0); else *Year=floor(D-4715.0); } // Utility function for extracting date components from a string @@ -95,4 +95,3 @@ int CompilerDay(const char* date) { double CompilerDateToJulian() { return julian(CompilerYear(__DATE__), CompilerMonth(__DATE__), CompilerDay(__DATE__)); } - diff --git a/src/lib/Library.h b/src/lib/Library.h index 8f775e221..a0ac59618 100644 --- a/src/lib/Library.h +++ b/src/lib/Library.h @@ -58,7 +58,7 @@ class Library libRec_t readRec(int address); void writeRec(int address, libRec_t data); void clearRec(int address); - inline double degRange(double d) { while (d>=360.0) d-=360.0; while (d< 0.0) d+=360.0; return d; } + inline double degRange(double d) { while (d >= 360.0) d-=360.0; while (d < 0.0) d+=360.0; return d; } int catalog; @@ -75,7 +75,7 @@ Library::Library() { catalog=0; - byteMin=200+PECBufferSize; + byteMin=200+pecBufferSize; byteMax=E2END-100; @@ -98,7 +98,7 @@ void Library::init() { boolean Library::setCatalog(int num) { - if ((num<0) || (num>14)) return false; + if ((num < 0) || (num > 14)) return false; catalog=num; return firstRec(); @@ -107,13 +107,13 @@ boolean Library::setCatalog(int num) void Library::writeVars(char* name, int code, double RA, double Dec) { libRec_t work; - for (int l=0; l<11; l++) work.libRec.name[l] = name[l]; + for (int l=0; l < 11; l++) work.libRec.name[l] = name[l]; work.libRec.code = (code | (catalog<<4)); // convert into ulong, RA=0..360 RA=degRange(RA)/360.0; // convert into ulong, Dec=0..180 - if (Dec>90.0) Dec=90.0; if (Dec<-90.0) Dec=-90.0; Dec=Dec+90.0; Dec=Dec/180.0; + if (Dec > 90.0) Dec=90.0; if (Dec < -90.0) Dec=-90.0; Dec=Dec+90.0; Dec=Dec/180.0; uint16_t r=round(RA*65536.0); uint16_t d=round(Dec*65536.0); @@ -131,9 +131,9 @@ void Library::readVars(char* name, int* code, double* RA, double* Dec) int cat = work.libRec.code>>4; // empty? or not found - if ((cat==15) || (cat!=catalog)) { name[0]=0; *code=0; *RA=0.0; *Dec=0.0; return; } + if ((cat == 15) || (cat!=catalog)) { name[0]=0; *code=0; *RA=0.0; *Dec=0.0; return; } - for (int l=0; l<11; l++) name[l]=work.libRec.name[l]; name[11]=0; + for (int l=0; l < 11; l++) name[l]=work.libRec.name[l]; name[11]=0; *code = work.libRec.code & 15; uint16_t r = work.libRec.RA; @@ -156,15 +156,15 @@ libRec_t Library::readRec(int address) void Library::writeRec(int address, libRec_t data) { - if ((address>=0) && (address= 0) && (address < recMax)) { int l=address*rec_size+byteMin; - for (int m=0;m<16;m++) nv.write(l+m,data.libRecBytes[m]); + for (int m=0;m < 16;m++) nv.write(l+m,data.libRecBytes[m]); } } void Library::clearRec(int address) { - if ((address>=0) && (address= 0) && (address < recMax)) { int l=address*rec_size+byteMin; int code=15<<4; nv.write(l+11,(byte)code); // catalog code 15 = deleted @@ -179,7 +179,7 @@ boolean Library::firstRec() recPos=0; work=readRec(recPos); int cat=(int)work.libRec.code>>4; - if ((work.libRec.name[0]!='$') && (cat==catalog)) return true; + if ((work.libRec.name[0]!='$') && (cat == catalog)) return true; // otherwise find the first one, if it exists return nextRec(); @@ -195,14 +195,14 @@ boolean Library::nameRec() do { - recPos++; if (recPos>=recMax) { break; } + recPos++; if (recPos >= recMax) { break; } work=readRec(recPos); cat=(int)work.libRec.code>>4; - if ((work.libRec.name[0]=='$') && (cat==catalog)) break; - } while (recPos=recMax) { recPos=recMax-1; return false; } + if ((work.libRec.name[0] == '$') && (cat == catalog)) break; + } while (recPos < recMax); + if (recPos >= recMax) { recPos=recMax-1; return false; } return true; } @@ -217,14 +217,14 @@ boolean Library::firstFreeRec() do { - recPos++; if (recPos>=recMax) { break; } + recPos++; if (recPos >= recMax) { break; } work=readRec(recPos); cat=(int)work.libRec.code>>4; - if (cat==15) break; // unused? - } while (recPos=recMax) { recPos=recMax-1; return false; } + if (cat == 15) break; // unused? + } while (recPos < recMax); + if (recPos >= recMax) { recPos=recMax-1; return false; } return true; } @@ -238,13 +238,13 @@ boolean Library::prevRec() do { - recPos--; if (recPos<0) break; + recPos--; if (recPos < 0) break; work=readRec(recPos); cat=(int)work.libRec.code>>4; - if ((work.libRec.name[0]!='$') && (cat==catalog)) break; - } while (recPos>=0); - if (recPos<0) { recPos=0; return false; } + if ((work.libRec.name[0]!='$') && (cat == catalog)) break; + } while (recPos >= 0); + if (recPos < 0) { recPos=0; return false; } return true; } @@ -258,13 +258,13 @@ boolean Library::nextRec() do { - recPos++; if (recPos>=recMax) break; + recPos++; if (recPos >= recMax) break; work=readRec(recPos); cat=(int)work.libRec.code>>4; - if ((work.libRec.name[0]!='$') && (cat==catalog)) break; - } while (recPos=recMax) { recPos=recMax-1; return false; } + if ((work.libRec.name[0]!='$') && (cat == catalog)) break; + } while (recPos < recMax); + if (recPos >= recMax) { recPos=recMax-1; return false; } return true; } @@ -278,14 +278,14 @@ boolean Library::gotoRec(int num) int l,r=0; int c=0; - for (l=0;l>4; - if ((work.libRec.name[0]!='$') && (cat==catalog)) c++; - if (c==num) break; + if ((work.libRec.name[0]!='$') && (cat == catalog)) c++; + if (c == num) break; } - if (c==num) { recPos=r; return true; } else return false; + if (c == num) { recPos=r; return true; } else return false; } // count all catalog records @@ -296,11 +296,11 @@ int Library::recCount() int cat; int c=0; - for (int l=0;l>4; - if ((work.libRec.name[0]!='$') && (cat==catalog)) c++; + if ((work.libRec.name[0]!='$') && (cat == catalog)) c++; } return c; @@ -314,11 +314,11 @@ int Library::recCountAll() int cat; int c=0; - for (int l=0;l>4; - if ((cat>=0) && (cat<=14)) c++; + if ((cat >= 0) && (cat <= 14)) c++; } return c; @@ -340,7 +340,7 @@ void Library::clearCurrentRec() work=readRec(recPos); cat=(int)work.libRec.code>>4; - if (cat==catalog) clearRec(recPos); + if (cat == catalog) clearRec(recPos); } // mark all catalog records as empty @@ -350,16 +350,16 @@ void Library::clearLib() int cat; - for (int l=0;l>4; - if (cat==catalog) clearRec(l); + if (cat == catalog) clearRec(l); } } // mark all records as empty void Library::clearAll() { - for (int l=0;l6) return false; - for (int l=0; l'9')) return false; + if (len > 6) return false; + for (int l=0; l < len; l++) { + if ((l == 0) && ((a[l] == '+') || (a[l] == '-')) && sign) continue; + if ((a[l] < '0') || (a[l] > '9')) return false; } long l=atol(a); - if ((l<-32767) || (l>32768)) return false; + if ((l < -32767) || (l > 32768)) return false; *i=l; return true; } @@ -19,10 +19,10 @@ bool atoi2(char *a, int *i, bool sign=true) { bool atof2(char *a, double *d, bool sign=true) { int dc=0; int len=strlen(a); - for (int l=0; l'9')) return false; + for (int l=0; l < len; l++) { + if ((l == 0) && ((a[l] == '+') || (a[l] == '-')) && sign) continue; + if (a[l] == '.') { if (dc == 0) { dc++; continue; } else return false; } + if ((a[l] < '0') || (a[l] > '9')) return false; } *d=atof(a); return true; @@ -30,25 +30,25 @@ bool atof2(char *a, double *d, bool sign=true) { // numeric help double timeRange(double t) { - while (t>=24.0) t-=24.0; - while (t< 0.0) t+=24.0; + while (t >= 24.0) t-=24.0; + while (t < 0.0) t+=24.0; return t; } double haRange(double d) { - while (d>=180.0) d-=360.0; - while (d<-180.0) d+=360.0; + while (d >= 180.0) d-=360.0; + while (d < -180.0) d+=360.0; return d; } double degRange(double d) { - while (d>=360.0) d-=360.0; - while (d< 0.0) d+=360.0; + while (d >= 360.0) d-=360.0; + while (d < 0.0) d+=360.0; return d; } double dist(double a, double b) { - if (a>b) return a-b; else return b-a; + if (a > b) return a-b; else return b-a; } double angDist(double h, double d, double h1, double d1) { diff --git a/src/lib/PushButton.h b/src/lib/PushButton.h index a7e8be832..67ca38372 100644 --- a/src/lib/PushButton.h +++ b/src/lib/PushButton.h @@ -17,11 +17,11 @@ class button { _state=digitalRead(_pin); if (lastState!=_state) { _avgPulseDuration=((_avgPulseDuration*49.0)+(double)(millis()-_stableStartMs))/50.0; _stableStartMs=millis(); } _stableMs=(long)(millis()-_stableStartMs); - if (_stableMs>3000UL) { _avgPulseDuration=((_avgPulseDuration*4.0)+2000.0)/5.0; } - if (_stableMs>_debounceMs) { - if ((_lastStableState==_UP) && (_state==_DOWN)) { + if (_stableMs > 3000UL) { _avgPulseDuration=((_avgPulseDuration*4.0)+2000.0)/5.0; } + if (_stableMs > _debounceMs) { + if ((_lastStableState == _UP) && (_state == _DOWN)) { static unsigned long lastPressTime=0; - if ((_wasPressed) && (millis()-lastPressTime<500)) _wasDoublePressed=true; + if ((_wasPressed) && (millis()-lastPressTime < 500)) _wasDoublePressed=true; _wasPressed=true; lastPressTime=millis(); } @@ -29,7 +29,7 @@ class button { } } // is the button down - bool isDown() { if ((_stableMs>_debounceMs) && (_state==_DOWN)) return true; else return false; } + bool isDown() { if ((_stableMs > _debounceMs) && (_state == _DOWN)) return true; else return false; } // was the button down since last checked bool wasPressed(boolean peek=false) { if (_wasPressed) { if (!peek) _wasPressed=false; return true; } else return false; } // was the button down since last checked @@ -39,13 +39,13 @@ class button { // clear pressed state void clearPress() {_wasPressed=false; } // is the button up - bool isUp() { if ((_stableMs>_debounceMs) && (_state==_UP)) return true; else return false; } + bool isUp() { if ((_stableMs > _debounceMs) && (_state == _UP)) return true; else return false; } // number of ms down - long timeDown() { if ((_stableMs>_debounceMs) && (_state==_DOWN)) return _stableMs; else return 0; } + long timeDown() { if ((_stableMs > _debounceMs) && (_state == _DOWN)) return _stableMs; else return 0; } // number of ms up - long timeUp() { if ((_stableMs>_debounceMs) && (_state==_UP)) return _stableMs; else return 0; } + long timeUp() { if ((_stableMs > _debounceMs) && (_state == _UP)) return _stableMs; else return 0; } // check to see if this button has the SHC tone - boolean hasTone() { if (fabs(_avgPulseDuration-40.0)<5.0) return true; else return false; } + boolean hasTone() { if (fabs(_avgPulseDuration-40.0) < 5.0) return true; else return false; } double toneFreq() { return _avgPulseDuration; } private: int _pin; @@ -60,4 +60,3 @@ class button { int _UP = HIGH; int _DOWN = LOW; }; - diff --git a/src/lib/Rotator.h b/src/lib/Rotator.h index bd7893adb..2ab86a096 100644 --- a/src/lib/Rotator.h +++ b/src/lib/Rotator.h @@ -55,19 +55,19 @@ class rotator { // sets logic state for reverse motion void setReverseState(int reverseState) { this->reverseState=reverseState; - if (reverseState==LOW) forwardState=HIGH; else forwardState=LOW; + if (reverseState == LOW) forwardState=HIGH; else forwardState=LOW; } // sets logic state for disabling stepper driver void setDisableState(boolean disableState) { this->disableState=disableState; - if (disableState==LOW) enableState=HIGH; else enableState=LOW; + if (disableState == LOW) enableState=HIGH; else enableState=LOW; if (enPin!=-1) { pinMode(enPin,OUTPUT); enableDriver(); currentlyDisabled=false; } } // allows enabling/disabling stepper driver void powerDownActive(boolean active) { - if (enPin==-1) { pda=false; return; } + if (enPin == -1) { pda=false; return; } pda=active; if (pda) { pinMode(enPin,OUTPUT); disableDriver(); currentlyDisabled=true; } } @@ -116,7 +116,7 @@ class rotator { // set movement rate in deg/second (continuous mode) void setMoveRate(double rate) { moveRate=rate*spd; // in steps per second - if (moveRate>spsMax) moveRate=spsMax; // limit to maxRate + if (moveRate > spsMax) moveRate=spsMax; // limit to maxRate } // check if moving @@ -137,7 +137,7 @@ class rotator { fixed_t xl; xl.part.m=(long)(increment*spd*1000.0); xl.fixed/=1000; target.fixed+=xl.fixed; - if ((long)target.part.m>smax) { target.part.m=smax; target.part.f=0; } + if ((long)target.part.m > smax) { target.part.m=smax; target.part.f=0; } } } @@ -149,7 +149,7 @@ class rotator { fixed_t xl; xl.part.m=(long)(increment*spd*1000.0); xl.fixed/=1000; target.fixed-=xl.fixed; - if ((long)target.part.msmax) spos=smax; + if (spos < smin) spos=smin; if (spos > smax) spos=smax; target.part.m=spos; target.part.f=0; } // set target void setTarget(double deg) { target.part.m=deg*spd; target.part.f=0; - if ((long)target.part.msmax) target.part.m=smax; + if ((long)target.part.m < smin) target.part.m=smin; if ((long)target.part.m > smax) target.part.m=smax; } // do de-rotate movement void move(boolean tracking) { if (DR && tracking) target.fixed+=deltaDR.fixed; target.fixed+=delta.fixed; - if (((long)target.part.msmax)) { DR=false; delta.fixed=0; deltaDR.fixed=0; } + if (((long)target.part.m < smin) || ((long)target.part.m > smax)) { DR=false; delta.fixed=0; deltaDR.fixed=0; } } #ifdef MOUNT_TYPE_ALTAZM @@ -196,20 +196,20 @@ class rotator { #endif void follow() { - if (pda && !currentlyDisabled && ((micros()-lastPhysicalMove)>10000000L)) { currentlyDisabled=true; disableDriver(); } + if (pda && !currentlyDisabled && ((micros()-lastPhysicalMove) > 10000000L)) { currentlyDisabled=true; disableDriver(); } unsigned long microsNow=micros(); - if ((long)(microsNow-nextPhysicalMove)>0) { + if ((long)(microsNow-nextPhysicalMove) > 0) { nextPhysicalMove=microsNow+(unsigned long)(maxRate*1000.0); - if ((spos<(long)target.part.m) && (spos(long)target.part.m) && (spos>smin)) { + if ((spos > (long)target.part.m) && (spos > smin)) { if (pda && currentlyDisabled) { currentlyDisabled=false; enableDriver(); delayMicroseconds(5); } digitalWrite(stepPin,LOW); delayMicroseconds(5); digitalWrite(dirPin,reverseState); delayMicroseconds(5); @@ -222,20 +222,20 @@ class rotator { private: void enableDriver() { - if (enPin==-1) return; + if (enPin == -1) return; // for Aux5/Aux6 (DAC) support for stepper driver EN control on MaxPCB #if defined(A21) && defined(A22) - if (enPin==A21) { if (enableState==HIGH) analogWrite(A21,1024); else analogWrite(A21,0); return; } - if (enPin==A22) { if (enableState==HIGH) analogWrite(A22,1024); else analogWrite(A22,0); return; } + if (enPin == A21) { if (enableState == HIGH) analogWrite(A21,1024); else analogWrite(A21,0); return; } + if (enPin == A22) { if (enableState == HIGH) analogWrite(A22,1024); else analogWrite(A22,0); return; } #endif digitalWrite(enPin,enableState); } void disableDriver() { - if (enPin==-1) return; + if (enPin == -1) return; #if defined(A21) && defined(A22) - if (enPin==A21) { if (disableState==HIGH) analogWrite(A21,1024); else analogWrite(A21,0); return; } - if (enPin==A22) { if (disableState==HIGH) analogWrite(A22,1024); else analogWrite(A22,0); return; } + if (enPin == A21) { if (disableState == HIGH) analogWrite(A21,1024); else analogWrite(A21,0); return; } + if (enPin == A22) { if (disableState == HIGH) analogWrite(A22,1024); else analogWrite(A22,0); return; } #endif digitalWrite(enPin,disableState); } @@ -251,8 +251,8 @@ class rotator { // one minute of HA in degrees=15/60=0.25 double a1=ParallacticAngle(HA-0.125,Dec); double a2=ParallacticAngle(HA+0.125,Dec); - if ((a1>+90.0) && (a2<-90.0)) a2+=360.0; - if ((a1<-90.0) && (a2>+90.0)) a1+=360.0; + if ((a1 > +90.0) && (a2 < -90.0)) a2+=360.0; + if ((a1 < -90.0) && (a2 > +90.0)) a1+=360.0; return (a2-a1)/60.0; /* double x=cos(Dec*Rad)*tan(latitude*Rad)-sin(Dec*Rad)*cos(HA*Rad); diff --git a/src/lib/SoftSPI.h b/src/lib/SoftSPI.h index 78db1f051..e09a5407d 100644 --- a/src/lib/SoftSPI.h +++ b/src/lib/SoftSPI.h @@ -10,11 +10,7 @@ class bbspi { _cs=cs; pinMode(cs,OUTPUT); digitalWrite(cs,HIGH); delayMicroseconds(1); _sck=sck; pinMode(_sck,OUTPUT); digitalWrite(_sck,HIGH); - - _miso=miso; -#ifndef ESP8266_CONTROL_ON - pinMode(_miso,INPUT); -#endif + _miso=miso; if (_miso >= 0) pinMode(_miso,INPUT); _mosi=mosi; pinMode(_mosi,OUTPUT); digitalWrite(cs,LOW); delayMicroseconds(1); @@ -36,17 +32,13 @@ class bbspi { { uint8_t data_in = 0; - for(int i=7; i>=0; i--) + for(int i=7; i >= 0; i--) { digitalWrite(_sck,LOW); digitalWrite(_mosi,bitRead(data_out,i)); delayMicroseconds(1); digitalWrite(_sck,HIGH); -#ifdef ESP8266_CONTROL_ON - bitWrite(data_in,i,0); -#else - bitWrite(data_in,i,digitalRead(_miso)); -#endif + if (_miso >= 0) bitWrite(data_in,i,digitalRead(_miso)); else bitWrite(data_in,i,0); delayMicroseconds(1); } @@ -57,17 +49,13 @@ class bbspi { { uint32_t data_in = 0; - for(int i=31; i>=0; i--) + for(int i=31; i >= 0; i--) { digitalWrite(_sck,LOW); digitalWrite(_mosi,bitRead(data_out,i)); delayMicroseconds(1); digitalWrite(_sck,HIGH); -#ifdef ESP8266_CONTROL_ON - bitWrite(data_in,i,0); -#else - bitWrite(data_in,i,digitalRead(_miso)); -#endif + if (_miso >= 0) bitWrite(data_in,i,digitalRead(_miso)); else bitWrite(data_in,i,0); delayMicroseconds(1); } @@ -79,4 +67,3 @@ class bbspi { int _miso = 0; int _mosi = 0; }; - diff --git a/src/lib/Sound.h b/src/lib/Sound.h index 85a3f7e7c..6eeca11a6 100644 --- a/src/lib/Sound.h +++ b/src/lib/Sound.h @@ -4,10 +4,10 @@ // sound/buzzer void soundAlert() { if (soundEnabled) { - #ifdef BUZZER_ON + #if BUZZER == ON digitalWrite(TonePin,HIGH); buzzerDuration=100; #endif - #ifdef BUZZER + #if BUZZER >= 0 tone(TonePin,BUZZER,1000); #endif } @@ -16,10 +16,10 @@ void soundAlert() { // sound/beep void soundBeep() { if (soundEnabled) { - #ifdef BUZZER_ON + #if BUZZER == ON digitalWrite(TonePin,HIGH); buzzerDuration=25; #endif - #ifdef BUZZER + #if BUZZER >= 0 tone(TonePin,BUZZER,250); #endif } @@ -28,10 +28,10 @@ void soundBeep() { // sound/click void soundClick() { if (soundEnabled) { - #ifdef BUZZER_ON + #if BUZZER == ON digitalWrite(TonePin,HIGH); buzzerDuration=5; #endif - #ifdef BUZZER + #if BUZZER >= 0 tone(TonePin,BUZZER,50); #endif } diff --git a/src/lib/St4SerialMaster.h b/src/lib/St4SerialMaster.h index 9c009de69..bb5e17609 100644 --- a/src/lib/St4SerialMaster.h +++ b/src/lib/St4SerialMaster.h @@ -32,7 +32,7 @@ class Mst4 : public Stream void end(); - // recvs one char and transmits one char to/from buffers; recvd chars <32 are returned directly and bypass the buffer + // recvs one char and transmits one char to/from buffers; recvd chars < 32 are returned directly and bypass the buffer inline char poll() { char c=0; if (trans(&c,_xmit_buffer[_xmit_head])) { @@ -42,7 +42,7 @@ class Mst4 : public Stream } // data coming in was good? if (!_recv_error) { - if (c>=(char)32) { _recv_buffer[_recv_tail]=c; _recv_tail++; _recv_buffer[_recv_tail]=(char)0; return (char)0; } else return c; + if (c >= (char)32) { _recv_buffer[_recv_tail]=c; _recv_tail++; _recv_buffer[_recv_tail]=(char)0; return (char)0; } else return c; } else return (char)0; } else return (char)0; } @@ -77,10 +77,10 @@ class Mst4 : public Stream // SHC_CLOCK HIGH for more than 1500 us means that a pair of data bytes is done being exchanged #ifdef HAL_SLOW_PROCESSOR #define XMIT_TIME 20 - if ((micros()-lastMicros)<10000L) return false; + if ((micros()-lastMicros) < 10000L) return false; #else #define XMIT_TIME 40 - if ((micros()-lastMicros)<3000L) return false; + if ((micros()-lastMicros) < 3000L) return false; #endif uint8_t s_parity=0; @@ -100,7 +100,7 @@ class Mst4 : public Stream delayMicroseconds(XMIT_TIME); if (_frame_error) { lastMicros=micros(); return false; } - for (int i=7; i>=0; i--) + for (int i=7; i >= 0; i--) { uint8_t state=bitRead(data_out,i); s_parity+=state; digitalWrite(ST4DEs,LOW); // clock @@ -125,7 +125,7 @@ class Mst4 : public Stream digitalWrite(ST4DEn,_recv_error); // send local parity check delayMicroseconds(XMIT_TIME); digitalWrite(ST4DEs,HIGH); // clock - if (digitalRead(ST4RAw)==HIGH) _send_error=true; // recv remote parity, ok? + if (digitalRead(ST4RAw) == HIGH) _send_error=true; // recv remote parity, ok? delayMicroseconds(XMIT_TIME); // stop bit @@ -159,7 +159,7 @@ void Mst4::end() { size_t Mst4::write(uint8_t data) { unsigned long t_start=millis(); - byte xh=_xmit_head; xh--; while (_xmit_tail == xh) { poll(); if ((millis()-t_start)>_timeout) return 0; } + byte xh=_xmit_head; xh--; while (_xmit_tail == xh) { poll(); if ((millis()-t_start) > _timeout) return 0; } _xmit_buffer[_xmit_tail]=data; _xmit_tail++; _xmit_buffer[_xmit_tail]=0; return 1; @@ -167,9 +167,9 @@ size_t Mst4::write(uint8_t data) { size_t Mst4::write(const uint8_t *data, size_t quantity) { // fail if trying to write more than the buffer can hold - if ((int)quantity>254) return 0; + if ((int)quantity > 254) return 0; - for (int i=0; i<(int)quantity; i++) { if (!write(data[i])) return 0; } + for (int i=0; i < (int)quantity; i++) { if (!write(data[i])) return 0; } return 1; } @@ -181,13 +181,13 @@ int Mst4::available(void) { int Mst4::read(void) { char c=_recv_buffer[_recv_head]; if (c!=0) _recv_head++; - if (c==0) c=-1; + if (c == 0) c=-1; return c; } int Mst4::peek(void) { int c=_recv_buffer[_recv_head]; - if (c==0) c=-1; + if (c == 0) c=-1; return c; } @@ -198,7 +198,7 @@ void Mst4::flush(void) { do { poll(); c=_xmit_buffer[_xmit_head]; - } while ((c!=0) || ((millis()-startMs)<_timeout)); + } while ((c!=0) || ((millis()-startMs) < _timeout)); } Mst4 SerialST4; diff --git a/src/lib/StepperDC.h b/src/lib/StepperDC.h index a644c2791..9a00d7b3d 100644 --- a/src/lib/StepperDC.h +++ b/src/lib/StepperDC.h @@ -18,7 +18,7 @@ class stepperDC { _enPin=enPin; _maxRate=maxRate; - if ((_enPin<0) || (_stepPin<0) || (_dirPin<0)) return; + if ((_enPin < 0) || (_stepPin < 0) || (_dirPin < 0)) return; pinMode(_enPin,OUTPUT); pinMode(_dirPin,OUTPUT); @@ -54,17 +54,17 @@ class stepperDC { } void poll() { - if (_enPin<0) return; + if (_enPin < 0) return; static unsigned long nextPass=0; unsigned long tempMs=millis(); - if ((long)(tempMs-nextPass)>0) { + if ((long)(tempMs-nextPass) > 0) { nextPass=tempMs+(unsigned long)_maxRate; - if (_power==0 || !_en) { disableDriver(); return; } + if (_power == 0 || !_en) { disableDriver(); return; } static int seq=0; - seq++; if (seq>9) seq=0; + seq++; if (seq > 9) seq=0; static byte pwr[10][10] = { {0,0,0,0,1,0,0,0,0,0}, @@ -85,8 +85,8 @@ class stepperDC { // power = 0 to 100% void setPower(int power) { _power=round(power/10.0); - if (_power<0) _power=0; - if (_power>10) _power=10; + if (_power < 0) _power=0; + if (_power > 10) _power=10; } void enabled(bool enState) { _en=enState; @@ -96,40 +96,40 @@ class stepperDC { // sets logic state for disabling stepper driver void setDisableState(boolean disableState) { _disableState=disableState; - if (_disableState==LOW) _enableState=HIGH; else _enableState=LOW; + if (_disableState == LOW) _enableState=HIGH; else _enableState=LOW; } void setDirectionIn() { - if (_phase==1 || _phase==3) nextDirection(); // switch to move in + if (_phase == 1 || _phase == 3) nextDirection(); // switch to move in } void setDirectionOut() { - if (_phase==5 || _phase==7) nextDirection(); // switch to move out + if (_phase == 5 || _phase == 7) nextDirection(); // switch to move out } void setPhase1() { - if (_phase==3 || _phase==7) priorPhase(); // switch to phase A + if (_phase == 3 || _phase == 7) priorPhase(); // switch to phase A } void setPhase2() { - if (_phase==1 || _phase==5) nextPhase(); // switch to phase B + if (_phase == 1 || _phase == 5) nextPhase(); // switch to phase B } private: void nextDirection() { - if ((_enPin<0) || (_stepPin<0)) return; + if ((_enPin < 0) || (_stepPin < 0)) return; if (!_A4988) enableDriver(); else disableDriver(); step(); step(); step(); step(); if (!_A4988) disableDriver(); } void nextPhase() { - if ((_enPin<0) || (_stepPin<0)) return; + if ((_enPin < 0) || (_stepPin < 0)) return; if (!_A4988) enableDriver(); else disableDriver(); step(); step(); if (!_A4988) disableDriver(); } void priorPhase() { - if ((_enPin<0) || (_stepPin<0)) return; + if ((_enPin < 0) || (_stepPin < 0)) return; if (!_A4988) enableDriver(); else disableDriver(); step(); step(); step(); step(); step(); step(); if (!_A4988) disableDriver(); @@ -137,22 +137,22 @@ class stepperDC { void step() { digitalWrite(_stepPin,HIGH); delayMicroseconds(2); digitalWrite(_stepPin,LOW); delayMicroseconds(2); - _phase++; if (_phase>8) _phase=1; + _phase++; if (_phase > 8) _phase=1; } void enableDriver() { - if (_enPin==-1) return; - if (_en_state==1) return; + if (_enPin == -1) return; + if (_en_state == 1) return; // for Aux5/Aux6 (DAC) support for stepper driver EN control on MaxPCB Aux5=A21=66 Aux6=A22=67 - if ((_enPin==66) || (_enPin==67)) { if (_enableState==HIGH) analogWrite(_enPin,255); else analogWrite(_enPin,0); delayMicroseconds(30); } else + if ((_enPin == 66) || (_enPin == 67)) { if (_enableState == HIGH) analogWrite(_enPin,255); else analogWrite(_enPin,0); delayMicroseconds(30); } else { digitalWrite(_enPin,_enableState); delayMicroseconds(2); } _en_state=1; } void disableDriver() { - if (_enPin==-1) return; - if (_en_state==0) return; - if ((_enPin==66) || (_enPin==67)) { if (_disableState==HIGH) analogWrite(_enPin,255); else analogWrite(_enPin,0); delayMicroseconds(30); } else + if (_enPin == -1) return; + if (_en_state == 0) return; + if ((_enPin == 66) || (_enPin == 67)) { if (_disableState == HIGH) analogWrite(_enPin,255); else analogWrite(_enPin,0); delayMicroseconds(30); } else { digitalWrite(_enPin,_disableState); delayMicroseconds(2); } _en_state=0; } diff --git a/src/lib/TMC_SPI.h b/src/lib/TMC_SPI.h index eafbfe1be..19bb224ac 100644 --- a/src/lib/TMC_SPI.h +++ b/src/lib/TMC_SPI.h @@ -42,8 +42,8 @@ class tmcSpiDriver { float Ifs = 0.325/rsense; unsigned long IHOLD=round(( ((float)ihold/1000.0)/Ifs)*32.0)-1; unsigned long IRUN =round(( ((float)irun/1000.0)/Ifs)*32.0)-1; - if (IHOLD<0) IHOLD=0; if (IHOLD>31) IHOLD=31; - if (IRUN<0) IRUN=0; if (IRUN>31) IRUN=31; + if (IHOLD < 0) IHOLD=0; if (IHOLD > 31) IHOLD=31; + if (IRUN < 0) IRUN=0; if (IRUN > 31) IRUN=31; // IHOLD + IRUN + IHOLDDELAY data_out=(IHOLD<<0)+(IRUN<<8)+(4UL<<16); @@ -112,36 +112,36 @@ class tmcSpiDriver { // ------------------------------- // CHOPCONF settings - bool set_CHOPCONF_toff(int v) { if ((v>=2) && (v<=15)) { _cc_toff=v; return true; } return false; } - bool set_CHOPCONF_hstart(int v) { if ((v>=0) && (v<=7)) { _cc_hstart=v; return true; } return false; } - bool set_CHOPCONF_hend(int v) { if ((v>=0) && (v<=15)) { _cc_hend=v; return true; } return false; } - bool set_CHOPCONF_rndtf(int v) { if ((v>=0) && (v<=1)) { _cc_rndtf=v; return true; } return false; } - bool set_CHOPCONF_tbl(int v) { if ((v>=0) && (v<=3)) { _cc_tbl=v; return true; } return false; } - bool set_CHOPCONF_vsense(int v) { if ((v>=0) && (v<=1)) { _cc_vsense=v; return true; } return false; } - bool set_CHOPCONF_vhighfs(int v) { if ((v>=0) && (v<=1)) { _cc_vhighfs=v; return true; } return false; } - bool set_CHOPCONF_vhignchm(int v) { if ((v>=0) && (v<=1)) { _cc_vhighchm=v; return true; } return false; } + bool set_CHOPCONF_toff(int v) { if ((v >= 2) && (v <= 15)) { _cc_toff=v; return true; } return false; } + bool set_CHOPCONF_hstart(int v) { if ((v >= 0) && (v <= 7)) { _cc_hstart=v; return true; } return false; } + bool set_CHOPCONF_hend(int v) { if ((v >= 0) && (v <= 15)) { _cc_hend=v; return true; } return false; } + bool set_CHOPCONF_rndtf(int v) { if ((v >= 0) && (v <= 1)) { _cc_rndtf=v; return true; } return false; } + bool set_CHOPCONF_tbl(int v) { if ((v >= 0) && (v <= 3)) { _cc_tbl=v; return true; } return false; } + bool set_CHOPCONF_vsense(int v) { if ((v >= 0) && (v <= 1)) { _cc_vsense=v; return true; } return false; } + bool set_CHOPCONF_vhighfs(int v) { if ((v >= 0) && (v <= 1)) { _cc_vhighfs=v; return true; } return false; } + bool set_CHOPCONF_vhignchm(int v) { if ((v >= 0) && (v <= 1)) { _cc_vhighchm=v; return true; } return false; } // ------------------------------- // TPOWERDOWN setting - bool set_TPOWERDOWN_value(int v) { if ((v>=0) && (v<=255)) { _tpd_value=v; return true; } return false; } + bool set_TPOWERDOWN_value(int v) { if ((v >= 0) && (v <= 255)) { _tpd_value=v; return true; } return false; } // ------------------------------- // TPWMTHRS setting - bool set_TPWMTHRS_value(int v) { if ((v>=0) && (v<=1048575)) { _tpt_value=v; return true; } return false; } + bool set_TPWMTHRS_value(int v) { if ((v >= 0) && (v <= 1048575)) { _tpt_value=v; return true; } return false; } // ------------------------------- // THIGH setting - bool set_THIGH_value(int v) { if ((v>=0) && (v<=1048575)) { _thigh_value=v; return true; } return false; } + bool set_THIGH_value(int v) { if ((v >= 0) && (v <= 1048575)) { _thigh_value=v; return true; } return false; } // ------------------------------- // PWMCONF settings - bool set_PWMCONF_PWM_AMPL(int v) { if ((v>=0) && (v<=255)) { _pc_PWM_AMPL=v; return true; } return false; } - bool set_PWMCONF_PWM_GRAD(int v) { if ((v>=0) && (v<=255)) { _pc_PWM_GRAD=v; return true; } return false; } - bool set_PWMCONF_pwm_freq(int v) { if ((v>=0) && (v<=3)) { _pc_pwm_freq=v; return true; } return false; } - bool set_PWMCONF_pwm_auto(int v) { if ((v>=0) && (v<=1)) { _pc_pwm_auto=v; return true; } return false; } - bool set_PWMCONF_pwm_sym(int v) { if ((v>=0) && (v<=1)) { _pc_pwm_sym=v; return true; } return false; } - bool set_PWMCONF_pwm_freewheel(int v) { if ((v>=0) && (v<=1)) { _pc_pwm_freewheel=v; return true; } return false; } + bool set_PWMCONF_PWM_AMPL(int v) { if ((v >= 0) && (v <= 255)) { _pc_PWM_AMPL=v; return true; } return false; } + bool set_PWMCONF_PWM_GRAD(int v) { if ((v >= 0) && (v <= 255)) { _pc_PWM_GRAD=v; return true; } return false; } + bool set_PWMCONF_pwm_freq(int v) { if ((v >= 0) && (v <= 3)) { _pc_pwm_freq=v; return true; } return false; } + bool set_PWMCONF_pwm_auto(int v) { if ((v >= 0) && (v <= 1)) { _pc_pwm_auto=v; return true; } return false; } + bool set_PWMCONF_pwm_sym(int v) { if ((v >= 0) && (v <= 1)) { _pc_pwm_sym=v; return true; } return false; } + bool set_PWMCONF_pwm_freewheel(int v) { if ((v >= 0) && (v <= 1)) { _pc_pwm_freewheel=v; return true; } return false; } // ---------------------------------------------------------------------------------------------------------------------- // DRVSTATUS @@ -198,13 +198,13 @@ class tmcSpiDriver { return true; } - bool set_COOLCONF_semin(int v) { if ((v>=0) && (v<=15)) { _ccf_semin=v; return true; } return false; } - bool set_COOLCONF_seup(int v) { if ((v>=0) && (v<=3)) { _ccf_seup=v; return true; } return false; } - bool set_COOLCONF_semax(int v) { if ((v>=0) && (v<=15)) { _ccf_semax=v; return true; } return false; } - bool set_COOLCONF_sedn(int v) { if ((v>=0) && (v<=3)) { _ccf_sedn=v; return true; } return false; } - bool set_COOLCONF_seimin(int v) { if ((v>=0) && (v<=1)) { _ccf_seimin=v; return true; } return false; } - bool set_COOLCONF_sgt(int v) { if ((v>=-64) && (v<=63)) { _ccf_sgt=v+64; return true; } return false; } - bool set_COOLCONF_sfilt(int v) { if ((v>=0) && (v<=1)) { _ccf_sfilt=v; return true; } return false; } + bool set_COOLCONF_semin(int v) { if ((v >= 0) && (v <= 15)) { _ccf_semin=v; return true; } return false; } + bool set_COOLCONF_seup(int v) { if ((v >= 0) && (v <= 3)) { _ccf_seup=v; return true; } return false; } + bool set_COOLCONF_semax(int v) { if ((v >= 0) && (v <= 15)) { _ccf_semax=v; return true; } return false; } + bool set_COOLCONF_sedn(int v) { if ((v >= 0) && (v <= 3)) { _ccf_sedn=v; return true; } return false; } + bool set_COOLCONF_seimin(int v) { if ((v >= 0) && (v <= 1)) { _ccf_seimin=v; return true; } return false; } + bool set_COOLCONF_sgt(int v) { if ((v >= -64) && (v <= 63)) { _ccf_sgt=v+64; return true; } return false; } + bool set_COOLCONF_sfilt(int v) { if ((v >= 0) && (v <= 1)) { _ccf_sfilt=v; return true; } return false; } private: uint8_t write(byte Address, uint32_t data_out) diff --git a/src/lib/Weather.h b/src/lib/Weather.h index 303231eb3..063ce9114 100644 --- a/src/lib/Weather.h +++ b/src/lib/Weather.h @@ -3,20 +3,17 @@ #pragma once -#if defined(WEATHER_BME280_ON) || defined(WEATHER_BME280) || defined(WEATHER_BME280SPI_ON) || defined(WEATHER_BME280SPI) - #include // https://github.com/adafruit/Adafruit_BME280_Library and https://github.com/adafruit/Adafruit_Sensor - #if defined(WEATHER_BME280SPI_ON) - Adafruit_BME280 bme(BME280_CS_PIN); // hardware SPI -// Adafruit_BME280 bme(BME280_CS_PIN, SSPI_MOSI, SSPI_MISO, SSPI_SCK); // software SPI - #elif defined(WEATHER_BME280SPI) - Adafruit_BME280 bme(WEATHER_BME280SPI); // hardware SPI (user defined CS) -// Adafruit_BME280 bme(WEATHER_BME280SPI, SSPI_MOSI, SSPI_MISO, SSPI_SCK); // software SPI (user defined CS) - #else +#if WEATHER == BME280 || WEATHER == BME280SPI + #include // https://github.com/adafruit/Adafruit_BME280_Library and https://github.com/adafruit/Adafruit_Sensor + #if WEATHER == BME280 Adafruit_BME280 bme; + #elif WEATHER == BME280SPI + Adafruit_BME280 bme(BME280_CS_PIN); // hardware SPI + //Adafruit_BME280 bme(BME280_CS_PIN, SSPI_MOSI, SSPI_MISO, SSPI_SCK); // software SPI #endif #endif -#ifdef TEMPERATURE_DS1820_ON +#if TELESCOPE_TEMPERATURE == DS1820 #include // added via built in Arduino IDE library manager #include // added via built in Arduino IDE library manager OneWire oneWire(OneWirePin); @@ -26,56 +23,55 @@ class weather { public: void init() { -#if defined(WEATHER_BME280_ON) || defined(WEATHER_BME280) || defined(WEATHER_BME280SPI_ON) || defined(WEATHER_BME280SPI) - #if defined(WEATHER_BME280) - if (bme.begin(WEATHER_BME280,&HAL_Wire)) _disabled=false; - #elif defined(WEATHER_BME280_ON) +#if TELESCOPE_TEMPERATURE == DS1820 + _disabled=false; +#endif +#if WEATHER == BME280 || WEATHER == BME280SPI + #if WEATHER == BME280 if (bme.begin(&HAL_Wire)) _disabled=false; #else if (bme.begin()) _disabled=false; #endif - if (!_disabled) { - _t=bme.readTemperature(); - _p=bme.readPressure()/100.0; - _h=bme.readHumidity(); - } #ifdef ESP32 HAL_Wire.end(); #endif -#endif -#ifdef TEMPERATURE_DS1820_ON - _disabled=false; - if (!_disabled) { - DS18B20.requestTemperatures(); - _t=DS18B20.getTempCByIndex(0); - } #endif } // designed for a 1s polling interval to refresh readings once a minute void poll() { -#if defined(WEATHER_BME280_ON) || defined(WEATHER_BME280) || defined(WEATHER_BME280SPI_ON) || defined(WEATHER_BME280SPI) + +#if WEATHER == BME280 || WEATHER == BME280SPI || TELESCOPE_TEMPERATURE == DS1820 if (!_disabled) { static int phase=0; - #ifdef ESP32 - if ((phase==10) || (phase==30) || (phase==50)) HAL_Wire.begin(); + + #if WEATHER == BME280 || WEATHER == BME280SPI + #ifdef ESP32 + if ((phase == 10) || (phase == 30) || (phase == 50)) HAL_Wire.begin(); + #endif + if (phase == 10) { + _t=bme.readTemperature(); + #if TELESCOPE_TEMPERATURE != DS1820 + _tt=_t; + #endif + } + if (phase == 30) _p=bme.readPressure()/100.0; + if (phase == 50) _h=bme.readHumidity(); + #ifdef ESP32 + if ((phase == 10) || (phase == 30) || (phase == 50)) HAL_Wire.end(); + #endif #endif - if (phase==10) _t=bme.readTemperature(); - if (phase==30) _p=bme.readPressure()/100.0; - if (phase==50) _h=bme.readHumidity(); - #ifdef ESP32 - if ((phase==10) || (phase==30) || (phase==50)) HAL_Wire.end(); + + #if TELESCOPE_TEMPERATURE == DS1820 + if (phase == 70) { + DS18B20.requestTemperatures(); + _tt=DS18B20.getTempCByIndex(0); + #if WEATHER != BME280 && WEATHER != BME280SPI + _t=_tt; + #endif + } #endif - phase++; if (phase==60) phase=0; - } -#endif -#ifdef TEMPERATURE_DS1820_ON - if (!_disabled) { - static int phase=0; - if (phase==10) { DS18B20.requestTemperatures(); _t=DS18B20.getTempCByIndex(0); } - if (phase==30) ; //nothing to do here - if (phase==50) ; //nothing to do here - phase++; if (phase==60) phase=0; + phase++; if (phase == 90) phase=0; } #endif } @@ -85,6 +81,11 @@ class weather { return _t; } + // get telescope temperature in deg. C + double getTelescopeTemperature() { + return _tt; + } + // set temperature in deg. C void setTemperature(double t) { _t=t; @@ -131,6 +132,7 @@ class weather { private: bool _disabled = true; double _t = 10.0; + double _tt = 10.0; double _p = 1010.0; double _h = 70.0; double _a = 200.0; diff --git a/src/pinmaps/Models.h b/src/pinmaps/Models.h new file mode 100644 index 000000000..536cfdbe3 --- /dev/null +++ b/src/pinmaps/Models.h @@ -0,0 +1,45 @@ +// ------------------------------------------------------------------------------------------------- +// Loads pinmap model for current configuration + +#if PINMAP == Classic + #include "Pins.Classic.h" +#endif +#if PINMAP == Mega2560Alt + #include "Pins.Mega2560Alt.h" +#endif +#if PINMAP == MiniPCB + #include "Pins.MiniPCB.h" +#endif +#if PINMAP == MiniEMB + #include "Pins.MiniPCB.h" +#endif +#if PINMAP == MiniPCB2 + #include "Pins.MiniPCB.h" +#endif +#if PINMAP == MaxPCB + #include "Pins.MaxPCB.h" +#endif +#if PINMAP == MaxPCB2 + #include "Pins.MaxPCB.h" +#endif +#if PINMAP == MaxTMC + #include "Pins.MaxPCB.h" +#endif +#if PINMAP == MaxESP + #include "Pins.MaxESP.h" +#endif +#if PINMAP == MaxESP2 + #include "Pins.MaxESP2.h" +#endif +#if PINMAP == MaxESP3 + #include "Pins.MaxESP3.h" +#endif +#if PINMAP == Ramps14 + #include "Pins.Ramps14.h" +#endif +#if PINMAP == STM32Blue + #include "Pins.STM32B.h" +#endif +#if PINMAP == STM32Black + #include "Pins.STM32B.h" +#endif diff --git a/src/pinmaps/Pins.Classic.h b/src/pinmaps/Pins.Classic.h index c6116e90b..0635c463d 100644 --- a/src/pinmaps/Pins.Classic.h +++ b/src/pinmaps/Pins.Classic.h @@ -4,162 +4,159 @@ #if defined(__AVR_ATmega2560__) // The PEC index sense is a 5V logic input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 2 -#define AnalogPecPin 1 +#define PecPin 2 +#define AnalogPecPin 1 // The limit switch sense is a 5V logic input which uses the internal (or external 2k) pull up, shorted to ground it stops gotos/tracking -#define LimitPin 3 +#define LimitPin 3 // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -// Atmel 2560 -#define LEDposPin 8 // Pin 8 (LED) PH5 -#define LEDnegPin 9 // Pin 9 (GND) PH6 -#define LEDneg2Pin 10 // Pin 10 (GND) PB4 -#define ReticulePin 44 // Pin 44 (GND) +// Atmel 2560 port/bit +#define LEDposPin 8 // LED PH5 +#define LEDnegPin 9 // GND PH6 +#define LEDneg2Pin 10 // PGND PB4 +#define ReticlePin 44 // PGND // For a piezo buzzer -#define TonePin 42 // Pin 42 (Tone) +#define TonePin 42 // Tone // The PPS pin is a 5V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 21 // Interrupt 2 on Pin 21 (alternate Int3 on Pin20) -#define DS3234_CS_PIN 10 - -#define Axis1DirPin 11 // Pin 11 (Dir) PB5 -#define Axis1DirBit 5 // -#define Axis1DirPORT PORTB // -#define Axis15vPin 12 // Pin 12 (5V?) PB6 -#define Axis1StepPin 13 // Pin 13 (Step) PB7 -#define Axis1StepBit 7 // -#define Axis1StepPORT PORTB // - // Pin GND (GND) - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis1_M0 22 // Pin 22 (Microstep Mode 0) -#define Axis1_M1 23 // Pin 23 (Microstep Mode 1) -#define Axis1_M2 24 // Pin 24 (Microstep Mode 2) -#define Axis1_EN 25 // Pin 25 (Enable) -#define Axis1_FAULT 26 // Pin 26 (Fault) -#define Axis1_Aux 26 // Pin 26 (Aux - SPI MISO) -#define Axis1_Mode 32 // Pin 32 (Mode switch for Axis1) - -// The HA(RA) and Dec jumpers (going to the big easy drivers) are simply four wire jumper cables, each has identical wiring - simple modular construction -#define Axis2DirPin 4 // Pin 4 (Dir) PG5 -#define Axis2DirBit 5 // -#define Axis2DirPORT PORTG // -#define Axis25vPin 5 // Pin 5 (5V?) PE3 -#define Axis2StepPin 6 // Pin 6 (Step) PH3 -#define Axis2StepBit 3 // -#define Axis2StepPORT PORTH // -#define Axis2GndPin 7 // Pin 7 (GND) PH4 - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis2_M0 27 // Pin 27 (Microstep Mode 0) -#define Axis2_M1 28 // Pin 28 (Microstep Mode 1) -#define Axis2_M2 29 // Pin 29 (Microstep Mode 2) -#define Axis2_EN 30 // Pin 30 (Enable) -#define Axis2_FAULT 31 // Pin 31 (Fault) -#define Axis2_Aux 31 // Pin 31 (Aux - SPI MISO) -#define Axis2_Mode 33 // Pin 33 (Mode switch for Axis2) +#define PpsPin 21 // Interrupt 2 on Pin 21 (alternate Int3 on Pin20) + +// Obsolete pins that would power Big Easy Drivers (A4988) back in the old days +#define POWER_SUPPLY_PINS_OFF +#define Axis15vPin 12 // 5V PB6 +#define Axis25vPin 5 // 5V PE3 +#define Axis2GndPin 7 // GND PH4 + +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 25 // Enable +#define Axis1_M0 22 // Microstep Mode 0 +#define Axis1_M1 23 // Microstep Mode 1 +#define Axis1_M2 24 // Microstep Mode 2 +#define Axis1_M3 26 // SPI MISO/Fault +#define Axis1StepPin 13 // Step PB7 +#define Axis1StepBit 7 // +#define Axis1StepPORT PORTB // +#define Axis1DirPin 11 // Dir PB5 +#define Axis1DirBit 5 // +#define Axis1DirPORT PORTB // +#define Axis1FaultPin 26 // SPI MISO/Fault +#define Axis1ModePin 32 // Mode switch for Axis1 + +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 30 // Enable +#define Axis2_M0 27 // Microstep Mode 0 +#define Axis2_M1 28 // Microstep Mode 1 +#define Axis2_M2 29 // Microstep Mode 2 +#define Axis2_M3 31 // SPI MISO/Fault +#define Axis2StepPin 6 // Step PH3 +#define Axis2StepBit 3 // +#define Axis2StepPORT PORTH // +#define Axis2DirPin 4 // Dir PG5 +#define Axis2DirBit 5 // +#define Axis2DirPORT PORTG // +#define Axis2FaultPin 31 // SPI MISO/Fault +#define Axis2ModePin 33 // Mode switch for Axis2 // Pins to rotator stepper driver -#define Axis3DirPin A8 // Pin A8 (Dir) -#define Axis3StepPin A9 // Pin A9 (Step) +#define Axis3_EN -1 // Enable +#define Axis3StepPin A9 // Step +#define Axis3DirPin A8 // Dir // Pins to focuser1 stepper driver -#define Axis4DirPin A10 // Pin A10 (Dir) -#define Axis4StepPin A11 // Pin A11 (Step) +#define Axis3_EN -1 // Enable +#define Axis4StepPin A11 // Step +#define Axis4DirPin A10 // Dir // Pins to focuser2 stepper driver -#define Axis5DirPin A12 // Pin A12 (Dir) -#define Axis5StepPin A13 // Pin A13 (Step) +#define Axis3_EN -1 // Enable +#define Axis5StepPin A13 // Step +#define Axis5DirPin A12 // Dir // ST4 interface #ifdef ST4_ALTERNATE_PINS_ON -#define ST4RAw 47 // Pin 47 ST4 RA- West -#define ST4DEs 43 // Pin 43 ST4 DE- South -#define ST4DEn 45 // Pin 45 ST4 DE+ North -#define ST4RAe 49 // Pin 49 ST4 RA+ East +#define ST4RAw 47 // ST4 RA- West +#define ST4DEs 43 // ST4 DE- South +#define ST4DEn 45 // ST4 DE+ North +#define ST4RAe 49 // ST4 RA+ East #else -#define ST4RAw 47 // Pin 47 ST4 RA- West -#define ST4DEs 49 // Pin 49 ST4 DE- South -#define ST4DEn 51 // Pin 51 ST4 DE+ North -#define ST4RAe 53 // Pin 53 ST4 RA+ East +#define ST4RAw 47 // ST4 RA- West +#define ST4DEs 49 // ST4 DE- South +#define ST4DEn 51 // ST4 DE+ North +#define ST4RAe 53 // ST4 RA+ East #endif #elif defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) // The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 2 -#define AnalogPecPin 14 +#define PecPin 2 +#define AnalogPecPin 14 // The limit switch sense is a 3.3V logic input which uses the internal pull up, shorted to ground it stops gotos/tracking -#define LimitPin 3 +#define LimitPin 3 // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDposPin 8 // Pin 8 (LED) -#define LEDnegPin 9 // Pin 9 (GND) -#define LEDneg2Pin 7 // Pin 7 (GND) -#define ReticulePin 9 // Pin 9 (GND) +#define LEDposPin 8 // LED +#define LEDnegPin 9 // GND +#define LEDneg2Pin 7 // GND +#define ReticlePin 9 // GND // For a piezo buzzer -#define TonePin 29 // Pin 29 (Tone) +#define TonePin 29 // Tone // The PPS pin is a logic level input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 23 // Pin 23 (PPS time source, GPS for example) - -#define Axis1DirPin 10 // Pin 10 (Dir) -#define Axis15vPin 11 // Pin 11 (5V?) -#define Axis1StepPin 12 // Pin 12 (Step) - // Pin GND (GND) - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis1_M0 13 // Pin 13 (Microstep Mode 0) -#define Axis1_M1 14 // Pin 14 (Microstep Mode 1) -#define Axis1_M2 15 // Pin 15 (Microstep Mode 2) -#define Axis1_EN 16 // Pin 16 (Enable) -#define Axis1_FAULT 17 // Pin 17 (Fault) -#define Axis1_Aux 17 // Pin 17 (Aux - ESP8266 GPIO0 or SPI MISO) - -// The HA(RA) and Dec jumpers (going to the big easy drivers) are simply four wire jumper cables, each has identical wiring - simple modular construction -#define Axis2DirPin 4 // Pin 4 (Dir) -#define Axis25vPin 5 // Pin 5 (5V?) -#define Axis2StepPin 6 // Pin 6 (Step) -#define Axis2GndPin 7 // Pin 7 (GND) - -#define Axis2_M0 18 // Pin 18 (Microstep Mode 0) -#define Axis2_M1 19 // Pin 19 (Microstep Mode 1) -#define Axis2_M2 20 // Pin 20 (Microstep Mode 2) -#define Axis2_EN 21 // Pin 21 (Enable) -#define Axis2_FAULT 22 // Pin 22 (Fault) -#define Axis2_Aux 22 // Pin 22 (Aux - ESP8266 Rst or SPI MISO) +#define PpsPin 23 // PPS time source, GPS for example + +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 16 // Enable +#define Axis1_M0 13 // Microstep Mode 0 +#define Axis1_M1 14 // Microstep Mode 1 +#define Axis1_M2 15 // Microstep Mode 2 +#define Axis1_M3 17 // ESP8266 GPIO0 or SPI MISO +#define Axis1StepPin 12 // Step +#define Axis1DirPin 10 // Dir +#define Axis1FaultPin 17 // Fault + +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 21 // Enable +#define Axis2_M0 18 // Microstep Mode 0 +#define Axis2_M1 19 // Microstep Mode 1 +#define Axis2_M2 20 // Microstep Mode 2 +#define Axis2_M3 22 // ESP8266 Rst or SPI MISO +#define Axis2FaultPin 22 // Fault +#define Axis2StepPin 6 // Step +#define Axis2DirPin 4 // Dir // For rotator stepper driver -#define Axis3DirPin 33 // Pin 33 (Dir) -#define Axis3StepPin 30 // Pin 30 (Step) +#define Axis3DirPin 33 // Dir +#define Axis3StepPin 30 // Step +#define Axis3_EN -1 // Enable // For focuser1 stepper driver #if defined(__MK64FX512__) || defined(__MK66FX1M0__) // teensy3.5/3.6 - #define Axis4DirPin 35 // Pin 35 (Dir) - #define Axis4StepPin 34 // Pin 34 (Step) + #define Axis4DirPin 35 // Dir + #define Axis4StepPin 34 // Step #else // teensy3.2 - #define Axis4DirPin 32 // Pin 32 (Dir) - #define Axis4StepPin 31 // Pin 31 (Step) + #define Axis4DirPin 32 // Dir + #define Axis4StepPin 31 // Step #endif +#define Axis4_EN -1 // Enable // For focuser2 stepper driver -#define Axis5DirPin 33 // Pin 33 (Dir) -#define Axis5StepPin 30 // Pin 30 (Step) +#define Axis5DirPin 33 // Dir +#define Axis5StepPin 30 // Step +#define Axis5_EN -1 // Enable // ST4 interface -#define ST4RAw 24 // Pin 24 ST4 RA- West -#define ST4DEs 25 // Pin 25 ST4 DE- South -#define ST4DEn 26 // Pin 26 ST4 DE+ North -#define ST4RAe 27 // Pin 27 ST4 RA+ East +#define ST4RAw 24 // ST4 RA- West +#define ST4DEs 25 // ST4 DE- South +#define ST4DEn 26 // ST4 DE+ North +#define ST4RAe 27 // ST4 RA+ East #else #error "Wrong processor for this configuration!" #endif - diff --git a/src/pinmaps/Pins.MaxESP.h b/src/pinmaps/Pins.MaxESP.h index ee8c31ab9..ad030ce1e 100644 --- a/src/pinmaps/Pins.MaxESP.h +++ b/src/pinmaps/Pins.MaxESP.h @@ -1,56 +1,62 @@ // ------------------------------------------------------------------------------------------------- -// Pin map for OnStep MaxESP (ESP32) Version 1.x +// Pin map for OnStep MaxESP Version 1.x (ESP32S) #if defined(ESP32) // The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux0 25 // Status LED -#define Aux3 5 // Home sw for Axis1 -#define Aux4 14 // Home sw for Axis2 -#define Aux5 0 // EN for Axis3 +#define Aux0 25 // Status LED +#define Aux3 5 // Home sw for Axis1 +#define Aux4 14 // Home sw for Axis2 +#define Aux5 0 // EN for Axis3 +#define Aux8 23 // LED2 or Reticle // The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 36 -#define AnalogPecPin A0 // A0 or GPIO36 (PEC Sense, analog or digital) +#define PecPin 36 +#define AnalogPecPin A0 // A0 or GPIO36 (PEC Sense, analog or digital) // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDnegPin Aux0 // Pin 25 (Drain) -#define LEDneg2Pin 23 // Pin 23 (Drain) -#define ReticulePin 23 // Pin 23 (Drain) +#define LEDnegPin Aux0 // Drain +#define LEDneg2Pin Aux8 // Drain +#define ReticlePin Aux8 // Drain // For a piezo buzzer -#define TonePin 13 // Pin 13 (Tone) +#define TonePin 13 // Tone // The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin Aux0 // Pin 25 (PPS time source, GPS for example) +#define PpsPin Aux0 // PPS time source, GPS for example -#define LimitPin 39 // Pin 39 (The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking) +#define LimitPin 39 // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking -#define Axis1DirPin 19 // Pin 19 (Dir) -#define Axis1StepPin 18 // Pin 18 (Step) -#define Axis1_HOME Aux3 // Pin 5 (Home sw) -#define Axis1_EN 4 // Pin 4 (Enable) +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 4 // Enable +#define Axis1StepPin 18 // Step +#define Axis1DirPin 19 // Dir -#define Axis2DirPin 26 // Pin 27 (Dir) -#define Axis2StepPin 27 // Pin 26 (Step) -#define Axis2_HOME Aux4 // Pin 14 (Home sw) -#define Axis2_EN 12 // Pin 12 (Enable) +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 12 // Enable +#define Axis2StepPin 27 // Step +#define Axis2DirPin 26 // Dir // For rotator stepper driver -#define Axis3DirPin 15 // Pin 15 (Dir) -#define Axis3StepPin 2 // Pin 2 (Step) -#define Axis3_EN Aux5 // Pin 0 (Enable) +#define Axis3_EN Aux5 // Enable +#define Axis3StepPin 2 // Step +#define Axis3DirPin 15 // Dir // For focuser1 stepper driver -#define Axis4DirPin 15 // Pin 15 (Dir) -#define Axis4StepPin 2 // Pin 2 (Step) -#define Axis4_EN Aux5 // Pin 0 (Enable) +#define Axis4_EN Aux5 // Enable +#define Axis4StepPin 2 // Step +#define Axis4DirPin 15 // Dir + +// For focuser2 stepper driver +#define Axis4_EN -1 // Enable +#define Axis4StepPin -1 // Step +#define Axis4DirPin -1 // Dir // ST4 interface -#define ST4RAw 34 // Pin 34 ST4 RA- West -#define ST4DEs 32 // Pin 32 ST4 DE- South -#define ST4DEn 33 // Pin 33 ST4 DE+ North -#define ST4RAe 35 // Pin 35 ST4 RA+ East +#define ST4RAw 34 // ST4 RA- West +#define ST4DEs 32 // ST4 DE- South +#define ST4DEn 33 // ST4 DE+ North +#define ST4RAe 35 // ST4 RA+ East #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.MaxESP2.h b/src/pinmaps/Pins.MaxESP2.h index 97b91f8eb..a5ef5258b 100644 --- a/src/pinmaps/Pins.MaxESP2.h +++ b/src/pinmaps/Pins.MaxESP2.h @@ -1,85 +1,81 @@ // ------------------------------------------------------------------------------------------------- -// Pin map for OnStep MaxESP (ESP32) Version 2.x +// Pin map for OnStep MaxESP Version 2.x (ESP32S) #if defined(ESP32) // The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux3 21 // Home SW for Axis1 (or I2C SDA) -#define Aux4 22 // Home SW for Axis2 (or I2C SCL) -//#define Aux5 "V0" // Virtual Aux Pin0 (usually maps to AXIS1_ENC_A_PIN) -//#define Aux6 "V1" // Virtual Aux Pin1 (usually maps to AXIS1_ENC_B_PIN) -#define Aux7 39 // Limit SW, Status LED2, Reticule, etc. -#define Aux8 25 // Status LED, PPS, Tone, etc. -//#define Aux9 "V2" // Virtual Aux Pin2 (usually maps to AXIS2_ENC_A_PIN) -//#define Aux10 "V3" // Virtual Aux Pin3 (usually maps to AXIS2_ENC_B_PIN) - -/* -// these enable virtual pin support -int vpin_array[8] = {-1,-1,-1,-1,-1,-1,-1,-1}; -void pinMode(const char* pin, byte mode) {} -void digitalWrite(const char* pin, int state) { int p=pin[1]-'0'; if ((pin[0]=='V') && (pin[2]==0) && (p>=0) && (p<=7)) { vpin_array[p]=state; } } -void analogWrite(const char* pin, int state) { int p=pin[1]-'0'; if ((pin[0]=='V') && (pin[2]==0) && (p>=0) && (p<=7)) { vpin_array[p]=state; } } -char* getVPins1to4() { static char s[20]; sprintf(s,"%d,%d,%d,%d",vpin_array[0],vpin_array[1],vpin_array[2],vpin_array[3]); return s; } -char* getVPins5to8() { static char s[20]; sprintf(s,"%d,%d,%d,%d",vpin_array[4],vpin_array[5],vpin_array[6],vpin_array[7]); return s; } -*/ +#define Aux1 12 // pullup driver RST or SPI MISO or Fault +#define Aux3 21 // Home SW for Axis1 (or I2C SDA) +#define Aux4 22 // Home SW for Axis2 (or I2C SCL) +#define Aux7 39 // Limit SW, PPS, etc. +#define Aux8 25 // OneWire, Status LED, Status2 LED, Reticle LED, Tone, etc. + +// Misc. pins +#ifndef OneWirePin + #define OneWirePin Aux8 // Default Pin for one wire bus +#endif // The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 36 -#define AnalogPecPin A0 // A0 or GPIO36 (PEC Sense, analog or digital) +#define PecPin 36 +#define AnalogPecPin A0 // PEC Sense, analog or digital (GPIO36) // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDnegPin Aux8 // Pin 25 (Drain) -#define LEDneg2Pin Aux8 // Pin 39 (Drain) -#define ReticulePin Aux8 // Pin 39 (Drain) +#define LEDnegPin Aux8 // Drain +#define LEDneg2Pin Aux8 // Drain +#define ReticlePin Aux8 // Drain // For a piezo buzzer -#define TonePin Aux8 // Pin 25 (Tone) +#define TonePin Aux8 // Tone // The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin Aux8 // Pin 25 (PPS time source, GPS for example) - -#define LimitPin Aux7 // Pin 39 (The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking) - -#define Axis1_HOME Aux3 // Pin 36 (Home sw) -#define Axis1DirPin 19 // Pin 19 (Dir) -#define Axis1StepPin 18 // Pin 18 (Step) -#define Axis1_Aux 12 // Pin 12 (pullup driver RST or SPI MISO) -#define Axis1_M2 23 // Pin 23 (Microstep Mode 2 or SPI CS) -#define Axis1_M1 14 // Pin 14 (Microstep Mode 1 or SPI SCK) -#define Axis1_M0 13 // Pin 13 (Microstep Mode 0 or SPI MOSI) -#define Axis1_EN 4 // Pin 4 (Enable) -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2_HOME Aux4 // Pin 39 (Home sw) -#define Axis2DirPin 26 // Pin 26 (Dir) -#define Axis2StepPin 27 // Pin 27 (Step) -#define Axis2_Aux 12 // Pin 12 (pullup driver RST or SPI MISO) -#define Axis2_M2 5 // Pin 5 (Microstep Mode 2 or SPI CS) -#define Axis2_M1 14 // Pin 14 (Microstep Mode 1 or SPI SCK) -#define Axis2_M0 13 // Pin 13 (Microstep Mode 0 or SPI MOSI) -#define Axis2_EN 4 // Pin 4 (Enable) -#define Axis2_Mode Axis2_M2 // (Decay mode switch) +#define PpsPin Aux7 // PPS time source, GPS for example + +#define LimitPin Aux7 // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking + +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 4 // Enable +#define Axis1_M0 13 // Microstep Mode 0 or SPI MOSI +#define Axis1_M1 14 // Microstep Mode 1 or SPI SCK +#define Axis1_M2 23 // Microstep Mode 2 or SPI CS or Decay Mode +#define Axis1_M3 Aux1 // Pullup driver RST or SPI MISO/Fault +#define Axis1StepPin 18 // Step +#define Axis1DirPin 19 // Dir +#define Axis1ModePin Axis1_M2 // Decay mode +#define Axis1FaultPin Aux1 // SPI MISO/Fault +#define Axis1HomePin Aux3 // Sense home position Axis1 + +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 4 // Enable +#define Axis2_M0 13 // Microstep Mode 0 or SPI MOSI +#define Axis2_M1 14 // Microstep Mode 1 or SPI SCK +#define Axis2_M2 5 // Microstep Mode 2 or SPI CS or Decay Mode +#define Axis2_M3 Aux1 // Pullup driver RST or SPI MISO/Fault +#define Axis2StepPin 27 // Step +#define Axis2DirPin 26 // Dir +#define Axis2ModePin Axis2_M2 // Decay mode +#define Axis2FaultPin Aux1 // SPI MISO/Fault +#define Axis2HomePin Aux4 // Sense home position Axis2 // For rotator stepper driver -#define Axis3DirPin 15 // Pin 15 (Dir) -#define Axis3StepPin 2 // Pin 2 (Step) -#define Axis3_EN 0 // Pin 0 (Enable) +#define Axis3_EN 0 // Enable +#define Axis3StepPin 2 // Step +#define Axis3DirPin 15 // Dir // For focuser1 stepper driver -#define Axis4DirPin 15 // Pin 15 (Dir) -#define Axis4StepPin 2 // Pin 2 (Step) -#define Axis4_EN 0 // Pin 0 (Enable) +#define Axis4_EN 0 // Enable +#define Axis4StepPin 2 // Step +#define Axis4DirPin 15 // Dir // For focuser2 stepper driver -#define Axis5DirPin 15 // Pin 15 (Dir) -#define Axis5StepPin 2 // Pin 2 (Step) -#define Axis5_EN 0 // Pin 0 (Enable) +#define Axis5_EN -1 // Enable +#define Axis5StepPin -1 // Step +#define Axis5DirPin -1 // Dir // ST4 interface -#define ST4RAw 34 // Pin 34 ST4 RA- West -#define ST4DEs 32 // Pin 32 ST4 DE- South -#define ST4DEn 33 // Pin 33 ST4 DE+ North -#define ST4RAe 35 // Pin 35 ST4 RA+ East +#define ST4RAw 34 // ST4 RA- West +#define ST4DEs 32 // ST4 DE- South +#define ST4DEn 33 // ST4 DE+ North +#define ST4RAe 35 // ST4 RA+ East #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.MaxESP3.h b/src/pinmaps/Pins.MaxESP3.h new file mode 100644 index 000000000..98dc8fb02 --- /dev/null +++ b/src/pinmaps/Pins.MaxESP3.h @@ -0,0 +1,82 @@ +// ------------------------------------------------------------------------------------------------- +// Pin map for OnStep MaxESP Version 3.x (ESP32S) + +#if defined(ESP32) + +// The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) +#define Aux1 26 // ESP8266 GPIO0 control (Axis2DirPin) +#define Aux2 4 // MISO for Axis1&2, or ESP8266 RST control, or Axis4 EN support +#define Aux3 21 // Home SW for Axis1 (or I2C SDA) +#define Aux4 22 // Home SW for Axis2 (or I2C SCL) +#define Aux7 39 // Limit SW, PPS, etc. +#define Aux8 25 // Status LED, Status2 LED, Reticle LED, Tone, OneWire, etc. + +// Misc. pins +#ifndef OneWirePin + #define OneWirePin Aux8 // Default Pin for one wire bus +#endif +#define ESP8266Gpio0Pin 2 // ESP8266 GPIO0 (Dir2) +#define ESP8266RstPin Aux2 // ESP8266 RST + +// The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset +#define PecPin 36 +#define AnalogPecPin A0 // PEC Sense, analog or digital (GPIO36) + +// The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED +#define LEDnegPin Aux8 // Drain +#define LEDneg2Pin Aux8 // Drain +#define ReticlePin Aux8 // Drain + +// For a piezo buzzer +#define TonePin Aux8 // Tone + +// The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency +#define PpsPin Aux7 // PPS time source, GPS for example + +#define LimitPin Aux7 // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking + +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 12 // Enable +#define Axis1_M0 13 // Microstep Mode 0 or SPI MOSI +#define Axis1_M1 14 // Microstep Mode 1 or SPI SCK +#define Axis1_M2 23 // Microstep Mode 2 or SPI CS +#define Axis1_M3 4 // SPI MISO/Fault +#define Axis1StepPin 18 // Step +#define Axis1DirPin 0 // Dir +#define Axis1HomePin Aux3 // Sense home position + +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 12 // Enable +#define Axis2_M0 13 // Microstep Mode 0 or SPI MOSI +#define Axis2_M1 14 // Microstep Mode 1 or SPI SCK +#define Axis2_M2 5 // Microstep Mode 2 or SPI CS +#define Axis2_M3 4 // SPI MISO/Fault +#define Axis2StepPin 27 // Step +#define Axis2DirPin 26 // Dir +#define Axis2HomePin Aux4 // Sense home position + +// For rotator stepper driver +#define Axis3_EN -1 // Enable +#define Axis3StepPin 2 // Step +#define Axis3DirPin 15 // Dir + +// For focuser1 stepper driver +#define Axis4_EN Aux2 // Enable +#define Axis4StepPin 19 // Step +#define Axis4DirPin 15 // Dir + +// For focuser2 stepper driver +#define Axis5_EN -1 // Enable +#define Axis5StepPin 2 // Step +#define Axis5DirPin 15 // Dir + +// ST4 interface +#define ST4RAw 34 // ST4 RA- West +#define ST4DEs 32 // ST4 DE- South +#define ST4DEn 33 // ST4 DE+ North +#define ST4RAe 35 // ST4 RA+ East + +#else +#error "Wrong processor for this configuration!" + +#endif diff --git a/src/pinmaps/Pins.MaxPCB.h b/src/pinmaps/Pins.MaxPCB.h index 48f3e68ff..74e00274e 100644 --- a/src/pinmaps/Pins.MaxPCB.h +++ b/src/pinmaps/Pins.MaxPCB.h @@ -4,91 +4,118 @@ #if defined(__MK64FX512__) || defined(__MK66FX1M0__) // The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux0 19 -#define Aux1 18 -#define Aux2 5 -#define Aux3 36 // this should also be ok as pwm analog output (w/#define Aux3_Analog) -#define Aux4 39 -#define Aux5 A21 // true analog output +#define Aux0 19 +#define Aux1 18 +#define Aux2 5 +#define Aux3 36 // Home SW, this should also be ok as pwm analog output (w/#define Aux3_Analog) +#define Aux4 39 // OneWire, Home SW +#define Aux5 A21 // true analog output #define Aux5_Analog -#define Aux6 A22 // true analog output +#define Aux6 A22 // true analog output #define Aux6_Analog -#define Aux7 4 // should be ok as pwm analog output (w/#define Aux7_Analog) -#define Aux8 22 // should be ok as pwm analog output (w/#define Aux8_Analog) +#define Aux7 4 // Limit SW, should be ok as pwm analog output (w/#define Aux7_Analog) +#define Aux8 22 // should be ok as pwm analog output (w/#define Aux8_Analog) // Misc. pins -#define OneWirePin Aux4 // Optional one wire bus -#define DS3234_CS_PIN 10 // Optional RTC CS pin +#ifndef DS3234_CS_PIN + #define DS3234_CS_PIN 10 // Default CS Pin for DS3234 on SPI +#endif +#ifndef OneWirePin + #define OneWirePin Aux4 // Default Pin for one wire bus +#endif +#if PINMAP == MaxTMC + #define ESP8266Gpio0Pin 2 // ESP8266 GPIO0 (Dir2) + #define ESP8266RstPin Aux2 // ESP8266 RST +#elif PINMAP == MaxPCB + #define ESP8266Gpio0Pin Aux1 // ESP8266 GPIO0 or SPI MISO/Fault + #define ESP8266RstPin Aux2 // ESP8266 RST or SPI MISO/Fault +#endif // The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 23 -#define AnalogPecPin 23 // Pin 23 (PEC Sense, analog or digital) +#define PecPin 23 +#define AnalogPecPin 23 // PEC Sense, analog or digital // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDnegPin Aux0 // Pin 19 (Drain) -#define LEDneg2Pin Aux8 // Pin 22 (Drain) -#define ReticulePin Aux8 // Pin 22 (Drain) +#define LEDnegPin Aux0 // Drain +#define LEDneg2Pin Aux8 // Drain +#define ReticlePin Aux8 // Drain // For a piezo buzzer -#define TonePin 29 // Pin 29 (Tone) +#define TonePin 29 // Tone // The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 28 // Pin 28 (PPS time source, GPS for example) - -#define LimitPin Aux7 // Pin 4 (The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking) - -// For ESP8266 control -#define ESP8266Gpio0Pin Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define ESP8266RstPin Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) - -#define Axis1DirPin 21 // Pin 21 (Dir) -#define Axis1StepPin 20 // Pin 20 (Step) -#define Axis1_HOME Aux3 // Pin 36 (Home sw) -#define Axis1_FAULT Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define Axis1_Aux Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define Axis1_M2 17 // Pin 17 (Microstep Mode 2 or SPI CS) -#define Axis1_M1 16 // Pin 16 (Microstep Mode 1 or SPI SCK) -#define Axis1_M0 15 // Pin 15 (Microstep Mode 0 or SPI MOSI) -#define Axis1_EN 14 // Pin 14 (Enable) -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2DirPin 2 // Pin 2 (Dir) -#define Axis2StepPin 3 // Pin 3 (Step) -#define Axis2_HOME Aux4 // Pin 39 (Home sw) -#define Axis2_FAULT Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) -#define Axis2_Aux Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) -#define Axis2_M2 6 // Pin 6 (Microstep Mode 2 or SPI CS) -#define Axis2_M1 7 // Pin 7 (Microstep Mode 1 or SPI SCK) -#define Axis2_M0 8 // Pin 8 (Microstep Mode 0 or SPI MOSI) -#define Axis2_EN 9 // Pin 9 (Enable) -#define Axis2_Mode Axis2_M2 // (Decay mode switch) +#define PpsPin 28 // PPS time source, GPS for example + +#define LimitPin Aux7 // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking + +// Axis1 RA/Azm step/dir driver +#define Axis1DirPin 21 // Dir +#define Axis1StepPin 20 // Step + +#define Axis1_EN 14 // Enable +#define Axis1_M0 15 // Microstep Mode 0 or SPI MOSI +#define Axis1_M1 16 // Microstep Mode 1 or SPI SCK +#define Axis1_M2 17 // Microstep Mode 2 or SPI CS or Decay Mode +#define Axis1_M3 Aux1 // SPI MISO/Fault (or ESP8266 GPIO0 on MaxPCB) +#define Axis1ModePin Axis1_M2 // Decay mode +#define Axis1FaultPin Aux1 // SPI MISO/Fault (or ESP8266 GPIO0 on MaxPCB) +#define Axis1HomePin Aux3 // Sense home position Axis1 + +// Axis2 Dec/Alt step/dir driver +#define Axis2DirPin 2 // Dir (ESP8266 GPIO0 on MaxTMC) +#define Axis2StepPin 3 // Step + +#define Axis2_EN 9 // Enable +#define Axis2_M0 8 // Microstep Mode 0 or SPI MOSI +#define Axis2_M1 7 // Microstep Mode 1 or SPI SCK +#define Axis2_M2 6 // Microstep Mode 2 or SPI CS or Decay Mode +#ifdef MaxTMC + #define Axis2_M3 Aux1 // SPI MISO +#else + #define Axis2_M3 Aux2 // ESP8266 RST or SPI MISO/Fault +#endif +#define Axis2ModePin Axis2_M2 // Decay mode +#define Axis2FaultPin Aux2 +#define Axis2HomePin Aux4 // Sense home position // For rotator stepper driver -#define Axis3DirPin 33 // Pin 33 (Dir) -#define Axis3StepPin 30 // Pin 30 (Step) -#ifndef Axis3_EN -#define Axis3_EN Aux5 // Pin A21 (Enable) +#define Axis3_EN Aux5 // Enable +#if PINMAP == MaxTMC + #define Axis3_M0 15 // SPI MOSI + #define Axis3_M1 16 // SPI SCK + #define Axis3_M2 7 // SPI CS or Decay Mode + #define Axis3_M3 Aux1 // SPI MISO #endif +#define Axis3StepPin 30 // Step +#define Axis3DirPin 33 // Dir // For focuser1 stepper driver -#define Axis4DirPin 35 // Pin 35 (Dir) -#define Axis4StepPin 34 // Pin 34 (Step) -#ifndef Axis4_EN -#define Axis4_EN Aux6 // Pin A22 (Enable) +#define Axis4_EN Aux6 // Enable +#if PINMAP == MaxTMC + #define Axis4_M0 15 // SPI MOSI + #define Axis4_M1 16 // SPI SCK + #define Axis4_M2 8 // SPI CS or Decay Mode + #define Axis4_M3 Aux1 // SPI MISO #endif +#define Axis4StepPin 34 // Step +#define Axis4DirPin 35 // Dir // For focuser2 stepper driver -#define Axis5DirPin 33 // Pin 33 (Dir) -#define Axis5StepPin 30 // Pin 30 (Step) -#ifndef Axis5_EN -#define Axis5_EN Aux5 // Pin A21 (Enable) +#define Axis5_EN Aux5 // Enable +#if PINMAP == MaxTMC + #define Axis5_M0 15 // SPI MOSI + #define Axis5_M1 16 // SPI SCK + #define Axis5_M2 7 // SPI CS or Decay Mode + #define Axis5_M3 Aux1 // SPI MISO #endif +#define Axis5StepPin 30 // Step +#define Axis5DirPin 33 // Dir // ST4 interface -#define ST4RAw 24 // Pin 24 ST4 RA- West -#define ST4DEs 25 // Pin 25 ST4 DE- South -#define ST4DEn 26 // Pin 26 ST4 DE+ North -#define ST4RAe 27 // Pin 27 ST4 RA+ East +#define ST4RAw 24 // ST4 RA- West +#define ST4DEs 25 // ST4 DE- South +#define ST4DEn 26 // ST4 DE+ North +#define ST4RAe 27 // ST4 RA+ East #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.Mega2560Alt.h b/src/pinmaps/Pins.Mega2560Alt.h index 6f2a36cf9..3bd346456 100644 --- a/src/pinmaps/Pins.Mega2560Alt.h +++ b/src/pinmaps/Pins.Mega2560Alt.h @@ -3,66 +3,88 @@ #if defined(__AVR_ATmega2560__) +// Misc. pins +#ifndef DS3234_CS_PIN + #define DS3234_CS_PIN 10 // Default CS Pin for DS3234 on SPI +#endif +#ifndef BME280_CS_PIN + #define BME280_CS_PIN 11 // Default CS Pin for BME280 on SPI +#endif +#ifndef OneWirePin + #define OneWirePin 24 // Default Pin for one wire bus +#endif + // The PEC index sense is a 5V logic input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 2 -#define AnalogPecPin 1 +#define PecPin 2 +#define AnalogPecPin 1 // The limit switch sense is a 5V logic input which uses the internal pull up, shorted to ground it stops gotos/tracking -#define LimitPin 3 +#define LimitPin 3 // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDposPin 8 // Pin 8 (LED) -#define LEDnegPin 9 // Pin 9 (GND) -#define LEDneg2Pin 7 // Pin 7 (GND) -#define ReticulePin 44 // Pin 44 (GND) +#define LEDposPin 8 // LED +#define LEDnegPin 9 // GND +#define LEDneg2Pin 7 // GND +#define ReticlePin 44 // GND // For a piezo buzzer -#define TonePin 42 // Pin 42 (Tone) +#define TonePin 42 // Tone // The PPS pin is a 5V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 21 // Interrupt 2 on Pin 21 (alternate Int3 on Pin20) -#define DS3234_CS_PIN 10 - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis1DirPin 37 // Pin 37 (Dir) PC0 -#define Axis1DirBit 0 // -#define Axis1DirPORT PORTC // -#define Axis1StepPin 35 // Pin 35 (Step) PC2 -#define Axis1StepBit 2 // -#define Axis1StepPORT PORTC // +#define PpsPin 21 // Interrupt 2 on Pin 21 (alternate Int3 on Pin20) -#define Axis1_M0 29 // Pin 29 (Microstep or Decay Mode 0) -#define Axis1_M1 27 // Pin 27 (Microstep or Decay Mode 1) -#define Axis1_M2 25 // Pin 25 (Microstep or Decay Mode 2) -#define Axis1_EN 23 // Pin 23 (Enable) -#define Axis1_FAULT 39 // Pin 39 (Fault) -#define Axis1_Aux 39 // Pin 39 (Aux - SPI MISO) -#define Axis1_Mode 41 // Pin 41 (Aux Decay Mode for Axis1) +// Axis1 RA/Azm step/dir driver +#define Axis1_EN 23 // Enable +#define Axis1_M0 29 // Microstep or Decay Mode 0 +#define Axis1_M1 27 // Microstep or Decay Mode 1 +#define Axis1_M2 25 // Microstep or Decay Mode 2 +#define Axis1_M3 39 // SPI MISO/Fault +#define Axis1StepPin 35 // Step PC2 +#define Axis1StepBit 2 // +#define Axis1StepPORT PORTC // +#define Axis1DirPin 37 // Dir PC0 +#define Axis1DirBit 0 // +#define Axis1DirPORT PORTC // +#define Axis1FaultPin 39 // SPI MISO/Fault +#define Axis1ModePin 41 // Decay mode -// The HA(RA) and Dec jumpers (going to the big easy drivers) are simply four wire jumper cables, each has identical wiring - simple modular construction -#define Axis2DirPin 22 // Pin 22 (Dir) PA0 -#define Axis2DirBit 0 // -#define Axis2DirPORT PORTA // -#define Axis2StepPin 24 // Pin 24 (Step) PA2 -#define Axis2StepBit 2 // -#define Axis2StepPORT PORTA // +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 36 // Enabled +#define Axis2_M0 30 // Microstep or Decay Mode 0 +#define Axis2_M1 32 // Microstep or Decay Mode 1 +#define Axis2_M2 34 // Microstep or Decay Mode 2 +#define Axis2_M3 38 // SPI MISO/Fault +#define Axis2StepPin 24 // Step PA2 +#define Axis2StepBit 2 // +#define Axis2StepPORT PORTA // +#define Axis2DirPin 22 // Dir PA0 +#define Axis2DirBit 0 // +#define Axis2DirPORT PORTA // +#define Axis2FaultPin 38 // SPI MISO/Fault +#define Axis2ModePin 40 // Decay mode -#define Axis2_M0 30 // Pin 30 (Microstep or Decay Mode 0) -#define Axis2_M1 32 // Pin 32 (Microstep or Decay Mode 1) -#define Axis2_M2 34 // Pin 34 (Microstep or Decay Mode 2) -#define Axis2_EN 36 // Pin 36 (Enabled) -#define Axis2_FAULT 38 // Pin 38 (Fault) -#define Axis2_Aux 38 // Pin 38 (Aux - SPI MISO) -#define Axis2_Mode 40 // Pin 40 (Aux Decay Mode for Axis2) +// For rotator stepper driver +#define Axis3_EN -1 // Enable +#define Axis3StepPin -1 // Step +#define Axis3DirPin -1 // Dir + +// For focuser1 stepper driver +#define Axis4_EN -1 // Enable +#define Axis4StepPin -1 // Step +#define Axis4DirPin -1 // Dir + +// For focuser2 stepper driver +#define Axis5_EN -1 // Enable +#define Axis5StepPin -1 // Step +#define Axis5DirPin -1 // Dir // ST4 interface -#define ST4RAw 47 // Pin 47 ST4 RA- West -#define ST4DEs 43 // Pin 43 ST4 DE- South -#define ST4DEn 45 // Pin 45 ST4 DE+ North -#define ST4RAe 49 // Pin 49 ST4 RA+ East +#define ST4RAw 47 // ST4 RA- West +#define ST4DEs 43 // ST4 DE- South +#define ST4DEn 45 // ST4 DE+ North +#define ST4RAe 49 // ST4 RA+ East #else #error "Wrong processor for this configuration!" #endif - diff --git a/src/pinmaps/Pins.MiniPCB.h b/src/pinmaps/Pins.MiniPCB.h index e0df3f966..e96e8a251 100644 --- a/src/pinmaps/Pins.MiniPCB.h +++ b/src/pinmaps/Pins.MiniPCB.h @@ -1,85 +1,98 @@ // ------------------------------------------------------------------------------------------------- -// Pin map for OnStep MiniPCB (Teensy3.2) +// Pin map for OnStep MiniPCB (Teensy3.0, 3.1, 3.2, and 4.0) #if defined(__MK20DX256__) || defined(_mk20dx128_h_) || defined(__MK20DX128__) || defined(__IMXRT1052__) || defined(__IMXRT1062__) // The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux0 19 -#define Aux1 18 -#define Aux2 5 -#define Aux3 4 // should be ok as pwm analog output (w/#define Aux3_Analog) -#define Aux4 22 // should be ok as pwm analog output (w/#define Aux4_Analog) +#define Aux0 19 +#define Aux1 18 +#define Aux2 5 +#define Aux3 4 // should be ok as pwm analog output (w/#define Aux3_Analog) +#define Aux4 22 // should be ok as pwm analog output (w/#define Aux4_Analog) #if !defined(_mk20dx128_h_) && !defined(__MK20DX128__) && !defined(__IMXRT1052__) && !defined(__IMXRT1062__) -#define Aux5 A14 // true analog output + #define Aux5 A14 // true analog output #endif #define Aux5_Analog -// Optional one wire bus +// Misc. pins #ifndef OneWirePin -#define OneWirePin 24 // Pin 24 + #define OneWirePin 24 // Default Pin for one wire bus +#endif +#ifdef MiniEMB + #define ESP8266Gpio0Pin 2 // ESP8266 GPIO0 (Dir2) + #define ESP8266RstPin Aux2 // ESP8266 RST +#else + #define ESP8266Gpio0Pin Aux1 // ESP8266 GPIO0 or SPI MISO/Fault + #define ESP8266RstPin Aux2 // ESP8266 RST or SPI MISO/Fault #endif // The PEC index sense is a logic level input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 23 -#define AnalogPecPin 23 // Pin 23 (PEC Sense, analog or digital) +#define PecPin 23 +#define AnalogPecPin 23 // PEC Sense, analog or digital // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDnegPin Aux0 // Pin 19 (Drain) -#define LEDneg2Pin Aux4 // Pin 22 (Drain) -#define ReticulePin Aux4 // Pin 22 (Drain) +#define LEDnegPin Aux0 // Drain +#define LEDneg2Pin Aux4 // Drain +#define ReticlePin Aux4 // Drain // For a piezo buzzer -#define TonePin 29 // Pin 29 (Tone) +#define TonePin 29 // Tone // The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 28 // Pin 28 (PPS time source, GPS for example) -#define DS3234_CS_PIN 10 - -// For ESP8266 control -#define ESP8266Gpio0Pin Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define ESP8266RstPin Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) - -#define Axis1DirPin 21 // Pin 21 (Dir) -#define Axis1StepPin 20 // Pin 20 (Step) -#define Axis1_FAULT Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define Axis1_Aux Aux1 // Pin 18 (Aux1 - ESP8266 GPIO0 or SPI MISO or Fault) -#define Axis1_M2 17 // Pin 17 (Microstep Mode 2 or SPI CS) -#define Axis1_M1 16 // Pin 16 (Microstep Mode 1 or SPI SCK) -#define Axis1_M0 15 // Pin 15 (Microstep Mode 0 or SPI MOSI) -#define Axis1_EN 14 // Pin 14 (Enable) -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2DirPin 2 // Pin 2 (Dir) -#define Axis2StepPin 3 // Pin 3 (Step) -#define LimitPin Aux3 // Pin 4 (The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking) -#define Axis2_FAULT Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) -#define Axis2_Aux Aux2 // Pin 5 (Aux2 - ESP8266 RST or SPI MISO or Fault) -#define Axis2_M2 6 // Pin 6 (Microstep Mode 2 or SPI CS) -#define Axis2_M1 7 // Pin 7 (Microstep Mode 1 or SPI SCK) -#define Axis2_M0 8 // Pin 8 (Microstep Mode 0 or SPI MOSI) -#define Axis2_EN 9 // Pin 9 (Enable) -#define Axis2_Mode Axis2_M2 // (Decay mode switch) +#define PpsPin 28 // PPS time source, GPS for example + +#define LimitPin Aux3 // The limit switch sense is a logic level input normally pull high (2k resistor,) shorted to ground it stops gotos/tracking + +// Axis1 RA/Azm step/dir driver +#define Axis1DirPin 21 // Dir +#define Axis1StepPin 20 // Step + +#define Axis1_EN 14 // Enable +#define Axis1_M0 15 // Microstep Mode 0 or SPI MOSI +#define Axis1_M1 16 // Microstep Mode 1 or SPI SCK +#define Axis1_M2 17 // Microstep Mode 2 or SPI CS or Decay Mode +#define Axis1_M3 Aux1 // ESP8266 GPIO0 (option on MiniPCB) or SPI MISO/Fault +#define Axis1ModePin Axis1_M2 // Decay mode +#define Axis1FaultPin Aux1 // SPI MISO/Fault +#define Axis1HomePin Aux3 // Sense home position + +#define Axis2DirPin 2 // Dir (ESP8266 GPIO0 on MiniEMB) +#define Axis2StepPin 3 // Step + +// Axis2 Dec/Alt step/dir driver +#define Axis2_EN 9 // Enable +#define Axis2_M0 8 // Microstep Mode 0 or SPI MOSI +#define Axis2_M1 7 // Microstep Mode 1 or SPI SCK +#define Axis2_M2 6 // Microstep Mode 2 or SPI CS or Decay Mode +#ifdef MiniEMB + #define Axis2_M3 Aux1 // SPI MISO/Fault or I2C SDA +#else + #define Axis2_M3 Aux2 // ESP8266 RST or SPI MISO/Fault +#endif +#define Axis2ModePin Axis2_M2 // Decay mode +#define Axis2FaultPin Axis2_M3 +#define Axis2HomePin Aux4 // Sense home position // For rotator stepper driver -#define Axis3DirPin 33 // Pin 33 (Dir) -#define Axis3StepPin 30 // Pin 30 (Step) -#define Axis3_EN -1 // No EN Pin +#define Axis3_EN -1 // ENable +#define Axis3StepPin 30 // Step +#define Axis3DirPin 33 // Dir // For focuser1 stepper driver -#define Axis4DirPin 32 // Pin 32 (Dir) -#define Axis4StepPin 31 // Pin 31 (Step) -#define Axis4_EN -1 // No EN Pin +#define Axis4_EN -1 // ENable +#define Axis4StepPin 31 // Step +#define Axis4DirPin 32 // Dir // For focuser2 stepper driver -#define Axis5DirPin 33 // Pin 33 (Dir) -#define Axis5StepPin 30 // Pin 30 (Step) -#define Axis5_EN -1 // No EN Pin +#define Axis5_EN -1 // ENable +#define Axis5StepPin 30 // Step +#define Axis5DirPin 33 // Dir // ST4 interface -#define ST4RAw 10 // Pin 10 ST4 RA- West -#define ST4DEs 11 // Pin 11 ST4 DE- South -#define ST4DEn 12 // Pin 12 ST4 DE+ North -#define ST4RAe 13 // Pin 13 ST4 RA+ East +#define ST4RAw 10 // ST4 RA- West +#define ST4DEs 11 // ST4 DE- South +#define ST4DEn 12 // ST4 DE+ North +#define ST4RAe 13 // ST4 RA+ East #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.Ramps14.h b/src/pinmaps/Pins.Ramps14.h index c7d2afe73..fc643aa0a 100644 --- a/src/pinmaps/Pins.Ramps14.h +++ b/src/pinmaps/Pins.Ramps14.h @@ -1,26 +1,34 @@ // ------------------------------------------------------------------------------------------------- -// Pin map for OnStep using RAMPS 1.4 Shield (Arduino Mega2560 or Arduino DUE) +// Pin map for OnStep using RAMPS 1.4 Pin defs (Arduino Mega2560) #if defined(__AVR_ATmega2560__) || defined(__SAM3X8E__) // The multi-purpose pins (Aux3..Aux8 can be analog (pwm/dac) if supported) -#define Aux0 11 -#define Aux1 29 -#define Aux2 37 -#define Aux3 62 -#define Aux4 24 -#define Aux5 30 -#define Aux6 8 // heater -#define Aux7 9 // heater, analog (pwm) +#define Aux0 11 +#define Aux1 29 +#define Aux2 37 +#define Aux3 20 // Home SW; note modified pinmap 9/30/19 Aux3 and Aux4 were changed, Aux5 was removed +#define Aux4 21 // Home SW +#define Aux6 8 // Heater +#define Aux7 9 // Heater, analog (pwm) #define Aux7_Analog -#define Aux8 10 // heater, analog (pwm) +#define Aux8 10 // Heater, analog (pwm) #define Aux8_Analog -#define Aux9 39 // general purpose -#define Aux10 41 -#define Aux11 43 -#define Aux12 45 -#define Aux13 47 -#define Aux14 32 +#define Aux9 39 // General purpose +#define Aux10 41 +#define Aux11 43 +#define Aux12 45 +#define Aux13 47 +#define Aux14 32 + +#ifndef DS3234_CS_PIN + #define DS3234_CS_PIN 53 // Default CS Pin for DS3234 on SPI +#endif +#ifndef BME280_CS_PIN + #define BME280_CS_PIN 49 // Default CS Pin for BME280 on SPI +#endif +#define ESP8266Gpio0Pin Aux1 // ESP8266 GPIO0 or SPI MISO/Fault +#define ESP8266RstPin Aux2 // ESP8266 RST or SPI MISO/Fault // For software SPI #define SSPI_SCK 52 @@ -28,81 +36,77 @@ #define SSPI_MOSI 51 // The PEC index sense is a 5V logic input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 57 // RAMPS AUX1, A-OUT (1=+5V, 2=GND, 3=PEC) -#define AnalogPecPin A3 // Note A3 is (57) +#define PecPin 57 // RAMPS AUX1, A-OUT (1=+5V, 2=GND, 3=PEC) +#define AnalogPecPin A3 // Note A3 is (57) // The limit switch sense is a 5V logic input which uses the internal (or external 2k) pull up, shorted to ground it stops gotos/tracking -#define LimitPin 3 // RAMPS X- (1=LMT, 2=GND, 3=+5) +#define LimitPin 3 // RAMPS X- (1=LMT, 2=GND, 3=+5) // The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDnegPin Aux0 // Pin 11 RAMPS SERVO1 (1=GND, 2=+5, 3=LED-) (active LOW) -#define LEDneg2Pin 6 // Pin 6 RAMPS SERVO2 (1=GND, 2=+5, 3=LED-) (active LOW) -#define ReticulePin 5 // Pin 5 RAMPS SERVO3 (1=GND, 2=+5, 3=LED-) (active LOW) +#define LEDnegPin Aux0 // RAMPS SERVO1 (1=GND, 2=+5, 3=LED-) (active LOW) +#define LEDneg2Pin 6 // RAMPS SERVO2 (1=GND, 2=+5, 3=LED-) (active LOW) +#define ReticlePin 5 // RAMPS SERVO3 (1=GND, 2=+5, 3=LED-) (active LOW) // Pin for a piezo buzzer output on RAMPS Y-MIN -#define TonePin 4 // Pin 4 RAMPS SERVO4 (1=GND, 2=+5, 3=TONE+) (active HIGH) +#define TonePin 4 // RAMPS SERVO4 (1=GND, 2=+5, 3=TONE+) (active HIGH) // The PPS pin is a 5V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 2 // RAMPS X+, Interrupt 0 on Pin 2 -#define DS3234_CS_PIN 53 -#define BME280_CS_PIN 49 - -// For ESP8266 control -#define ESP8266Gpio0Pin Aux1 -#define ESP8266RstPin Aux2 +#define PpsPin 2 // RAMPS X+, Interrupt 0 on Pin 2 // Pins to Axis1 RA/Azm on RAMPS X -#define Axis1DirPin 55 // Pin A1 (Dir) -#define Axis1DirBit 1 // -#define Axis1DirPORT PORTF // -#define Axis1StepPin 54 // Pin A0 (Step) -#define Axis1StepBit 0 // -#define Axis1StepPORT PORTF // -#define Axis1_HOME 20 // Pin 20 (Home sw) -#define Axis1_FAULT Aux1 // Pin 29 (Aux1 - SPI MISO or Fault) -#define Axis1_Aux Aux1 // Pin 29 (Aux1 - SPI MISO or Fault) -#define Axis1_M2 27 // Pin 27 (Microstep Mode 2 or SPI CS) -#define Axis1_M1 25 // Pin 25 (Microstep Mode 1 or SPI SCK) -#define Axis1_M0 23 // Pin 23 (Microstep Mode 0 or SPI MOSI) -#define Axis1_EN 38 // Pin 38 (Enable) -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -// Pins to Axis2 Dec/Alt on RAMPS Y -#define Axis2DirPin 61 // Pin A7 (Dir) -#define Axis2DirBit 7 // -#define Axis2DirPORT PORTF // -#define Axis2StepPin 60 // Pin A6 (Step) -#define Axis2StepBit 6 // -#define Axis2StepPORT PORTF // -#define Axis2_HOME 21 // Pin 21 (Home sw) -#define Axis2_FAULT Aux2 // Pin 37 (Aux2 - SPI MISO or Fault) -#define Axis2_Aux Aux2 // Pin 37 (Aux2 - SPI MISO or Fault) -#define Axis2_M2 35 // Pin 35 (Microstep Mode 2 or SPI CS) -#define Axis2_M1 33 // Pin 33 (Microstep Mode 1 or SPI SCK) -#define Axis2_M0 31 // Pin 31 (Microstep Mode 0 or SPI MOSI) -#define Axis2_EN 56 // Pin A2 (Enable) -#define Axis2_Mode Axis2_M2 // (Decay mode switch) +#define Axis1DirPin 55 // Dir +#define Axis1DirBit 1 // +#define Axis1DirPORT PORTF // +#define Axis1StepPin 54 // Step +#define Axis1StepBit 0 // +#define Axis1StepPORT PORTF // + +#define Axis1_EN 38 // Enable +#define Axis1_M0 23 // Microstep Mode 0 or SPI MOSI +#define Axis1_M1 25 // Microstep Mode 1 or SPI SCK +#define Axis1_M2 27 // Microstep Mode 2 or SPI CS +#define Axis1_M3 Aux1 // SPI MISO/Fault +#define Axis1ModePin Axis1_M2 // Decay mode +#define Axis1FaultPin Aux1 +#define Axis1HomePin Aux3 // Sense home position + +// Axis2 Dec/Alt step/dir driver on RMAPS Y +#define Axis2DirPin 61 // Dir +#define Axis2DirBit 7 // +#define Axis2DirPORT PORTF // +#define Axis2StepPin 60 // Step (Pin A6) +#define Axis2StepBit 6 // +#define Axis2StepPORT PORTF // + +#define Axis2_EN 56 // Enable (Pin A2) +#define Axis2_M0 31 // Microstep Mode 0 or SPI MOSI +#define Axis2_M1 33 // Microstep Mode 1 or SPI SCK +#define Axis2_M2 35 // Microstep Mode 2 or SPI CS +#define Axis2_M3 Aux2 // SPI MISO/Fault +#define Axis2ModePin Axis2_M2 // Decay mode +#define Axis2FaultPin Aux2 +#define Axis2HomePin Aux4 // Sense home position // For rotator stepper driver on RAMPS Z -#define Axis3DirPin 48 // Pin 48 (Dir) -#define Axis3StepPin 46 // Pin 46 (Step) -#define Axis3_EN Aux3 // Pin A8 (Enable) +#define Axis3_EN 62 // Enable (Pin A8) +#define Axis3StepPin 46 // Step +#define Axis3DirPin 48 // Dir // For focuser1 stepper driver on RAMPS E0 -#define Axis4DirPin 28 // Pin 28 (Dir) -#define Axis4StepPin 26 // Pin 26 (Step) -#define Axis4_EN Aux4 // Pin 24 (Enable) +#define Axis4_EN 24 // Enable +#define Axis4StepPin 26 // Step +#define Axis4DirPin 28 // Dir // For focuser2 stepper driver on RAMPS E1 -#define Axis5DirPin 34 // Pin 34 (Dir) -#define Axis5StepPin 36 // Pin 36 (Step) -#define Axis5_EN Aux5 // Pin 30 (Enable) +#define Axis5_EN 30 // Enable +#define Axis5StepPin 36 // Step +#define Axis5DirPin 34 // Dir // ST4 interface on RAMPS AUX-2 -#define ST4RAw A9 // Pin A9 ST4 RA- West -#define ST4DEs 40 // Pin 40 ST4 DE- South -#define ST4DEn 42 // Pin 42 ST4 DE+ North -#define ST4RAe A11 // Pin A11 ST4 RA+ East +#define ST4RAw A9 // ST4 RA- West (Pin A9) +#define ST4DEs 40 // ST4 DE- South +#define ST4DEn 42 // ST4 DE+ North +#define ST4RAe A11 // ST4 RA+ East (Pin A11) #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.STM32B.h b/src/pinmaps/Pins.STM32B.h index 99edf3d99..8fb01918d 100644 --- a/src/pinmaps/Pins.STM32B.h +++ b/src/pinmaps/Pins.STM32B.h @@ -32,7 +32,7 @@ // STM32 pin PB6 -> SCL on DS3231 // STM32 pin PB7 -> SDA on DS3231 -#if defined(STM32Blue_ON) +#if PINMAP == STM32Blue #define A1EN PA12 #define A1M0 PA11 @@ -70,7 +70,7 @@ #define LIMIT PA14 #define SPARE_PA13 PA13 -#elif defined(STM32Black_ON) +#elif PINMAP == STM32Black #define A1EN PA3 #define A1M0 PA2 @@ -95,6 +95,7 @@ #define LED PB12 #define TONE PB1 + #define RETICLE -1 #define SQW PB5 #define PECIDX PB0 @@ -111,78 +112,81 @@ // The pins here are not tested yet, and need to change // The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux0 LED -#define Aux1 A1MISO -#define Aux2 A2MISO +#define Aux0 LED +#define Aux1 A1MISO +#define Aux2 A2MISO // For ESP8266 control -#define ESP8266Gpio0Pin Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO -#define ESP8266RstPin Aux2 // Aux2 - ESP8266 RST or SPI MISO or Fault - -#define Axis1_EN A1EN // Enable -#define Axis1_M0 A1M0 // Microstep Mode 0 -#define Axis1_M1 A1M1 // Microstep Mode 1 -#define Axis1_M2 A1M2 // Microstep Mode 2 -#define Axis1StepPin A1ST // Step -#define Axis1DirPin A1DR // Motor Direction -#define Axis1_Aux Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Fault -#define Axis1_FAULT Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Fault -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2_EN A2EN // Enable -#define Axis2_M0 A2M0 // Microstep Mode 0 -#define Axis2_M1 A2M1 // Microstep Mode 1 -#define Axis2_M2 A2M2 // Microstep Mode 2 -#define Axis2StepPin A2ST // Step -#define Axis2DirPin A2DR // Motor Direction -#define Axis2_Aux Aux2 // Aux2 - ESP8266 RST or SPI MISO or Fault -#define Axis2_FAULT Aux2 // Aux2 - ESP8266 RST or SPI MISO or Fault -#define Axis2_Mode Axis2_M2 // (Decay mode switch) +#define ESP8266Gpio0Pin Aux1 // ESP8266 GPIO0 or SPI MISO/Fault +#define ESP8266RstPin Aux2 // ESP8266 RST or SPI MISO/Fault + +// Axis1 RA/Azm step/dir driver +#define Axis1StepPin A1ST // Step +#define Axis1DirPin A1DR // Motor Direction + +#define Axis1_EN A1EN // Enable +#define Axis1_M0 A1M0 // Microstep Mode 0 +#define Axis1_M1 A1M1 // Microstep Mode 1 +#define Axis1_M2 A1M2 // Microstep Mode 2 +#define Axis1_M3 Aux1 // ESP8266 GPIO0 or SPI MISO/Fault +#define Axis1FaultPin Aux1 // ESP8266 GPIO0 or SPI MISO/Fault +#define Axis1ModePin Axis1_M2 // Decay mode + +// Axis2 Dec/Alt step/dir driver +#define Axis2StepPin A2ST // Step +#define Axis2DirPin A2DR // Motor Direction + +#define Axis2_EN A2EN // Enable +#define Axis2_M0 A2M0 // Microstep Mode 0 +#define Axis2_M1 A2M1 // Microstep Mode 1 +#define Axis2_M2 A2M2 // Microstep Mode 2 +#define Axis2_M3 Aux2 // ESP8266 RST or SPI MISO/Fault +#define Axis2FaultPin Aux2 // ESP8266 RST or SPI MISO/Fault +#define Axis2ModePin Axis2_M2 // Decay mode // ST4 interface -#define ST4DEn S4N // ST4 DE+ North -#define ST4DEs S4S // ST4 DE- South -#define ST4RAw S4W // ST4 RA- West -#define ST4RAe S4E // ST4 RA+ East +#define ST4DEn S4N // ST4 DE+ North +#define ST4DEs S4S // ST4 DE- South +#define ST4RAw S4W // ST4 RA- West +#define ST4RAe S4E // ST4 RA+ East // This is the built in LED for the Black Pill board. There is a pin // available from it too, in case you want to power another LED with a wire -#define LEDnegPin Aux0 // Drain +#define LEDnegPin Aux0 // Drain +#define LEDneg2Pin -1 // Drain // For a piezo buzzer -#define TonePin TONE // Tone +#define TonePin TONE // Tone // The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and // adjusts the internal sidereal clock frequency -#define PpsPin SQW // Pulse Per Second time source, e.g. GPS, RTC +#define PpsPin SQW // Pulse Per Second time source, e.g. GPS, RTC // For rotator stepper driver -#define Axis3DirPin F1DR // Dir -#define Axis3StepPin F1ST // Step -#define Axis3_EN F1EN // Enable +#define Axis3_EN F1EN // Enable +#define Axis3StepPin F1ST // Step +#define Axis3DirPin F1DR // Dir // Pins to focuser1 stepper driver -#define Axis4DirPin F1DR // Dir -#define Axis4StepPin F1ST // Step -#define Axis4_EN F1EN // Enable +#define Axis4_EN F1EN // Enable +#define Axis4StepPin F1ST // Step +#define Axis4DirPin F1DR // Dir // For focuser2 stepper driver -#define Axis5DirPin F1DR // Dir -#define Axis5StepPin F1ST // Step -#define Axis5_EN F1EN // Enable +#define Axis5_EN -1 // Enable +#define Axis5StepPin -1 // Step +#define Axis5DirPin -1 // Dir // The limit switch sense is a logic level input which uses the internal pull up, // shorted to ground it stops gotos/tracking -#define LimitPin LIMIT +#define LimitPin LIMIT // The PEC index sense is a logic level input, resets the PEC index on rising // edge then waits for 60 seconds before allowing another reset -#define PecPin PECIDX -//#define AnalogPecPin Undefined // PEC Sense, analog or digital +#define PecPin PECIDX +#define AnalogPecPin -1 // PEC Sense, analog or digital -//#define LEDneg2Pin Undefined // Drain - -#define ReticulePin RETICLE // Drain +#define ReticlePin RETICLE // Drain #else #error "Wrong processor for this configuration!" diff --git a/src/pinmaps/Pins.STM32CZ.h b/src/pinmaps/Pins.STM32CZ.h deleted file mode 100644 index b0d4322cc..000000000 --- a/src/pinmaps/Pins.STM32CZ.h +++ /dev/null @@ -1,96 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep on STM32 -// -// This pin map is for an STM32F103C8T6 "Black Pill" stick. -// It runs at 72MHz has 128K flash and 20K RAM, and is 3.3V only -// -// Cost on eBay and AliExpress is less than US $2.50 -// More info, schematic at: -// http://wiki.stm32duino.com/index.php?title=Black_Pill -// -// Other boards based on the following chips also have enough flash -// and RAM for OnStep, and should work, with pin modifications. -// -// STM32103VC: 72MHz, 256K flash, 48K RAM -// STM32103VE: 72MHz, 512K flash, 64K RAM -// STM32103ZE: 72MHz, 512K flash, 64K RAM -// STM32103RC: 72MHz, 256K flash, 48K RAM -// STM32103RE: 72MHz, 512K flash, 64K RAM - -#if defined(__STM32F1__) - -// The pins here are not tested yet, and need to change - -// The multi-purpose pins (Aux3..Aux8 can be analog pwm/dac if supported) -#define Aux0 PE6 -#define Aux1 PA8 -#define Aux2 PA12 - -// For ESP8266 control -#define ESP8266Gpio0Pin Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Tone or Fault -#define ESP8266RstPin Aux2 // Aux2 - ESP8266 RST or SPI MISO or PPS - -#define Axis1_EN PC15 // Enable -#define Axis1_M0 PC14 // Microstep Mode 0 -#define Axis1_M1 PC13 // Microstep Mode 1 -#define Axis1_M2 PE4 // Microstep Mode 2 -#define Axis1StepPin PE3 // Step -#define Axis1DirPin PE2 // Motor Direction -#define Axis1_Aux Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Tone or Fault -#define Axis1_FAULT Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Tone or Fault -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2_EN PB5 // Enable -#define Axis2_M0 PB4 // Microstep Mode 0 -#define Axis2_M1 PB3 // Microstep Mode 1 -#define Axis2_M2 PD7 // Microstep Mode 2 -#define Axis2StepPin PD6 // Step -#define Axis2DirPin PD5 // Motor Direction -#define Axis2_Aux Aux2 // Aux2 - ESP8266 RST or SPI MISO or PPS or Fault -#define Axis2_FAULT Aux2 // Aux2 - ESP8266 RST or SPI MISO or PPS or Fault -#define Axis2_Mode Axis2_M2 // (Decay mode switch) - -// This is the built in LED for the Black Pill board. There is a pin -// available from it too, in case you want to power another LED with a wire -#define LEDnegPin Aux0 // Drain -//#define LEDneg2Pin Undefined // Drain -//#define ReticulePin Undefined // Drain - -// For a piezo buzzer -#define TonePin Aux1 // Aux1 - ESP8266 GPIO0 or SPI MISO or Tone or Fault - -// ST4 interface -#define ST4DEn PB13 // ST4 DE+ North -#define ST4DEs PB14 // ST4 DE- South -#define ST4RAw PB15 // ST4 RA- West -#define ST4RAe PA8 // ST4 RA+ East - -// For rotator stepper driver -#define Axis3DirPin PB4 // Dir -#define Axis3StepPin PB5 // Step - -// Pins to focuser1 stepper driver -#define Axis4DirPin A15 // Dir -#define Axis4StepPin PB3 // Step - -// For focuser2 stepper driver -#define Axis5DirPin PB4 // Dir -#define Axis5StepPin PB5 // Step - -// The limit switch sense is a logic level input which uses the internal pull up, -// shorted to ground it stops gotos/tracking -//#define LimitPin Undefined - -// The PEC index sense is a logic level input, resets the PEC index on rising -// edge then waits for 60 seconds before allowing another reset -//#define PecPin Undefined -//#define AnalogPecPin Undefined // PEC Sense, analog or digital - -// The PPS pin is a 3.3V logic input, OnStep measures time between rising edges and -// adjusts the internal sidereal clock frequency -#define PpsPin Aux2 // Aux2 - ESP8266 RST or SPI MISO or PPS or Fault - -#else -#error "Wrong processor for this configuration!" - -#endif diff --git a/src/pinmaps/Pins.TM4C.h b/src/pinmaps/Pins.TM4C.h deleted file mode 100644 index cdb7feee4..000000000 --- a/src/pinmaps/Pins.TM4C.h +++ /dev/null @@ -1,150 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Pin map for OnStep Launchpad TM4C varients - -#if (defined(__TM4C123GH6PM__) || defined(__LM4F120H5QR__)) -// Note that TM4C123 has resistors R9 and R10 between pins 14 (B6) and 23 (D0) and between pins 15 (B7) and 24 (D1) -// Make sure you look at the list of the pins and options to avoid clashes or desolder the two bridges -// These pins are used for Axis2_M2 (14) and DE_M3 (15) and for Axis2DirPin (23) and Axis25vPin (24) -// If you have defined AXIS2_MODE_OFF in Config.h you should be safe to leave things as they are. - -// Also note that we are using UART1 and UART 5 which use pins 3-6 - -// The PEC index sense is a 5V logic input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 11 // Pin A2 - -// The limit switch sense is a 5V logic input which uses the internal (or external 2k) pull up, shorted to ground it stops gotos/tracking -#define LimitPin 12 // Pin A3 - -// The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDposPin 2 // Pin B5 (LED) -#define LEDnegPin 33 // Pin D6 (GND) -#define LEDneg2Pin 26 // Pin D3 (GND) -#define ReticulePin 33 - -// For a piezo buzzer -#define TonePin 19 // Pin B5 - -// The PPS pin is a 5V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 19 // Pin B2 (PPS time source, GPS for example) - -#define Axis1DirPin 27 // Pin E1 (Dir) -#define Axis1DirBit GPIO_PIN_1 // Pin 27 -#define Axis1DirPORT GPIO_PORTE_BASE // -#define Axis15vPin 28 // Pin E2 (5V?) -#define Axis1StepPin 29 // Pin E3 (Step) -#define Axis1StepBit GPIO_PIN_3 // Pin 29 -#define Axis1StepPORT GPIO_PORTE_BASE // -// Pin GND (GND) - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis1_M0 34 // Pin C7 (Microstep Mode 0) -#define Axis1_M1 35 // Pin C6 (Microstep Mode 1) -#define Axis1_M2 36 // Pin C5 (Microstep Mode 2) -#define Axis1_EN 37 // Pin C4 (Enable) -#define Axis1_FAULT 38 // Pin B3 (Fault) - -// The HA(RA) and Dec jumpers (going to the big easy drivers) are simply four wire jumper cables, each has identical wiring - simple modular construction -#define Axis2DirPin 23 // Pin D0 (Dir) -#define Axis2DirBit GPIO_PIN_0 // Pin 23=D0=B6 = pin 14 -#define Axis2DirPORT GPIO_PORTD_BASE // -#define Axis25vPin 24 // Pin D1 (5V?) -#define Axis2StepPin 25 // Pin D2 (Step) -#define Axis2StepBit GPIO_PIN_2 // Pin 25 -#define Axis2StepPORT GPIO_PORTD_BASE // -#define Axis2GndPin 26 // Pin D3 (GND) -#define Axis1_Mode Axis1_M2 // (Decay mode switch) - -#define Axis2_M0 13 // Pin A4 (Microstep Mode 0) -#define Axis2_M1 14 // Pin B6 (Microstep Mode 1) IF USED MAKE SURE YOU DESOLDER A BRIDGE or change pins around, otherwise pin 14 is connected to pin 23 -#define Axis2_M2 15 // Pin B7 (Microstep Mode 2) IF USED MAKE SURE YOU DESOLDER A BRIDGE or change pins around, otherwise pin 15 is connected to pin 24 -#define Axis2_EN 18 // Pin E0 (Enable) -#define Axis2_FAULT 17 // Pin F0 (Fault) NOTE, this is connected to pushbutton switch 2 -#define Axis2_Mode Axis2_M2 // (Decay mode switch) - -// Pins to rotator stepper driver -#define Axis3DirPin 38 // Pin 38 (Dir) -#define Axis3StepPin 17 // Pin 17 (Step) - -// For focuser1 stepper driver -#define Axis4DirPin 38 // Pin 38 (Dir) -#define Axis4StepPin 17 // Pin 17 (Step) - -// ST4 interface -#define ST4RAw 7 // Pin B4 ST4 RA- West -#define ST4DEs 8 // Pin A5 ST4 DE- South -#define ST4DEn 9 // Pin A6 ST4 DE+ North -#define ST4RAe 10 // Pin A7 ST4 RA+ East - -#elif defined(__TM4C1294NCPDT__) || defined(__TM4C1294XNCZAD__) -// No need to desolder anything on this launchpad as pins we are using are not bridged - -// Note that we are using UART7 and UART 5 which use pins 3-5 and pin 8 (C4,C5,C6,C7) - -// The PEC index sense is a 5V logic input, resets the PEC index on rising edge then waits for 60 seconds before allowing another reset -#define PecPin 11 // Pin P2 - -// The limit switch sense is a 5V logic input which uses the internal pull up, shorted to ground it stops gotos/tracking -#define LimitPin 12 // Pin N3 - -// The status LED is a two wire jumper with a 10k resistor in series to limit the current to the LED -#define LEDposPin 2 // Pin E4 (LED) -#define LEDnegPin 33 // Pin L1 (GND) -#define LEDneg2Pin 26 // Pin E3 (GND) -#define ReticulePin 33 - -// For a piezo buzzer -#define TonePin 19 // Pin M3 - -// The PPS pin is a 5V logic input, OnStep measures time between rising edges and adjusts the internal sidereal clock frequency -#define PpsPin 19 // Pin M3 (PPS time source, GPS for example) - -#define Axis1DirPin 27 // Pin D7 (Dir) -#define Axis1DirBit GPIO_PIN_7 // Pin 27 -#define Axis1DirPORT GPIO_PORTD_BASE // -#define Axis15vPin 28 // Pin A6 (5V?) -#define Axis1StepPin 29 // Pin M4 (Step) -#define Axis1StepBit GPIO_PIN_4 // Pin 29 -#define Axis1StepPORT GPIO_PORTM_BASE // -// Pin GND (GND) - -// Pins to enable/disable the stepper drivers and set microstep mode, optional and normally just hard-wired (DRV8825)/ignored (BED-A4988) -#define Axis1_M0 34 // Pin L0 (Microstep Mode 0) -#define Axis1_M1 35 // Pin L5 (Microstep Mode 1) -#define Axis1_M2 36 // Pin L4 (Microstep Mode 2) -#define Axis1_EN 37 // Pin G0 (Enabled when LOW) -#define Axis1_FAULT 38 // Pin F3 (Fault if LOW) - -// The HA(RA) and Dec jumpers (going to the big easy drivers) are simply four wire jumper cables, each has identical wiring - simple modular construction -#define Axis2DirPin 23 // Pin E0 (Dir) -#define Axis2DirBit GPIO_PIN_0 // Pin 23 -#define Axis2DirPORT GPIO_PORTE_BASE // -#define Axis25vPin 24 // Pin E1 (5V?) -#define Axis2StepPin 25 // Pin E2 (Step) -#define Axis2StepBit GPIO_PIN_2 // Pin 25 -#define Axis2StepPORT GPIO_PORTE_BASE // -#define Axis2GndPin 26 // Pin E3 (GND) - -#define Axis2_M0 13 // Pin N2 (Microstep Mode 0) -#define Axis2_M1 14 // Pin D0 (Microstep Mode 1) -#define Axis2_M2 15 // Pin D1 (Microstep Mode 2) -#define Axis2_EN 18 // Pin H2 (Enable) -#define Axis2_FAULT 17 // Pin H3 (Fault) NOTE, this is connected to pushbutton switch 2 - -// For rotator stepper driver -#define Axis3DirPin 38 // Pin 38 (Dir) -#define Axis3StepPin 17 // Pin 17 (Step) - -// For focuser1 stepper driver -#define Axis4DirPin 38 // Pin 38 (Dir) -#define Axis4StepPin 17 // Pin 17 (Step) - -// ST4 interface -#define ST4RAw 7 // Pin D3 ST4 RA- West -#define ST4DEs 6 // Pin C7 ST4 DE- South -#define ST4DEn 9 // Pin B2 ST4 DE+ North -#define ST4RAe 10 // Pin B3 ST4 RA+ East - -#else -#error "Wrong processor for this configuration!" - -#endif diff --git a/src/step_dir_drivers/A4988_Validate.h b/src/step_dir_drivers/A4988_Validate.h index 5f783ab73..2a6bd8246 100644 --- a/src/step_dir_drivers/A4988_Validate.h +++ b/src/step_dir_drivers/A4988_Validate.h @@ -1,32 +1,32 @@ // A4988 stepper driver validate #if AXIS1_DRIVER_MODEL == A4988 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 - #error "Configuration: AXIS1_MICROSTEPS; A4988 invalid micro-step mode, use: 16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; A4988 invalid micro-step mode, use: 16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < A4988_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the A4988 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == A4988 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 - #error "Configuration: AXIS2_MICROSTEPS; A4988 invalid micro-step mode, use: 16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; A4988 invalid micro-step mode, use: 16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < A4988_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the A4988 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == A4988 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; A4988 invalid micro-step mode, use: 16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; A4988 invalid micro-step mode, use: 16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == A4988 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; A4988 invalid micro-step mode, use: 16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; A4988 invalid micro-step mode, use: 16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/DRV8825_Validate.h b/src/step_dir_drivers/DRV8825_Validate.h index e5904c6df..1f3514e63 100644 --- a/src/step_dir_drivers/DRV8825_Validate.h +++ b/src/step_dir_drivers/DRV8825_Validate.h @@ -1,32 +1,32 @@ // DRV8825 stepper driver validate #if AXIS1_DRIVER_MODEL == DRV8825 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 - #error "Configuration: AXIS1_MICROSTEPS; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < DRV8825_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the DRV8825 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == DRV8825 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 - #error "Configuration: AXIS2_MICROSTEPS; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < DRV8825_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the DRV8825 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == DRV8825 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == DRV8825 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; DRV8825 invalid micro-step mode, use: 32,16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/LV8729_Validate.h b/src/step_dir_drivers/LV8729_Validate.h index d69843e7a..44bcc2f4d 100644 --- a/src/step_dir_drivers/LV8729_Validate.h +++ b/src/step_dir_drivers/LV8729_Validate.h @@ -1,32 +1,32 @@ // LV8729 stepper driver validate #if AXIS1_DRIVER_MODEL == LV8729 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 && AXIS1_MICROSTEPS!=64 && AXIS1_MICROSTEPS!=128 - #error "Configuration: AXIS1_MICROSTEPS; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 && AXIS1_DRIVER_MICROSTEPS != 64 && AXIS1_DRIVER_MICROSTEPS != 128 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < LV8729_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the LV8729 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == LV8729 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 && AXIS2_MICROSTEPS!=64 && AXIS2_MICROSTEPS!=128 - #error "Configuration: AXIS2_MICROSTEPS; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 && AXIS2_DRIVER_MICROSTEPS != 64 && AXIS2_DRIVER_MICROSTEPS != 128 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < LV8729_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the LV8729 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == LV8729 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 && AXIS1_MICROSTEPS_GOTO!=64 && AXIS1_MICROSTEPS_GOTO!=128 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 && AXIS1_DRIVER_MICROSTEPS_GOTO != 64 && AXIS1_DRIVER_MICROSTEPS_GOTO != 128 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == LV8729 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 && AXIS2_MICROSTEPS_GOTO!=64 && AXIS2_MICROSTEPS_GOTO!=128 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 && AXIS2_DRIVER_MICROSTEPS_GOTO != 64 && AXIS2_DRIVER_MICROSTEPS_GOTO != 128 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; LV8729 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/Models.h b/src/step_dir_drivers/Models.h index c66bbc4f1..55d421946 100644 --- a/src/step_dir_drivers/Models.h +++ b/src/step_dir_drivers/Models.h @@ -4,23 +4,14 @@ #define TMC2130 100 #define TMC2130_QUIET 101 #define TMC2130_VQUIET 102 -#define TMC2130_LOWPWR 103 -#define TMC2130_QUIET_LOWPWR 104 -#define TMC2130_VQUIET_LOWPWR 105 #define TMC5160 110 #define TMC5160_QUIET 111 #define TMC5160_VQUIET 112 -#define TMC5160_LOWPWR 113 -#define TMC5160_QUIET_LOWPWR 114 -#define TMC5160_VQUIET_LOWPWR 115 // Macros, these variations don't appear at run-time and are changed to "TMC2209" #define TMC2209_QUIET 121 #define TMC2209_VQUIET 122 -#define TMC2209_LOWPWR 123 -#define TMC2209_QUIET_LOWPWR 124 -#define TMC2209_VQUIET_LOWPWR 125 // Models #define DRIVER_MODEL_FIRST 1 @@ -58,6 +49,17 @@ #define SPREADCYCLE 0 #define OPEN 2 +// EN signal state defaults LOW +#define AXIS1_DRIVER_ENABLE LOW +#define AXIS2_DRIVER_ENABLE LOW +#define AXIS3_DRIVER_ENABLE LOW +#define AXIS4_DRIVER_ENABLE LOW +#define AXIS5_DRIVER_ENABLE LOW + +// default mode switch state and sleep is disabled +#define MODE_SWITCH_BEFORE_SLEW OFF +#define MODE_SWITCH_SLEEP OFF + // ------------------------------------------------------------------------------------------------------------------------ // search function diff --git a/src/step_dir_drivers/RAPS128_Validate.h b/src/step_dir_drivers/RAPS128_Validate.h index 4ce15c9c3..48d8fce8d 100644 --- a/src/step_dir_drivers/RAPS128_Validate.h +++ b/src/step_dir_drivers/RAPS128_Validate.h @@ -1,32 +1,32 @@ // RAPS128 stepper driver validate #if AXIS1_DRIVER_MODEL == RAPS128 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 && AXIS1_MICROSTEPS!=64 && AXIS1_MICROSTEPS!=128 - #error "Configuration: AXIS1_MICROSTEPS; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 && AXIS1_DRIVER_MICROSTEPS != 64 && AXIS1_DRIVER_MICROSTEPS != 128 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < RAPS128_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the RAPS128 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == RAPS128 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 && AXIS2_MICROSTEPS!=64 && AXIS2_MICROSTEPS!=128 - #error "Configuration: AXIS2_MICROSTEPS; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 && AXIS2_DRIVER_MICROSTEPS != 64 && AXIS2_DRIVER_MICROSTEPS != 128 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < RAPS128_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the RAPS128 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == RAPS128 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 && AXIS1_MICROSTEPS_GOTO!=64 && AXIS1_MICROSTEPS_GOTO!=128 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 && AXIS1_DRIVER_MICROSTEPS_GOTO != 64 && AXIS1_DRIVER_MICROSTEPS_GOTO != 128 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == RAPS128 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 && AXIS2_MICROSTEPS_GOTO!=64 && AXIS2_MICROSTEPS_GOTO!=128 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 && AXIS2_DRIVER_MICROSTEPS_GOTO != 64 && AXIS2_DRIVER_MICROSTEPS_GOTO != 128 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; RAPS128 invalid micro-step mode, use: 128,64,32,16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/S109_Validate.h b/src/step_dir_drivers/S109_Validate.h index 8f371a2b3..b3c67b624 100644 --- a/src/step_dir_drivers/S109_Validate.h +++ b/src/step_dir_drivers/S109_Validate.h @@ -1,32 +1,32 @@ // S109 stepper driver validate #if AXIS1_DRIVER_MODEL == S109 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 - #error "Configuration: AXIS1_MICROSTEPS; S109 invalid micro-step mode, use: 32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; S109 invalid micro-step mode, use: 32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < S109_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the S109 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == S109 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 - #error "Configuration: AXIS2_MICROSTEPS; S109 invalid micro-step mode, use: 32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; S109 invalid micro-step mode, use: 32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < S109_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the S109 stepper driver specifications." #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == S109 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; S109 invalid micro-step mode, use: 32,16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; S109 invalid micro-step mode, use: 32,16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == S109 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; S109 invalid micro-step mode, use: 32,16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; S109 invalid micro-step mode, use: 32,16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/ST820_Validate.h b/src/step_dir_drivers/ST820_Validate.h index 2434e39fa..cdda77c74 100644 --- a/src/step_dir_drivers/ST820_Validate.h +++ b/src/step_dir_drivers/ST820_Validate.h @@ -1,32 +1,32 @@ // ST820 stepper driver validate #if AXIS1_DRIVER_MODEL == ST820 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 && AXIS1_MICROSTEPS!=128 && AXIS1_MICROSTEPS!=256 - #error "Configuration: AXIS1_MICROSTEPS; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 && AXIS1_DRIVER_MICROSTEPS != 128 && AXIS1_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < ST820_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the ST820 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == ST820 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 && AXIS2_MICROSTEPS!=128 && AXIS2_MICROSTEPS!=256 - #error "Configuration: AXIS2_MICROSTEPS; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 && AXIS2_DRIVER_MICROSTEPS != 128 && AXIS2_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,or 1" #endif #if HAL_PULSE_WIDTH < ST820_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the ST820 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == ST820 - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 && AXIS1_MICROSTEPS_GOTO!=128 && AXIS1_MICROSTEPS_GOTO!=256 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,1,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 && AXIS1_DRIVER_MICROSTEPS_GOTO != 128 && AXIS1_DRIVER_MICROSTEPS_GOTO != 256 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,1,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == ST820 - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 && AXIS2_MICROSTEPS_GOTO!=128 && AXIS2_MICROSTEPS_GOTO!=256 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,1,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 && AXIS2_DRIVER_MICROSTEPS_GOTO != 128 && AXIS2_DRIVER_MICROSTEPS_GOTO != 256 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; ST820 invalid micro-step mode, use: 256,128,32,16,8,4,2,1,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/TMC2100_Init.h b/src/step_dir_drivers/TMC2100_Init.h index 8379fc104..62cdb736d 100644 --- a/src/step_dir_drivers/TMC2100_Init.h +++ b/src/step_dir_drivers/TMC2100_Init.h @@ -1,6 +1,8 @@ // TMC2100 stepper driver init -#if (AXIS1_DRIVER_MODEL == TMC2100) || (AXIS2_DRIVER_MODEL == TMC2100) - #define MODE_SWITCH_BEFORE_SLEW_ON - #define MODE_SWITCH_SLEEP_ON +#if AXIS1_DRIVER_MODEL == TMC2100 || AXIS2_DRIVER_MODEL == TMC2100 + #undef MODE_SWITCH_BEFORE_SLEW + #define MODE_SWITCH_BEFORE_SLEW ON + #undef MODE_SWITCH_SLEEP + #define MODE_SWITCH_SLEEP ON #endif diff --git a/src/step_dir_drivers/TMC2100_Validate.h b/src/step_dir_drivers/TMC2100_Validate.h index 487af00cc..b79599d19 100644 --- a/src/step_dir_drivers/TMC2100_Validate.h +++ b/src/step_dir_drivers/TMC2100_Validate.h @@ -1,34 +1,34 @@ // TMC2100 stepper driver validate #if AXIS1_DRIVER_MODEL == TMC2100 - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=16 - #error "Configuration: AXIS1_MICROSTEPS; TMC2100 invalid micro-step mode, use: 16,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; TMC2100 invalid micro-step mode, use: 16,4,2,or 1" #endif - #warning "Configuration: AXIS1_MICROSTEPS; This mode is supported in spreadCycle but without 256x interpolation: it's usually best to hard-wire the TMC2100 and use: _OFF here" + #warning "Configuration: AXIS1_DRIVER_MICROSTEPS; This mode is supported in spreadCycle but without 256x interpolation: it's usually best to hard-wire the TMC2100 and use: OFF here" #if HAL_PULSE_WIDTH < TMC2100_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC2100 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == TMC2100 - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=16 - #error "Configuration: AXIS2_MICROSTEPS; TMC2100 invalid micro-step mode, use: 16,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; TMC2100 invalid micro-step mode, use: 16,4,2,or 1" #endif - #warning "Configuration: AXIS2_MICROSTEPS; This mode is supported in spreadCycle but without 256x interpolation: it's usually best to hard-wire the TMC2100 and use: _OFF here" + #warning "Configuration: AXIS2_DRIVER_MICROSTEPS; This mode is supported in spreadCycle but without 256x interpolation: it's usually best to hard-wire the TMC2100 and use: OFF here" #if HAL_PULSE_WIDTH < TMC2100_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width exceeds the TMC2100 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == TMC2100 - #if AXIS1_MICROSTEPS != AXIS1_MICROSTEPS_GOTO - #error "Configuration: AXIS1_MICROSTEPS_GOTO; must be set to the same value as AXIS1_MICROSTEPS,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS != AXIS1_DRIVER_MICROSTEPS_GOTO + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; must be set to the same value as AXIS1_DRIVER_MICROSTEPS or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == TMC2100 - #if AXIS2_MICROSTEPS != AXIS2_MICROSTEPS_GOTO - #error "Configuration: AXIS2_MICROSTEPS_GOTO; must be set to the same value as AXIS2_MICROSTEPS,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS != AXIS2_DRIVER_MICROSTEPS_GOTO + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; must be set to the same value as AXIS2_DRIVER_MICROSTEPS or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/TMC2130_Init.h b/src/step_dir_drivers/TMC2130_Init.h index 561ceb646..84206affa 100644 --- a/src/step_dir_drivers/TMC2130_Init.h +++ b/src/step_dir_drivers/TMC2130_Init.h @@ -1,113 +1,114 @@ // TMC2130 stepper driver init -#if AXIS1_DRIVER_MODEL == TMC2130_LOWPWR +#if AXIS1_DRIVER_MODEL == TMC2130_QUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC2130 - #if defined(AXIS1_TMC_IGOTO) || defined(AXIS1_TMC_IRUN) || defined(AXIS1_TMC_IHOLD) - #error "Configuration: AXIS1 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS1_TMC_IHOLD 1000 // 40% of Vref setting on trim-pot - #define AXIS1_TMC_IRUN 1250 // 50% - #define AXIS1_TMC_IGOTO 2500 // 100% - #define AXIS1_TMC_VREF -#elif AXIS1_DRIVER_MODEL == TMC2130_QUIET - #undef AXIS1_DRIVER_MODEL - #define AXIS1_DRIVER_MODEL TMC2130 - #define AXIS1_TMC_MODE STEALTHCHOP -#elif AXIS1_DRIVER_MODEL == TMC2130_QUIET_LOWPWR - #undef AXIS1_DRIVER_MODEL - #define AXIS1_DRIVER_MODEL TMC2130 - #define AXIS1_TMC_MODE STEALTHCHOP - #if defined(AXIS1_TMC_IGOTO) || defined(AXIS1_TMC_IRUN) || defined(AXIS1_TMC_IHOLD) - #error "Configuration: AXIS1 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS1_TMC_IHOLD 1000 - #define AXIS1_TMC_IRUN 1250 - #define AXIS1_TMC_IGOTO 2500 - #define AXIS1_TMC_VREF + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS1_DRIVER_MODEL == TMC2130_VQUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC2130 - #define AXIS1_TMC_MODE STEALTHCHOP - #define AXIS1_TMC_MODE_GOTO STEALTHCHOP -#elif AXIS1_DRIVER_MODEL == TMC2130_VQUIET_LOWPWR - #undef AXIS1_DRIVER_MODEL - #define AXIS1_DRIVER_MODEL TMC2130 - #define AXIS1_TMC_MODE STEALTHCHOP - #define AXIS1_TMC_MODE_GOTO STEALTHCHOP - #if defined(AXIS1_TMC_IGOTO) || defined(AXIS1_TMC_IRUN) || defined(AXIS1_TMC_IHOLD) - #error "Configuration: AXIS1 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS1_TMC_IHOLD 1000 - #define AXIS1_TMC_IRUN 1250 - #define AXIS1_TMC_IGOTO 2500 - #define AXIS1_TMC_VREF + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS1_DRIVER_DECAY_MODE_GOTO STEALTHCHOP #endif - #if AXIS1_DRIVER_MODEL == TMC2130 #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC_SPI - #if !defined(AXIS1_TMC_VREF) && (defined(AXIS1_TMC_IRUN) && !defined(AXIS1_TMC_IGOTO) && !defined(AXIS1_TMC_IHOLD)) - #warning "Configuration: AXIS1 TMC2130, use Vref=2.5V and be sure AXIS1_TMC_IRUN matches your stepper motor's current rating" - #elif !defined(AXIS1_TMC_VREF) && (defined(AXIS1_TMC_IRUN) || defined(AXIS1_TMC_IGOTO) || defined(AXIS1_TMC_IHOLD)) - #warning "Configuration: AXIS1 TMC2130, use Vref=2.5V and be sure AXIS1_TMC_IRUN, AXIS1_TMC_IGOTO, and AXIS1_TMC_IHOLD are all set properly for your stepper motor." + #if AXIS1_DRIVER_IRUN != OFF && AXIS1_DRIVER_IGOTO == OFF && AXIS1_DRIVER_IHOLD == OFF + #warning "Configuration: AXIS1 TMC2130, use Vref=2.5V and be sure AXIS1_DRIVER_IRUN matches your stepper motor's current rating" + #elif AXIS1_DRIVER_IRUN != OFF || AXIS1_DRIVER_IGOTO != OFF || AXIS1_DRIVER_IHOLD != OFF + #warning "Configuration: AXIS1 TMC2130, use Vref=2.5V and be sure AXIS1_DRIVER_IRUN, AXIS1_DRIVER_IGOTO, and AXIS1_DRIVER_IHOLD are all set properly for your stepper motor." #else #warning "Configuration: AXIS1 TMC2130, set Vref to match your stepper motor's current rating." #endif #endif -#if AXIS2_DRIVER_MODEL == TMC2130_LOWPWR - #undef AXIS2_DRIVER_MODEL - #define AXIS2_DRIVER_MODEL TMC2130 - #if defined(AXIS2_TMC_IGOTO) || defined(AXIS2_TMC_IRUN) || defined(AXIS2_TMC_IHOLD) - #error "Configuration: AXIS2 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS2_TMC_IHOLD 1000 - #define AXIS2_TMC_IRUN 1250 - #define AXIS2_TMC_IGOTO 2500 - #define AXIS2_TMC_VREF -#elif AXIS2_DRIVER_MODEL == TMC2130_QUIET - #undef AXIS2_DRIVER_MODEL - #define AXIS2_DRIVER_MODEL TMC2130 - #define AXIS2_TMC_MODE STEALTHCHOP -#elif AXIS2_DRIVER_MODEL == TMC2130_QUIET_LOWPWR +#if AXIS2_DRIVER_MODEL == TMC2130_QUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC2130 - #define AXIS2_TMC_MODE STEALTHCHOP - #if defined(AXIS2_TMC_IGOTO) || defined(AXIS2_TMC_IRUN) || defined(AXIS2_TMC_IHOLD) - #error "Configuration: AXIS2 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS2_TMC_IHOLD 1000 - #define AXIS2_TMC_IRUN 1250 - #define AXIS2_TMC_IGOTO 2500 - #define AXIS2_TMC_VREF + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS2_DRIVER_MODEL == TMC2130_VQUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC2130 - #define AXIS2_TMC_MODE STEALTHCHOP - #define AXIS2_TMC_MODE_GOTO STEALTHCHOP -#elif AXIS2_DRIVER_MODEL == TMC2130_VQUIET_LOWPWR - #undef AXIS2_DRIVER_MODEL - #define AXIS2_DRIVER_MODEL TMC2130 - #define AXIS2_TMC_MODE STEALTHCHOP - #define AXIS2_TMC_MODE_GOTO STEALTHCHOP - #if defined(AXIS2_TMC_IGOTO) || defined(AXIS2_TMC_IRUN) || defined(AXIS2_TMC_IHOLD) - #error "Configuration: AXIS2 TMC2130, setting current directly is incompatible with _LOWPWR option." - #endif - #define AXIS2_TMC_IHOLD 1000 - #define AXIS2_TMC_IRUN 1250 - #define AXIS2_TMC_IGOTO 2500 - #define AXIS2_TMC_VREF + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS2_DRIVER_DECAY_MODE_GOTO STEALTHCHOP #endif - #if AXIS2_DRIVER_MODEL == TMC2130 #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC_SPI - #if !defined(AXIS2_TMC_VREF) && (defined(AXIS2_TMC_IRUN) && !defined(AXIS2_TMC_IGOTO) && !defined(AXIS2_TMC_IHOLD)) - #warning "Configuration: AXIS2 TMC2130, use Vref=2.5V and be sure AXIS2_TMC_IRUN matches your stepper motor's current rating." - #elif !defined(AXIS2_TMC_VREF) && (defined(AXIS2_TMC_IRUN) || defined(AXIS2_TMC_IGOTO) || defined(AXIS2_TMC_IHOLD)) - #warning "Configuration: AXIS2 TMC2130, use Vref=2.5V and be sure AXIS2_TMC_IRUN, AXIS2_TMC_IGOTO, and AXIS2_TMC_IHOLD are all set properly for your stepper motor." + #if AXIS2_DRIVER_IRUN != OFF && AXIS2_DRIVER_IGOTO == OFF && AXIS2_DRIVER_IHOLD == OFF + #warning "Configuration: AXIS2 TMC2130, use Vref=2.5V and be sure AXIS2_DRIVER_IRUN matches your stepper motor's current rating." + #elif AXIS2_DRIVER_IRUN != OFF || AXIS2_DRIVER_IGOTO != OFF || AXIS2_DRIVER_IHOLD != OFF + #warning "Configuration: AXIS2 TMC2130, use Vref=2.5V and be sure AXIS2_DRIVER_IRUN, AXIS2_DRIVER_IGOTO, and AXIS2_DRIVER_IHOLD are all set properly for your stepper motor." #else #warning "Configuration: AXIS2 TMC2130, set Vref to match your stepper motor's current rating." #endif #endif + +#if ROTATOR == ON + #if AXIS3_DRIVER_MODEL == TMC2130_QUIET + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC2130 + #define AXIS3_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS3_DRIVER_MODEL == TMC2130_VQUIET + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC2130 + #define AXIS3_DRIVER_DECAY_MODE STEALTHCHOP + #endif + #if AXIS3_DRIVER_MODEL == TMC2130 + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC_SPI + #if AXIS3_DRIVER_IRUN != OFF && AXIS3_DRIVER_IHOLD == OFF + #warning "Configuration: AXIS3 TMC2130, use Vref=2.5V and be sure AXIS3_DRIVER_IRUN is set properly for your power supply, voltage regulator, and stepper motor limits." + #elif AXIS3_DRIVER_IRUN != OFF || AXIS3_DRIVER_IHOLD != OFF + #warning "Configuration: AXIS3 TMC2130, use Vref=2.5V and be sure AXIS3_DRIVER_IRUN and AXIS3_DRIVER_IHOLD are set properly for your power supply, voltage regulator, and stepper motor limits." + #else + #warning "Configuration: AXIS3 TMC2130, set Vref to match your stepper motor's current rating." + #endif + #endif +#endif + +#if FOCUSER1 == ON + #if AXIS4_DRIVER_MODEL == TMC2130_QUIET + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC2130 + #define AXIS4_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS4_DRIVER_MODEL == TMC2130_VQUIET + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC2130 + #define AXIS4_DRIVER_DECAY_MODE STEALTHCHOP + #endif + #if AXIS4_DRIVER_MODEL == TMC2130 + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC_SPI + #if AXIS4_DRIVER_IRUN != OFF && AXIS4_DRIVER_IHOLD == OFF + #warning "Configuration: AXIS4 TMC2130, use Vref=2.5V and be sure AXIS4_DRIVER_IRUN is set properly for your power supply, voltage regulator, and stepper motor limits." + #elif AXIS4_DRIVER_IRUN != OFF || AXIS4_DRIVER_IHOLD != OFF + #warning "Configuration: AXIS4 TMC2130, use Vref=2.5V and be sure AXIS4_DRIVER_IRUN and AXIS4_DRIVER_IHOLD are set properly for your power supply, voltage regulator, and stepper motor limits." + #else + #warning "Configuration: AXIS4 TMC2130, set Vref to match your stepper motor's current rating." + #endif + #endif +#endif + +#if FOCUSER2 == ON + #if AXIS5_DRIVER_MODEL == TMC2130_QUIET + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC2130 + #define AXIS5_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS5_DRIVER_MODEL == TMC2130_VQUIET + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC2130 + #define AXIS5_DRIVER_DECAY_MODE STEALTHCHOP + #endif + #if AXIS5_DRIVER_MODEL == TMC2130 + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC_SPI + #if AXIS5_DRIVER_IRUN != OFF && AXIS5_DRIVER_IHOLD == OFF + #warning "Configuration: AXIS5 TMC2130, use Vref=2.5V and be sure AXIS5_DRIVER_IRUN is set properly for your power supply, voltage regulator, and stepper motor limits." + #elif AXIS5_DRIVER_IRUN != OFF || AXIS5_DRIVER_IHOLD != OFF + #warning "Configuration: AXIS5 TMC2130, use Vref=2.5V and be sure AXIS5_DRIVER_IRUN and AXIS5_DRIVER_IHOLD are set properly for your power supply, voltage regulator, and stepper motor limits." + #else + #warning "Configuration: AXIS5 TMC2130, set Vref to match your stepper motor's current rating." + #endif + #endif +#endif diff --git a/src/step_dir_drivers/TMC2208_Validate.h b/src/step_dir_drivers/TMC2208_Validate.h index ca650cb12..cce138651 100644 --- a/src/step_dir_drivers/TMC2208_Validate.h +++ b/src/step_dir_drivers/TMC2208_Validate.h @@ -1,32 +1,32 @@ // TMC2208 stepper driver validate #if AXIS1_DRIVER_MODEL == TMC2208 - #if AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 - #error "Configuration: AXIS1_MICROSTEPS; TMC2208 invalid micro-step mode, use: 16,8,4,or 2" + #if AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; TMC2208 invalid micro-step mode, use: 16,8,4,or 2" #endif #if HAL_PULSE_WIDTH < TMC2208_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC2208 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == TMC2208 - #if AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 - #error "Configuration: AXIS2_MICROSTEPS; TMC2208 invalid micro-step mode, use: 16,8,4,or 2" + #if AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; TMC2208 invalid micro-step mode, use: 16,8,4,or 2" #endif #if HAL_PULSE_WIDTH < TMC2208_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC2208 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == TMC2208 - #if AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; TMC2208 invalid micro-step mode, use: 16,8,4,2,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; TMC2208 invalid micro-step mode, use: 16,8,4,2,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == TMC2208 - #if AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; TMC2208 invalid micro-step mode, use: 16,8,4,2,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; TMC2208 invalid micro-step mode, use: 16,8,4,2,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/TMC2209_Init.h b/src/step_dir_drivers/TMC2209_Init.h index 0cca0e68a..6f252c285 100644 --- a/src/step_dir_drivers/TMC2209_Init.h +++ b/src/step_dir_drivers/TMC2209_Init.h @@ -3,73 +3,77 @@ #if AXIS1_DRIVER_MODEL == TMC2209_QUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC2209 - #define AXIS1_TMC_MODE STEALTHCHOP + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS1_DRIVER_MODEL == TMC2209_VQUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC2209 - #define AXIS1_TMC_MODE STEALTHCHOP - #define AXIS1_TMC_MODE_GOTO STEALTHCHOP -#elif (AXIS1_DRIVER_MODEL == TMC2209_LOWPWR) || (AXIS1_DRIVER_MODEL == TMC2209_QUIET_LOWPWR) || (AXIS1_DRIVER_MODEL == TMC2209_VQUIET_LOWPWR) - #error "Configuration: AXIS1 _LOWPWR option isn't supported for TMC2209 stepper drivers." + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS1_DRIVER_DECAY_MODE_GOTO STEALTHCHOP #endif #if AXIS2_DRIVER_MODEL == TMC2209_QUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC2209 - #define AXIS2_TMC_MODE STEALTHCHOP + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS2_DRIVER_MODEL == TMC2209_VQUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC2209 - #define AXIS2_TMC_MODE STEALTHCHOP - #define AXIS2_TMC_MODE_GOTO STEALTHCHOP -#elif (AXIS2_DRIVER_MODEL == TMC2209_LOWPWR) || (AXIS2_DRIVER_MODEL == TMC2209_QUIET_LOWPWR) || (AXIS2_DRIVER_MODEL == TMC2209_VQUIET_LOWPWR) - #error "Configuration: AXIS2 _LOWPWR option isn't supported for TMC2209 stepper drivers." + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS2_DRIVER_DECAY_MODE_GOTO STEALTHCHOP #endif #if AXIS1_DRIVER_MODEL == TMC2209 - #define AXIS1_DISABLE_M2 - #ifdef AXIS1_TMC_MODE - #if AXIS1_TMC_MODE == STEALTHCHOP - #define AXIS1_DECAY_MODE LOW // stealthChop + #define AXIS1_DRIVER_DISABLE_M2 + #ifdef AXIS1_DRIVER_DECAY_MODE + #if AXIS1_DRIVER_DECAY_MODE == STEALTHCHOP + #undef AXIS1_DRIVER_DECAY_MODE + #define AXIS1_DRIVER_DECAY_MODE LOW #endif - #if AXIS1_TMC_MODE == SPREADCYCLE - #define AXIS1_DECAY_MODE HIGH // spreadCycle + #if AXIS1_DRIVER_DECAY_MODE == SPREADCYCLE + #undef AXIS1_DRIVER_DECAY_MODE + #define AXIS1_DRIVER_DECAY_MODE HIGH #endif #else - #define AXIS1_DECAY_MODE HIGH + #define AXIS1_DRIVER_DECAY_MODE HIGH #endif - #ifdef AXIS1_TMC_MODE_GOTO - #if AXIS1_TMC_MODE_GOTO == STEALTHCHOP - #define AXIS1_DECAY_MODE_GOTO LOW + #ifdef AXIS1_DRIVER_DECAY_MODE_GOTO + #if AXIS1_DRIVER_DECAY_MODE_GOTO == STEALTHCHOP + #undef AXIS1_DRIVER_DECAY_MODE_GOTO + #define AXIS1_DRIVER_DECAY_MODE_GOTO LOW #endif - #if AXIS1_TMC_MODE_GOTO == SPREADCYCLE - #define AXIS1_DECAY_MODE_GOTO HIGH + #if AXIS1_DRIVER_DECAY_MODE_GOTO == SPREADCYCLE + #undef AXIS1_DRIVER_DECAY_MODE_GOTO + #define AXIS1_DRIVER_DECAY_MODE_GOTO HIGH #endif #else - #define AXIS1_DECAY_MODE_GOTO HIGH + #define AXIS1_DRIVER_DECAY_MODE_GOTO HIGH #endif #endif #if AXIS2_DRIVER_MODEL == TMC2209 - #define AXIS2_DISABLE_M2 - #ifdef AXIS2_TMC_MODE - #if AXIS2_TMC_MODE == STEALTHCHOP - #define AXIS2_DECAY_MODE LOW // stealthChop + #define AXIS2_DRIVER_DISABLE_M2 + #ifdef AXIS2_DRIVER_DECAY_MODE + #if AXIS2_DRIVER_DECAY_MODE == STEALTHCHOP + #undef AXIS2_DRIVER_DECAY_MODE + #define AXIS2_DRIVER_DECAY_MODE LOW #endif - #if AXIS2_TMC_MODE == SPREADCYCLE - #define AXIS2_DECAY_MODE HIGH // spreadCycle + #if AXIS2_DRIVER_DECAY_MODE == SPREADCYCLE + #undef AXIS2_DRIVER_DECAY_MODE + #define AXIS2_DRIVER_DECAY_MODE HIGH #endif #else - #define AXIS2_DECAY_MODE HIGH + #define AXIS2_DRIVER_DECAY_MODE HIGH #endif - #ifdef AXIS2_TMC_MODE_GOTO - #if AXIS2_TMC_MODE_GOTO == STEALTHCHOP - #define AXIS2_DECAY_MODE_GOTO LOW + #ifdef AXIS2_DRIVER_DECAY_MODE_GOTO + #if AXIS2_DRIVER_DECAY_MODE_GOTO == STEALTHCHOP + #undef AXIS2_DRIVER_DECAY_MODE_GOTO + #define AXIS2_DRIVER_DECAY_MODE_GOTO LOW #endif - #if AXIS2_TMC_MODE_GOTO == SPREADCYCLE - #define AXIS2_DECAY_MODE_GOTO HIGH + #if AXIS2_DRIVER_DECAY_MODE_GOTO == SPREADCYCLE + #undef AXIS2_DRIVER_DECAY_MODE_GOTO + #define AXIS2_DRIVER_DECAY_MODE_GOTO HIGH #endif #else - #define AXIS2_DECAY_MODE_GOTO HIGH + #define AXIS2_DRIVER_DECAY_MODE_GOTO HIGH #endif #endif diff --git a/src/step_dir_drivers/TMC2209_Validate.h b/src/step_dir_drivers/TMC2209_Validate.h index 704bea416..1652e7686 100644 --- a/src/step_dir_drivers/TMC2209_Validate.h +++ b/src/step_dir_drivers/TMC2209_Validate.h @@ -1,32 +1,32 @@ // TMC2209 stepper driver validate #if AXIS1_DRIVER_MODEL == TMC2209 - #if AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 && AXIS1_MICROSTEPS!=64 - #error "Configuration: AXIS1_MICROSTEPS; TMC2208 invalid micro-step mode, use: 64,32,16,or 8" + #if AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 && AXIS1_DRIVER_MICROSTEPS != 64 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; TMC2208 invalid micro-step mode, use: 64,32,16,or 8" #endif #if HAL_PULSE_WIDTH < TMC2209_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC2209 stepper driver specifications." #endif #endif #if AXIS2_DRIVER_MODEL == TMC2209 - #if AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 && AXIS2_MICROSTEPS!=64 - #error "Configuration: AXIS2_MICROSTEPS; TMC2209 invalid micro-step mode, use: 64,32,16,or 8" + #if AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 && AXIS2_DRIVER_MICROSTEPS != 64 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; TMC2209 invalid micro-step mode, use: 64,32,16,or 8" #endif #if HAL_PULSE_WIDTH < TMC2209_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC2209 stepper driver specifications." #endif #endif -#ifdef AXIS1_MICROSTEPS_GOTO +#if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS1_DRIVER_MODEL == TMC2209 - #if AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 && AXIS1_MICROSTEPS_GOTO!=64 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; TMC2209 invalid micro-step mode, use: 64,32,16,8,or _OFF" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 && AXIS1_DRIVER_MICROSTEPS_GOTO != 64 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; TMC2209 invalid micro-step mode, use: 64,32,16,8,or OFF" #endif #endif #endif -#ifdef AXIS2_MICROSTEPS_GOTO +#if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF #if AXIS2_DRIVER_MODEL == TMC2209 - #if AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 && AXIS2_MICROSTEPS_GOTO!=64 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; TMC2209 invalid micro-step mode, use: 64,32,16,8,or _OFF" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 && AXIS2_DRIVER_MICROSTEPS_GOTO != 64 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; TMC2209 invalid micro-step mode, use: 64,32,16,8,or OFF" #endif #endif #endif diff --git a/src/step_dir_drivers/TMC5160_Init.h b/src/step_dir_drivers/TMC5160_Init.h index e9179be77..474c42db0 100644 --- a/src/step_dir_drivers/TMC5160_Init.h +++ b/src/step_dir_drivers/TMC5160_Init.h @@ -3,49 +3,112 @@ #if AXIS1_DRIVER_MODEL == TMC5160_QUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC5160 - #define AXIS1_TMC_MODE STEALTHCHOP + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS1_DRIVER_MODEL == TMC5160_VQUIET #undef AXIS1_DRIVER_MODEL #define AXIS1_DRIVER_MODEL TMC5160 - #define AXIS1_TMC_MODE STEALTHCHOP - #define AXIS1_TMC_MODE_GOTO STEALTHCHOP -#elif (AXIS1_DRIVER_MODEL == TMC5160_LOWPWR) || (AXIS1_DRIVER_MODEL == TMC5160_QUIET_LOWPWR) || (AXIS1_DRIVER_MODEL == TMC5160_VQUIET_LOWPWR) - #error "Configuration: AXIS1 _LOWPWR option isn't supported for TMC5160 stepper drivers, use AXISn_TMC_IRUN and _IGOTO to set the pwr levels." + #define AXIS1_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS1_DRIVER_DECAY_MODE_GOTO STEALTHCHOP +#endif +#if AXIS1_DRIVER_MODEL == TMC5160 + #undef AXIS1_DRIVER_MODEL + #define AXIS1_DRIVER_MODEL TMC_SPI + #ifndef AXIS1_DRIVER_IRUN + #warning "Configuration: AXIS1_DRIVER_IRUN current isn't specified, falling back to 600 (mA.)" + #define AXIS1_DRIVER_IRUN 600 // peak current in mA (0.6A) + #endif + #ifndef AXIS1_DRIVER_RSENSE + #define AXIS1_DRIVER_RSENSE 0.075 + #endif #endif #if AXIS2_DRIVER_MODEL == TMC5160_QUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC5160 - #define AXIS2_TMC_MODE STEALTHCHOP + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP #elif AXIS2_DRIVER_MODEL == TMC5160_VQUIET #undef AXIS2_DRIVER_MODEL #define AXIS2_DRIVER_MODEL TMC5160 - #define AXIS2_TMC_MODE STEALTHCHOP - #define AXIS2_TMC_MODE_GOTO STEALTHCHOP -#elif (AXIS2_DRIVER_MODEL == TMC5160_LOWPWR) || (AXIS2_DRIVER_MODEL == TMC5160_QUIET_LOWPWR) || (AXIS2_DRIVER_MODEL == TMC5160_VQUIET_LOWPWR) - #error "Configuration: AXIS2 _LOWPWR option isn't supported for TMC5160 stepper drivers, use AXISn_TMC_IRUN and _IGOTO to set the pwr levels." + #define AXIS2_DRIVER_DECAY_MODE STEALTHCHOP + #define AXIS2_DRIVER_DECAY_MODE_GOTO STEALTHCHOP +#endif +#if AXIS2_DRIVER_MODEL == TMC5160 + #undef AXIS2_DRIVER_MODEL + #define AXIS2_DRIVER_MODEL TMC_SPI + #ifndef AXIS2_DRIVER_IRUN + #warning "Configuration: AXIS2_DRIVER_IRUN current isn't specified, falling back to 600 (mA.)" + #define AXIS2_DRIVER_IRUN 600 + #endif + #ifndef AXIS2_DRIVER_RSENSE + #define AXIS2_DRIVER_RSENSE 0.075 + #endif #endif -#if AXIS1_DRIVER_MODEL == TMC5160 - #undef AXIS1_DRIVER_MODEL - #define AXIS1_DRIVER_MODEL TMC_SPI - #ifndef AXIS1_TMC_IRUN - #warning "Configuration: AXIS1_TMC_IRUN current isn't specified, falling back to 600 (mA.)" - #define AXIS1_TMC_IRUN 600 // peak current in mA (0.6A) +#if ROTATOR == ON + #if AXIS3_DRIVER_MODEL == TMC5160_QUIET + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC5160 + #define AXIS3_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS3_DRIVER_MODEL == TMC5160_VQUIET + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC5160 + #define AXIS3_DRIVER_DECAY_MODE STEALTHCHOP #endif - #ifndef AXIS1_TMC_RSENSE - #define AXIS1_TMC_RSENSE 0.075 + #if AXIS3_DRIVER_MODEL == TMC5160 + #undef AXIS3_DRIVER_MODEL + #define AXIS3_DRIVER_MODEL TMC_SPI + #ifndef AXIS3_DRIVER_IRUN + #warning "Configuration: AXIS3_DRIVER_IRUN current isn't specified, falling back to 200 (mA.)" + #define AXIS3_DRIVER_IRUN 200 + #endif + #ifndef AXIS3_DRIVER_RSENSE + #define AXIS3_DRIVER_RSENSE 0.075 + #endif #endif #endif -#if AXIS2_DRIVER_MODEL == TMC5160 - #undef AXIS2_DRIVER_MODEL - #define AXIS2_DRIVER_MODEL TMC_SPI - #ifndef AXIS2_TMC_IRUN - #warning "Configuration: AXIS2_TMC_IRUN current isn't specified, falling back to 600 (mA.)" - #define AXIS2_TMC_IRUN 600 +#if FOCUSER1 == ON + #if AXIS4_DRIVER_MODEL == TMC5160_QUIET + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC5160 + #define AXIS4_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS4_DRIVER_MODEL == TMC5160_VQUIET + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC5160 + #define AXIS4_DRIVER_DECAY_MODE STEALTHCHOP + #endif + #if AXIS4_DRIVER_MODEL == TMC5160 + #undef AXIS4_DRIVER_MODEL + #define AXIS4_DRIVER_MODEL TMC_SPI + #ifndef AXIS4_DRIVER_IRUN + #warning "Configuration: AXIS4_DRIVER_IRUN current isn't specified, falling back to 200 (mA.)" + #define AXIS4_DRIVER_IRUN 200 + #endif + #ifndef AXIS4_DRIVER_RSENSE + #define AXIS4_DRIVER_RSENSE 0.075 + #endif + #endif +#endif + +#if FOCUSER2 == ON + #if AXIS5_DRIVER_MODEL == TMC5160_QUIET + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC5160 + #define AXIS5_DRIVER_DECAY_MODE STEALTHCHOP + #elif AXIS5_DRIVER_MODEL == TMC5160_VQUIET + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC5160 + #define AXIS5_DRIVER_DECAY_MODE STEALTHCHOP #endif - #ifndef AXIS2_TMC_RSENSE - #define AXIS2_TMC_RSENSE 0.075 + #if AXIS5_DRIVER_MODEL == TMC5160 + #undef AXIS5_DRIVER_MODEL + #define AXIS5_DRIVER_MODEL TMC_SPI + #ifndef AXIS5_DRIVER_IRUN + #warning "Configuration: AXIS5_DRIVER_IRUN current isn't specified, falling back to 200 (mA.)" + #define AXIS5_DRIVER_IRUN 200 + #endif + #ifndef AXIS5_DRIVER_RSENSE + #define AXIS5_DRIVER_RSENSE 0.075 + #endif #endif #endif diff --git a/src/step_dir_drivers/TMC_SPI_Init.h b/src/step_dir_drivers/TMC_SPI_Init.h index dea52ad1a..21ebae0b2 100644 --- a/src/step_dir_drivers/TMC_SPI_Init.h +++ b/src/step_dir_drivers/TMC_SPI_Init.h @@ -1,53 +1,110 @@ // TMC SPI stepper driver init #if (AXIS1_DRIVER_MODEL == TMC_SPI) || (AXIS2_DRIVER_MODEL == TMC_SPI) - #define MODE_SWITCH_BEFORE_SLEW_SPI + #undef MODE_SWITCH_BEFORE_SLEW + #define MODE_SWITCH_BEFORE_SLEW TMC_SPI #endif #if AXIS1_DRIVER_MODEL == TMC_SPI - #ifndef AXIS1_TMC_MODE - #define AXIS1_TMC_MODE SPREADCYCLE + #ifndef AXIS1_DRIVER_DECAY_MODE + #define AXIS1_DRIVER_DECAY_MODE SPREADCYCLE #endif - #ifndef AXIS1_TMC_MODE_GOTO - #define AXIS1_TMC_MODE_GOTO SPREADCYCLE + #ifndef AXIS1_DRIVER_DECAY_MODE_GOTO + #define AXIS1_DRIVER_DECAY_MODE_GOTO SPREADCYCLE #endif - #ifndef AXIS1_TMC_INTPOL - #define AXIS1_TMC_INTPOL true + #ifndef AXIS1_DRIVER_INTPOL + #define AXIS1_DRIVER_INTPOL true #endif - #ifndef AXIS1_TMC_IRUN - #define AXIS1_TMC_IRUN 2500 + #ifndef AXIS1_DRIVER_IRUN + #define AXIS1_DRIVER_IRUN 2500 #endif - #ifndef AXIS1_TMC_IHOLD - #define AXIS1_TMC_IHOLD (AXIS1_TMC_IRUN/2) + #ifndef AXIS1_DRIVER_IHOLD + #define AXIS1_DRIVER_IHOLD (AXIS1_DRIVER_IRUN/2) #endif - #ifndef AXIS1_TMC_IGOTO - #define AXIS1_TMC_IGOTO AXIS1_TMC_IRUN + #ifndef AXIS1_DRIVER_IGOTO + #define AXIS1_DRIVER_IGOTO AXIS1_DRIVER_IRUN #endif - #ifndef AXIS1_TMC_RSENSE - #define AXIS1_TMC_RSENSE 0.11+0.02 + #ifndef AXIS1_DRIVER_RSENSE + #define AXIS1_DRIVER_RSENSE 0.11+0.02 #endif #endif #if AXIS2_DRIVER_MODEL == TMC_SPI - #ifndef AXIS2_TMC_MODE - #define AXIS2_TMC_MODE SPREADCYCLE + #ifndef AXIS2_DRIVER_DECAY_MODE + #define AXIS2_DRIVER_DECAY_MODE SPREADCYCLE #endif - #ifndef AXIS2_TMC_MODE_GOTO - #define AXIS2_TMC_MODE_GOTO SPREADCYCLE + #ifndef AXIS2_DRIVER_DECAY_MODE_GOTO + #define AXIS2_DRIVER_DECAY_MODE_GOTO SPREADCYCLE #endif - #ifndef AXIS2_TMC_INTPOL - #define AXIS2_TMC_INTPOL true + #ifndef AXIS2_DRIVER_INTPOL + #define AXIS2_DRIVER_INTPOL true #endif - #ifndef AXIS2_TMC_IRUN - #define AXIS2_TMC_IRUN 2500 + #ifndef AXIS2_DRIVER_IRUN + #define AXIS2_DRIVER_IRUN 2500 #endif - #ifndef AXIS2_TMC_IHOLD - #define AXIS2_TMC_IHOLD (AXIS2_TMC_IRUN/2) + #ifndef AXIS2_DRIVER_IHOLD + #define AXIS2_DRIVER_IHOLD (AXIS2_DRIVER_IRUN/2) #endif - #ifndef AXIS2_TMC_IGOTO - #define AXIS2_TMC_IGOTO AXIS2_TMC_IRUN + #ifndef AXIS2_DRIVER_IGOTO + #define AXIS2_DRIVER_IGOTO AXIS2_DRIVER_IRUN #endif - #ifndef AXIS2_TMC_RSENSE - #define AXIS2_TMC_RSENSE 0.11+0.02 + #ifndef AXIS2_DRIVER_RSENSE + #define AXIS2_DRIVER_RSENSE 0.11+0.02 + #endif +#endif + +// Focuser/rotator + +#if ROTATOR == ON && AXIS3_DRIVER_MODEL == TMC_SPI + #ifndef AXIS3_DRIVER_DECAY_MODE + #define AXIS3_DRIVER_DECAY_MODE SPREADCYCLE + #endif + #ifndef AXIS3_DRIVER_INTPOL + #define AXIS3_DRIVER_INTPOL true + #endif + #ifndef AXIS3_DRIVER_IRUN + #define AXIS3_DRIVER_IRUN 2500 + #endif + #ifndef AXIS3_DRIVER_IHOLD + #define AXIS3_DRIVER_IHOLD (AXIS3_DRIVER_IRUN/2) + #endif + #ifndef AXIS3_DRIVER_RSENSE + #define AXIS3_DRIVER_RSENSE 0.11+0.02 + #endif +#endif + +#if FOCUSER1 == ON && AXIS4_DRIVER_MODEL == TMC_SPI + #ifndef AXIS4_DRIVER_DECAY_MODE + #define AXIS4_DRIVER_DECAY_MODE SPREADCYCLE + #endif + #ifndef AXIS4_DRIVER_INTPOL + #define AXIS4_DRIVER_INTPOL true + #endif + #ifndef AXIS4_DRIVER_IRUN + #define AXIS4_DRIVER_IRUN 2500 + #endif + #ifndef AXIS4_DRIVER_IHOLD + #define AXIS4_DRIVER_IHOLD (AXIS4_DRIVER_IRUN/2) + #endif + #ifndef AXIS4_DRIVER_RSENSE + #define AXIS4_DRIVER_RSENSE 0.11+0.02 + #endif +#endif + +#if FOCUSER2 == ON && AXIS5_DRIVER_MODEL == TMC_SPI + #ifndef AXIS5_DRIVER_DECAY_MODE + #define AXIS5_DRIVER_DECAY_MODE SPREADCYCLE + #endif + #ifndef AXIS5_DRIVER_INTPOL + #define AXIS5_DRIVER_INTPOL true + #endif + #ifndef AXIS5_DRIVER_IRUN + #define AXIS5_DRIVER_IRUN 2500 + #endif + #ifndef AXIS5_DRIVER_IHOLD + #define AXIS5_DRIVER_IHOLD (AXIS5_DRIVER_IRUN/2) + #endif + #ifndef AXIS5_DRIVER_RSENSE + #define AXIS5_DRIVER_RSENSE 0.11+0.02 #endif #endif diff --git a/src/step_dir_drivers/TMC_SPI_Validate.h b/src/step_dir_drivers/TMC_SPI_Validate.h index eb7cc5665..3a37cafb3 100644 --- a/src/step_dir_drivers/TMC_SPI_Validate.h +++ b/src/step_dir_drivers/TMC_SPI_Validate.h @@ -1,37 +1,59 @@ // TMC_SPI stepper driver validate #if AXIS1_DRIVER_MODEL == TMC_SPI - #if AXIS1_MICROSTEPS!=1 && AXIS1_MICROSTEPS!=2 && AXIS1_MICROSTEPS!=4 && AXIS1_MICROSTEPS!=8 && AXIS1_MICROSTEPS!=16 && AXIS1_MICROSTEPS!=32 && AXIS1_MICROSTEPS!=64 && AXIS1_MICROSTEPS!=128 && AXIS1_MICROSTEPS!=256 - #error "Configuration: AXIS1_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS != 1 && AXIS1_DRIVER_MICROSTEPS != 2 && AXIS1_DRIVER_MICROSTEPS != 4 && AXIS1_DRIVER_MICROSTEPS != 8 && AXIS1_DRIVER_MICROSTEPS != 16 && AXIS1_DRIVER_MICROSTEPS != 32 && AXIS1_DRIVER_MICROSTEPS != 64 && AXIS1_DRIVER_MICROSTEPS != 128 && AXIS1_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" #endif #if AXIS2_DRIVER_MODEL != TMC_SPI #error "Configuration: TMC SPI stepper drivers must be used in pairs (both Axis1 and Axis2.)" #endif - #ifdef AXIS1_MICROSTEPS_GOTO - #if AXIS1_MICROSTEPS_GOTO!=1 && AXIS1_MICROSTEPS_GOTO!=2 && AXIS1_MICROSTEPS_GOTO!=4 && AXIS1_MICROSTEPS_GOTO!=8 && AXIS1_MICROSTEPS_GOTO!=16 && AXIS1_MICROSTEPS_GOTO!=32 && AXIS1_MICROSTEPS_GOTO!=64 && AXIS1_MICROSTEPS_GOTO!=128 && AXIS1_MICROSTEPS_GOTO!=256 - #error "Configuration: AXIS1_MICROSTEPS_GOTO; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #if AXIS1_DRIVER_MICROSTEPS_GOTO != OFF + #if AXIS1_DRIVER_MICROSTEPS_GOTO != 1 && AXIS1_DRIVER_MICROSTEPS_GOTO != 2 && AXIS1_DRIVER_MICROSTEPS_GOTO != 4 && AXIS1_DRIVER_MICROSTEPS_GOTO != 8 && AXIS1_DRIVER_MICROSTEPS_GOTO != 16 && AXIS1_DRIVER_MICROSTEPS_GOTO != 32 && AXIS1_DRIVER_MICROSTEPS_GOTO != 64 && AXIS1_DRIVER_MICROSTEPS_GOTO != 128 && AXIS1_DRIVER_MICROSTEPS_GOTO != 256 + #error "Configuration: AXIS1_DRIVER_MICROSTEPS_GOTO; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" #endif - #if AXIS1_MICROSTEPS != AXIS1_MICROSTEPS_GOTO - #warning "Configuration: AXIS2_MICROSTEPS_GOTO; is NOT _OFF. This can effect pointing accuracy and PEC if index sensing isn't used." + #if AXIS1_DRIVER_MICROSTEPS != AXIS1_DRIVER_MICROSTEPS_GOTO + #warning "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; is not OFF. This can effect pointing accuracy and PEC if index sensing isn't used." #endif #endif #if HAL_PULSE_WIDTH < TMC_SPI_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC SPI stepper driver specifications." #endif #endif + #if AXIS2_DRIVER_MODEL == TMC_SPI - #if AXIS2_MICROSTEPS!=1 && AXIS2_MICROSTEPS!=2 && AXIS2_MICROSTEPS!=4 && AXIS2_MICROSTEPS!=8 && AXIS2_MICROSTEPS!=16 && AXIS2_MICROSTEPS!=32 && AXIS2_MICROSTEPS!=64 && AXIS2_MICROSTEPS!=128 && AXIS2_MICROSTEPS!=256 - #error "Configuration: AXIS2_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS != 1 && AXIS2_DRIVER_MICROSTEPS != 2 && AXIS2_DRIVER_MICROSTEPS != 4 && AXIS2_DRIVER_MICROSTEPS != 8 && AXIS2_DRIVER_MICROSTEPS != 16 && AXIS2_DRIVER_MICROSTEPS != 32 && AXIS2_DRIVER_MICROSTEPS != 64 && AXIS2_DRIVER_MICROSTEPS != 128 && AXIS2_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #endif + #if AXIS1_DRIVER_MODEL != TMC_SPI + #error "Configuration: TMC SPI stepper drivers must be used in pairs (both Axis1 and Axis2.)" #endif - #ifdef AXIS2_MICROSTEPS_GOTO - #if AXIS2_MICROSTEPS_GOTO!=1 && AXIS2_MICROSTEPS_GOTO!=2 && AXIS2_MICROSTEPS_GOTO!=4 && AXIS2_MICROSTEPS_GOTO!=8 && AXIS2_MICROSTEPS_GOTO!=16 && AXIS2_MICROSTEPS_GOTO!=32 && AXIS2_MICROSTEPS_GOTO!=64 && AXIS2_MICROSTEPS_GOTO!=128 && AXIS2_MICROSTEPS_GOTO!=256 - #error "Configuration: AXIS2_MICROSTEPS_GOTO; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #if AXIS2_DRIVER_MICROSTEPS_GOTO != OFF + #if AXIS2_DRIVER_MICROSTEPS_GOTO != 1 && AXIS2_DRIVER_MICROSTEPS_GOTO != 2 && AXIS2_DRIVER_MICROSTEPS_GOTO != 4 && AXIS2_DRIVER_MICROSTEPS_GOTO != 8 && AXIS2_DRIVER_MICROSTEPS_GOTO != 16 && AXIS2_DRIVER_MICROSTEPS_GOTO != 32 && AXIS2_DRIVER_MICROSTEPS_GOTO != 64 && AXIS2_DRIVER_MICROSTEPS_GOTO != 128 && AXIS2_DRIVER_MICROSTEPS_GOTO != 256 + #error "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" #endif - #if AXIS2_MICROSTEPS != AXIS2_MICROSTEPS_GOTO - #warning "Configuration: AXIS2_MICROSTEPS_GOTO; is NOT _OFF. This can effect pointing accuracy." + #if AXIS2_DRIVER_MICROSTEPS != AXIS2_DRIVER_MICROSTEPS_GOTO + #warning "Configuration: AXIS2_DRIVER_MICROSTEPS_GOTO; is not OFF. This can effect pointing accuracy." #endif #endif #if HAL_PULSE_WIDTH < TMC_SPI_PULSE_WIDTH #error "Configuration: STEP_WAVE_FORM PULSE; Pulse width is below the TMC SPI stepper driver specifications." #endif #endif + +#if ROTATOR == ON && AXIS3_DRIVER_MODEL == TMC_SPI + #if AXIS3_DRIVER_MICROSTEPS != 1 && AXIS3_DRIVER_MICROSTEPS != 2 && AXIS3_DRIVER_MICROSTEPS != 4 && AXIS3_DRIVER_MICROSTEPS != 8 && AXIS3_DRIVER_MICROSTEPS != 16 && AXIS3_DRIVER_MICROSTEPS != 32 && AXIS3_DRIVER_MICROSTEPS != 64 && AXIS3_DRIVER_MICROSTEPS != 128 && AXIS3_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS3_DRIVER_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #endif +#endif + +#if FOCUSER1 == ON && AXIS4_DRIVER_MODEL == TMC_SPI + #if AXIS4_DRIVER_MICROSTEPS != 1 && AXIS4_DRIVER_MICROSTEPS != 2 && AXIS4_DRIVER_MICROSTEPS != 4 && AXIS4_DRIVER_MICROSTEPS != 8 && AXIS4_DRIVER_MICROSTEPS != 16 && AXIS4_DRIVER_MICROSTEPS != 32 && AXIS4_DRIVER_MICROSTEPS != 64 && AXIS4_DRIVER_MICROSTEPS != 128 && AXIS4_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS4_DRIVER_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #endif +#endif + +#if FOCUSER2 == ON && AXIS5_DRIVER_MODEL == TMC_SPI + #if AXIS5_DRIVER_MICROSTEPS != 1 && AXIS5_DRIVER_MICROSTEPS != 2 && AXIS5_DRIVER_MICROSTEPS != 4 && AXIS5_DRIVER_MICROSTEPS != 8 && AXIS5_DRIVER_MICROSTEPS != 16 && AXIS5_DRIVER_MICROSTEPS != 32 && AXIS5_DRIVER_MICROSTEPS != 64 && AXIS5_DRIVER_MICROSTEPS != 128 && AXIS5_DRIVER_MICROSTEPS != 256 + #error "Configuration: AXIS5_DRIVER_MICROSTEPS; TMC SPI stepper driver invalid micro-step mode, use: 256,128,64,32,16,8,4,2,or 1" + #endif +#endif