Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of INA219 by
Revision 1:044908c80119, committed 2017-03-25
- Comitter:
- NilliM
- Date:
- Sat Mar 25 01:44:05 2017 +0000
- Parent:
- 0:eee9c8ba72ff
- Commit message:
- Super;
Changed in this revision
INA219.cpp | Show annotated file Show diff for this revision Revisions of this file |
INA219.hpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r eee9c8ba72ff -r 044908c80119 INA219.cpp --- a/INA219.cpp Thu Aug 28 10:32:20 2014 +0000 +++ b/INA219.cpp Sat Mar 25 01:44:05 2017 +0000 @@ -85,4 +85,14 @@ { float raw_current = read_current_raw(); return raw_current / current_divider; +} +int16_t INA219::read_bus_voltage_raw() +{ + return ((int16_t)read_register_u16(INA219_REG_BUSVOLTAGE)>>3)*4; +} + +float INA219::read_bus_voltage() +{ + float raw_voltage = read_bus_voltage_raw(); + return raw_voltage*0.001; } \ No newline at end of file
diff -r eee9c8ba72ff -r 044908c80119 INA219.hpp --- a/INA219.hpp Thu Aug 28 10:32:20 2014 +0000 +++ b/INA219.hpp Sat Mar 25 01:44:05 2017 +0000 @@ -76,7 +76,7 @@ * @returns * A value between -32768 and +32768. Depending on the calibration and configuration register values, the actual shunt voltage can be calculated. */ - //int16_t read_shunt_voltage_raw(); + int16_t read_shunt_voltage_raw(); /** Reads the shunt voltage from the INA219 and calculates the actual value in mV. * * @see read_shunt_voltage_raw @@ -84,7 +84,7 @@ * @returns * A floating point value corresponding to the potential difference across the current shunt, in mV. */ - //float read_shunt_voltage_mV(); + float read_shunt_voltage_mV(); /** Reads the raw bus voltage. * @@ -93,7 +93,7 @@ * @returns * A value between -32768 and +32768 corresponding to the bus voltage. */ - //int16_t read_bus_voltage_raw(); + int16_t read_bus_voltage_raw(); /** Reads the bus voltage and uses it to calculate the actual bus voltage. * * @see read_bus_voltage_raw @@ -101,7 +101,7 @@ * @returns * A floating point value corresponding to the voltage of V+ (in V). */ - //float read_bus_voltage(); + float read_bus_voltage(); /** Sets the calibration register. *