2025-11-16 10:31:46 -06:00
|
|
|
#ifndef IND_SENSOR_MAP_HPP
|
|
|
|
|
#define IND_SENSOR_MAP_HPP
|
|
|
|
|
|
2025-11-16 20:05:18 -06:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2025-11-16 10:31:46 -06:00
|
|
|
// Inductive Sensor Mapping Struct
|
|
|
|
|
typedef struct IndSensorMap {
|
|
|
|
|
double A;
|
|
|
|
|
double K;
|
|
|
|
|
double B;
|
|
|
|
|
double C;
|
|
|
|
|
double v;
|
|
|
|
|
} IndSensorMap;
|
|
|
|
|
|
2025-11-16 13:50:04 -06:00
|
|
|
class IndSensor {
|
2025-11-16 20:05:18 -06:00
|
|
|
public:
|
|
|
|
|
bool oor;
|
|
|
|
|
float mmVal;
|
2025-11-16 10:31:46 -06:00
|
|
|
|
2025-11-16 20:05:18 -06:00
|
|
|
// Constructor
|
|
|
|
|
IndSensor(IndSensorMap calibration, uint8_t analogPin);
|
|
|
|
|
// Read sensor directly from pin and convert to millimeters
|
|
|
|
|
float readMM();
|
2025-11-16 13:50:04 -06:00
|
|
|
|
2025-11-16 20:05:18 -06:00
|
|
|
private:
|
|
|
|
|
IndSensorMap consts;
|
|
|
|
|
uint8_t pin;
|
2025-11-16 13:50:04 -06:00
|
|
|
|
2025-11-16 20:05:18 -06:00
|
|
|
// helper function to convert analog reading to millimeters
|
|
|
|
|
float toMM(unsigned int raw);
|
2025-11-16 13:50:04 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// sensor instances
|
|
|
|
|
extern IndSensor indL;
|
|
|
|
|
extern IndSensor indR;
|
|
|
|
|
extern IndSensor indF;
|
|
|
|
|
extern IndSensor indB;
|
2025-11-16 10:31:46 -06:00
|
|
|
|
|
|
|
|
#endif // IND_SENSOR_MAP_HPP
|