Skip to content

Commit

Permalink
Added several missing commands: (indilib#1957)
Browse files Browse the repository at this point in the history
  • Loading branch information
amendolajamie authored Nov 2, 2023
1 parent 16fef45 commit d7c3b1b
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 9 deletions.
226 changes: 218 additions & 8 deletions drivers/telescope/lx200_pegasus_nyx101.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,32 @@ bool LX200NYX101::initProperties()

// Overwrite TRACK_CUSTOM, with TRACK_KING
IUFillSwitch(&TrackModeS[TRACK_KING], "TRACK_KING", "King", ISS_OFF);


// Elevation Limits
ElevationLimitNP[OVERHEAD].fill("ELEVATION_OVERHEAD", "Overhead", "%g", 60, 90, 1, 90);
ElevationLimitNP[HORIZON].fill("ELEVATION_HORIZON", "Horizon", "%g", -30, 0, 1, 0);
ElevationLimitNP.fill(getDeviceName(), "ELEVATION_LIMIT", "Elevation Limit", MAIN_CONTROL_TAB, IP_RW, 0,
IPS_IDLE);

// Meridian
MeridianLimitNP[0].fill("VALUE", "Degrees (+/- 120)", "%.f", -120, 120, 1, 0);
MeridianLimitNP.fill(getDeviceName(), "MERIDIAN_LIMIT", "Limit", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE);

// Flip
FlipSP[0].fill("Flip", "Flip", ISS_OFF);
FlipSP.fill(getDeviceName(), "FLIP", "Pier Side", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);

// Refraction
RefractSP[REFRACT_ON].fill("REFRACTION_ON", "On", ISS_OFF);
RefractSP[REFRACT_OFF].fill("REFRACTION_OFF", "Off", ISS_OFF);
RefractSP.fill(getDeviceName(), "REFRACTION",
"Refraction", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);

// Safety Limits
SafetyLimitSP[SET_SAFETY_LIMIT].fill("SET_SAFETY_LIMIT", "Set", ISS_OFF);
SafetyLimitSP[CLEAR_SAFETY_LIMIT].fill("CLEAR_SAFETY_LIMIT", "Clear", ISS_OFF);
SafetyLimitSP.fill(getDeviceName(), "SAFETY_LIMIT",
"Custom Limits", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
// Guide Rate
int guideRate = 1;
IUGetConfigOnSwitchIndex(getDeviceName(), "GUIDE_RATE", &guideRate);
Expand All @@ -100,6 +125,12 @@ bool LX200NYX101::initProperties()
Report[0].fill("Report","GU","-");
Report.fill(getDeviceName(), "Report", "Report", STATUS_TAB, IP_RO, 60, IPS_IDLE);

#ifdef DEBUG_NYX
DebugCommandTP[0].fill("Command", "", "");
DebugCommandTP.fill(getDeviceName(), "DebugCommand", "", MAIN_CONTROL_TAB, IP_RW, 0,
IPS_IDLE);
#endif

IsTracking[0].fill("IsTracking","n","-");
IsTracking.fill(getDeviceName(),"IsTracking","IsTracking",STATUS_TAB, IP_RO, 60, IPS_IDLE);

Expand Down Expand Up @@ -145,7 +176,10 @@ bool LX200NYX101::initProperties()
SlewingHome[0].fill("SlewingHome","h","-");
SlewingHome.fill(getDeviceName(),"SlewingHome","SlewingHome",STATUS_TAB, IP_RO, 60, IPS_IDLE);


// Reboot
RebootSP[0].fill("Reboot", "Reboot", ISS_OFF);
RebootSP.fill(getDeviceName(), "REBOOT", "Reboot", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);

// Slew Rates
strncpy(SlewRateS[0].label, "2x", MAXINDILABEL);
strncpy(SlewRateS[1].label, "8x", MAXINDILABEL);
Expand Down Expand Up @@ -198,11 +232,38 @@ bool LX200NYX101::updateProperties()
GuideRateSP.apply();
}

if(sendCommand(":Go#", status))
{
std::string c = status;
ElevationLimitNP[OVERHEAD].value = std::stoi(c);
}

if(sendCommand(":Gh#", status))
{
std::string c = status;
ElevationLimitNP[HORIZON].value = std::stoi(c);
}

if(sendCommand(":GXE9#", status))
{
std::string c = status;
MeridianLimitNP[0].setValue(std::stoi(c));
}

defineProperty(MountTypeSP);
defineProperty(GuideRateSP);
defineProperty(HomeSP);
defineProperty(ResetHomeSP);
defineProperty(Report);
defineProperty(FlipSP);
defineProperty(MeridianLimitNP);
defineProperty(ElevationLimitNP);
defineProperty(RefractSP);
defineProperty(SafetyLimitSP);
#ifdef DEBUG_NYX
defineProperty(DebugCommandTP);
#endif
defineProperty(RebootSP);
defineProperty(VerboseReportSP);
defineProperty(IsTracking);
defineProperty(IsSlewCompleted);
Expand All @@ -225,9 +286,18 @@ bool LX200NYX101::updateProperties()
deleteProperty(MountTypeSP);
deleteProperty(GuideRateSP);
deleteProperty(HomeSP);
deleteProperty(MeridianLimitNP);
deleteProperty(FlipSP);
deleteProperty(ElevationLimitNP);
deleteProperty(SafetyLimitSP);
deleteProperty(ResetHomeSP);
deleteProperty(Report);
#ifdef DEBUG_NYX
deleteProperty(DebugCommandTP);
#endif
deleteProperty(RebootSP);
deleteProperty(VerboseReportSP);
deleteProperty(RefractSP);
deleteProperty(IsTracking);
deleteProperty(IsSlewCompleted);
deleteProperty(IsParked);
Expand Down Expand Up @@ -305,7 +375,7 @@ bool LX200NYX101::ReadScopeStatus()

TelescopePierSide _PierSide = PIER_UNKNOWN;

//bool _DoesRefractionComp = false;
bool _DoesRefractionComp = false;
SetPropertyText(DoesRefractionComp, IPS_BUSY);

//bool _WaitingAtHome = false;
Expand All @@ -320,9 +390,6 @@ bool LX200NYX101::ReadScopeStatus()
//bool _SlewingHome = false;
SetPropertyText(SlewingHome, IPS_BUSY);




char status[DRIVER_LEN] = {0};
if(sendCommand(":GU#", status))
{
Expand Down Expand Up @@ -383,7 +450,7 @@ bool LX200NYX101::ReadScopeStatus()
_PierSide = PIER_WEST;
continue;
case 'r':
//_DoesRefractionComp = true;
_DoesRefractionComp = true;
SetPropertyText(DoesRefractionComp, IPS_OK);
continue;
case 'w':
Expand All @@ -410,7 +477,17 @@ bool LX200NYX101::ReadScopeStatus()
break;
}
}

if(_DoesRefractionComp ){
RefractSP[REFRACT_ON].setState(ISS_ON);
RefractSP[REFRACT_OFF].setState(ISS_OFF);
RefractSP.setState(IPS_OK);
RefractSP.apply();
} else {
RefractSP[REFRACT_ON].setState(ISS_OFF);
RefractSP[REFRACT_OFF].setState(ISS_ON);
RefractSP.setState(IPS_OK);
RefractSP.apply();
}
TrackModeS[TRACK_SIDEREAL].s = ISS_OFF;
TrackModeS[TRACK_LUNAR].s = ISS_OFF;
TrackModeS[TRACK_SOLAR].s = ISS_OFF;
Expand Down Expand Up @@ -487,6 +564,55 @@ bool LX200NYX101::ReadScopeStatus()

bool LX200NYX101::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
if (MeridianLimitNP.isNameMatch(name))
{
MeridianLimitNP.update(values, names, n);
if (!isSimulation())
{
std::string command = ":SXE9," + std::to_string(MeridianLimitNP[0].getValue()) + "#";;
sendCommand(command.c_str());
command = ":SXEA," + std::to_string(MeridianLimitNP[0].getValue()) + "#";;
sendCommand(command.c_str());
if (MeridianLimitNP.getState() == IPS_OK)
{
LOGF_INFO("Meridian!: ", MeridianLimitNP[0].getValue());

}
}
else
{
MeridianLimitNP.setState(IPS_OK);
}

MeridianLimitNP.apply();
return true;
}

if (ElevationLimitNP.isNameMatch(name))
{
if(ElevationLimitNP.update(values, names, n))
{
for(int i = 0; i<n; ++i)
{
if(ElevationLimitNP[OVERHEAD].isNameMatch(names[i]))
{
std::string command = ":So" + std::to_string(static_cast<int>(ElevationLimitNP[OVERHEAD].getValue())) + "#";;
sendCommand(command.c_str());
}
else if(ElevationLimitNP[HORIZON].isNameMatch(names[i]))
{
std::string command = ":Sh" + std::to_string(static_cast<int>(ElevationLimitNP[HORIZON].getValue())) + "#";;
sendCommand(command.c_str());
}
}
ElevationLimitNP.apply();
return true;
}
}
}

return LX200Generic::ISNewNumber(dev, name, values, names, n);
}

Expand Down Expand Up @@ -540,6 +666,32 @@ bool LX200NYX101::ISNewSwitch(const char *dev, const char *name, ISState *states
HomeSP.apply();
return true;
}
else if(FlipSP.isNameMatch(name))
{
FlipSP.update(states, names, n);
IPState state = IPS_OK;
if (isConnected())
{
FlipSP[0].setState(ISS_OFF);
sendCommand(":MN#");
}
FlipSP.setState(state);
FlipSP.apply();
return true;
}
else if(RebootSP.isNameMatch(name))
{
RebootSP.update(states, names, n);
IPState state = IPS_OK;
if (isConnected())
{
RebootSP[0].setState(ISS_OFF);
sendCommand(":ERESET#");
}
RebootSP.setState(state);
RebootSP.apply();
return true;
}
else if(ResetHomeSP.isNameMatch(name))
{
ResetHomeSP.update(states, names, n);
Expand All @@ -553,6 +705,39 @@ bool LX200NYX101::ISNewSwitch(const char *dev, const char *name, ISState *states
ResetHomeSP.apply();
return true;
}
else if(SafetyLimitSP.isNameMatch(name))
{
SafetyLimitSP.update(states, names, n);
auto index = SafetyLimitSP.findOnSwitchIndex();
switch(index){
case SET_SAFETY_LIMIT:
sendCommand(":Sc1#");
sendCommand(":Sc#");
break;
case CLEAR_SAFETY_LIMIT:
sendCommand(":Sc0#");
sendCommand(":Sc#");
break;
}
SafetyLimitSP.apply();
return true;
}
else if(RefractSP.isNameMatch(name))
{
RefractSP.update(states, names, n);
auto index = RefractSP.findOnSwitchIndex();

switch(index){
case REFRACT_ON:
sendCommand(":Tr#");
break;
case REFRACT_OFF:
sendCommand(":Tn#");
break;
}
RefractSP.apply();
return true;
}
else if(VerboseReportSP.isNameMatch(name))
{
VerboseReportSP.update(states, names, n);
Expand Down Expand Up @@ -591,6 +776,31 @@ bool LX200NYX101::ISNewSwitch(const char *dev, const char *name, ISState *states
return LX200Generic::ISNewSwitch(dev, name, states, names, n);
}

#ifdef DEBUG_NYX
bool LX200NYX101::ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
{
if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
{
if (DebugCommandTP.isNameMatch(name))
{
DebugCommandTP.update(texts, names, n);
for(int i = 0; i<n; i++)
{
if(DebugCommandTP[0].isNameMatch(names[i]))
{
char status[DRIVER_LEN] = {0};
sendCommand(texts[i]);
i=n;
}
}
return true;
}
}
return LX200Generic::ISNewText(dev, name, texts, names, n);

}
#endif

bool LX200NYX101::SetSlewRate(int index)
{
double value = 0.0;
Expand Down
34 changes: 33 additions & 1 deletion drivers/telescope/lx200_pegasus_nyx101.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#pragma once

#include "lx200generic.h"
//#define DEBUG_NYX


class LX200NYX101 : public LX200Generic
{
Expand All @@ -33,7 +35,12 @@ class LX200NYX101 : public LX200Generic
virtual bool initProperties() override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
#ifdef DEBUG_NYX
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;

INDI::PropertyText DebugCommandTP {1};
#endif

protected:
virtual bool ReadScopeStatus() override;
virtual const char *getDefaultName() override;
Expand All @@ -52,6 +59,18 @@ class LX200NYX101 : public LX200Generic
static const char DRIVER_STOP_CHAR { 0x23 };
static constexpr const uint8_t DRIVER_TIMEOUT {3};

enum RefractionState
{
REFRACT_ON,
REFRACT_OFF
};

enum SafetyLimits
{
SET_SAFETY_LIMIT,
CLEAR_SAFETY_LIMIT
};

enum NYXTelescopeTrackMode
{
TRACK_SIDEREAL,
Expand All @@ -66,6 +85,13 @@ class LX200NYX101 : public LX200Generic
AltAz,
Equatorial
};

enum ElevationNumber
{
OVERHEAD,
HORIZON
};

INDI::PropertySwitch GuideRateSP {3};
INDI::PropertySwitch HomeSP {1};
INDI::PropertySwitch ResetHomeSP {1};
Expand All @@ -86,7 +112,13 @@ class LX200NYX101 : public LX200Generic
INDI::PropertyText IsHomePaused {1};
INDI::PropertyText ParkFailed {1};
INDI::PropertyText SlewingHome {1};

INDI::PropertySwitch FlipSP {1};
INDI::PropertySwitch RebootSP {1};
INDI::PropertySwitch RefractSP {2};
INDI::PropertyNumber ElevationLimitNP {2};
INDI::PropertyNumber MeridianLimitNP {1};
INDI::PropertySwitch SafetyLimitSP {2};


bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
void hexDump(char * buf, const char * data, int size);
Expand Down

0 comments on commit d7c3b1b

Please sign in to comment.