-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdpsxxxx_comm.h
108 lines (87 loc) · 2.39 KB
/
dpsxxxx_comm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
dpsxxxx_comm.h
*/
#ifndef DPSXXXX_COMM_h
#define DPSXXXX_COMM_h
#include <Arduino.h>
class DPScomm
{
typedef struct {
float setVoltage;
float setAmp;
float outVoltage;
float outAmp;
float power;
float inputVoltage;
bool lock;
uint16_t protect;
bool cccvState;
bool onoff;
uint16_t brightness;
}DPSvaluesPacket;
public:
/**
* @brief Class constructor
*/
DPScomm(void);
DPSvaluesPacket DPSvalues;
/**
* @brief Initializes the Modbus communication with DPS50xx
*/
void DPScommInit(void);
/**
* @brief Read the DPS model through Modbus
* @return DPS model (eg. 5015)
*/
uint16_t checkDPSmodel(void);
/**
* @brief Read all operating values through Modbus and store them in DPSvalues structure.
* @return true if successful
*/
bool readDPSOperatingValues(void);
/**
* @brief Read DPS50xx LCD brightness
* @return true if successful
*/
bool readLCDBrightness(void);
/**
* @brief Set DPS50xx LCD brightness
* @param brightness - brightness from 0 to 5 (0 = darkest)
* @return true if successful
*/
bool setLCDBrightness(uint8_t brigthness);
/**
* @brief Set output voltage (limits are checked regarding parameters declared in HW_limits.h)
* @param voltage - set output voltage (in V)
* @return true if successful, false means that voltage parameter is out of range
*/
bool setOutVoltage(float voltage);
/**
* @brief Set output current (limits are checked regarding parameters declared in HW_limits.h)
* @param current - set output current (in Amp)
* @return true if successful, false means that current parameter is out of range
*/
bool setOutCurrent(float current);
/**
* @brief Lock the DPS50xx keys. A locker should appear on the DPS50xx display. The Modbus commands are still executed.
*/
void lockDPS(void);
/**
* @brief Unlock the DPS50xx keys. The locker should disappear on the DPS50xx display.
*/
void unlockDPS(void);
/**
* @brief Switch the output ON.
*/
void switchOutputON(void);
/**
* @brief Switch the output OFF.
*/
void switchOutputOFF(void);
/**
* @brief Get the DPS50xx max power (regarding parameters declared in HW_limits.h)
* @return Max output power of the DPS50xx
*/
float getMaxPower(void);
};
#endif