#ifndef WEATHERSTATION_H
#define WEATHERSTATION_H

////////////////////////////////////////////////////////
//  Global defines/variables                           /
////////////////////////////////////////////////////////
//
unsigned long timer;
const int ONESECOND = 1000;

enum PKTTYPE {
  THP=0,
  WIND,
  ELEC
}; 

struct THPStruct {
  float temperature;
  float humidity;
  float pressure;
};

struct WindSpeedStruct {
  float windspeed;
};

struct VoltageCurrentStruct {
  float LipoVoltage;
  float LipoCurrent;
  float SolarVoltage;
  float SolarCurrent;
  float LoadVoltage;
  float LoadCurrent;
};

typedef struct WirelessData {
  PKTTYPE type;
  union {
    struct THPStruct env;
    struct WindSpeedStruct wind;
    struct VoltageCurrentStruct elec;
  } data;
} WData;


///////////////////////////////////////////////////////
//           A N E M O M E T E R                      /
///////////////////////////////////////////////////////
//
#define anemometerPin  A0                                         // Defines the anemometer input pin
const float voltageConversionConstant = 0.00322265625;            // Maps the analog read to actual voltage @ 3.3v
const float voltageMin = 0.4;                                     // Mininum output voltage from anemometer in mV
const float voltageMax = 2.0;                                     // Maximum output voltage from anemometer in mV
const float windSpeedMin = 0;                                     // Wind speed in meters/sec corresponding to minimum voltage of 0.4 VDC
const float windSpeedMax = 32.4;                                  // Wind speed in meters/sec corresponding to maximum voltage of 2.0 VDC

///////////////////////////////////////////////////////
//           R F M 6 9                                /
///////////////////////////////////////////////////////    
//
#define OUTNODEID   1
#define INNODEID    2
#define NETWORKID   100
#define FREQUENCY   RF69_915MHZ                                   // RF69_433MHZ, RF69_868MHZ, RF69_915MHZ
#define KEY         "SyrinxTechSecret"                            // Has to be same 16 bytes on all nodes
RFM69 radio;                                                      // Radio object

///////////////////////////////////////////////////////
//           I N A 3 2 2 1                            /
///////////////////////////////////////////////////////    
//
SDL_Arduino_INA3221 ina3221;                                      // Current/voltage sensor object
#define LIPO_BATTERY_CHANNEL 1
#define SOLAR_CELL_CHANNEL   2
#define OUTPUT_CHANNEL       3

///////////////////////////////////////////////////////
//           B M E 2 8 0                              /
///////////////////////////////////////////////////////
//
bool BME280Present = true;                                        // Is the BME280 board present

///////////////////////////////////////////////////////
//           F L A S H                                /
///////////////////////////////////////////////////////    
//
SPIFlash flash(8, 0xEF30);                                        // SPI_CS, Manufacturer ID

#endif
