/**
 * Author : Anatole SCHRAMM-HENRY
 * Created the : 29/05/2021
 * This file contains all the config used by the other classes and sources files.
 */
#ifndef DEFINITION_H
#define DEFINITION_H

#include <Arduino.h>
#include <RF24.h>
#include "packet_format.h"

//Serial debug config part
#define SERIAL_DEBUG_ENABLED 0
#define SERIAL_BAUD_RATE 115200

//Battery config part
#define ADC_QUANTUM 0.00323632812 //ADC_VREF / ADC_RESOLUTION -> 3.314 and 10 bits (1024) in my case
#define VOLTAGE_DIV_COEFF 1.3125  //(R1 + R2)/R2

//NRF Radio config part
#define RADIO_CHANNEL 108
#define RADIO_NODE_ADDRESS "WEST1" //Weather Station 1
#define RADIO_PA_LEVEL RF24_PA_LOW //RF24_PA_MIN,RF24_PA_LOW,RF24_PA_HIGH,RF24_PA_MAX
#define RADIO_DATARATE RF24_250KBPS

//Sleep config part : in 4 second increments ie : 1 corresponds to 4s of sleep, and 15 correponds to 60 seconds of sleep. 
#define SLEEP_4_SEC_INTERVAL 15

//Pin config part
typedef enum
{
  D2_LDO_EN = 2,
  D3_NRF_CE = 3,
  A4_SDA = A4,
  A5_SCL = A5,
  D4_LDR_V_SENS_EN = 4,
  D5_BAT_V_SENS_EN = 5,
  D10_NRF_CS = 10,
  D11_MOSI = 11,
  D12_MISO = 12,
  D13_SCK = 13,
  A0_BAT_V_SENS = A0,
  A1_LDR_V_SENS = A1,
} Pin;

//Payload structure
typedef struct 
{
  uint16_t id;
  HEADER_e header : 6;
  unsigned int ldr : 10;
  float battery;
  float bmpTemp;
  float bmpPress;
  float humidity;
  float compensatedHumidity;
  float htuTemp;
} DataPacket __attribute__((__packed__));

#endif //DEFINITION_H
