Key_user.c 17.7 KB
Newer Older
hu's avatar
hu committed
1 2

#include "Key.h"
3 4
#include "Menu.h"
#include "Services_ODO_User.h"
hu's avatar
hu committed
5 6 7 8 9

#include "DisplaySch_user.h"
#include "Sound_Scheduler.h"
#include "System_Monitor.h"
#include "RTE_ADC.h"
hu's avatar
hu committed
10 11

#include "CAN_Communication_Matrix.h"
hu's avatar
hu committed
12
#include "GUI.h"
hu's avatar
hu committed
13

hu's avatar
hu committed
14
/*-------------------------------------------------------*/
15 16
/*无车速限制值*/
#define DISPSPEEDNULLMAX   66
hu's avatar
hu committed
17 18 19

#define K_Line_User_RYLQQ       100
#define K_Line_User_KQGZJ       100
hu's avatar
hu committed
20 21 22 23 24 25 26 27 28 29 30
/*----------按键具体功能执行的回调函数-----------------------*/


void Key_Operation_Enter(Key_Event_en_t enKeyEvent);
void Key_Operation_Return(Key_Event_en_t enKeyEvent);
void Key_Operation_Up(Key_Event_en_t enKeyEvent);
void Key_Operation_Down(Key_Event_en_t enKeyEvent);
void Key_Operation_Menu(Key_Event_en_t enKeyEvent);

Key_IGN_en_t Key_Get_IGN_Status(void);

31
struct
hu's avatar
hu committed
32
{
33 34 35 36 37 38
    /* data */
    uint8_t Up ;
    uint8_t Down ;
    uint8_t Enter ;
    uint8_t Menu ;
    uint8_t Return ;
hu's avatar
hu committed
39

40
} KeyTest;
hu's avatar
hu committed
41 42 43 44 45 46 47 48 49

/*******************************UP***********************************************
  Function: Key_Operation_Up
  Description:
  Input:
  Output:
 *******************************UP***********************************************/
void Key_Operation_Up(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
50
    uint8_t CanStatus1 = 0u;
51 52 53
    uint16_t DispVSpeed = 0u;
    KeyTest.Up ++ ;
    HMI_Set_KEY_UP(enKeyEvent);
hu's avatar
hu committed
54

55
    DispVSpeed =  Common_Get_Disp_V_Speed();
hu's avatar
hu committed
56
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);
57 58 59 60 61

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
hu's avatar
hu committed
62 63
            /*主界面 一级菜单 二级菜单那*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2))
hu's avatar
hu committed
64
            {
hu's avatar
hu committed
65
                /*故障码*/
hu's avatar
hu committed
66
                if ((CanStatus1 == CAN_SIG_LOST) && (bCurMenuIDX == _MN_DSP_LEVEL2MENU_2))
hu's avatar
hu committed
67
                {
hu's avatar
hu committed
68
                    NextMenu(_MN_DSP_LEVEL2MENU_1);
hu's avatar
hu committed
69 70 71 72 73 74
                }
                else
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_UP);
                }
            }
hu's avatar
hu committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
            /*保养通知设定 更换机油&机油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
            {
                if (User_set_Num.User_FDJYLQQ == (uint32_t)K_Line_Set.K_Line_LID4F * 1000  )
                    User_set_Num.User_FDJYLQQ = 0 ;
            }
            /*保养通知设定 更换燃油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
            {
                if (User_set_Num.User_RYLQQ == (uint32_t)K_Line_User_RYLQQ * 1000 )
                    User_set_Num.User_RYLQQ = 0 ;
            }
            /*保养通知设定 更换变速箱油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
            {
                if (User_set_Num.User_BSXY == (uint32_t)K_Line_Set.K_Line_LID4A * 1000  )
                    User_set_Num.User_BSXY = 0;
            }
            /*保养通知设定 更换差速器右*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
            {
                if (User_set_Num.User_CSQY == (uint32_t)K_Line_Set.K_Line_LID4B * 1000 )
                    User_set_Num.User_CSQY = 0 ;
            }
            /*保养通知设定 更换动力转向油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
            {
                if (User_set_Num.User_DLZXY == (uint32_t)K_Line_Set.K_Line_LID4D * 1000 )
                    User_set_Num.User_DLZXY = 0 ;
            }
            /*保养通知设定 轮胎换位.更换*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
            {
                if (User_set_Num.User_LT == (uint32_t)K_Line_Set.K_Line_LID4E * 1000 )
                    User_set_Num.User_LT = 0 ;
            }
            /*语言设置 ----反*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
            {
                if (User_set_Num.User_Language > 1)
                    User_set_Num.User_Language-- ;
            }

118 119 120 121 122 123 124 125
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
126 127 128 129 130 131 132 133 134 135
}

/*******************************DOWN***********************************************
  Function: Key_Operation_Down
  Description:
  Input:
  Output:
 *******************************DOWN***********************************************/
void Key_Operation_Down(Key_Event_en_t enKeyEvent)
{
136 137 138 139 140 141 142 143 144
    uint16_t DispVSpeed = 0u;
    KeyTest.Down ++ ;
    HMI_Set_KEY_DOWN(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
hu's avatar
hu committed
145 146
            /*主界面 一级菜单 二级菜单*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2))
147 148 149
            {
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_DOWN);
            }
hu's avatar
hu committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
            /*保养通知设定 更换机油&机油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
            {
                if (User_set_Num.User_FDJYLQQ == 0 )
                    User_set_Num.User_FDJYLQQ = (uint32_t)K_Line_Set.K_Line_LID4F * 1000 ;
            }
            /*保养通知设定 更换燃油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
            {
                if (User_set_Num.User_RYLQQ == 0 )
                    User_set_Num.User_RYLQQ = (uint32_t)K_Line_User_RYLQQ * 1000 ;
            }
            /*保养通知设定 更换变速箱油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
            {
                if (User_set_Num.User_BSXY == 0 )
                    User_set_Num.User_BSXY = (uint32_t)K_Line_Set.K_Line_LID4A * 1000 ;
            }
            /*保养通知设定 更换差速器油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
            {
                if (User_set_Num.User_CSQY == 0 )
                    User_set_Num.User_CSQY = (uint32_t)K_Line_Set.K_Line_LID4B * 1000 ;
            }
            /*保养通知设定 更换动力转向液*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
            {
                if (User_set_Num.User_DLZXY == 0 )
                    User_set_Num.User_DLZXY = (uint32_t)K_Line_Set.K_Line_LID4D * 1000 ;
            }
            /*保养通知设定 轮胎换位.更换*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
            {
                if (User_set_Num.User_LT == 0 )
                    User_set_Num.User_LT = (uint32_t)K_Line_Set.K_Line_LID4E * 1000 ;
            }
            /*语言设置 ----反*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
            {
                if (User_set_Num.User_Language < 7 )
                    User_set_Num.User_Language++ ;
            }
hu's avatar
hu committed
192

193 194 195 196 197 198 199 200
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
201 202 203 204 205 206 207 208 209
}
/*******************************ENTER***********************************************
  Function: Key_Operation_Enter
  Description:
  Input:
  Output:
 *******************************ENTER***********************************************/
void Key_Operation_Enter(Key_Event_en_t enKeyEvent)
{
210 211 212
    uint16_t DispVSpeed = 0u;
    KeyTest.Enter ++ ;
    HMI_Set_KEY_CONFIRM(enKeyEvent);
hu's avatar
hu committed
213

214 215 216 217 218 219
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
hu's avatar
hu committed
220
            if (((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
hu's avatar
hu committed
221
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_11) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_22)) ||
hu's avatar
hu committed
222
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
hu's avatar
hu committed
223
            {
hu's avatar
hu committed
224
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
hu's avatar
hu committed
225
            }
hu's avatar
hu committed
226 227
            else if (((bCurMenuIDX >= _MN_DSP_LEVEL3_3_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_3_MENU_7)) ||
                     (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3) ||
hu's avatar
hu committed
228
                     ((bCurMenuIDX >= _MN_DSP_LEVEL4_4_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL4_4_MENU_7)))
229
            {
hu's avatar
hu committed
230 231
                MenuFlag.Menu_Return = 1;
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
hu's avatar
hu committed
232 233 234 235 236
            }
            /*轮胎匹配界面*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
            {

hu's avatar
hu committed
237 238 239 240 241 242
            }
            /*Go Return*/
            else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
            {
                MenuFlag.Menu_Return = 1;
                NextMenu(_MN_DSP_RETURN_MENU);
243 244
            }
        }
hu's avatar
hu committed
245 246 247 248 249 250 251 252 253
        else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
        {
            /*Go Enter*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL3_2_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_2_MENU_8))
            {
                MenuFlag.Menu_Enter_Return = bCurMenuIDX ;
                NextMenu(_MN_DSP_ENTER_MENU);
            }
        }
254 255 256 257 258 259
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
hu's avatar
hu committed
260 261 262
        else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
        {
        }
263
    }
hu's avatar
hu committed
264 265 266 267 268 269 270 271 272 273
}

/*******************************RETURN***********************************************
  Function: Key_Operation_Return
  Description:
  Input:
  Output:
 *******************************RETURN***********************************************/
void Key_Operation_Return(Key_Event_en_t enKeyEvent)
{
274 275 276 277 278 279 280 281 282 283 284 285
    uint16_t DispVSpeed = 0u;
    KeyTest.Return ++ ;
    HMI_Set_KEY_CANCEL(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
            if ((bCurMenuIDX >= _MN_DSP_LEVEL2_1_MENU_1) && (bCurMenuIDX < _MN_DSP_ENTER_MENU))
            {
                if (
hu's avatar
hu committed
286
                    ( bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3 ) ||                                            /*语言设定*/
hu's avatar
hu committed
287
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41 ) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47))  /*省油设定子菜单*/
288 289 290 291 292
                )
                {
                    MenuFlag.Menu_Return = 0;
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
hu's avatar
hu committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5 )                /*胎压设置界面返回操作*/
                {
                    if (User_set_Num.User_TpmsStatus != 2)                      /*不是正在匹配状态*/
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
                    else
                    {
                        User_set_Num.User_TpmsStatus  = 1;                      /*退出匹配界面*/
                        if (User_set_Num.User_Temp_Return == 0)
                        {
                            User_set_Num.User_Temp_Return = 1;                    /*取消配对标记*/
                            User_set_Num.User_TpmsSend = 3;                       /*报文外发次数*/
                        }
                        else
                        {
                            ; /* do nonthing*/
                        }
                    }
                }
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
                else
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
            }
            /*Enter Go*/
            else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
            {
                MenuFlag.Menu_Return = 0;
                NextMenu(MenuFlag.Menu_Enter_Return);
            }
            else
            {
                ;/*do nothing*/
            }
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
336 337 338 339 340 341 342 343 344 345
}

/*******************************Menu***********************************************
  Function: Key_Operation_Menu
  Description:
  Input:
  Output:
 *******************************Menu***********************************************/
void Key_Operation_Menu(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
346
    uint8_t CanStatus1 = 0u;
347 348
    uint16_t DispVSpeed = 0u;
    KeyTest.Menu ++ ;
hu's avatar
hu committed
349

350 351
    HMI_Set_KEY_MENU(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();
hu's avatar
hu committed
352

hu's avatar
hu committed
353 354
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);

355 356 357 358 359 360 361 362 363
    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
            /*记录进入menu菜单的位置*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL1MENU_6))
            {
                MenuFlag.Menu_Flag =  bCurMenuIDX;

hu's avatar
hu committed
364
                if (CanStatus1 == CAN_SIG_LOST)  /*有故障码*/
365
                {
hu's avatar
hu committed
366
                    NextMenu(_MN_DSP_LEVEL2MENU_1);
367 368 369 370 371 372 373
                }
                else  /*无故障码*/
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                }
            }
            /*无论从哪里都能回去*/
hu's avatar
hu committed
374 375
            else if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_RETURN_MENU))
            {
hu's avatar
hu committed
376 377 378 379 380
                //if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_A) /*胎压设置界面*/
                //{
                //    NextMenu(_MN_DSP_LEVEL2MENU_4);           /*menu回到用户设置界面*/
                //}
                //else
hu's avatar
hu committed
381 382 383 384
                {
                    NextMenu(MenuFlag.Menu_Flag);
                }
            }
385 386 387 388 389 390 391 392
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
}



/*------------读按键实时状态的回调函数-------------------------------------------*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void);
Key_Real_Status_en_t Key_Real_Status_Read_Return(void);
Key_Real_Status_en_t Key_Real_Status_Read_Up(void);
Key_Real_Status_en_t Key_Real_Status_Read_Down(void);
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void) ;
/*-------------------------------------------------*/

//Menu_R   = 24000*470 / (24000 + 470) =  460.97Ω
//Enter_R  = 24000*6800 / (24000 + 6800) =  5298.7Ω
//Return_R = 24000*15000 / (24000 + 15000) =  9230.77Ω
408
//Up_R     = 24000*1200 / (24000 + 1200) =  1142.86Ω
hu's avatar
hu committed
409 410 411 412 413
//Down_R   = 24000*3300 / (24000 + 3300) =  2901.1Ω

//Menu_R   = 16000*470 / (16000 + 470) =  456.59Ω
//Enter_R  = 16000*6800 / (16000 + 6800) =  4771.9Ω
//Return_R = 16000*15000 / (16000 + 15000) =  7741.94Ω
414
//Up_R     = 16000*1200 / (16000 + 1200) =  1116.28Ω
hu's avatar
hu committed
415 416 417
//Down_R   = 16000*3300 / (16000 + 3300) =  2736Ω

//实际按键测试
418 419 420 421 422 423
//无操作     21000~24000Ω
//Menu_R        640~680Ω
//Enter_R       5300~5700Ω
//Return_R      9000~9500Ω
//Up_R          1300~1400Ω
//Down_R        3000~3200Ω
hu's avatar
hu committed
424

425 426 427

/*上*/
Key_Real_Status_en_t Key_Real_Status_Read_Up(void)
hu's avatar
hu committed
428 429 430
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
        if ((Key_R >= (1200 - 300)) && (Key_R <= (1200 + 300)))
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
449 450 451 452

    return enKeyRealStatus;
}

453 454
/*下*/
Key_Real_Status_en_t Key_Real_Status_Read_Down(void)
hu's avatar
hu committed
455 456 457
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
        if ((Key_R >= (2900 - 300)) && (Key_R <= (2900 + 300)))
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }

hu's avatar
hu committed
477 478 479
    return enKeyRealStatus;
}

480 481
/*Enter*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void)
hu's avatar
hu committed
482 483 484 485
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;

486 487 488 489 490 491 492 493
    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
hu's avatar
hu committed
494
        if ((Key_R >= (5300 - 300)) && (Key_R <= (5300 + 300)))
495 496 497 498 499 500 501 502
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
503 504 505
    return enKeyRealStatus;
}

506 507
/*Return*/
Key_Real_Status_en_t Key_Real_Status_Read_Return(void)
hu's avatar
hu committed
508 509 510
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
        if ((Key_R >= (9150 - 300)) && (Key_R <= (9150 + 300)))
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
529 530 531 532

    return enKeyRealStatus;
}

533 534
/*Menu*/
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void)
hu's avatar
hu committed
535 536 537
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
        if ((Key_R >= (550 - 300)) && (Key_R <= (550 + 300)))
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582

    return enKeyRealStatus;
}

/*---------------------------------------------------------------------------------------*/
const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] =
{
    {KEY_NEED_DEBOUNCE_NORMAL, Key_Real_Status_Read_Up, Key_Operation_Up},
    {KEY_NEED_DEBOUNCE_NORMAL, Key_Real_Status_Read_Down, Key_Operation_Down},
    {KEY_NEED_DEBOUNCE_NORMAL, Key_Real_Status_Read_Enter, Key_Operation_Enter},
    {KEY_NEED_DEBOUNCE_NORMAL, Key_Real_Status_Read_Return, Key_Operation_Return},
    {KEY_NEED_DEBOUNCE_NORMAL, Key_Real_Status_Read_Menu, Key_Operation_Menu},
};

Key_IGN_en_t Key_Get_IGN_Status(void)
{
    Key_IGN_en_t ret = KEY_IG_INVALID;
    if (SYS_OPR_STAT_IGN_ON)
    {
        ret = KEY_IG_ON;
    }
    else
    {
        ret = KEY_IG_OFF;
    }
    return ret;
}