|
| ADS7828Channel (ADS7828 *const, uint8_t, uint8_t, uint16_t, uint16_t) |
|
uint8_t | commandByte () |
| Return command byte for channel object. More...
|
|
ADS7828 * | device () |
| Return pointer to parent device object. More...
|
|
uint8_t | id () |
| Return ID number of channel object (+IN connection). More...
|
|
uint8_t | index () |
| Return index position within moving average array. More...
|
|
void | newSample (uint16_t) |
| Add (unscaled) sample value to moving average array, update totalizer. More...
|
|
void | reset () |
| Reset moving average array, index, totalizer to zero. More...
|
|
uint16_t | sample () |
| Return most-recent (unscaled) sample value from moving average array. More...
|
|
uint8_t | start () |
| Initiate A/D conversion for channel object. More...
|
|
uint16_t | total () |
| Return (unscaled) totalizer value for channel object. More...
|
|
uint8_t | update () |
| Initiate A/D conversion, read data, update moving average for channel object. More...
|
|
uint16_t | value () |
| Return moving average value for channel object. More...
|
|
|
uint16_t | maxScale |
| Maximum value of moving average (defaults to 0x0FFF). More...
|
|
uint16_t | minScale |
| Minimum value of moving average (defaults to 0x0000). More...
|
|
|
uint8_t | commandByte_ |
| Command byte for channel object (SD C2 C1 C0 bits only).
|
|
ADS7828 * | device_ |
| Pointer to parent device object.
|
|
uint8_t | index_ |
| Index position within moving average array.
|
|
uint16_t | samples_ [1<< 4] |
| Array of (unscaled) sample values. More...
|
|
uint16_t | total_ |
| (Unscaled) running total of moving average array elements.
|
|
§ ADS7828Channel()
ADS7828Channel::ADS7828Channel |
( |
ADS7828 * const |
device, |
|
|
uint8_t |
id, |
|
|
uint8_t |
options, |
|
|
uint16_t |
min, |
|
|
uint16_t |
max |
|
) |
| |
36 this->
commandByte_ = (bitRead(options, 7) << 7) | (bitRead(
id, 0) << 6) |
37 (bitRead(
id, 2) << 5) | (bitRead(
id, 1) << 4);
void reset()
Reset moving average array, index, totalizer to zero.
Definition: i2c_adc_ads7828.cpp:149
ADS7828 * device()
Return pointer to parent device object.
Definition: i2c_adc_ads7828.cpp:71
ADS7828 * device_
Pointer to parent device object.
Definition: i2c_adc_ads7828.h:248
uint16_t minScale
Minimum value of moving average (defaults to 0x0000).
Definition: i2c_adc_ads7828.h:234
uint8_t commandByte_
Command byte for channel object (SD C2 C1 C0 bits only).
Definition: i2c_adc_ads7828.h:245
uint16_t maxScale
Maximum value of moving average (defaults to 0x0FFF).
Definition: i2c_adc_ads7828.h:222
§ commandByte()
uint8_t ADS7828Channel::commandByte |
( |
| ) |
|
Return command byte for channel object.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Returns
- command byte (0x00..0xFC)
- Usage:
-
uint8_t commandByte()
Return command byte for device object (PD1 PD0 bits only).
Definition: i2c_adc_ads7828.cpp:400
ADS7828 * device_
Pointer to parent device object.
Definition: i2c_adc_ads7828.h:248
uint8_t commandByte_
Command byte for channel object (SD C2 C1 C0 bits only).
Definition: i2c_adc_ads7828.h:245
§ device()
ADS7828 * ADS7828Channel::device |
( |
| ) |
|
Return pointer to parent device object.
- Returns
- pointer to parent ADS7828 object
- Usage:
-
- Examples:
- examples/two_devices/two_devices.ino.
ADS7828 * device_
Pointer to parent device object.
Definition: i2c_adc_ads7828.h:248
§ id()
uint8_t ADS7828Channel::id |
( |
| ) |
|
Return ID number of channel object (+IN connection).
Single-ended inputs use COM as -IN; Differential inputs are as follows:
- 0 indicates CH0 as +IN, CH1 as -IN
- 1 indicates CH1 as +IN, CH0 as -IN
- 2 indicates CH2 as +IN, CH3 as -IN
- ...
- 7 indicates CH7 as +IN, CH6 as -IN
- Returns
- id (0..7)
- Return values
-
0 | command byte C2 C1 C0 = 000 |
1 | command byte C2 C1 C0 = 100 |
2 | command byte C2 C1 C0 = 001 |
3 | command byte C2 C1 C0 = 101 |
4 | command byte C2 C1 C0 = 010 |
5 | command byte C2 C1 C0 = 110 |
6 | command byte C2 C1 C0 = 011 |
7 | command byte C2 C1 C0 = 111 |
- Usage:
...
ADS7828 adc(0);
uint8_t channelId = temperature->
id();
...
- Examples:
- examples/two_devices/two_devices.ino.
uint8_t commandByte_
Command byte for channel object (SD C2 C1 C0 bits only).
Definition: i2c_adc_ads7828.h:245
§ index()
uint8_t ADS7828Channel::index |
( |
| ) |
|
Return index position within moving average array.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Returns
- index (0..2MOVING_AVERAGE_BITS_ - 1)
- Usage:
...
ADS7828 adc(0);
uint8_t channelIndex = temperature->
index();
...
uint8_t index_
Index position within moving average array.
Definition: i2c_adc_ads7828.h:251
§ newSample()
void ADS7828Channel::newSample |
( |
uint16_t |
sample | ) |
|
Add (unscaled) sample value to moving average array, update totalizer.
- Parameters
-
sample | sample value (0x0000..0xFFFF) |
uint16_t sample()
Return most-recent (unscaled) sample value from moving average array.
Definition: i2c_adc_ads7828.cpp:170
static const uint8_t MOVING_AVERAGE_BITS_
Quantity of samples to be averaged = 2MOVING_AVERAGE_BITS_.
Definition: i2c_adc_ads7828.h:264
uint16_t total_
(Unscaled) running total of moving average array elements.
Definition: i2c_adc_ads7828.h:258
uint16_t samples_[1<< 4]
Array of (unscaled) sample values.
Definition: i2c_adc_ads7828.h:255
uint8_t index_
Index position within moving average array.
Definition: i2c_adc_ads7828.h:251
§ reset()
void ADS7828Channel::reset |
( |
| ) |
|
Reset moving average array, index, totalizer to zero.
- Usage:
-
static const uint8_t MOVING_AVERAGE_BITS_
Quantity of samples to be averaged = 2MOVING_AVERAGE_BITS_.
Definition: i2c_adc_ads7828.h:264
uint16_t total_
(Unscaled) running total of moving average array elements.
Definition: i2c_adc_ads7828.h:258
uint16_t samples_[1<< 4]
Array of (unscaled) sample values.
Definition: i2c_adc_ads7828.h:255
uint8_t index_
Index position within moving average array.
Definition: i2c_adc_ads7828.h:251
§ sample()
uint16_t ADS7828Channel::sample |
( |
| ) |
|
Return most-recent (unscaled) sample value from moving average array.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Returns
- sample value (0x0000..0xFFFF)
- Usage:
...
ADS7828 adc(0);
uint16_t sampleValue = temperature->
sample();
...
uint16_t samples_[1<< 4]
Array of (unscaled) sample values.
Definition: i2c_adc_ads7828.h:255
uint8_t index_
Index position within moving average array.
Definition: i2c_adc_ads7828.h:251
§ start()
uint8_t ADS7828Channel::start |
( |
| ) |
|
Initiate A/D conversion for channel object.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Todo:
- Determine whether this function is needed.
- Return values
-
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
- Usage:
...
ADS7828 adc(0);
uint8_t status = temperature->
start();
...
uint8_t start()
Initiate communication with device.
Definition: i2c_adc_ads7828.cpp:423
ADS7828 * device_
Pointer to parent device object.
Definition: i2c_adc_ads7828.h:248
§ total()
uint16_t ADS7828Channel::total |
( |
| ) |
|
Return (unscaled) totalizer value for channel object.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Returns
- totalizer value (0x0000..0xFFFF)
- Usage:
...
ADS7828 adc(0);
uint16_t totalValue = temperature->
total();
...
uint16_t total_
(Unscaled) running total of moving average array elements.
Definition: i2c_adc_ads7828.h:258
§ update()
uint8_t ADS7828Channel::update |
( |
| ) |
|
Initiate A/D conversion, read data, update moving average for channel object.
- Optional Function (Troubleshooting):
- This function is for testing and troubleshooting.
- Todo:
- Determine whether this function is needed.
- Return values
-
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
- Usage:
...
ADS7828 adc(0);
uint8_t status = temperature->
update();
...
ADS7828 * device_
Pointer to parent device object.
Definition: i2c_adc_ads7828.h:248
uint8_t update()
Update all unmasked channels on device.
Definition: i2c_adc_ads7828.cpp:469
§ value()
uint16_t ADS7828Channel::value |
( |
| ) |
|
Return moving average value for channel object.
- Required Function:
- This is the most commonly-used channel function.
- Returns
- scaled value (0x0000..0xFFFF)
- Usage:
...
ADS7828 adc(0);
uint16_t ambient = temperature->
value();
...
- Examples:
- examples/one_device/one_device.ino, and examples/two_devices/two_devices.ino.
static const uint8_t MOVING_AVERAGE_BITS_
Quantity of samples to be averaged = 2MOVING_AVERAGE_BITS_.
Definition: i2c_adc_ads7828.h:264
uint16_t total_
(Unscaled) running total of moving average array elements.
Definition: i2c_adc_ads7828.h:258
uint16_t minScale
Minimum value of moving average (defaults to 0x0000).
Definition: i2c_adc_ads7828.h:234
uint16_t maxScale
Maximum value of moving average (defaults to 0x0FFF).
Definition: i2c_adc_ads7828.h:222
§ maxScale
uint16_t ADS7828Channel::maxScale |
§ minScale
uint16_t ADS7828Channel::minScale |
§ samples_
uint16_t ADS7828Channel::samples_[1<< 4] |
|
private |
§ MOVING_AVERAGE_BITS_
const uint8_t ADS7828Channel::MOVING_AVERAGE_BITS_ = 4 |
|
staticprivate |
The documentation for this class was generated from the following files: