|
DUDS
|
Distributed Update of Data from Something
|
Preliminary support for Microchip's MCP9808 temperature sensor. More...
#include <MCP9808.hpp>
Public Types | |
| enum | Resolution { Half, Quarter, Eighth, Sixteenth } |
Public Member Functions | |
| MCP9808 (std::unique_ptr< duds::hardware::interface::Smbus > &c) | |
| Prepares to use a MCP9808 by identifying the device and reading, but not changing, its current configuration. More... | |
| ~MCP9808 () | |
| Stops sampling. More... | |
| void | resolution (Resolution r) |
| Changes the sampling resolution. More... | |
| Resolution | resolution () const |
| Returns the current sampling resolution. More... | |
| double | resolutionDegrees () const |
| void | resume () |
| Begin sampling. More... | |
| bool | running () const |
| True when the device is sampling. More... | |
| void | sample () |
| Reads sample data from the device. More... | |
| void | start () |
| Begin sampling. More... | |
| void | suspend () |
| Stop sampling. More... | |
| duds::data::Quantity | temperature () const |
| Returns the last sampled temperature. More... | |
Private Attributes | |
| std::unique_ptr< duds::hardware::interface::Smbus > | com |
| Communication bus. More... | |
| std::uint16_t | config |
| The configuration word. More... | |
| char | res |
| The raw data for the configured resolution. More... | |
| char | rev |
| Device's revision byte. More... | |
| double | temp |
| Last temperature sample. More... | |
Preliminary support for Microchip's MCP9808 temperature sensor.
The device continually samples temperature and can provide interrupt or thermostat-like output.
Normally uses an address formed by a bit-wise OR of 0x18 and the state of of three address lines hardwired to the device that supply the 3 LSb (0x7). Some variation of the device uses 0x48 to OR with the hardwired line bits.
Does not use PEC; not quite a SMBus device.
Definition at line 31 of file MCP9808.hpp.
| Enumerator | |
|---|---|
| Half | |
| Quarter | |
| Eighth | |
| Sixteenth | |
Definition at line 53 of file MCP9808.hpp.
| duds::hardware::devices::instruments::MCP9808::MCP9808 | ( | std::unique_ptr< duds::hardware::interface::Smbus > & | c | ) |
Prepares to use a MCP9808 by identifying the device and reading, but not changing, its current configuration.
While sampling is a power-on default, this does not prevent a previously running process from suspending sampling. The constructor does not change the device's configuration, so do not assume the device is sampling after construction.
| c | The SMBus interface to use for communication. PEC must be disabled. |
| DeviceMisidentified | The device did not respond as expected. |
Definition at line 16 of file MCP9808.cpp.
| duds::hardware::devices::instruments::MCP9808::~MCP9808 | ( | ) |
Stops sampling.
Definition at line 42 of file MCP9808.cpp.
| void duds::hardware::devices::instruments::MCP9808::resolution | ( | Resolution | r | ) |
Changes the sampling resolution.
Definition at line 56 of file MCP9808.cpp.
|
inline |
Returns the current sampling resolution.
Definition at line 110 of file MCP9808.hpp.
Referenced by resume().
| double duds::hardware::devices::instruments::MCP9808::resolutionDegrees | ( | ) | const |
|
inline |
Begin sampling.
Definition at line 94 of file MCP9808.hpp.
|
inline |
True when the device is sampling.
Definition at line 84 of file MCP9808.hpp.
| void duds::hardware::devices::instruments::MCP9808::sample | ( | ) |
Reads sample data from the device.
Definition at line 76 of file MCP9808.cpp.
Referenced by resolution().
| void duds::hardware::devices::instruments::MCP9808::start | ( | ) |
| void duds::hardware::devices::instruments::MCP9808::suspend | ( | ) |
Stop sampling.
Definition at line 51 of file MCP9808.cpp.
Referenced by resume(), and ~MCP9808().
| duds::data::Quantity duds::hardware::devices::instruments::MCP9808::temperature | ( | ) | const |
Returns the last sampled temperature.
Definition at line 81 of file MCP9808.cpp.
Referenced by resolution().
|
private |
Communication bus.
Definition at line 35 of file MCP9808.hpp.
Referenced by MCP9808(), resolution(), sample(), start(), and suspend().
|
private |
The configuration word.
Definition at line 43 of file MCP9808.hpp.
|
private |
The raw data for the configured resolution.
Definition at line 47 of file MCP9808.hpp.
Referenced by MCP9808(), resolution(), and resolutionDegrees().
|
private |
|
private |
Last temperature sample.
Definition at line 39 of file MCP9808.hpp.
Referenced by sample(), and temperature().