diff --git a/drivers/telescope/scopesim_helper.cpp b/drivers/telescope/scopesim_helper.cpp index b0fef8bb77..210b46397f 100644 --- a/drivers/telescope/scopesim_helper.cpp +++ b/drivers/telescope/scopesim_helper.cpp @@ -190,16 +190,21 @@ void Axis::update() // called about once a second to update the position //LOGF_DEBUG("move %s: change %f, position %f", b, change, position.Degrees()); } + int rate = std::max(-4,std::min(4,mcRate)); + if(rate != mcRate) { + LOGF_ERROR("Invalid mcRate Detected = %d",mcRate); + } + // handle the motion control - if (mcRate < 0) + if (rate < 0) { - change = -mcRates[-mcRate].Degrees() * interval; + change = -mcRates[-rate].Degrees() * interval; //LOGF_DEBUG("mcRate %d, rate %f, change %f", mcRate, mcRates[-mcRate].Degrees(), change); position += change; } - else if (mcRate > 0) + else if (rate > 0) { - change = mcRates[mcRate].Degrees() * interval; + change = mcRates[rate].Degrees() * interval; //LOGF_DEBUG("mcRate %d, rate %f, change %f", mcRate, mcRates[mcRate].Degrees(), change); position += change; } diff --git a/drivers/telescope/scopesim_helper.h b/drivers/telescope/scopesim_helper.h index 2a3242729f..60021725d2 100644 --- a/drivers/telescope/scopesim_helper.h +++ b/drivers/telescope/scopesim_helper.h @@ -288,7 +288,7 @@ class Axis guideDuration = 0; } - bool isSlewing; + bool isSlewing = false; bool isTracking() { @@ -328,7 +328,7 @@ class Axis return guideDuration > 0; } - int mcRate; // int -4 to 4 sets move rate, zero is stopped + int mcRate = 0; // int -4 to 4 sets move rate, zero is stopped void update(); // called about once a second to update the position and mode @@ -346,13 +346,13 @@ class Axis 0, 0 }; - bool tracking; // this allows the tracking state and rate to be set independently + bool tracking = false; // this allows the tracking state and rate to be set independently AXIS_TRACK_RATE trackingRate { AXIS_TRACK_RATE::OFF }; Angle rotateCentre { 90.0 }; - double guideDuration; + double guideDuration = 0; Angle guideRateDegSec; // rates are angles in degrees per second derived from the values in indicom.h