/* Smart device Example

   For other examples please check:
   https://github.com/espressif/esp-iot-solution/tree/master/examples

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
 */

#ifndef _IOT_PLUG_CONFIG_H_
#define _IOT_PLUG_CONFIG_H_
#include "sdkconfig.h"
#include "driver/gpio.h"

#ifdef __cplusplus
extern "C" {
#endif

#if CONFIG_SMART_PLUG_DEVICE
#define PLUG_NAME_SPACE                       CONFIG_SMART_PLUG_NAME_SPACE
#define PLUG_PARAM_KEY                        CONFIG_SMART_PLUG_PARAM_KEY

#define PLUG_POWER_METER_ENABLE               CONFIG_SMART_PLUG_POWER_METER_ENABLE
#define PM_CF_IO_NUM                          CONFIG_SMART_PLUG_PM_CF_IO
#define PM_CF_PCNT_UNIT_NUM                   CONFIG_SMART_PLUG_PM_CF_PCNT_UNIT_NUM
#define PM_CFI_IO_NUM                         CONFIG_SMART_PLUG_PM_CFI_IO
#define PM_CFI_PCNT_UNIT_NUM                  CONFIG_SMART_PLUG_PM_CFI_PCNT_UNIT_NUM
#define PM_POWER_PARAM                        CONFIG_SMART_PLUG_PM_POWER_COEF
#define PM_CURRENT_PARAM                      CONFIG_SMART_PLUG_PM_CURRENT_COEF
#define PM_VOLTAGE_PARAM                      CONFIG_SMART_PLUG_PM_VOLTAGE_COEF
#define PM_MODE_SEL_PIN                       CONFIG_SMART_PLUG_PM_MODE_SEL_PIN
#define PM_MODE_SEL_PIN_LEVEL                 CONFIG_SMART_PLUG_PM_MODE_SEL_PIN_LEVEL

#define BUTTON_IO_NUM_MAIN                    CONFIG_SMART_PLUG_MAIN_BUTTON_IO
#define BUTTON_ACTIVE_LEVEL                   CONFIG_SMART_PLUG_MAIN_BUTTON_ACT_LEVEL
#define NET_LED_NUM                           CONFIG_SMART_PLUG_NET_STATUS_LED_IO
#define LED_DARK_LEVEL                        CONFIG_SMART_PLUG_NET_STATUS_LED_OFF_LEVEL
#define PLUG_UNIT_NUM                         CONFIG_SMART_PLUG_UNIT_NUM

#define SMART_PLUG_UNIT0_BUTTON_IO            CONFIG_SMART_PLUG_UNIT0_BUTTON_IO
#define SMART_PLUG_UNIT0_BUTTON_ACTIVE_LEVEL  CONFIG_SMART_PLUG_UNIT0_BUTTON_ACTIVE_LEVEL
#define SMART_PLUG_UNIT0_LED_IO               CONFIG_SMART_PLUG_UNIT0_LED_IO
#define SMART_PLUG_UNIT0_LED_OFF_LEVEL        CONFIG_SMART_PLUG_UNIT0_LED_OFF_LEVEL
#define SMART_PLUG_UNIT0_RELAY_OFF_LEVEL      CONFIG_SMART_PLUG_UNIT0_RELAY_OFF_LEVEL
#define SMART_PLUG_UNIT0_RELAY_CTRL_MODE      CONFIG_SMART_PLUG_UNIT0_RELAY_CTRL_MODE
#define SMART_PLUG_UNIT0_RELAY_IO_MODE        CONFIG_SMART_PLUG_UNIT0_RELAY_IO_MODE
#define SMART_PLUG_UNIT0_RELAY_CTL_IO         CONFIG_SMART_PLUG_UNIT0_RELAY_CTL_IO
#define SMART_PLUG_UNIT0_RELAY_CLK_IO         CONFIG_SMART_PLUG_UNIT0_RELAY_CLK_IO
#if PLUG_UNIT_NUM > 1
#define SMART_PLUG_UNIT1_BUTTON_IO            CONFIG_SMART_PLUG_UNIT1_BUTTON_IO
#define SMART_PLUG_UNIT1_BUTTON_ACTIVE_LEVEL  CONFIG_SMART_PLUG_UNIT1_BUTTON_ACTIVE_LEVEL
#define SMART_PLUG_UNIT1_LED_IO               CONFIG_SMART_PLUG_UNIT1_LED_IO
#define SMART_PLUG_UNIT1_LED_OFF_LEVEL        CONFIG_SMART_PLUG_UNIT1_LED_OFF_LEVEL
#define SMART_PLUG_UNIT1_RELAY_OFF_LEVEL      CONFIG_SMART_PLUG_UNIT1_RELAY_OFF_LEVEL
#define SMART_PLUG_UNIT1_RELAY_CTRL_MODE      CONFIG_SMART_PLUG_UNIT1_RELAY_CTRL_MODE
#define SMART_PLUG_UNIT1_RELAY_IO_MODE        CONFIG_SMART_PLUG_UNIT1_RELAY_IO_MODE
#define SMART_PLUG_UNIT1_RELAY_CTL_IO         CONFIG_SMART_PLUG_UNIT1_RELAY_CTL_IO
#define SMART_PLUG_UNIT1_RELAY_CLK_IO         CONFIG_SMART_PLUG_UNIT1_RELAY_CLK_IO
#endif
#if PLUG_UNIT_NUM > 2
#define SMART_PLUG_UNIT2_BUTTON_IO            CONFIG_SMART_PLUG_UNIT2_BUTTON_IO
#define SMART_PLUG_UNIT2_BUTTON_ACTIVE_LEVEL  CONFIG_SMART_PLUG_UNIT2_BUTTON_ACTIVE_LEVEL
#define SMART_PLUG_UNIT2_LED_IO               CONFIG_SMART_PLUG_UNIT2_LED_IO
#define SMART_PLUG_UNIT2_LED_OFF_LEVEL        CONFIG_SMART_PLUG_UNIT2_LED_OFF_LEVEL
#define SMART_PLUG_UNIT2_RELAY_OFF_LEVEL      CONFIG_SMART_PLUG_UNIT2_RELAY_OFF_LEVEL
#define SMART_PLUG_UNIT2_RELAY_CTRL_MODE      CONFIG_SMART_PLUG_UNIT2_RELAY_CTRL_MODE
#define SMART_PLUG_UNIT2_RELAY_IO_MODE        CONFIG_SMART_PLUG_UNIT2_RELAY_IO_MODE
#define SMART_PLUG_UNIT2_RELAY_CTL_IO         CONFIG_SMART_PLUG_UNIT2_RELAY_CTL_IO
#define SMART_PLUG_UNIT2_RELAY_CLK_IO         CONFIG_SMART_PLUG_UNIT2_RELAY_CLK_IO
#endif
#if PLUG_UNIT_NUM > 3
#define SMART_PLUG_UNIT3_BUTTON_IO            CONFIG_SMART_PLUG_UNIT3_BUTTON_IO
#define SMART_PLUG_UNIT3_BUTTON_ACTIVE_LEVEL  CONFIG_SMART_PLUG_UNIT3_BUTTON_ACTIVE_LEVEL
#define SMART_PLUG_UNIT3_LED_IO               CONFIG_SMART_PLUG_UNIT3_LED_IO
#define SMART_PLUG_UNIT3_LED_OFF_LEVEL        CONFIG_SMART_PLUG_UNIT3_LED_OFF_LEVEL
#define SMART_PLUG_UNIT3_RELAY_OFF_LEVEL      CONFIG_SMART_PLUG_UNIT3_RELAY_OFF_LEVEL
#define SMART_PLUG_UNIT3_RELAY_CTRL_MODE      CONFIG_SMART_PLUG_UNIT3_RELAY_CTRL_MODE
#define SMART_PLUG_UNIT3_RELAY_IO_MODE        CONFIG_SMART_PLUG_UNIT3_RELAY_IO_MODE
#define SMART_PLUG_UNIT3_RELAY_CTL_IO         CONFIG_SMART_PLUG_UNIT3_RELAY_CTL_IO
#define SMART_PLUG_UNIT3_RELAY_CLK_IO         CONFIG_SMART_PLUG_UNIT3_RELAY_CLK_IO
#endif

#else
#define PLUG_NAME_SPACE                       "socket"
#define PLUG_PARAM_KEY                        "socket_param"

#define PLUG_POWER_METER_ENABLE               (1)
#define PM_CF_IO_NUM                          (25)
#define PM_CF_PCNT_UNIT_NUM                   (0)
#define PM_CFI_IO_NUM                         (26)
#define PM_CFI_PCNT_UNIT_NUM                  (1)
#define PM_POWER_PARAM                        (1293699)
#define PM_CURRENT_PARAM                      (13670)
#define PM_VOLTAGE_PARAM                      (102961)
#define PM_MODE_SEL_PIN                       (17)
#define PM_MODE_SEL_PIN_LEVEL                 (0)

#define BUTTON_IO_NUM_MAIN                    (4)
#define BUTTON_ACTIVE_LEVEL                   (0)
#define NET_LED_NUM                           GPIO_NUM_19
#define PLUG_UNIT_NUM                         (2)
#define LED_DARK_LEVEL                        LED_DARK_LOW
#if PLUG_UNIT_NUM > 0
#define SMART_PLUG_UNIT0_BUTTON_IO            (5)
#define SMART_PLUG_UNIT0_BUTTON_ACTIVE_LEVEL  (0)
#define SMART_PLUG_UNIT0_LED_IO               (17)
#define SMART_PLUG_UNIT0_LED_OFF_LEVEL        (0)
#define SMART_PLUG_UNIT0_RELAY_OFF_LEVEL      (1)
#define SMART_PLUG_UNIT0_RELAY_CTRL_MODE      (1)
#define SMART_PLUG_UNIT0_RELAY_IO_MODE        (0)
#define SMART_PLUG_UNIT0_RELAY_CTL_IO         (12)
#define SMART_PLUG_UNIT0_RELAY_CLK_IO         (-1)
#endif
#if PLUG_UNIT_NUM > 1
#define SMART_PLUG_UNIT1_BUTTON_IO            (2)
#define SMART_PLUG_UNIT1_BUTTON_ACTIVE_LEVEL  (0)
#define SMART_PLUG_UNIT1_LED_IO               (18)
#define SMART_PLUG_UNIT1_LED_OFF_LEVEL        (0)
#define SMART_PLUG_UNIT1_RELAY_OFF_LEVEL      (1)
#define SMART_PLUG_UNIT1_RELAY_CTRL_MODE      (1)
#define SMART_PLUG_UNIT1_RELAY_IO_MODE        (0)
#define SMART_PLUG_UNIT1_RELAY_CTL_IO         (13)
#define SMART_PLUG_UNIT1_RELAY_CLK_IO         (-1)
#endif
#if PLUG_UNIT_NUM > 2
#define SMART_PLUG_UNIT2_BUTTON_IO            (20)
#define SMART_PLUG_UNIT2_BUTTON_ACTIVE_LEVEL  (0)
#define SMART_PLUG_UNIT2_LED_IO               (21)
#define SMART_PLUG_UNIT2_LED_OFF_LEVEL        (0)
#define SMART_PLUG_UNIT2_RELAY_OFF_LEVEL      (1)
#define SMART_PLUG_UNIT2_RELAY_CTRL_MODE      (1)
#define SMART_PLUG_UNIT2_RELAY_IO_MODE        (0)
#define SMART_PLUG_UNIT2_RELAY_CTL_IO         (22)
#define SMART_PLUG_UNIT2_RELAY_CLK_IO         (-1)
#endif
#if PLUG_UNIT_NUM > 3
#define SMART_PLUG_UNIT3_BUTTON_IO            (23)
#define SMART_PLUG_UNIT3_BUTTON_ACTIVE_LEVEL  (0)
#define SMART_PLUG_UNIT3_LED_IO               (24)
#define SMART_PLUG_UNIT3_LED_OFF_LEVEL        (0)
#define SMART_PLUG_UNIT3_RELAY_OFF_LEVEL      (1)
#define SMART_PLUG_UNIT3_RELAY_CTRL_MODE      (1)
#define SMART_PLUG_UNIT3_RELAY_IO_MODE        (0)
#define SMART_PLUG_UNIT3_RELAY_CTL_IO         (27)
#define SMART_PLUG_UNIT3_RELAY_CLK_IO         (-1)
#endif
#endif

#ifdef __cplusplus
}
#endif

#endif

