calibration.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program 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
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 namespace eez {
22 namespace psu {
24 namespace calibration {
25 
26 enum Level {
27  LEVEL_NONE = 0,
28  LEVEL_MIN = 1,
29  LEVEL_MID = 2,
30  LEVEL_MAX = 3
31 };
32 
34 struct Value {
35  bool voltOrCurr;
36 
37  int8_t level;
38 
39  bool min_set;
40  float min_val;
41  float min_adc;
42 
43  bool mid_set;
44  float mid_val;
45  float mid_adc;
46 
47  bool max_set;
48  float max_val;
49  float max_adc;
50 
51  float minPossible;
52  float maxPossible;
53 
54  Value(bool voltOrCurr);
55 
56  void reset();
57 
58  float getLevelValue();
59  float getAdcValue();
60 
61  void setLevel(int8_t level);
62  void setData(float data, float adc);
63 
64  bool checkRange(float value, float adc);
65  bool checkMid();
66 
67 private:
68  float getRange();
69 };
70 
71 extern Value g_voltage;
72 extern Value g_current;
73 
74 bool isEnabled();
75 
78 void start(Channel *channel);
79 
81 void stop();
82 
84 void resetChannelToZero();
85 
87 bool isRemarkSet();
88 
90 const char *getRemark();
91 
93 void setRemark(const char *value, size_t len);
94 
96 bool isVoltageCalibrated();
97 
99 bool isCurrentCalibrated();
100 
102 bool canSave(int16_t &scpiErr);
103 
105 bool save();
106 
109 bool clear(Channel *channel);
110 
111 }
112 }
113 } // namespace eez::psu::calibration
void resetChannelToZero()
Set U and I to zero for the calibration channel.
Definition: calibration.cpp:167
bool isCurrentCalibrated()
Are current calibration parameters entered?
Definition: calibration.cpp:238
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
void setRemark(const char *value, size_t len)
Set calibration remark.
Definition: calibration.cpp:214
bool canSave(int16_t &scpiErr)
Are all calibration parameters entered?
Definition: calibration.cpp:242
bool clear(Channel *channel)
Clear calibration parameters for the currently selected channel.
Definition: calibration.cpp:338
void start(Channel *channel_)
Start calibration procedure on the channel.
Definition: calibration.cpp:176
void stop()
Stop calibration procedure.
Definition: calibration.cpp:193
bool isVoltageCalibrated()
Are voltage calibration parameters entered?
Definition: calibration.cpp:234
PSU channel.
Definition: channel.h:62
Calibration parameters for the voltage or current during calibration procedure.
Definition: calibration.h:34
bool save()
Save calibration parameters entered during calibration procedure.
Definition: calibration.cpp:277
const char * getRemark()
Get currently set remark.
Definition: calibration.cpp:210
bool isRemarkSet()
Is calibration remark is set.
Definition: calibration.cpp:206