2019-09-21 12:33:13 -07:00
|
|
|
/**
|
|
|
|
* @file adc_subscription.h
|
|
|
|
*/
|
|
|
|
|
2019-09-24 18:11:41 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "functional_sensor.h"
|
2019-09-21 12:33:13 -07:00
|
|
|
#include "global.h"
|
2024-04-21 17:03:42 -07:00
|
|
|
#include "biquad.h"
|
|
|
|
|
|
|
|
struct AdcSubscriptionEntry {
|
|
|
|
FunctionalSensor *Sensor;
|
|
|
|
float VoltsPerAdcVolt;
|
2024-04-21 17:38:55 -07:00
|
|
|
// raw voltage before we apply biquad filter
|
2024-04-21 17:03:42 -07:00
|
|
|
float sensorVolts;
|
|
|
|
Biquad Filter;
|
|
|
|
adc_channel_e Channel;
|
|
|
|
bool HasUpdated = false;
|
|
|
|
};
|
2019-09-21 11:33:38 -07:00
|
|
|
|
|
|
|
class AdcSubscription {
|
|
|
|
public:
|
2024-04-21 17:03:42 -07:00
|
|
|
static AdcSubscriptionEntry *SubscribeSensor(FunctionalSensor &sensor, adc_channel_e channel, float lowpassCutoffHZ, float voltsPerAdcVolt = 0.0f);
|
2021-08-14 05:41:27 -07:00
|
|
|
static void UnsubscribeSensor(FunctionalSensor& sensor);
|
2023-01-06 05:09:17 -08:00
|
|
|
static void UnsubscribeSensor(FunctionalSensor& sensor, adc_channel_e newChannel);
|
2020-02-08 14:48:15 -08:00
|
|
|
static void UpdateSubscribers(efitick_t nowNt);
|
2022-10-10 04:44:20 -07:00
|
|
|
|
2024-07-06 21:21:21 -07:00
|
|
|
static void ResetFilters();
|
|
|
|
|
2022-10-10 04:44:20 -07:00
|
|
|
static void PrintInfo();
|
2019-09-21 11:33:38 -07:00
|
|
|
};
|