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:3ba6b3eb0a5a, committed 2016-03-30
- Comitter:
- MLev
- Date:
- Wed Mar 30 14:09:41 2016 +0000
- Parent:
- 0:eee9c8ba72ff
- Commit message:
- hop !;
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 3ba6b3eb0a5a INA219.cpp --- a/INA219.cpp Thu Aug 28 10:32:20 2014 +0000 +++ b/INA219.cpp Wed Mar 30 14:09:41 2016 +0000 @@ -73,7 +73,7 @@ // Set current divider current_divider = 20; - power_divider = 1; + power_divider = 2000; } int16_t INA219::read_current_raw() @@ -85,4 +85,15 @@ { 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); +} + +float INA219::read_bus_voltage() +{ + float raw_volt = read_bus_voltage_raw(); + return (raw_volt * 0.0005) ; } \ No newline at end of file
diff -r eee9c8ba72ff -r 3ba6b3eb0a5a INA219.hpp --- a/INA219.hpp Thu Aug 28 10:32:20 2014 +0000 +++ b/INA219.hpp Wed Mar 30 14:09:41 2016 +0000 @@ -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. * @@ -115,7 +115,7 @@ int i2c_addr; int current_divider; - int power_divider; + float power_divider; //... /** Writes a uint8_t array to the specified I2C register.