43 std::function<
float(
float)> voltageToCurrent)
44 : getVoltage(getVoltage), voltageToCurrent(voltageToCurrent)
49 bool init()
override {
return true; };
57 ADCData adc_data = getVoltage();
67 current_data.current +=
68 voltageToCurrent(adc_data.voltage) * MOVING_AVERAGE_COEFF;
75 std::function<
ADCData()> getVoltage;
78 std::function<float(
float)> voltageToCurrent;
81 static constexpr float MOVING_AVERAGE_COMP_COEFF = 1 - MOVING_AVERAGE_COEFF;
Common class for current sensors.
bool selfTest() override
Check if the sensor is working.
static constexpr int MOVING_AVERAGE_N
CurrentSensor(std::function< ADCData()> getVoltage, std::function< float(float)> voltageToCurrent)
bool init() override
Initialize the sensor.
CurrentData sampleImpl() override
< Converts the voltage value to pressure
Base sensor class with has to be extended by any sensor driver.
This file includes all the types the logdecoder script will decode.
Structure to handle ADC data.
Structure to handle current data.
uint64_t currentTimestamp