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