#include "RTE_GPIO.h"
#include "Key.h"
#include "Display_Info.h"
#include "Check_Ctrl.h"
#include "CAN_APP.h"
#include "GenDelay.h"
uint8_t rightkey;
uint8_t rightkeytime;
uint8_t clear_odo;
void Key_Operation_SW5(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
       key_left =1;
         Gen_TimeDelay ( 100 *1000,50U);
        key_left =0;


    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {

    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {

    }
    else
    {
        // if(clear_odo == 0)
        // {
        //     if(rightkey)
        //     {
        //         if(rightkeytime < 10)
        //         {
        //             ;
        //         }
        //         else
        //         {
        //             rightkey = 0;
        //             rightkeytime = 0;
        //         }
        //     }
        //     else
        //     {
        //         key_right = 0;
        //     }
        // }
    }
}
uint8_t leftkey;
uint8_t leftkeytime;
uint8_t rightflag=0;
void Key_Operation_SW4(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
       key_right=1;
         Gen_TimeDelay ( 100 *1000,50U);
         key_right=0;
     
    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {

    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {

    }
    else
    {

    }
}
void Key_Operation_SW7(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
         key_on=1;
                  Gen_TimeDelay ( 100 *1000,50U);
        key_on=0;
             
        
    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {
    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {
    }
    else
    {
    }
}

void Key_Operation_SW8(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    { 
          key_up=1;
            Gen_TimeDelay ( 100 *1000,50U);
        key_up=0;
    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {
    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {
    }
    else
    {
    }
}
uint8_t leftflag=0;
uint8_t leftflag2=0;
uint8_t middlekey;
uint8_t middlekeytime;
uint8_t shoubing=0;
void Key_Operation_SW2(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
     
       key_left=1;
        leftflag=1;

    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {
       
    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {

    }
    else
    {
    }
}
void Key_Operation_SW1(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
        Meterfieldstep = 0;
        MENU_CHECK_STEP_ADD( );
    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {
       

    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {

    }
    else
    {
    }
}


void Key_Operation_SW3(Key_Event_en_t enKeyEvent)
{
    if ( enKeyEvent == KEY_EVENT_SHORT_PRESS )
    {
        LINE_RESET=1;
    }
    else if ( enKeyEvent == KEY_EVENT_LONG_PRESS )
    {
      

    }
    else if ( enKeyEvent == KEY_EVENT_SUPER_LONG_PRESS )
    {

    }
    else
    {
    }
}

/*-------------------------------------------------*/
Key_Real_Status_en_t Key_Real_sw5(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    if ( SW5 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    else
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw4(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW4 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw7(void)
{

      Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW7 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw8(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW8 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw2(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW2 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw1(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW1 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}
Key_Real_Status_en_t Key_Real_sw3(void)
{

    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;

    if ( SW3 == 0U )
    {
        enKeyRealStatus = KEY_LINE_PRESS;
    }
    return enKeyRealStatus;
}

/*---------------------------------------------------------------------------------------*/
const Key_Attribute_st_t stKeyAttribute [ KEY_NUM_MAX ] = {
    {KEY_TYPE_LINE, Key_Real_sw5, Key_Operation_SW5},    //SW5
    {KEY_TYPE_LINE, Key_Real_sw4, Key_Operation_SW4},    //SW4
    {KEY_TYPE_LINE, Key_Real_sw7, Key_Operation_SW7},
    {KEY_TYPE_LINE, Key_Real_sw8, Key_Operation_SW8},
    {KEY_TYPE_LINE, Key_Real_sw2, Key_Operation_SW2},      //SW2-
    {KEY_TYPE_LINE, Key_Real_sw1, Key_Operation_SW1},    //SW1+
    {KEY_TYPE_LINE, Key_Real_sw3, Key_Operation_SW3},    //SW1+

};
