-
Notifications
You must be signed in to change notification settings - Fork 1
/
HX711Dual.h
55 lines (40 loc) · 1.16 KB
/
HX711Dual.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
#ifndef HX711DUAL_H_
#define HX711DUAL_H_
#include <stdint.h>
typedef enum _channel_gain {
CHANNEL_A_GAIN_128 = 25,
CHANNEL_B_GAIN_32 = 26,
CHANNEL_A_GAIN_64 = 27
} ChannelGain_e;
typedef enum _channel {
CHANNEL_A,
CHANNEL_B
} Channel_e;
class HX711Dual {
public:
explicit HX711Dual(int DT, int SCK,
ChannelGain_e ch_a_gain = CHANNEL_A_GAIN_128,
ChannelGain_e ch_b_gain = CHANNEL_B_GAIN_32);
virtual ~HX711Dual();
void setChannelAGain(ChannelGain_e new_gain);
void setChannelBGain(ChannelGain_e new_gain);
void channelACalibrate(int sample_number = 16);
void channelBCalibrate(int sample_number = 16);
void channelCalibrate(Channel_e ch, int sample_number = 16);
int32_t readChannelARaw();
int32_t readChannelBRaw();
int32_t readChannelRaw(Channel_e ch);
float readChannelA();
float readChannelB();
float readChannel(Channel_e ch);
private:
void _setReadingChannel(Channel_e ch);
int32_t _readChannel(Channel_e ch);
int _dt_pin;
int _sck_pin;
int32_t _ch_a_offset;
int32_t _ch_b_offset;
ChannelGain_e _ch_a_gain;
ChannelGain_e _ch_b_gain;
};
#endif