Skip to content

Commit

Permalink
indi-eqmod: check if mount supports led brightness control (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
geehalel committed Apr 2, 2020
1 parent 263ae03 commit 7c25c27
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
35 changes: 25 additions & 10 deletions indi-eqmod/eqmodbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void EQMod::ISGetProperties(const char *dev)
defineSwitch(TrackDefaultSP);
defineSwitch(ST4GuideRateNSSP);
defineSwitch(ST4GuideRateWESP);
defineNumber(LEDBrightnessNP);

#if defined WITH_ALIGN && defined WITH_ALIGN_GEEHALEL
defineSwitch(&AlignMethodSP);
#endif
Expand All @@ -359,7 +359,6 @@ void EQMod::ISGetProperties(const char *dev)
defineSwitch(DEPPECTrainingSP);
defineSwitch(DEPPECSP);
}

if (mount->HasSnapPort1())
{
defineSwitch(SNAPPORT1SP);
Expand All @@ -368,6 +367,10 @@ void EQMod::ISGetProperties(const char *dev)
{
defineSwitch(SNAPPORT2SP);
}
if (mount->HasPolarLed())
{
defineNumber(LEDBrightnessNP);
}

#ifdef WITH_ALIGN_GEEHALEL
if (align)
Expand Down Expand Up @@ -495,7 +498,7 @@ bool EQMod::updateProperties()
defineSwitch(TrackDefaultSP);
defineSwitch(ST4GuideRateNSSP);
defineSwitch(ST4GuideRateWESP);
defineNumber(LEDBrightnessNP);

#if defined WITH_ALIGN && defined WITH_ALIGN_GEEHALEL
defineSwitch(&AlignMethodSP);
#endif
Expand Down Expand Up @@ -578,6 +581,11 @@ bool EQMod::updateProperties()
}
}

if (mount->HasPolarLed())
{
defineNumber(LEDBrightnessNP);
}

LOG_DEBUG("Init backlash.");
mount->SetBacklashUseRA((IUFindSwitch(UseBacklashSP, "USEBACKLASHRA")->s == ISS_ON ? true : false));
mount->SetBacklashUseDE((IUFindSwitch(UseBacklashSP, "USEBACKLASHDE")->s == ISS_ON ? true : false));
Expand Down Expand Up @@ -678,6 +686,10 @@ bool EQMod::updateProperties()
{
deleteProperty(SNAPPORT2SP->name);
}
if (mount->HasPolarLed())
{
deleteProperty(LEDBrightnessNP->name);
}
#if defined WITH_ALIGN && defined WITH_ALIGN_GEEHALEL
deleteProperty(AlignMethodSP.name);
#endif
Expand Down Expand Up @@ -2604,14 +2616,17 @@ bool EQMod::ISNewNumber(const char *dev, const char *name, double values[], char
return true;
}

if (strcmp(name, "LED_BRIGHTNESS") == 0)
if (mount->HasPolarLed())
{
IUUpdateNumber(LEDBrightnessNP, values, names, n);
LEDBrightnessNP->s = IPS_OK;
IDSetNumber(LEDBrightnessNP, nullptr);
mount->SetLEDBrightness(static_cast<uint8_t>(values[0]));
LOGF_INFO("Setting LED brightness to %.f", values[0]);
return true;
if (strcmp(name, "LED_BRIGHTNESS") == 0)
{
IUUpdateNumber(LEDBrightnessNP, values, names, n);
LEDBrightnessNP->s = IPS_OK;
IDSetNumber(LEDBrightnessNP, nullptr);
mount->SetLEDBrightness(static_cast<uint8_t>(values[0]));
LOGF_INFO("Setting LED brightness to %.f", values[0]);
return true;
}
}

if (strcmp(name, "STANDARDSYNCPOINT") == 0)
Expand Down
12 changes: 11 additions & 1 deletion indi-eqmod/skywatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ bool Skywatcher::HasSnapPort2()
return MountCode == 0x06;
}

bool Skywatcher::HasPolarLed()
{
return (AxisFeatures[Axis1].hasPolarLed) && (AxisFeatures[Axis2].hasPolarLed);
}

void Skywatcher::InquireRAEncoderInfo(INumberVectorProperty *encoderNP)
{
double steppersvalues[3];
Expand Down Expand Up @@ -1279,7 +1284,12 @@ void Skywatcher::SetLEDBrightness(uint8_t value)
char hexa[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
cmd[0] = hexa[(value & 0xF0) >> 4];
cmd[1] = hexa[(value & 0x0F)];
dispatch_command(SetPolarScopeLED, Axis1, cmd);
try {
dispatch_command(SetPolarScopeLED, Axis1, cmd);
} catch (EQModError e) {
DEBUGF(telescope->DBG_MOUNT, "%s(): Mount does not support led brightness (%c command)", __FUNCTION__,
SetPolarScopeLED);
}
}

void Skywatcher::TurnRAPPECTraining(bool on)
Expand Down
1 change: 1 addition & 0 deletions indi-eqmod/skywatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Skywatcher
bool HasPPEC();
bool HasSnapPort1();
bool HasSnapPort2();
bool HasPolarLed();

uint32_t GetRAEncoder();
uint32_t GetDEEncoder();
Expand Down

0 comments on commit 7c25c27

Please sign in to comment.