DUDS
Distributed Update of Data from Something
INA219.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #ifndef INA219_HPP
11 #define INA219_HPP
12 
14 #include <duds/data/Quantity.hpp>
15 
16 namespace duds { namespace hardware { namespace devices { namespace instruments {
17 
31 class INA219 : boost::noncopyable {
35  std::unique_ptr<duds::hardware::interface::Smbus> com;
39  double shunt;
43  std::int16_t shuntV;
47  std::int16_t busV;
48 public:
56  INA219(
57  std::unique_ptr<duds::hardware::interface::Smbus> &c, // no PEC!
58  double sr
59  );
60  ~INA219();
91  void sample();
92 
93  void vals(std::int16_t &sV, std::int16_t &bV) {
94  sV = shuntV;
95  bV = busV;
96  }
97 };
98 
99 } } } }
100 
101 #endif // #ifndef INA219_HPP
A container for a value and a unit to better describe the value.
Definition: Quantity.hpp:37
duds::data::Quantity shuntVoltage() const
Returns the sampled shunt voltage.
Definition: INA219.cpp:40
duds::data::Quantity busPower() const
Returns the computed bus power using the sampled bus voltage and the computed bus current...
Definition: INA219.cpp:52
std::unique_ptr< duds::hardware::interface::Smbus > com
Communication bus.
Definition: INA219.hpp:35
duds::data::Quantity maxCurrent() const
Returns the maximum current that can be measured by the device.
Definition: INA219.cpp:32
void vals(std::int16_t &sV, std::int16_t &bV)
Definition: INA219.hpp:93
duds::data::Quantity shuntResistance() const
Returns the shunt resistance.
Definition: INA219.cpp:36
std::int16_t busV
The raw data for the sampled bus voltage.
Definition: INA219.hpp:47
std::int16_t shuntV
The raw data for the sampled shunt voltage.
Definition: INA219.hpp:43
duds::data::Quantity busVoltage() const
Returns the sampled bus voltage.
Definition: INA219.cpp:44
INA219(std::unique_ptr< duds::hardware::interface::Smbus > &c, double sr)
Definition: INA219.cpp:14
double shunt
Shunt resistance; used to compute current.
Definition: INA219.hpp:39
void sample()
Reads sample data from the device.
Definition: INA219.cpp:56
Preliminary support for TI&#39;s INA219 voltage and current sensor.
Definition: INA219.hpp:31
duds::data::Quantity busCurrent() const
Returns the computed bus current using the sampled shunt voltage and the shunt resistance.
Definition: INA219.cpp:48