wideband/firmware/sampling.h

46 lines
1.1 KiB
C
Raw Normal View History

2020-10-29 02:55:55 -07:00
#pragma once
#include "timer.h"
2023-06-20 17:24:48 -07:00
struct ISampler
{
virtual float GetNernstDc() const = 0;
virtual float GetNernstAc() const = 0;
virtual float GetPumpNominalCurrent() const = 0;
virtual float GetInternalBatteryVoltage() const = 0;
2023-06-20 17:26:54 -07:00
virtual float GetSensorTemperature() const = 0;
virtual float GetSensorInternalResistance() const = 0;
2023-06-20 17:24:48 -07:00
};
2023-08-09 12:31:49 -07:00
struct AnalogChannelResult;
class Sampler : public ISampler
{
public:
void ApplySample(AnalogChannelResult& result, float virtualGroundVoltageInt);
void Init();
2023-08-09 12:31:49 -07:00
float GetNernstDc() const override;
float GetNernstAc() const override;
float GetPumpNominalCurrent() const override;
float GetInternalBatteryVoltage() const override;
float GetSensorTemperature() const override;
float GetSensorInternalResistance() const override;
private:
float r_2 = 0;
float r_3 = 0;
float nernstAc = 0;
float nernstDc = 0;
float pumpCurrentSenseVoltage = 0;
float internalBatteryVoltage = 0;
Timer m_startupTimer;
2023-08-09 12:31:49 -07:00
};
2023-06-20 17:24:48 -07:00
// Get the sampler for a particular channel
const ISampler& GetSampler(int ch);
2023-06-20 17:24:48 -07:00
2020-10-29 02:55:55 -07:00
void StartSampling();