diff --git a/drivers/telescope/lx200_pegasus_nyx101.cpp b/drivers/telescope/lx200_pegasus_nyx101.cpp index 2014b2bf1e..24656d735e 100644 --- a/drivers/telescope/lx200_pegasus_nyx101.cpp +++ b/drivers/telescope/lx200_pegasus_nyx101.cpp @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -305,7 +375,7 @@ bool LX200NYX101::ReadScopeStatus() TelescopePierSide _PierSide = PIER_UNKNOWN; - //bool _DoesRefractionComp = false; + bool _DoesRefractionComp = false; SetPropertyText(DoesRefractionComp, IPS_BUSY); //bool _WaitingAtHome = false; @@ -320,9 +390,6 @@ bool LX200NYX101::ReadScopeStatus() //bool _SlewingHome = false; SetPropertyText(SlewingHome, IPS_BUSY); - - - char status[DRIVER_LEN] = {0}; if(sendCommand(":GU#", status)) { @@ -383,7 +450,7 @@ bool LX200NYX101::ReadScopeStatus() _PierSide = PIER_WEST; continue; case 'r': - //_DoesRefractionComp = true; + _DoesRefractionComp = true; SetPropertyText(DoesRefractionComp, IPS_OK); continue; case 'w': @@ -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; @@ -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(ElevationLimitNP[OVERHEAD].getValue())) + "#";; + sendCommand(command.c_str()); + } + else if(ElevationLimitNP[HORIZON].isNameMatch(names[i])) + { + std::string command = ":Sh" + std::to_string(static_cast(ElevationLimitNP[HORIZON].getValue())) + "#";; + sendCommand(command.c_str()); + } + } + ElevationLimitNP.apply(); + return true; + } + } + } + return LX200Generic::ISNewNumber(dev, name, values, names, n); } @@ -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); @@ -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); @@ -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