Skip to content

Commit

Permalink
Switched to using F() macro for debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hjd1964 committed Jul 16, 2020
1 parent b3c7ddc commit cdea5ce
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 114 deletions.
16 changes: 8 additions & 8 deletions AlignEq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ void TGeoAlign::init() {
// remember the alignment between sessions
void TGeoAlign::readCoe() {
ax1Cor=nv.readFloat(EE_ax1Cor);
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("ERR, readCoe(): bad NV ax1Cor"); }
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DLF("ERR, readCoe(): bad NV ax1Cor"); }
ax2Cor=nv.readFloat(EE_ax2Cor);
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("ERR, readCoe(): bad NV ax2Cor"); }
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DLF("ERR, readCoe(): bad NV ax2Cor"); }
dfCor=nv.readFloat(EE_dfCor); // dfCor is ffCor for fork mounts
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("ERR, readCoe(): bad NV dfCor"); }
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DLF("ERR, readCoe(): bad NV dfCor"); }
tfCor=nv.readFloat(EE_tfCor);
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("ERR, readCoe(): bad NV tfCor"); }
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DLF("ERR, readCoe(): bad NV tfCor"); }
doCor=nv.readFloat(EE_doCor);
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("ERR, readCoe(): bad NV doCor"); }
if (doCor < -10 || doCor > 10) { doCor=0.0; DLF("ERR, readCoe(): bad NV doCor"); }
pdCor=nv.readFloat(EE_pdCor);
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("ERR, readCoe(): bad NV pdCor"); }
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DLF("ERR, readCoe(): bad NV pdCor"); }
altCor=nv.readFloat(EE_altCor);
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("ERR, readCoe(): bad NV altCor"); }
if (altCor < -10 || altCor > 10) { altCor=0.0; DLF("ERR, readCoe(): bad NV altCor"); }
azmCor=nv.readFloat(EE_azmCor);
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("ERR, readCoe(): bad NV azmCor"); }
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DLF("ERR, readCoe(): bad NV azmCor"); }
}

void TGeoAlign::writeCoe() {
Expand Down
16 changes: 8 additions & 8 deletions AlignHor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ void TGeoAlignH::init() {
// remember the alignment between sessions
void TGeoAlignH::readCoe() {
ax1Cor=nv.readFloat(EE_ax1Cor);
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DL("ERR, readCoe(): bad NV ax1Cor"); }
if (ax1Cor < -360 || ax1Cor > 360) { ax1Cor=0.0; DLF("ERR, readCoe(): bad NV ax1Cor"); }
ax2Cor=nv.readFloat(EE_ax2Cor);
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DL("ERR, readCoe(): bad NV ax2Cor"); }
if (ax2Cor < -360 || ax2Cor > 360) { ax2Cor=0.0; DLF("ERR, readCoe(): bad NV ax2Cor"); }
dfCor=nv.readFloat(EE_dfCor); // dfCor is ffCor for fork mounts
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DL("ERR, readCoe(): bad NV dfCor"); }
if (dfCor < -10 || dfCor > 10) { dfCor=0.0; DLF("ERR, readCoe(): bad NV dfCor"); }
tfCor=nv.readFloat(EE_tfCor);
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DL("ERR, readCoe(): bad NV tfCor"); }
if (tfCor < -10 || tfCor > 10) { tfCor=0.0; DLF("ERR, readCoe(): bad NV tfCor"); }
doCor=nv.readFloat(EE_doCor);
if (doCor < -10 || doCor > 10) { doCor=0.0; DL("ERR, readCoe(): bad NV doCor"); }
if (doCor < -10 || doCor > 10) { doCor=0.0; DLF("ERR, readCoe(): bad NV doCor"); }
pdCor=nv.readFloat(EE_pdCor);
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DL("ERR, readCoe(): bad NV pdCor"); }
if (pdCor < -10 || pdCor > 10) { pdCor=0.0; DLF("ERR, readCoe(): bad NV pdCor"); }
altCor=nv.readFloat(EE_altCor);
if (altCor < -10 || altCor > 10) { altCor=0.0; DL("ERR, readCoe(): bad NV altCor"); }
if (altCor < -10 || altCor > 10) { altCor=0.0; DLF("ERR, readCoe(): bad NV altCor"); }
azmCor=nv.readFloat(EE_azmCor);
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DL("ERR, readCoe(): bad NV azmCor"); }
if (azmCor < -10 || azmCor > 10) { azmCor=0.0; DLF("ERR, readCoe(): bad NV azmCor"); }
}

void TGeoAlignH::writeCoe() {
Expand Down
41 changes: 30 additions & 11 deletions Command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,11 @@ void processCommands() {
case 'F':
for (int x=0; x <= E2END+16; x++) {
if (x < 8 || x > E2END+8) {
if (x%8 == 0) D("-----------");
D("--");
if (x%8 == 0) DF("-----------");
DF("--");
if (x%8 == 7) DL();
} else {
if (x%8 == 0) { D(":SXFF,"); char s[8]; sprintf(s,"%04d=",x/8); D(s); }
if (x%8 == 0) { DF(":SXFF,"); char s[8]; sprintf(s,"%04d=",x/8); D(s); }
int v=nv.read(x-8);
if (v < 16) D(0); DebugSer.print(v,HEX);
if (x%8 == 7) DL("#");
Expand Down Expand Up @@ -2117,13 +2117,13 @@ void processCommands() {
if (command[1] >= '0' && command[1] <= '3' && parameter[0] == 0) {
currentSite=command[1]-'0'; nv.update(EE_currentSite,currentSite); booleanReply=false;
double f=nv.readFloat(EE_sites+currentSite*25+0);
if (f < -90 || f > 90) { f=0.0; DL("ERR, processCommands(): bad NV latitude"); }
if (f < -90 || f > 90) { f=0.0; DLF("ERR, processCommands(): bad NV latitude"); }
setLatitude(f);
longitude=nv.readFloat(EE_sites+currentSite*25+4);
if (longitude < -360 || longitude > 360) { longitude=0.0; DL("ERR, processCommands(): bad NV longitude"); }
if (longitude < -360 || longitude > 360) { longitude=0.0; DLF("ERR, processCommands(): bad NV longitude"); }
timeZone=nv.read(EE_sites+currentSite*25+8)-128;
timeZone=decodeTimeZone(timeZone);
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DL("ERR, processCommands(): bad NV timeZone"); }
if (timeZone < -12 || timeZone > 14) { timeZone=0.0; DLF("ERR, processCommands(): bad NV timeZone"); }
updateLST(jd2last(JD,UT1,false));
} else
if (command[1] == '?') {
Expand Down Expand Up @@ -2229,7 +2229,12 @@ void decMinLimit() {
if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; trackingState = TrackingNone; } else {
if (getInstrPierSide() == PierSideWest && guideDirAxis2 == 'n' ) guideDirAxis2='b'; else
if (getInstrPierSide() == PierSideEast && guideDirAxis2 == 's' ) guideDirAxis2='b'; else
if (guideDirAxis2 == 0 && generalError != ERR_DEC) trackingState = TrackingNone;
if (guideDirAxis2 == 0 && generalError != ERR_DEC) {
if (trackingState != TrackingNone) {
trackingState=TrackingNone;
DLF("WRN, decMinLimit(): Limit exceeded tracking/slewing stopped");
}
}
}
}

Expand All @@ -2238,7 +2243,12 @@ void decMaxLimit() {
if (trackingState == TrackingMoveTo) { if (!abortSlew) abortSlew=StartAbortSlew; trackingState = TrackingNone; } else {
if (getInstrPierSide() == PierSideWest && guideDirAxis2 == 's' ) guideDirAxis2='b'; else
if (getInstrPierSide() == PierSideEast && guideDirAxis2 == 'n' ) guideDirAxis2='b'; else
if (guideDirAxis2 == 0 && generalError != ERR_DEC) trackingState = TrackingNone;
if (guideDirAxis2 == 0 && generalError != ERR_DEC) {
if (trackingState != TrackingNone) {
trackingState=TrackingNone;
DLF("WRN, decMaxLimit(): Limit exceeded tracking/slewing stopped");
}
}
}
}

Expand All @@ -2247,15 +2257,24 @@ void stopLimit() {
if (trackingState == TrackingMoveTo) {
if (!abortSlew) abortSlew=StartAbortSlew;
} else {
trackingState=TrackingNone;
if (spiralGuide) stopGuideSpiral();
if (spiralGuide) stopGuideSpiral(); else {
if (trackingState != TrackingNone) {
trackingState=TrackingNone;
DLF("WRN, stopLimit(): Limit exceeded tracking/goto stopped");
}
}
}
}

// stops all motion including guiding
void hardLimit() {
stopSlewing();
if (trackingState != TrackingMoveTo) trackingState=TrackingNone;
if (trackingState != TrackingMoveTo) {
if (trackingState != TrackingNone) {
trackingState=TrackingNone;
DLF("WRN, hardLimit(): Limit exceeded tracking/slewing stopped");
}
}
}

// calculate the checksum and add to string
Expand Down
3 changes: 2 additions & 1 deletion Goto.ino
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ CommandErrors goTo(double thisTargetAxis1, double thisTargetAxis2, double altTar

axis1DriverGotoMode();
axis2DriverGotoMode();


VLF("MSG: Goto started");
return CE_NONE;
}
57 changes: 31 additions & 26 deletions Home.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,30 @@ void checkHome() {
if (findHomeMode == FH_DONE && guideDirAxis1 == 0 && guideDirAxis2 == 0) {
findHomeMode=FH_OFF;

#if AXIS2_TANGENT_ARM == ON
trackingState=abortTrackingState;
cli();
targetAxis2.part.m = 0; targetAxis2.part.f = 0;
posAxis2 = 0;
sei();
#else
// at the polar home position
InitStartPosition();
atHome=true;
#endif
VLF("MSG: Homing done");
#if AXIS2_TANGENT_ARM == ON
trackingState=abortTrackingState;
cli();
targetAxis2.part.m = 0; targetAxis2.part.f = 0;
posAxis2 = 0;
sei();
#else
// at the polar home position
InitStartPosition();
atHome=true;
#endif
}
}

void StopAxis1() {
guideDirAxis1='b';
VLF("MSG: Homing limit detected, stopping guide on Axis1");
if (guideDirAxis2 != 'n' && guideDirAxis2 != 's') { if (findHomeMode == FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode == FH_FAST) findHomeMode=FH_IDLE; }
}

void StopAxis2() {
guideDirAxis2='b';
VLF("MSG: Homing limit detected, stopping guide on Axis2");
if (guideDirAxis1 != 'e' && guideDirAxis1 != 'w') { if (findHomeMode == FH_SLOW) findHomeMode=FH_DONE; if (findHomeMode == FH_FAST) findHomeMode=FH_IDLE; }
}
#endif
Expand Down Expand Up @@ -82,11 +85,11 @@ CommandErrors goHome(boolean fast) {

// start guides
if (fast) {
#if AXIS2_TANGENT_ARM != ON
// make sure tracking is disabled
trackingState=TrackingNone;
#endif

#if AXIS2_TANGENT_ARM != ON
// make sure tracking is disabled
trackingState=TrackingNone;
#endif
// make sure motors are powered on
enableStepperDrivers();

Expand All @@ -95,19 +98,21 @@ CommandErrors goHome(boolean fast) {
findHomeTimeout=millis()+(unsigned long)(secPerDeg*180.0*1000.0);

// 8=HalfMaxRate
#if AXIS2_TANGENT_ARM != ON
e=startGuideAxis1(a1,8,0);
#endif
if (e == CE_NONE) e=startGuideAxis2(a2,8,0,true);
#if AXIS2_TANGENT_ARM != ON
e=startGuideAxis1(a1,8,0);
#endif

if (e == CE_NONE) { VLF("MSG: Homing started phase 1"); e=startGuideAxis2(a2,8,0,true); } else { stopGuideAxis1(); VLF("MSG: Homing failed"); }
} else {
findHomeMode=FH_SLOW;
findHomeTimeout=millis()+30000UL;

// 7=48x sidereal
#if AXIS2_TANGENT_ARM != ON
e=startGuideAxis1(a1,7,0);
#endif
if (e == CE_NONE) e=startGuideAxis2(a2,7,0,true);
#if AXIS2_TANGENT_ARM != ON
e=startGuideAxis1(a1,7,0);
#endif

if (e == CE_NONE) { e=startGuideAxis2(a2,7,0,true); VLF("MSG: Homing started phase 2"); } else { stopGuideAxis1(); VLF("MSG: Homing failed"); }
}
if (e != CE_NONE) stopSlewing();
return e;
Expand All @@ -127,7 +132,7 @@ CommandErrors goHome(boolean fast) {
e=goTo(homePositionAxis1,homePositionAxis2,homePositionAxis1,homePositionAxis2,PierSideEast);
#endif

if (e == CE_NONE) homeMount=true; else trackingState=abortTrackingState;
if (e == CE_NONE) { VLF("MSG: Homing started"); homeMount=true; } else { VLF("MSG: Homing failed"); trackingState=abortTrackingState; }
return e;
#endif
}
Expand Down Expand Up @@ -161,13 +166,13 @@ CommandErrors setHome() {

// reset PEC, unless we have an index to recover from this
pecRecorded=nv.read(EE_pecRecorded);
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DL("ERR, setHome(): bad NV pecRecorded"); }
if (pecRecorded != true && pecRecorded != false) { pecRecorded=false; DLF("ERR, setHome(): bad NV pecRecorded"); }
#if PEC_SENSE == OFF
pecStatus=IgnorePEC;
nv.write(EE_pecStatus,pecStatus);
#else
pecStatus=nv.read(EE_pecStatus);
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DL("ERR, setHome(): bad NV pecStatus"); }
if (pecStatus < PEC_STATUS_FIRST || pecStatus > PEC_STATUS_LAST) { pecStatus=IgnorePEC; DLF("ERR, setHome(): bad NV pecStatus"); }
#endif
if (!pecRecorded) pecStatus=IgnorePEC;

Expand Down
Loading

0 comments on commit cdea5ce

Please sign in to comment.