Newer
Older
#include "../espnow/Message.hpp"
#include "ForteSensor.hpp"
#include "esp_log.h"
#include "Definitions.h"

Zoe Michaela Dietmar Pfister
committed
class DR26 : public ForteSensor<Measurement> {

Zoe Michaela Dietmar Pfister
committed
void setup() override;

Zoe Michaela Dietmar Pfister
committed
Measurement readData() override;
// TODO: Should ADS be a singleton?
/**
* @brief Set the voltage range of the ADS1115
* @param newVoltageRange
* @details The following functions change the ADC input range: be careful
* to never to exceed VDD +0.3V max, or to exceed the upper and
* lower limits if you adjust the input range.
* SETTING THE GAIN VALUE INCORRECTLY MAY DESTROY THE ADC!
* The maximum output of the dendrometer is 2.5V, and so a gain of
* one (max 4.096V) or two (max 2.048V) is optimal. Changing the gain
* changes the accuracy of the sensor: higher gain gives a higher
* precision but a smaller range.
*
* GAIN_TWOTHIRDS // 2/3x gain +/- 6.144V 1 bit = 0.1875mV (default)
* GAIN_ONE* // 1x gain +/- 4.096V 1 bit = 0.125mV
* GAIN_TWO* // 2x gain +/- 2.048V 1 bit = 0.0625mV
* GAIN_FOUR // 4x gain +/- 1.024V 1 bit = 0.03125mV
* GAIN_EIGHT // 8x gain +/- 0.512V 1 bit = 0.015625mV
* GAIN_SIXTEEN // 16x gain +/- 0.256V 1 bit = 0.0078125mV
*/
void setVoltageRange(ADS1115_RANGE newVoltageRange);
/**
* @brief Set the channel of the ADS1115
* @param newChannel
*/
void setChannel(ADS1115_MUX newChannel);

Zoe Michaela Dietmar Pfister
committed
std::list<Message> buildMessages() override;

Zoe Michaela Dietmar Pfister
committed
[[nodiscard]] SensorInformation getSensorInformation() const override;
/**
* @brief Constructor for the DR26 class.
* @param channel
* @param voltageRange
*/
explicit DR26(ADS1115_MUX channel, ADS1115_RANGE voltageRange);
explicit DR26(ADS1115_MUX channel, ADS1115_RANGE voltageRange, uint8_t address);
float readChannel(ADS1115_MUX compareChannel);

Zoe Michaela Dietmar Pfister
committed
const SensorInformation sensorInformation{HardwareName::DRS26, SensorProtocol::Analog};
ADS1115_MUX channel;
ADS1115_RANGE voltageRange = ADS1115_RANGE::ADS1115_RANGE_4096;

Zoe Michaela Dietmar Pfister
committed
bool sensorConnected = false;