Skip to content

Commit

Permalink
Update TemperatureCompensateSP Property
Browse files Browse the repository at this point in the history
  • Loading branch information
naheedsa committed Feb 22, 2024
1 parent a3d26b6 commit 25ca248
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
30 changes: 15 additions & 15 deletions drivers/focuser/moonlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ bool MoonLite::initProperties()
OPTIONS_TAB, IP_RW, 0, IPS_IDLE);

// Compensate for temperature
IUFillSwitch(&TemperatureCompensateS[0], "Enable", "", ISS_OFF);
IUFillSwitch(&TemperatureCompensateS[1], "Disable", "", ISS_ON);
IUFillSwitchVector(&TemperatureCompensateSP, TemperatureCompensateS, 2, getDeviceName(), "T. Compensate",
TemperatureCompensateSP[Enable].fill("Enable", "", ISS_OFF);
TemperatureCompensateSP[Disable].fill("Disable", "", ISS_ON);
TemperatureCompensateSP.fill(getDeviceName(), "T. Compensate",
"", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);

/* Relative and absolute movement */
Expand Down Expand Up @@ -97,7 +97,7 @@ bool MoonLite::updateProperties()
defineProperty(TemperatureNP);
defineProperty(StepModeSP);
defineProperty(TemperatureSettingNP);
defineProperty(&TemperatureCompensateSP);
defineProperty(TemperatureCompensateSP);

GetFocusParams();

Expand All @@ -108,7 +108,7 @@ bool MoonLite::updateProperties()
deleteProperty(TemperatureNP.getName());
deleteProperty(StepModeSP.getName());
deleteProperty(TemperatureSettingNP.getName());
deleteProperty(TemperatureCompensateSP.name);
deleteProperty(TemperatureCompensateSP.getName());
}

return true;
Expand Down Expand Up @@ -367,24 +367,24 @@ bool MoonLite::ISNewSwitch(const char * dev, const char * name, ISState * states
}

// Temperature Compensation Mode
if (strcmp(TemperatureCompensateSP.name, name) == 0)
if (TemperatureCompensateSP.isNameMatch(name))
{
int last_index = IUFindOnSwitchIndex(&TemperatureCompensateSP);
IUUpdateSwitch(&TemperatureCompensateSP, states, names, n);
int last_index = TemperatureCompensateSP.findOnSwitchIndex();
TemperatureCompensateSP.update(states, names, n);

bool rc = setTemperatureCompensation((TemperatureCompensateS[0].s == ISS_ON));
bool rc = setTemperatureCompensation((TemperatureCompensateSP[Enable].getState() == ISS_ON));

if (!rc)
{
TemperatureCompensateSP.s = IPS_ALERT;
IUResetSwitch(&TemperatureCompensateSP);
TemperatureCompensateS[last_index].s = ISS_ON;
IDSetSwitch(&TemperatureCompensateSP, nullptr);
TemperatureCompensateSP.setState(IPS_ALERT);
TemperatureCompensateSP.reset();
TemperatureCompensateSP[last_index].setState(ISS_ON);
TemperatureCompensateSP.apply();
return false;
}

TemperatureCompensateSP.s = IPS_OK;
IDSetSwitch(&TemperatureCompensateSP, nullptr);
TemperatureCompensateSP.setState(IPS_OK);
TemperatureCompensateSP.apply();
return true;
}
}
Expand Down
8 changes: 6 additions & 2 deletions drivers/focuser/moonlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ class MoonLite : public INDI::Focuser
};

// Temperature Compensation Enable/Disable
ISwitch TemperatureCompensateS[2];
ISwitchVectorProperty TemperatureCompensateSP;
INDI::PropertySwitch TemperatureCompensateSP {2};
enum
{
Enable,
Disable
};

// MoonLite Buffer
static const uint8_t ML_RES { 32 };
Expand Down

0 comments on commit 25ca248

Please sign in to comment.