#ifndef DEFINITION_H
#define DEFINITION_H

#include <Adafruit_SSD1306.h>
#include <Arduino.h>

typedef enum {  GPIO_0 = 0,
                GPIO_1_TX = 1,
                GPIO_2 = 2,
                GPIO_3_RX = 3,
                GPIO_4_SDA = 4,
                GPIO_5_SCL = 5,
                GPIO_10 = 10,
                GPIO_12_MISO = 12,
                GPIO_13_MOSI = 13,
                GPIO_14_CLK = 14,
                GPIO_15 = 15,
                GPIO_16 = 16,
                ADC = A0,
                DEFAULT_PIN = -1 } Pin;
                
#define MALLOC_ERR   B00000001

#define AP_AND_STA_ENABLED_ERR B00000001
#define AP_SETUP_ERR B00000010
#define STA_SETUP_ERR B00000100

#define NO_ERROR 0

#define NO_CURRENT_VIEW NULL
#define LAST_VIEW -1
#define RESERVED_VIEW_UID -2

#define BATT_FULL 870 //8.4v
#define BATT_EMPTY 775 //7.4v
#define BATT_DIFF 95
#define USB_THRESHOLD 600

//SD card file structure :
#define AP_CFG_FILE "/CONFIG/AP.CFG"
#define STA_CFG_FILE "/CONFIG/STA.CFG"
#define WWW_DIR "/WWW"
#define LOG_DIR "/LOGS"
#define FTP_DIR "/FTP"

typedef enum { OR_0 = 2, OR_90 = 3, OR_180 = 0, OR_270 = 1 } Orientation;

typedef enum { BIT = 0, BYTE, KBIT, KBYTE, MBIT, MBYTE, GBIT, GBYTE } SizeUnit;

typedef enum { BATTERY = 0, USB } PowerType;

//Data structure for the view handling
typedef struct viewLink{
    boolean (*viewLogicFunction)(Adafruit_SSD1306&, void*);
    void *pData;
    const int UID;
    struct viewLink *next;
} ViewLink, *ViewLinkedList;

//Data structure for the battery info
typedef struct powerInfo
{
  PowerType powerType;
  unsigned char level;
}PowerInfo;

char *addChar(char *pointer, const char character);

char *dateTimeFormater(char *pointer, const uint8_t value, const char character);

#endif //DEFINITION_H
