Key_user.c 38.1 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

#include "DisplaySch_user.h"
hu's avatar
hu committed
7
#include "DispSch.h"
hu's avatar
hu committed
8 9 10
#include "Sound_Scheduler.h"
#include "System_Monitor.h"
#include "RTE_ADC.h"
hu's avatar
hu committed
11 12

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

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

hu's avatar
hu committed
19 20 21 22 23 24 25 26 27 28
/*----------按键具体功能执行的回调函数-----------------------*/

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);

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

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

/*******************************UP***********************************************
  Function: Key_Operation_Up
  Description:
  Input:
  Output:
 *******************************UP***********************************************/
void Key_Operation_Up(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
48
    uint8_t CanStatus1 = 0u;
49
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
50
    UElib_uint16_t HMI_MENU_Sta = 0u;
51

52
    HMI_Set_KEY_UP(enKeyEvent);
hu's avatar
hu committed
53

hu's avatar
hu committed
54 55 56
    HMI_MENU_Sta = Get_Cur_HMI();

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

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

hu's avatar
hu committed
121
                    if (User_set_Num.Year > 99u)
hu's avatar
hu committed
122
                    {
123
                        User_set_Num.Year = 0u;
hu's avatar
hu committed
124
                    }
125 126 127 128 129 130 131
                }
                /*设置日期-月*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
                {
                    User_set_Num.Month++;

                    if (User_set_Num.Month > 12u)
hu's avatar
hu committed
132
                    {
133
                        User_set_Num.Month = 1u;
hu's avatar
hu committed
134
                    }
135 136 137 138 139
                }
                /*设置日期-日*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
                {
                    User_set_Num.Date++;
hu's avatar
hu committed
140

141
                    switch (User_set_Num.Month)
hu's avatar
hu committed
142
                    {
143 144 145 146 147 148 149 150
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        if (User_set_Num.Date > 31u)
hu's avatar
hu committed
151 152 153
                        {
                            User_set_Num.Date = 1u;
                        }
154 155 156 157 158 159
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                        if (User_set_Num.Date > 30u)
hu's avatar
hu committed
160 161 162
                        {
                            User_set_Num.Date = 1u;
                        }
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
                        break;
                    case 2:
                        if (((User_set_Num.Year % 4u == 0u) && (User_set_Num.Year % 100 != 0u)) || (User_set_Num.Year % 400u == 0u))
                        {
                            User_set_Num.LeapYear = 1u;
                        }
                        else
                        {
                            User_set_Num.LeapYear = 0u;
                        }

                        if (User_set_Num.LeapYear)
                        {
                            if (User_set_Num.Date > 29u)
                            {
                                User_set_Num.Date = 1u;
                            }
                        }
                        else
                        {
                            if (User_set_Num.Date > 28u)
                            {
                                User_set_Num.Date = 1u;
                            }
                        }
                        break;
                    default:
                        break;
hu's avatar
hu committed
191 192
                    }
                }
193 194
                /*设置时间-时*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
hu's avatar
hu committed
195
                {
hu's avatar
hu committed
196
                    User_set_Num.Hour++;
hu's avatar
hu committed
197

198 199
                    if (User_set_Num.Hour > 23u)
                    {
hu's avatar
hu committed
200
                        User_set_Num.Hour = 0u;
201
                    }
hu's avatar
hu committed
202
                }
203 204
                /*设置时间-分*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
hu's avatar
hu committed
205
                {
206 207 208 209
                    User_set_Num.Minute++;

                    if (User_set_Num.Minute > 59u)
                    {
hu's avatar
hu committed
210
                        User_set_Num.Minute = 0u;
211
                    }
hu's avatar
hu committed
212
                }
213 214
                /*语言设置 ----反*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
hu's avatar
hu committed
215
                {
216 217
                    if (User_set_Num.User_Language > 0u)
                    {
hu's avatar
hu committed
218
                        User_set_Num.User_Language--;
219
                    }
hu's avatar
hu committed
220
                }
hu's avatar
hu committed
221 222 223 224 225 226 227 228
                /*胎压匹配界面*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
                {
                    if (User_set_Num.User_TpmsStatus == 0)
                        User_set_Num.User_TpmsStatus = 1;
                    if ((User_set_Num.User_TpmsStatus == 1) && (User_set_Num.User_Tpms < 12))
                        User_set_Num.User_Tpms++;
                }
229 230
                /*高速路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
hu's avatar
hu committed
231
                {
232 233 234 235 236 237 238 239
                    if (User_set_Num.User_Gsl < 110)
                    {
                        User_set_Num.User_Gsl++;
                    }
                    else if (User_set_Num.User_Gsl == 0xFF)
                    {
                        User_set_Num.User_Gsl = 20;
                    }
hu's avatar
hu committed
240
                }
241 242
                /*一般路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
hu's avatar
hu committed
243
                {
244 245 246 247 248 249 250 251
                    if (User_set_Num.User_Ybl < 110)
                    {
                        User_set_Num.User_Ybl++;
                    }
                    else if (User_set_Num.User_Ybl == 0xFF)
                    {
                        User_set_Num.User_Ybl = 20;
                    }
hu's avatar
hu committed
252
                }
253 254
                /*发动机转速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
hu's avatar
hu committed
255
                {
256 257
                    if (User_set_Num.User_Speed < 99)
                    {
hu's avatar
hu committed
258
                        User_set_Num.User_Speed++;
259 260 261 262 263
                    }
                    else if (User_set_Num.User_Speed == 0xFF)
                    {
                        User_set_Num.User_Speed = 0;
                    }
hu's avatar
hu committed
264
                }
265 266
                /*急加速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
hu's avatar
hu committed
267
                {
268 269 270 271 272 273 274 275
                    if (User_set_Num.User_JADD < 99)
                    {
                        User_set_Num.User_JADD++;
                    }
                    else if (User_set_Num.User_JADD == 0xFF)
                    {
                        User_set_Num.User_JADD = 5;
                    }
hu's avatar
hu committed
276
                }
277 278
                /*急减速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
hu's avatar
hu committed
279
                {
280 281 282 283 284 285 286 287
                    if (User_set_Num.User_JSUB < 99)
                    {
                        User_set_Num.User_JSUB++;
                    }
                    else if (User_set_Num.User_JSUB == 0xFF)
                    {
                        User_set_Num.User_JSUB = 5;
                    }
hu's avatar
hu committed
288
                }
289 290
                /*长时间怠速设定*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
hu's avatar
hu committed
291
                {
292 293 294 295
                    if (User_set_Num.User_IDLING == 0xFFu)
                    {
                        User_set_Num.User_IDLING = 0u;
                    }
hu's avatar
hu committed
296
                }
297 298
                /*辅助驻车解除设定*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
hu's avatar
hu committed
299
                {
hu's avatar
hu committed
300
                    if (User_set_Num.User_Parking == 0xFFu)
301 302 303
                    {
                        User_set_Num.User_Parking = 0u;
                    }
hu's avatar
hu committed
304 305
                }
            }
306
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
307
            {
hu's avatar
hu committed
308
                ; /*D0 Nothing!*/
hu's avatar
hu committed
309
            }
310 311 312 313 314
        }
        /*----无车速,有报警----*/
        else
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
315
            {
hu's avatar
hu committed
316
                ; /*D0 Nothing!*/
hu's avatar
hu committed
317
            }
318
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
319
            {
hu's avatar
hu committed
320
                ; /*D0 Nothing!*/
hu's avatar
hu committed
321
            }
322 323 324 325
        }
    }
    else
    {
326
        /*----有车速,无报警----*/
hu's avatar
hu committed
327
        if (HMI_MENU_Sta != Display_Alarm)
328 329 330
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
331
                ; /*D0 Nothing!*/
332 333 334
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
335
                ; /*D0 Nothing!*/
336 337 338 339
            }
        }
        /*----有车速,有报警----*/
        else
340
        {
341 342
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
343
                ; /*D0 Nothing!*/
344 345 346
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
347
                ; /*D0 Nothing!*/
348
            }
349 350
        }
    }
hu's avatar
hu committed
351 352 353 354 355 356 357 358 359 360
}

/*******************************DOWN***********************************************
  Function: Key_Operation_Down
  Description:
  Input:
  Output:
 *******************************DOWN***********************************************/
void Key_Operation_Down(Key_Event_en_t enKeyEvent)
{
361
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
362
    UElib_uint16_t HMI_MENU_Sta = 0u;
363

364
    HMI_Set_KEY_DOWN(enKeyEvent);
hu's avatar
hu committed
365 366 367

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
368 369 370

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
371
        /*----无车速,无报警----*/
hu's avatar
hu committed
372
        if (HMI_MENU_Sta != Display_Alarm)
373
        {
374
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
375
            {
376 377
                /*主界面 一级菜单 二级菜单*/
                if (((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
378
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
hu's avatar
hu committed
379
                {
380
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_DOWN);
hu's avatar
hu committed
381
                }
382 383
                /*保养通知设定 更换机油&机油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
hu's avatar
hu committed
384
                {
hu's avatar
hu committed
385 386
                    if (User_set_Num.User_FDJYLQQ == 0u)
                        User_set_Num.User_FDJYLQQ = (uint32_t)K_Line_Set.K_Line_LID4F * 1000u;
hu's avatar
hu committed
387
                }
388 389
                /*保养通知设定 更换燃油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
hu's avatar
hu committed
390
                {
hu's avatar
hu committed
391 392
                    if (User_set_Num.User_RYLQQ == 0u)
                        User_set_Num.User_RYLQQ = (uint32_t)K_Line_User_RYLQQ * 1000u;
hu's avatar
hu committed
393
                }
394 395
                /*保养通知设定 更换变速箱油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
hu's avatar
hu committed
396
                {
hu's avatar
hu committed
397 398
                    if (User_set_Num.User_BSXY == 0u)
                        User_set_Num.User_BSXY = (uint32_t)K_Line_Set.K_Line_LID4A * 1000u;
hu's avatar
hu committed
399
                }
400 401 402
                /*保养通知设定 更换差速器油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
                {
hu's avatar
hu committed
403 404
                    if (User_set_Num.User_CSQY == 0u)
                        User_set_Num.User_CSQY = (uint32_t)K_Line_Set.K_Line_LID4B * 1000u;
405 406 407 408
                }
                /*保养通知设定 更换动力转向液*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
                {
hu's avatar
hu committed
409 410
                    if (User_set_Num.User_DLZXY == 0u)
                        User_set_Num.User_DLZXY = (uint32_t)K_Line_Set.K_Line_LID4D * 1000u;
411 412 413
                }
                /*保养通知设定 轮胎换位.更换*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
hu's avatar
hu committed
414
                {
hu's avatar
hu committed
415 416
                    if (User_set_Num.User_LT == 0u)
                        User_set_Num.User_LT = (uint32_t)K_Line_Set.K_Line_LID4E * 1000u;
417 418 419 420
                }
                /*设置日期-年*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
                {
hu's avatar
hu committed
421
                    if (User_set_Num.Year > 0u)
hu's avatar
hu committed
422
                    {
423
                        User_set_Num.Year--;
hu's avatar
hu committed
424
                    }
425
                    else
hu's avatar
hu committed
426
                    {
427
                        User_set_Num.Year = 99u;
hu's avatar
hu committed
428
                    }
429 430 431 432 433
                }
                /*设置日期-月*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
                {
                    if (User_set_Num.Month > 1u)
hu's avatar
hu committed
434
                    {
435
                        User_set_Num.Month--;
hu's avatar
hu committed
436 437 438
                    }
                    else
                    {
439
                        User_set_Num.Month = 12u;
hu's avatar
hu committed
440
                    }
441 442 443 444 445 446
                }
                /*设置日期-日*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
                {
                    User_set_Num.Date--;
                    switch (User_set_Num.Month)
hu's avatar
hu committed
447
                    {
448 449 450 451 452 453 454
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
hu's avatar
hu committed
455 456
                        if (User_set_Num.Date < 1u)
                        {
457
                            User_set_Num.Date = 31u;
hu's avatar
hu committed
458
                        }
459 460 461 462 463
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
hu's avatar
hu committed
464 465
                        if (User_set_Num.Date < 1u)
                        {
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
                            User_set_Num.Date = 30u;
                        }
                        break;
                    case 2:
                        if (((User_set_Num.Year % 4u == 0u) && (User_set_Num.Year % 100u != 0u)) || (User_set_Num.Year % 400u == 0u))
                        {
                            User_set_Num.LeapYear = 1u;
                        }
                        else
                        {
                            User_set_Num.LeapYear = 0u;
                        }

                        if (User_set_Num.LeapYear)
                        {
                            if (User_set_Num.Date < 1u)
                            {
                                User_set_Num.Date = 29u;
                            }
                        }
                        else
                        {
                            if (User_set_Num.Date < 1u)
                            {
                                User_set_Num.Date = 28u;
                            }
hu's avatar
hu committed
492
                        }
493 494 495
                        break;
                    default:
                        break;
hu's avatar
hu committed
496 497
                    }
                }
498 499
                /*设置时间-时*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
hu's avatar
hu committed
500
                {
501 502 503 504 505 506
                    if (User_set_Num.Hour > 0u)
                    {
                        User_set_Num.Hour--;
                    }
                    else
                    {
hu's avatar
hu committed
507
                        User_set_Num.Hour = 23u;
508
                    }
hu's avatar
hu committed
509
                }
510 511
                /*设置时间-分*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
hu's avatar
hu committed
512
                {
513 514
                    if (User_set_Num.Minute > 0u)
                    {
hu's avatar
hu committed
515
                        User_set_Num.Minute--;
516 517 518
                    }
                    else
                    {
hu's avatar
hu committed
519
                        User_set_Num.Minute = 59u;
520
                    }
hu's avatar
hu committed
521
                }
522 523
                /*语言设置 ----反*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
hu's avatar
hu committed
524
                {
hu's avatar
hu committed
525 526
                    if (User_set_Num.User_Language < 1)
                        User_set_Num.User_Language++;
hu's avatar
hu committed
527
                }
hu's avatar
hu committed
528 529 530 531 532 533 534 535 536 537 538 539 540 541
                /*胎压匹配界面*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
                {
                    /*if(User_set_Num.User_TpmsStatus == 0)
                    {
                      if(User_set_Num.User_Par_Temp == 0)
                        User_set_Num.User_Par_Temp = 1;
                      else
                        User_set_Num.User_Par_Temp = 0;
                    }
                    else */
                    if ((User_set_Num.User_TpmsStatus == 1) && (User_set_Num.User_Tpms > 1))
                        User_set_Num.User_Tpms--;
                }
542 543
                /*高速路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
hu's avatar
hu committed
544
                {
545 546 547 548 549 550 551 552
                    if ((User_set_Num.User_Gsl > 20) && (User_set_Num.User_Gsl <= 110))
                    {
                        User_set_Num.User_Gsl--;
                    }
                    else
                    {
                        User_set_Num.User_Gsl = 0xFF;
                    }
hu's avatar
hu committed
553
                }
554 555
                /*一般路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
hu's avatar
hu committed
556
                {
557 558 559 560 561 562 563 564
                    if ((User_set_Num.User_Ybl > 20) && (User_set_Num.User_Ybl <= 110))
                    {
                        User_set_Num.User_Ybl--;
                    }
                    else
                    {
                        User_set_Num.User_Ybl = 0xFF;
                    }
hu's avatar
hu committed
565
                }
566 567
                /*发动机转速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
hu's avatar
hu committed
568
                {
569 570 571 572
                    if ((User_set_Num.User_Speed >= 0) && (User_set_Num.User_Speed <= 99))
                    {
                        User_set_Num.User_Speed--;
                    }
hu's avatar
hu committed
573
                }
574 575
                /*急加速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
hu's avatar
hu committed
576
                {
577 578 579 580 581 582 583 584
                    if ((User_set_Num.User_JADD > 5) && (User_set_Num.User_JADD <= 99))
                    {
                        User_set_Num.User_JADD--;
                    }
                    else
                    {
                        User_set_Num.User_JADD = 0xFF;
                    }
hu's avatar
hu committed
585
                }
586 587
                /*急减速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
hu's avatar
hu committed
588
                {
589 590 591 592 593 594 595 596
                    if ((User_set_Num.User_JSUB > 5) && (User_set_Num.User_JSUB <= 99))
                    {
                        User_set_Num.User_JSUB--;
                    }
                    else
                    {
                        User_set_Num.User_JSUB = 0xFF;
                    }
hu's avatar
hu committed
597
                }
598 599
                /*长时间怠速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
hu's avatar
hu committed
600
                {
601 602 603 604
                    if (User_set_Num.User_IDLING == 0u)
                    {
                        User_set_Num.User_IDLING = 0xFFu;
                    }
hu's avatar
hu committed
605
                }
606 607
                /*辅助驻车解除*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
hu's avatar
hu committed
608
                {
609 610 611 612
                    if (User_set_Num.User_Parking == 0u)
                    {
                        User_set_Num.User_Parking = 0xFFu;
                    }
hu's avatar
hu committed
613 614
                }
            }
615
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
616
            {
hu's avatar
hu committed
617
                ; /*D0 Nothing!*/
hu's avatar
hu committed
618
            }
619 620 621 622 623
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
624
            {
hu's avatar
hu committed
625
                ; /*D0 Nothing!*/
hu's avatar
hu committed
626
            }
627
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
628
            {
hu's avatar
hu committed
629
                ; /*D0 Nothing!*/
hu's avatar
hu committed
630
            }
631 632 633 634
        }
    }
    else
    {
635
        /*----有车速,无报警----*/
hu's avatar
hu committed
636
        if (HMI_MENU_Sta != Display_Alarm)
637
        {
638 639
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
640
                ; /*D0 Nothing!*/
641 642 643
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
644
                ; /*D0 Nothing!*/
645 646 647 648 649 650 651
            }
        }
        /*----有车速,有报警----*/
        else
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
652
                ; /*D0 Nothing!*/
653 654 655
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
656
                ; /*D0 Nothing!*/
657
            }
658 659
        }
    }
hu's avatar
hu committed
660 661 662 663 664 665 666 667 668
}
/*******************************ENTER***********************************************
  Function: Key_Operation_Enter
  Description:
  Input:
  Output:
 *******************************ENTER***********************************************/
void Key_Operation_Enter(Key_Event_en_t enKeyEvent)
{
669
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
670
    UElib_uint16_t HMI_MENU_Sta = 0u;
671

672
    HMI_Set_KEY_CONFIRM(enKeyEvent);
hu's avatar
hu committed
673

hu's avatar
hu committed
674 675
    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
676 677 678

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
679
        /*----无车速,无报警----*/
hu's avatar
hu committed
680
        if (HMI_MENU_Sta != Display_Alarm)
681
        {
682
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
683
            {
684
                if (((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
685
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
686 687 688 689 690 691 692 693 694 695 696 697
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                }
                else if (((bCurMenuIDX >= _MN_DSP_LEVEL3_3_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_3)) ||
                         ((bCurMenuIDX >= _MN_DSP_LEVEL4_4_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL4_4_MENU_7)))
                {
                    MenuFlag.Menu_Return = 1u;
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                }
                /*轮胎匹配界面*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
                {
hu's avatar
hu committed
698 699 700 701 702 703
                    if (User_set_Num.User_TpmsStatus == 1)
                    {
                        User_set_Num.User_TpmsStatus = 2;  /*匹配轮胎*/
                        User_set_Num.User_TpmsSend   = 3;  /*报文外发状态*/
                        User_set_Num.User_Temp_Return = 0; /*清空取消标记位*/
                    }
704 705 706 707 708 709 710
                }
                /*Go Return*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 1;
                    NextMenu(_MN_DSP_RETURN_MENU);
                }
hu's avatar
hu committed
711
            }
712
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
713
            {
714 715 716
                /*Go Enter*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL3_2_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_2_MENU_8))
                {
hu's avatar
hu committed
717
                    MenuFlag.Menu_Enter_Return = bCurMenuIDX;
718 719
                    NextMenu(_MN_DSP_ENTER_MENU);
                }
720 721
            }
        }
722
        else
hu's avatar
hu committed
723
        {
724 725 726
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
727
                ; /*D0 Nothing!*/
728 729
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
730
            {
hu's avatar
hu committed
731
                ; /*D0 Nothing!*/
hu's avatar
hu committed
732 733
            }
        }
734 735 736
    }
    else
    {
737
        /*----有车速,无报警----*/
hu's avatar
hu committed
738
        if (HMI_MENU_Sta != Display_Alarm)
739
        {
740 741
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
742
                ; /*D0 Nothing!*/
743 744 745
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
746
                ; /*D0 Nothing!*/
747
            }
748
        }
749 750
        /*----有车速,有报警----*/
        else
hu's avatar
hu committed
751
        {
752 753
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
754
                ; /*D0 Nothing!*/
755 756 757
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
758
                ; /*D0 Nothing!*/
759
            }
hu's avatar
hu committed
760
        }
761
    }
hu's avatar
hu committed
762 763 764 765 766 767 768 769 770 771
}

/*******************************RETURN***********************************************
  Function: Key_Operation_Return
  Description:
  Input:
  Output:
 *******************************RETURN***********************************************/
void Key_Operation_Return(Key_Event_en_t enKeyEvent)
{
772
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
773
    UElib_uint16_t HMI_MENU_Sta = 0u;
774

775
    HMI_Set_KEY_CANCEL(enKeyEvent);
hu's avatar
hu committed
776 777 778

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
779 780 781

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
782
        /*----无车速,无报警----*/
hu's avatar
hu committed
783
        if (HMI_MENU_Sta != Display_Alarm)
784
        {
785
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
786
            {
787
                if ((bCurMenuIDX >= _MN_DSP_LEVEL2_1_MENU_1) && (bCurMenuIDX < _MN_DSP_ENTER_MENU))
hu's avatar
hu committed
788
                {
789
                    if (
hu's avatar
hu committed
790
                        (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3) ||                                              /*语言设定*/
791
                        (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1) ||                                              /*亮度调节*/
hu's avatar
hu committed
792
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)) /*省油设定子菜单*/
793
                    )
hu's avatar
hu committed
794
                    {
795
                        MenuFlag.Menu_Return = 0u;
hu's avatar
hu committed
796 797
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
798
                    else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5) /*胎压设置界面返回操作*/
hu's avatar
hu committed
799
                    {
800
                        if (User_set_Num.User_TpmsStatus != 2u) /*不是正在匹配状态*/
hu's avatar
hu committed
801
                        {
802
                            NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
hu's avatar
hu committed
803 804 805
                        }
                        else
                        {
806 807
                            User_set_Num.User_TpmsStatus = 1u; /*退出匹配界面*/
                            if (User_set_Num.User_Temp_Return == 0u)
808
                            {
809 810
                                User_set_Num.User_Temp_Return = 1u; /*取消配对标记*/
                                User_set_Num.User_TpmsSend   = 3u;  /*报文外发状态*/
811 812 813 814 815
                            }
                            else
                            {
                                ; /* do nonthing*/
                            }
hu's avatar
hu committed
816 817
                        }
                    }
818 819 820 821
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
822
                }
823 824
                /*系统演示模式*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
825
                {
826
                    MenuFlag.Menu_Return = 0;
827 828
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
829 830 831 832 833 834 835 836
                /*Enter Go*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 0;
                    NextMenu(MenuFlag.Menu_Enter_Return);
                }
                else
                {
hu's avatar
hu committed
837
                    ; /*do nothing*/
838
                }
839
            }
840
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
841
            {
hu's avatar
hu committed
842
                ; /*D0 Nothing!*/
843
            }
844 845 846 847 848
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
849
            {
hu's avatar
hu committed
850
                ; /*Do Nothing!*/
851
            }
852
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
853
            {
854
                MenuFlag.Key_Menu_Popup_time = 6000u;
855 856 857 858 859
            }
        }
    }
    else
    {
hu's avatar
hu committed
860
        if (HMI_MENU_Sta != Display_Alarm)
861
        {
862 863 864
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
865
                ; /*Do Nothing!*/
866 867 868
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
869
                ; /*Do Nothing!*/
870 871 872 873 874 875 876
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
877
                ; /*Do Nothing!*/
878 879 880 881 882
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
                MenuFlag.Key_Menu_Popup_time = 6000u;
            }
883 884
        }
    }
hu's avatar
hu committed
885 886 887 888 889 890 891 892 893 894
}

/*******************************Menu***********************************************
  Function: Key_Operation_Menu
  Description:
  Input:
  Output:
 *******************************Menu***********************************************/
void Key_Operation_Menu(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
895
    uint8_t CanStatus1 = 0u;
896
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
897
    UElib_uint16_t HMI_MENU_Sta = 0u;
hu's avatar
hu committed
898

899
    HMI_Set_KEY_MENU(enKeyEvent);
hu's avatar
hu committed
900 901 902

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
hu's avatar
hu committed
903

hu's avatar
hu committed
904 905
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);

906 907
    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
908
        /*----无车速,无报警----*/
hu's avatar
hu committed
909
        if (HMI_MENU_Sta != Display_Alarm)
910
        {
911
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
912
            {
913 914
                /*记录进入menu菜单的位置*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL1MENU_6))
915
                {
hu's avatar
hu committed
916
                    MenuFlag.Menu_Flag = bCurMenuIDX;
917 918 919 920 921 922 923 924 925 926 927

                    /*有故障码*/
                    if (CanStatus1 == CAN_SIG_LOST)
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_1);
                    }
                    /*无故障码*/
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                    }
928
                }
929 930
                /*无论从哪里都能回去*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_RETURN_MENU))
931
                {
hu's avatar
hu committed
932
                    // if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_A) /*胎压设置界面*/
933
                    //{
hu's avatar
hu committed
934 935 936
                    //     NextMenu(_MN_DSP_LEVEL2MENU_4);           /*menu回到用户设置界面*/
                    // }
                    // else
937 938 939
                    {
                        NextMenu(MenuFlag.Menu_Flag);
                    }
940
                }
941
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
hu's avatar
hu committed
942 943 944 945
                {
                    NextMenu(MenuFlag.Menu_Flag);
                }
            }
946
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
947
            {
hu's avatar
hu committed
948
                ; /*Do Nothing!*/
949 950 951 952 953 954 955
            }
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
956
                ; /*Do Nothing!*/
957 958 959
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
960
                ; /*Do Nothing!*/
961
            }
962 963 964 965
        }
    }
    else
    {
hu's avatar
hu committed
966
        if (HMI_MENU_Sta != Display_Alarm)
967
        {
968 969 970
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
971
                ; /*Do Nothing!*/
972 973 974
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
975
                ; /*Do Nothing!*/
976 977 978 979 980 981 982
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
983
                ; /*Do Nothing!*/
984 985 986
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
987
                ; /*Do Nothing!*/
988
            }
989 990
        }
    }
hu's avatar
hu committed
991 992
}

hu's avatar
hu committed
993 994 995 996
uint8_t Common_Get_RetMenu_Flag(void)
{
    return MenuFlag.Menu_Flag;
}
hu's avatar
hu committed
997 998 999 1000 1001
/*------------读按键实时状态的回调函数-------------------------------------------*/
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);
hu's avatar
hu committed
1002
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void);
hu's avatar
hu committed
1003 1004
/*-------------------------------------------------*/

hu's avatar
hu committed
1005 1006 1007 1008 1009
// Menu_R   = 24000*470 / (24000 + 470) =  460.97Ω
// Enter_R  = 24000*6800 / (24000 + 6800) =  5298.7Ω
// Return_R = 24000*15000 / (24000 + 15000) =  9230.77Ω
// Up_R     = 24000*1200 / (24000 + 1200) =  1142.86Ω
// Down_R   = 24000*3300 / (24000 + 3300) =  2901.1Ω
hu's avatar
hu committed
1010

hu's avatar
hu committed
1011 1012 1013 1014 1015
// Menu_R   = 16000*470 / (16000 + 470) =  456.59Ω
// Enter_R  = 16000*6800 / (16000 + 6800) =  4771.9Ω
// Return_R = 16000*15000 / (16000 + 15000) =  7741.94Ω
// Up_R     = 16000*1200 / (16000 + 1200) =  1116.28Ω
// Down_R   = 16000*3300 / (16000 + 3300) =  2736Ω
hu's avatar
hu committed
1016 1017

//实际按键测试
1018
//无操作     21000~24000Ω
hu's avatar
hu committed
1019 1020 1021 1022 1023
// Menu_R        640~680Ω
// Enter_R       5300~5700Ω
// Return_R      9000~9500Ω
// Up_R          1300~1400Ω
// Down_R        3000~3200Ω
1024 1025 1026

/*上*/
Key_Real_Status_en_t Key_Real_Status_Read_Up(void)
hu's avatar
hu committed
1027 1028 1029
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1030 1031 1032 1033 1034 1035 1036 1037 1038

    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
1039
        if ((Key_R >= (1250 - 400)) && (Key_R <= (1250 + 400)))
1040 1041 1042 1043 1044 1045 1046 1047
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1048 1049 1050 1051

    return enKeyRealStatus;
}

1052 1053
/*下*/
Key_Real_Status_en_t Key_Real_Status_Read_Down(void)
hu's avatar
hu committed
1054 1055 1056
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1057 1058 1059 1060 1061 1062 1063 1064 1065

    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
1066
        if ((Key_R >= (2900 - 400)) && (Key_R <= (2900 + 400)))
1067 1068 1069 1070 1071 1072 1073 1074 1075
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }

hu's avatar
hu committed
1076 1077 1078
    return enKeyRealStatus;
}

1079 1080
/*Enter*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void)
hu's avatar
hu committed
1081 1082 1083 1084
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;

1085 1086 1087 1088 1089 1090 1091 1092
    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
1093
        if ((Key_R >= (4800 - 400)) && (Key_R <= (4800 + 400)))
1094 1095 1096 1097 1098 1099 1100 1101
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1102 1103 1104
    return enKeyRealStatus;
}

1105 1106
/*Return*/
Key_Real_Status_en_t Key_Real_Status_Read_Return(void)
hu's avatar
hu committed
1107 1108 1109
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1110 1111 1112 1113 1114 1115 1116 1117 1118

    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
1119
        if ((Key_R >= (7800 - 400)) && (Key_R <= (7800 + 400)))
1120 1121 1122 1123 1124 1125 1126 1127
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1128 1129 1130 1131

    return enKeyRealStatus;
}

1132 1133
/*Menu*/
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void)
hu's avatar
hu committed
1134 1135 1136
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1137 1138 1139 1140 1141 1142 1143 1144 1145

    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
1146
        if ((Key_R >= (500 - 300)) && (Key_R <= (500 + 300)))
1147 1148 1149 1150 1151 1152 1153 1154
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1155 1156 1157 1158 1159 1160

    return enKeyRealStatus;
}

/*---------------------------------------------------------------------------------------*/
const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] =
1161 1162 1163 1164 1165 1166
{
    {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},
hu's avatar
hu committed
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
};

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;
1181
}