Skip to content

Commit

Permalink
requested change
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmannjan committed Jun 6, 2019
1 parent d830058 commit 6d26de2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
23 changes: 10 additions & 13 deletions Adafruit_INA219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,19 @@ void Adafruit_INA219::setCalibration_32V_2A() {
}

/*!
* @brief Enable power save mode
* @brief Set power save mode according to parameters
* @param on
* boolean value
*/
void Adafruit_INA219::powerSaveModeOn() {
void Adafruit_INA219::powerSave(bool on) {
uint16_t current;
wireReadRegister(INA219_REG_CONFIG, &current);
uint16_t next = current | INA219_CONFIG_MODE_POWERDOWN;
wireWriteRegister(INA219_REG_CONFIG, next);
}

/*!
* @brief Disable power save mode
*/
void Adafruit_INA219::powerSaveModeOff() {
uint16_t current;
wireReadRegister(INA219_REG_CONFIG, &current);
uint8_t next = current & ~INA219_CONFIG_MODE_POWERDOWN;
uint8_t next;
if (on) {
next = current | INA219_CONFIG_MODE_POWERDOWN;
} else {
next = current & ~INA219_CONFIG_MODE_POWERDOWN;
}
wireWriteRegister(INA219_REG_CONFIG, next);
}

Expand Down
3 changes: 1 addition & 2 deletions Adafruit_INA219.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ class Adafruit_INA219 {
float getShuntVoltage_mV();
float getCurrent_mA();
float getPower_mW();
void powerSaveModeOn();
void powerSaveModeOff();
void powerSave(bool on);

private:
TwoWire *_i2c;
Expand Down

0 comments on commit 6d26de2

Please sign in to comment.