#ifndef INCLUDE_CONFIGURATION_H_
#define INCLUDE_CONFIGURATION_H_

#include <user_config.h>
#include <SmingCore/SmingCore.h>

// If you want, you can define WiFi settings globally in Eclipse Environment Variables
#ifndef WIFI_SSID
#define WIFI_SSID "Heaven-WiFi" // Put you SSID and Password here
#define WIFI_PWD "Heaven-32847"
#endif

#define PinSet(pin)		GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, ((uint16_t)1<<(pin)))
#define PinRes(pin)		GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, ((uint16_t)1<<(pin)))
#define PinOut(pin, val)	GPIO_REG_WRITE((((val != LOW) ? GPIO_OUT_W1TS_ADDRESS : GPIO_OUT_W1TC_ADDRESS)), (1<<pin));
#define Pin16Set		WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xffffffff))
#define Pin16Res		WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe))
#define Pin16Out(pin, val)	WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(val & 1));

// Pin for communication with DHT sensor
#define DHT_PIN 2

// MAX7219
#define PIN_DIN			14
#define PIN_CLK			13
#define PIN_LOAD		12
#define MAX7219_DIGITS		8
#define MAX7219_DIG_MASK	0xDB
// ^^ reverse of -- 11011 011 -- без BCD декодирования 2, 5

#define CLOCK_CONFIG_FILE ".clock.conf" // leading point for security reasons :)

struct ClockConfig
{
    ClockConfig ()
    {
        AddTZ = 2;
        LightTrhLow = 341;
        LightTrhHigh = 683;
        BrightnessLow = 1;
        BrightnessMiddle = 7;
        BrightnessHigh = 15;
    }

    String NetworkSSID;
    String NetworkPassword;

    float AddTZ; // TimeZone - local time offset
    uint16_t LightTrhLow; // Low Light level
    uint16_t LightTrhHigh; // High Light level
    int8_t BrightnessLow; // Low LED brightness level
    int8_t BrightnessMiddle; // Middle LED brightness level
    int8_t BrightnessHigh; // High LED brightness level
};

ClockConfig
loadConfig ();
void
saveConfig (ClockConfig& cfg);

extern ClockConfig ActiveConfig;

#endif /* INCLUDE_CONFIGURATION_H_ */
