add setchannel
This commit is contained in:
parent
890031c9f1
commit
ad26ad425f
2 changed files with 19 additions and 0 deletions
|
|
@ -147,6 +147,24 @@ bool Adafruit_NAU7802::available(void) {
|
||||||
return conv_ready.read();
|
return conv_ready.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Set which channel for ADC
|
||||||
|
@param channel Set to 0 for CH1, 1 for CH2
|
||||||
|
@returns False if any I2C error occured
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
bool Adafruit_NAU7802::setChannel(uint8_t channel) {
|
||||||
|
if (channel > 1)
|
||||||
|
channel = 1;
|
||||||
|
|
||||||
|
Adafruit_I2CRegister ctrl2_reg = Adafruit_I2CRegister(i2c_dev, NAU7802_CTRL2);
|
||||||
|
Adafruit_I2CRegisterBits ch_select =
|
||||||
|
Adafruit_I2CRegisterBits(&ctrl2_reg, 1, 7); // # bits, bit_shift
|
||||||
|
|
||||||
|
return ch_select.write(channel);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Read the stored 24-bit ADC output value.
|
@brief Read the stored 24-bit ADC output value.
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ public:
|
||||||
bool available(void);
|
bool available(void);
|
||||||
int32_t read(void);
|
int32_t read(void);
|
||||||
|
|
||||||
|
bool setChannel(uint8_t channel);
|
||||||
bool setLDO(NAU7802_LDOVoltage voltage);
|
bool setLDO(NAU7802_LDOVoltage voltage);
|
||||||
NAU7802_LDOVoltage getLDO(void);
|
NAU7802_LDOVoltage getLDO(void);
|
||||||
bool setGain(NAU7802_Gain gain);
|
bool setGain(NAU7802_Gain gain);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue