Kstars

indilightbox.cpp
1 /*
2  SPDX-FileCopyrightText: 2022 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include <basedevice.h>
8 #include "indilightbox.h"
9 
10 namespace ISD
11 {
12 
13 bool LightBox::isLightOn()
14 {
15  auto lightSP = getSwitch("FLAT_LIGHT_CONTROL");
16  if (!lightSP)
17  return false;
18 
19  auto lightON = lightSP->findWidgetByName("FLAT_LIGHT_ON");
20  if (!lightON)
21  return false;
22 
23  return lightON->getState() == ISS_ON;
24 }
25 
26 bool LightBox::setLightEnabled(bool enable)
27 {
28  auto lightSP = getSwitch("FLAT_LIGHT_CONTROL");
29 
30  if (!lightSP)
31  return false;
32 
33  auto lightON = lightSP->findWidgetByName("FLAT_LIGHT_ON");
34  auto lightOFF = lightSP->findWidgetByName("FLAT_LIGHT_OFF");
35 
36  if (!lightON || !lightOFF)
37  return false;
38 
39  lightSP->reset();
40 
41  if (enable)
42  lightON->setState(ISS_ON);
43  else
44  lightOFF->setState(ISS_ON);
45 
46  sendNewProperty(lightSP);
47 
48  return true;
49 }
50 
51 bool LightBox::setBrightness(uint16_t val)
52 {
53  auto lightIntensity = getNumber("FLAT_LIGHT_INTENSITY");
54  if (!lightIntensity)
55  return false;
56 
57  lightIntensity->at(0)->setValue(val);
58  sendNewProperty(lightIntensity);
59  return true;
60 }
61 
62 
63 }
INDI::PropertyView< ISwitch > * getSwitch(const QString &name) const
Q_SCRIPTABLE bool setLightEnabled(bool enable)
SetLightEnabled Turn on/off light.
Q_SCRIPTABLE bool setBrightness(uint16_t val)
SetBrightness Set light box brightness levels if dimmable.
void sendNewProperty(INDI::Property prop)
Send new property command to server.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 04:02:40 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.