#ifndef _SENSOR_H
#define _SENSOR_H

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BMP3XX.h"



struct Sensor_Readings
{
    float ts;
    float temp_before_radiator;
    float temp_after_radiator;
    float pressure_before_radiator;
    float pressure_after_radiator;
    float wind_speed;
};

enum Mux_Input {
  thermistor_before_radiator=D0,
  thermistor_after_radiator=D0,
  pressure_before_radiator=D5,
  pressure_sensor_after_radiator=D5,
  Last    
};

class Multiplexer {
    public:
        void activate(Mux_Input device_to_activate);
};

extern double floatmap(float x, float in_min, float in_max, float out_min, float out_max);

class Barometer {
  Adafruit_BMP3XX bmp;
  double ambient_pressure;

  public:
    void init();
    float readWindSpeed();
    float readAltitude();
    void setAmbientPressure();
};

class Thermistor {       // The class
    private:             // Access specifier
        int temp_range_start = 300;
        int temp_range_end = -55;
        int temp_range_step = 10;
        float tempistor_y[35] = {519910.0, 158090.0, 71668.0, 44087.0, 27936.0, 18187.0, 12136.0, 8284.0, 5774.0, 4103.0, 2967.0, 2182.0, 1629.0, 1234.0, 946.6, 735.5, 578.1, 459.4, 368.8, 298.9, 244.4, 201.6, 167.6, 140.4, 118.5, 100.7, 86.08, 74.05, 64.08, 55.75, 48.76, 42.87, 37.86, 33.59, 29.94 };
        int pin;
        int voltage_divider_ohm;
        float supply_voltage;

        float resistance(float measured_bit_value);
        float ohm_to_temperature(float resistance);
    
    public:
        Thermistor(int pin, int voltage_divider_ohm);

        float read();
};

class FluidPressureSensor {
    private:
        int pin;


    public:
        FluidPressureSensor(int pin);
        double read();
};

extern void async_wait(int ms);


#endif