Instrument Neutral Distributed Interface INDI 2.2.5
myDewControllerPro.h
Go to the documentation of this file.
1/*
2 myDewControllerPro Driver
3 Copyright (C) 2017-2023 Chemistorge
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include <defaultdevice.h>
24#include <indipowerinterface.h>
26
27/***************************** myDewControllerPro Commands **************************/
28
29#define MDCP_CMD_LEN 8
30
31//LCD Display Commands
32#define MDCP_GET_LCD_STATE "5#"
33#define MDCP_GET_LCD_STATE_RESPONSE "5%d$"
34#define MDCP_LCD_DISABLE "{#"
35#define MDCP_LCD_ENABLE "}#"
36#define MDCP_GET_LCD_DISPLAY_TIME "H#"
37#define MDCP_GET_LCD_DISPLAY_TIME_RESPONSE "H%d$"
38#define MDCP_SET_LCD_DISPLAY_TIME "b%d#"
39#define MDCP_GET_TEMP_DISPLAY "h#"
40#define MDCP_GET_TEMP_DISPLAY_RESPONSE "h%d$"
41#define MDCP_LCD_DISPLAY_CELSIUS "c#"
42#define MDCP_LCD_DISPLAY_FAHRENHEIT "f#"
43
44
45//Misc Commands
46#define MDCP_GET_VERSION "v#"
47#define MDCP_IDENTIFY_RESPONSE "v%u$" // Firmware version? Mine is "v342"
48#define MDCP_SAVE_TO_EEPROM "w#"
49#define MDCP_RESET_EEPROM_TO_DEFAULT "r#"
50#define MDCP_GET_NUMBER_OF_PROBES "g#"
51
52//Tracking Mode Commands
53
54#define MDCP_SET_TRACKING_MODE "a%1u#"
55#define MDCP_GET_TRACKING_MODE "T#"
56#define MDCP_GET_TRACKING_MODE_RESPONSE "T%d$"
57#define MDCP_GET_TRACKING_MODE_OFFSET "y#"
58#define MDCP_GET_TRACKING_MODE_OFFSET_RESPONSE "y%d$"
59#define MDCP_SET_TRACKING_MODE_OFFSET "3%d#"
60
61//DHT Probe Commands
62
63#define MDCP_GET_AMB_TEMP "A#"
64#define MDCP_GET_AMB_TEMP_REPSONSE "A%f$"
65#define MDCP_GET_AMB_TEMP_OFFSET "B#"
66#define MDCP_GET_AMB_TEMP_OFFSET_RESPONSE "B%d$"
67#define MDCP_SET_AMB_TEMP_OFFSET "e%1d#"
68#define MDCP_GET_REL_HUMIDITY "R#"
69#define MDCP_GET_REL_HUMIDITY_REPSONSE "R%f$"
70#define MDCP_GET_DEW_POINT "D#"
71#define MDCP_GET_DEW_POINT_RESPONSE "D%f$"
72
73
74//Temperature Probe Commands
75
76#define MDCP_GET_PROBE_TEMPS "C#"
77#define MDCP_SET_TEMP_CH1_OFFSET "[%.1f#"
78#define MDCP_SET_TEMP_CH2_OFFSET "]%.1f#"
79#define MDCP_SET_TEMP_CH3_OFFSET "%%%.1f#"
80#define MDCP_CLEAR_TEMP_OFFSETS "&#"
81#define MDCP_GET_TEMP_OFFSETS "?#"
82#define MDCP_GET_TEMP_OFFSETS_RESPONSE "?%f#%f#%f$"
83#define MDCP_GET_TEMP_RESPONSE "C%f#%f#%f$"
84
85//Board Cooling Fan Commands
86
87#define MDCP_GET_FAN_SPEED "F#"
88#define MDCP_SET_FAN_SPEED "s%d#"
89#define MDCP_GET_BOARD_TEMP "K#"
90#define MDCP_GET_BOARD_TEMP_RESPONSE "K%f$"
91#define MDCP_GET_FAN_ON_TEMP "J#"
92#define MDCP_GET_FAN_ON_TEMP_RESPONSE "J%d$"
93#define MDCP_GET_FAN_OFF_TEMP "L#"
94#define MDCP_GET_FAN_OFF_TEMP_RESPONSE "L%d$"
95#define MDCP_SET_FAN_ON_TEMP "N%d#"
96#define MDCP_SET_FAN_OFF_TEMP "M%d#"
97#define MDCP_GET_FAN_MODE "O#"
98#define MDCP_GET_FAN_MODE_RESPONSE "O%d$"
99#define MDCP_SET_FAN_MODE "I%d#"
100
101//Dew Strap Commands
102
103#define MDCP_BOOST_CH1 "1#"
104#define MDCP_BOOST_CH2 "2#"
105#define MDCP_CANCEL_BOOST "n#"
106#define MDCP_GET_CHANNEL_POWER "W#"
107#define MDCP_GET_CHANNEL_POWER_RESPONSE "W%d#%d#%d$"
108#define MDCP_GET_CH3_SETTINGS "E#"
109#define MDCP_GET_CH3_SETTINGS_RESPONSE "E%d$"
110#define MDCP_SET_CH3_SETTINGS "S%d#"
111#define MDCP_SET_CH3_MANUAL_POWER "G%d#"
112
113#define MDCP_RES_LEN 80
114
115
116/******************************************************************************/
117
118namespace Connection
119{
120class Serial;
121};
122
124{
125 public:
127 virtual ~myDewControllerPro() = default;
128
129 virtual const char *getDefaultName() override;
130 virtual bool initProperties() override;
131 virtual bool updateProperties() override;
132 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
133 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
134 virtual void TimerHit() override;
135
136 // INDI::PowerInterface virtual methods
137 virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override;
138 virtual bool SetAutoDewEnabled(size_t port, bool enabled) override;
139 virtual bool saveConfigItems(FILE *fp) override;
140
141 private:
142 bool sendCommand(const char *cmd, char *response);
143 bool Handshake();
144 bool Ack();
145 bool readMainValues();
146 bool readLCDDisplayValues();
147 bool readBoardFanValues();
148 bool readOffsetValues();
149 bool setOutputBoost(unsigned int channel);
150 bool cancelOutputBoost();
151 bool setTempCalibrations(float ch1, float ch2, float ch3, int ambient);
152 bool setFanTempTrigger(int tempOn, int tempOff);
153 bool zeroTempCalibrations();
154 bool setInt(int mode, const char* mask, const char* errMessage);
155 bool setChoice(int testInt, const char* positiveChoice, const char* negativeChoice, const char* errMessage);
156
157 Connection::Serial *serialConnection{ nullptr };
158 int PortFD{ -1 };
159
160
161 INDI::PropertyNumber OutputsNP{3};
162 enum
163 {
164 DEW_STRAP_ONE_POWER,
165 DEW_STRAP_TWO_POWER,
166 DEW_STRAP_THREE_POWER
167 };
168
169 INDI::PropertySwitch CH1CH2BoostSP{2};
170 enum
171 {
172 CH1_BOOST_100,
173 CH2_BOOST_100,
174 };
175
176 INDI::PropertySwitch CH3_ModeSP{ 5 };
177 enum
178 {
179 DISABLED_STRAP,
180 DEWSTRAP_ONE,
181 DEWSTRAP_TWO,
182 MANUAL_STRAP,
183 TEMP_PROBE_THREE
184 };
185
186 INDI::PropertySwitch FanModeSP{ 2 };
187 enum
188 {
189 BOARD_TEMP,
190 MANUAL_FAN
191 };
192
193 INDI::PropertyNumber TemperaturesNP{ 5 };
194 enum
195 {
196 PROBE_1,
197 PROBE_2,
198 PROBE_3,
199 AMBIENT_PROBE,
200 BOARD_PROBE
201 };
202
203 INDI::PropertyNumber TemperatureOffsetsNP{ 4 };
204 enum
205 {
206 TEMP_PROBE_ONE_OFFSET,
207 TEMP_PROBE_TWO_OFFSET,
208 TEMP_PROBE_THREE_OFFSET,
209 AMBIENT_TEMP_PROBE_OFFSET
210 };
211
212 INDI::PropertySwitch TrackingModeSP{ 3 };
213 enum
214 {
215 AMBIENT,
216 DEWPOINT,
217 MIDPOINT
218 };
219
220 INDI::PropertyNumber FanTempTriggerNP{ 2 };
221 enum
222 {
223 FANTEMPON,
224 FANTEMPOFF
225 };
226
227 INDI::PropertySwitch LCDDisplayTempUnitsSP{ 2 };
228 enum
229 {
230 CELCIUS,
231 FAHRENHEIT
232 };
233
234 INDI::PropertySwitch EnableLCDDisplaySP{ 2 };
235 enum
236 {
237 DISABLE_LCD,
238 ENABLE_LCD
239 };
240
241 INDI::PropertySwitch EEPROMSP{ 2 };
242 enum
243 {
244 RESET_EEPROM,
245 SAVE_TO_EEPROM
246 };
247
248 INDI::PropertyNumber CH3_Manual_PowerNP{ 1 };
249 INDI::PropertyNumber FanSpeedNP{ 1 };
250 INDI::PropertySwitch ZeroTempOffsetsSP{ 1 };
251 INDI::PropertyNumber TrackingModeOffsetNP{ 1 };
252 INDI::PropertyNumber HumidityNP{ 1 };
253 INDI::PropertyNumber DewpointNP{ 1 };
254 INDI::PropertyNumber FWVersionNP{ 1 };
255 INDI::PropertyNumber LCDPageRefreshNP{ 1 };
256
257 static constexpr const char *ENVIRONMENT_TAB {"Environment"};
258
259};
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement weather reporting and safety monitoring functionality.
virtual ~myDewControllerPro()=default
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual const char * getDefaultName() override
virtual bool SetDewPort(size_t port, bool enabled, double dutyCycle) override
SetDewPort Set DEW/Dew port duty cycle.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool SetAutoDewEnabled(size_t port, bool enabled) override
SetAutoDewEnabled Enable/disable automatic dew control.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
ISState
Switch state.
Definition indiapi.h:148
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition arduino_st4.h:34
uint8_t cmd[4]
Definition pwc-ioctl.h:2