Instrument Neutral Distributed Interface INDI 2.2.5
hitechweather.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2025 Jasem Mutlaq. All rights reserved.
3
4 INDI HiTech Weather Station Driver
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#pragma once
26
27#include "indiweather.h"
28
29#ifdef _USE_SYSTEM_HIDAPILIB
30#include <hidapi/hidapi.h>
31#else
32#include <indi_hidapi.h>
33#endif
34
36{
37 public:
39 virtual ~HitechWeather();
40
41 // Generic indi device entries
42 bool Connect() override;
43 bool Disconnect() override;
44 const char *getDefaultName() override;
45
46 virtual bool initProperties() override;
47
48 protected:
49 virtual IPState updateWeather() override;
50
51 private:
52 // HID device handle
53 hid_device *m_hidHandle {nullptr};
54
55 // HiTech Weather USB identifiers
56 static constexpr unsigned short HITECH_VID = 0x04D8;
57 static constexpr unsigned short HITECH_PID = 0xF772;
58
59 // Command bytes
60 static constexpr unsigned char CMD_GET_SKY_TEMP = 0x50;
61 static constexpr unsigned char CMD_GET_AMBIENT = 0x5A;
62
63 // Helper functions
64 bool getSkyTemperature(double &skyTemp);
65 bool getAmbientTemperature(double &ambientTemp);
66 double calculateCloudCover(double ambientTemp, double skyTemp);
67};
bool Disconnect() override
Disconnect from device.
virtual ~HitechWeather()
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
const char * getDefaultName() override
IPState
Property state.
Definition indiapi.h:158