moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / indi / indi_lpi.cpp
blobfc0b30297908fd976c94d2b9acafe8bb80d106ce
1 /*
2 Meade LPI Experimental driver
3 Copyright (C) 2005 by Jasem Mutlaq
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "v4ldriver.h"
23 class Meade_LPI : public V4L_Driver
25 public:
26 Meade_LPI();
27 ~Meade_LPI();
29 #ifdef HAVE_LINUX_VIDEODEV2_H
30 void connectCamera(void);
31 #endif
35 Meade_LPI::Meade_LPI() : V4L_Driver()
39 Meade_LPI::~Meade_LPI()
43 #ifdef HAVE_LINUX_VIDEODEV2_H
44 void Meade_LPI::connectCamera()
46 char errmsg[ERRMSGSIZ];
48 switch (PowerS[0].s)
50 case ISS_ON:
51 if (v4l_base->connectCam(PortT[0].text, errmsg, V4L2_PIX_FMT_SBGGR8, 352, 288) < 0)
53 PowerSP.s = IPS_IDLE;
54 PowerS[0].s = ISS_OFF;
55 PowerS[1].s = ISS_ON;
56 IDSetSwitch(&PowerSP, "Error: %s", errmsg);
57 IDLog("Error: %s\n", errmsg);
58 return;
61 /* Sucess! */
62 PowerS[0].s = ISS_ON;
63 PowerS[1].s = ISS_OFF;
64 PowerSP.s = IPS_OK;
65 IDSetSwitch(&PowerSP, "Meade LPI is online. Retrieving basic data.");
67 v4l_base->registerCallback(newFrame, this);
69 V4LFrame->compressedFrame = (unsigned char *) malloc (sizeof(unsigned char) * 1);
71 IDLog("V4L Device is online. Retrieving basic data.\n");
72 getBasicData();
74 break;
76 case ISS_OFF:
77 PowerS[0].s = ISS_OFF;
78 PowerS[1].s = ISS_ON;
79 PowerSP.s = IPS_IDLE;
81 free(V4LFrame->compressedFrame);
82 V4LFrame->compressedFrame = NULL;
83 v4l_base->disconnectCam();
85 IDSetSwitch(&PowerSP, "Video4Linux Generic Device is offline.");
87 break;
91 #endif
93 Meade_LPI *MainCam = NULL; /* Main and only camera */
95 /* send client definitions of all properties */
96 void ISInit()
98 if (MainCam == NULL)
100 MainCam = new Meade_LPI();
101 MainCam->initProperties("Meade LPI");
102 MainCam->initCamBase();
106 void ISGetProperties (const char *dev)
108 ISInit();
110 MainCam->ISGetProperties(dev);
114 void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
117 ISInit();
119 MainCam->ISNewSwitch(dev, name, states, names, n);
122 void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
125 ISInit();
127 MainCam->ISNewText(dev, name, texts, names, n);
131 void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
134 ISInit();
136 MainCam->ISNewNumber(dev, name, values, names, n);
139 void ISNewBLOB (const char */*dev*/, const char */*name*/, int */*sizes[]*/, char **/*blobs[]*/, char **/*formats[]*/, char **/*names[]*/, int /*n*/)
142 // We use this if we're receving binary data from the client. Most likely we won't for this driver.