/**
 * @file ate0003.h
 */

#pragma once

#include "zh_160x_i2c.h"
#include "zh_ac_dimmer.h"
#include "zh_encoder.h"
#include "nvs_flash.h"
#include "esp_wifi.h"
#include "zh_ota_server.h"

#define HIGH true
#define LOW false

#define LED_OFF LOW
#define LED_ON HIGH

#define RELAY_OFF LOW
#define RELAY_ON HIGH

#define WIFI_SSID "ATE0003"
#define WIFI_PASS "repairlab"
#define WIFI_CHANNEL 1
#define MAX_STA_CONNECTION 4

#define LCD_I2C_ADDRESS 0x20    /*!< U4. */
#define BUTTON_I2C_ADDRESS 0x24 /*!< U5. */
#define LED_1_I2C_ADDRESS 0x22  /*!< U6. */
#define LED_2_I2C_ADDRESS 0x21  /*!< U7. */
#define RELAY_I2C_ADDRESS 0x23  /*!< U8. */

#define GROUND_RELAY 0x00 /*!< Relay K1. RL1 pin on U8. */
#define DMM_RELAY 0x01    /*!< Relay K2. RL2 pin on U8. */
#define L_1_RELAY 0x03    /*!< Relay K4. RL4 pin on U8. */
#define L_2_RELAY 0x04    /*!< Relay K3. RL3 pin on U8. */
#define L_3_RELAY 0x05    /*!< Relay K6. RL6 pin on U8. */
#define L_4_RELAY 0x02    /*!< Relay K5. RL5 pin on U8. */
#define L5_RELAY 0x06     /*!< Relay K7. RL7 pin on U8. */

#define POWER_ENCODER 0x01     /*!< Connector EN2. */
#define COMPONENT_ENCODER 0x02 /*!< Connector EN1. */

#define DMM_BUTTON 0x00   /*!< Connector BT1. BT1-0 on U5. */
#define FIX_BUTTON 0x01   /*!< Connector BT2. BT2-1 on U5. */
#define NUM_1_BUTTON 0x02 /*!< Connector BT3. BT3-2 on U5. */
#define NUM_2_BUTTON 0x03 /*!< Connector BT4. BT4-3 on U5. */
#define NUM_3_BUTTON 0x04 /*!< Connector BT5. BT5-4 on U5. */
#define NUM_4_BUTTON 0x05 /*!< Connector BT6. BT6-5 on U5. */

#define DMM_LED_RED 0x00     /*!< Connector LE1. 2 PIN. L1-0 pin on U6. */
#define DMM_LED_GREEN 0x01   /*!< Connector LE1. 1 PIN. L1-1 pin on U6. */
#define FIX_LED_BLUE 0x02    /*!< Connector LE2. 2 PIN. L2-2 pin on U6. */
#define FIX_LED_GREEN 0x03   /*!< Connector LE2. 1 PIN. L2-3 pin on U6. */
#define NUM_1_LED_BLUE 0x04  /*!< Connector LE3. 2 PIN. L3-4 pin on U6. */
#define NUM_1_LED_GREEN 0x05 /*!< Connector LE3. 1 PIN. L3-5 pin on U6. */
#define NUM_2_LED_BLUE 0x06  /*!< Connector LE4. 2 PIN. L4-6 pin on U6. */
#define NUM_2_LED_GREEN 0x07 /*!< Connector LE4. 1 PIN. L4-7 pin on U6. */
#define NUM_3_LED_BLUE 0x00  /*!< Connector LE5. 2 PIN. L5-0 pin on U7. */
#define NUM_3_LED_GREEN 0x01 /*!< Connector LE5. 1 PIN. L5-1 pin on U7. */
#define NUM_4_LED_BLUE 0x02  /*!< Connector LE6. 2 PIN. L6-2 pin on U7. */
#define NUM_4_LED_GREEN 0x03 /*!< Connector LE6. 1 PIN. L6-3 pin on U7. */

#define CHANNEL_1 0x08
#define CHANNEL_2 0x04
#define CHANNEL_3 0x02
#define CHANNEL_4 0x01

#ifdef __cplusplus
extern "C"
{
#endif

    typedef struct
    {
        char *_pn;
        char *_doc;
        char *_channel_1;
        char *_channel_2;
        char *_channel_3;
        char *_channel_4;
        uint8_t _used_channel;

    } _component_t;

    const _component_t _component[] =
        {
            {"SELECT P/N", "N/A", "N/A", "N/A", "N/A", "N/A", 0x00},
            {"30-2581-3", "334230", "LOGO", "N/A", "N/A", "N/A", 0x08},
            {"4298117", "334612", "400W", "600W", "N/A", "N/A", 0x0C},
            {"4236534", "334303", "RUNW", "N/A", "N/A", "N/A", 0x08},
            {"8000306Y00", "334303", "RUNW", "N/A", "N/A", "N/A", 0x08},
            {"8000281Y00", "334303", "RUNW", "N/A", "N/A", "N/A", 0x08},
            {"4292491", "334711", "LOGO", "N/A", "N/A", "N/A", 0x08},
            {"4328733", "334711", "LOGO", "N/A", "N/A", "N/A", 0x08},
            {"4358532", "334711", "LOGO", "N/A", "N/A", "N/A", 0x08},
            {"ANY", "ANY   ", "RED", "GRN", "ORG", "WHT", 0x0F}};

#ifdef __cplusplus
}
#endif