Key_user.c 40.4 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
                    /*故障码*/
                    if ((CanStatus1 == CAN_SIG_LOST) && (bCurMenuIDX == _MN_DSP_LEVEL2MENU_2))
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_1);
                    }
hu's avatar
hu committed
75 76 77 78 79
                    /*系统演示模式*/
                    else if ((bCurMenuIDX == _MN_DSP_LEVEL2MENU_6) && (K_Line_Set.K_Line_LID27 != 0x01u) && (K_Line_Set.K_Line_LID28 != 0x01u))
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_4);
                    }
80 81 82 83
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_UP);
                    }
hu's avatar
hu committed
84
                }
hu's avatar
hu committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
                /*系统演示模式子菜单*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL2_5_MENU_1) && (_MN_DSP_LEVEL2_5_MENU_4 <= _MN_DSP_LEVEL2_5_MENU_1))
                {
                    /*if ()
                    {

                    }
                    else if ()
                    {

                    }
                    else if ()
                    {

                    }
                    else
                    {

                    }*/
                }
105 106
                /*保养通知设定 更换机油&机油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
hu's avatar
hu committed
107
                {
108
                    if (User_set_Num.User_FDJYLQQ == (uint32_t)K_Line_Set.K_Line_LID4F * 1000u)
hu's avatar
hu committed
109
                    {
hu's avatar
hu committed
110
                        User_set_Num.User_FDJYLQQ = 0u;
hu's avatar
hu committed
111
                    }
hu's avatar
hu committed
112
                }
113 114
                /*保养通知设定 更换燃油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
hu's avatar
hu committed
115
                {
116
                    if (User_set_Num.User_RYLQQ == (uint32_t)K_Line_User_RYLQQ * 1000u)
hu's avatar
hu committed
117
                    {
hu's avatar
hu committed
118
                        User_set_Num.User_RYLQQ = 0u;
hu's avatar
hu committed
119
                    }
hu's avatar
hu committed
120
                }
121 122
                /*保养通知设定 更换变速箱油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
hu's avatar
hu committed
123
                {
124
                    if (User_set_Num.User_BSXY == (uint32_t)K_Line_Set.K_Line_LID4A * 1000u)
hu's avatar
hu committed
125
                    {
126
                        User_set_Num.User_BSXY = 0u;
hu's avatar
hu committed
127
                    }
hu's avatar
hu committed
128
                }
129 130
                /*保养通知设定 更换差速器右*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
hu's avatar
hu committed
131
                {
132
                    if (User_set_Num.User_CSQY == (uint32_t)K_Line_Set.K_Line_LID4B * 1000u)
hu's avatar
hu committed
133
                    {
hu's avatar
hu committed
134
                        User_set_Num.User_CSQY = 0u;
hu's avatar
hu committed
135
                    }
136 137 138 139 140
                }
                /*保养通知设定 更换动力转向油*/
                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
141
                    {
hu's avatar
hu committed
142
                        User_set_Num.User_DLZXY = 0u;
hu's avatar
hu committed
143
                    }
144 145 146 147 148
                }
                /*保养通知设定 轮胎换位.更换*/
                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
149
                    {
hu's avatar
hu committed
150
                        User_set_Num.User_LT = 0u;
hu's avatar
hu committed
151
                    }
152 153 154 155
                }
                /*设置日期-年*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
                {
hu's avatar
hu committed
156
                    User_set_Num.Year++;
157

hu's avatar
hu committed
158
                    if (User_set_Num.Year > 99u)
hu's avatar
hu committed
159
                    {
160
                        User_set_Num.Year = 0u;
hu's avatar
hu committed
161
                    }
162 163 164 165 166 167 168
                }
                /*设置日期-月*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
                {
                    User_set_Num.Month++;

                    if (User_set_Num.Month > 12u)
hu's avatar
hu committed
169
                    {
170
                        User_set_Num.Month = 1u;
hu's avatar
hu committed
171
                    }
172 173 174 175 176
                }
                /*设置日期-日*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
                {
                    User_set_Num.Date++;
hu's avatar
hu committed
177

178
                    switch (User_set_Num.Month)
hu's avatar
hu committed
179
                    {
180 181 182 183 184 185 186 187
                    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
188 189 190
                        {
                            User_set_Num.Date = 1u;
                        }
191 192 193 194 195 196
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                        if (User_set_Num.Date > 30u)
hu's avatar
hu committed
197 198 199
                        {
                            User_set_Num.Date = 1u;
                        }
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
                        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
228 229
                    }
                }
230 231
                /*设置时间-时*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
hu's avatar
hu committed
232
                {
hu's avatar
hu committed
233
                    User_set_Num.Hour++;
hu's avatar
hu committed
234

235 236
                    if (User_set_Num.Hour > 23u)
                    {
hu's avatar
hu committed
237
                        User_set_Num.Hour = 0u;
238
                    }
hu's avatar
hu committed
239
                }
240 241
                /*设置时间-分*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
hu's avatar
hu committed
242
                {
243 244 245 246
                    User_set_Num.Minute++;

                    if (User_set_Num.Minute > 59u)
                    {
hu's avatar
hu committed
247
                        User_set_Num.Minute = 0u;
248
                    }
hu's avatar
hu committed
249
                }
250 251
                /*语言设置 ----反*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
hu's avatar
hu committed
252
                {
253 254
                    if (User_set_Num.User_Language > 0u)
                    {
hu's avatar
hu committed
255
                        User_set_Num.User_Language--;
256
                    }
hu's avatar
hu committed
257
                }
hu's avatar
hu committed
258 259 260 261
                /*胎压匹配界面*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
                {
                    if (User_set_Num.User_TpmsStatus == 0)
hu's avatar
hu committed
262
                    {
hu's avatar
hu committed
263
                        User_set_Num.User_TpmsStatus = 1;
hu's avatar
hu committed
264
                    }
hu's avatar
hu committed
265
                    if ((User_set_Num.User_TpmsStatus == 1) && (User_set_Num.User_Tpms < 12))
hu's avatar
hu committed
266
                    {
hu's avatar
hu committed
267
                        User_set_Num.User_Tpms++;
hu's avatar
hu committed
268
                    }
hu's avatar
hu committed
269
                }
270 271
                /*高速路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
hu's avatar
hu committed
272
                {
273 274 275 276 277 278 279 280
                    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
281
                }
282 283
                /*一般路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
hu's avatar
hu committed
284
                {
285 286 287 288 289 290 291 292
                    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
293
                }
294 295
                /*发动机转速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
hu's avatar
hu committed
296
                {
297 298
                    if (User_set_Num.User_Speed < 99)
                    {
hu's avatar
hu committed
299
                        User_set_Num.User_Speed++;
300 301 302 303 304
                    }
                    else if (User_set_Num.User_Speed == 0xFF)
                    {
                        User_set_Num.User_Speed = 0;
                    }
hu's avatar
hu committed
305
                }
306 307
                /*急加速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
hu's avatar
hu committed
308
                {
309 310 311 312 313 314 315 316
                    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
317
                }
318 319
                /*急减速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
hu's avatar
hu committed
320
                {
321 322 323 324 325 326 327 328
                    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
329
                }
330 331
                /*长时间怠速设定*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
hu's avatar
hu committed
332
                {
333 334 335 336
                    if (User_set_Num.User_IDLING == 0xFFu)
                    {
                        User_set_Num.User_IDLING = 0u;
                    }
hu's avatar
hu committed
337
                }
338 339
                /*辅助驻车解除设定*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
hu's avatar
hu committed
340
                {
hu's avatar
hu committed
341
                    if (User_set_Num.User_Parking == 0xFFu)
342 343 344
                    {
                        User_set_Num.User_Parking = 0u;
                    }
hu's avatar
hu committed
345 346
                }
            }
347
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
348
            {
hu's avatar
hu committed
349
                ; /*D0 Nothing!*/
hu's avatar
hu committed
350
            }
351 352 353 354 355
        }
        /*----无车速,有报警----*/
        else
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
356
            {
hu's avatar
hu committed
357
                ; /*D0 Nothing!*/
hu's avatar
hu committed
358
            }
359
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
360
            {
hu's avatar
hu committed
361
                ; /*D0 Nothing!*/
hu's avatar
hu committed
362
            }
363 364 365 366
        }
    }
    else
    {
367
        /*----有车速,无报警----*/
hu's avatar
hu committed
368
        if (HMI_MENU_Sta != Display_Alarm)
369 370 371
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
372
                ; /*D0 Nothing!*/
373 374 375
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
376
                ; /*D0 Nothing!*/
377 378 379 380
            }
        }
        /*----有车速,有报警----*/
        else
381
        {
382 383
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
384
                ; /*D0 Nothing!*/
385 386 387
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
388
                ; /*D0 Nothing!*/
389
            }
390 391
        }
    }
hu's avatar
hu committed
392 393 394 395 396 397 398 399 400 401
}

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

405
    HMI_Set_KEY_DOWN(enKeyEvent);
hu's avatar
hu committed
406 407 408

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
409 410 411

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
412
        /*----无车速,无报警----*/
hu's avatar
hu committed
413
        if (HMI_MENU_Sta != Display_Alarm)
414
        {
415
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
416
            {
417 418
                /*主界面 一级菜单 二级菜单*/
                if (((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
419
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
hu's avatar
hu committed
420
                {
hu's avatar
hu committed
421 422 423 424 425 426 427 428 429
                    /*系统演示模式*/
                    if ((bCurMenuIDX == _MN_DSP_LEVEL2MENU_4) && (K_Line_Set.K_Line_LID27 != 0x01u) && (K_Line_Set.K_Line_LID28 != 0x01u))
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_6);
                    }
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_DOWN);
                    }
hu's avatar
hu committed
430
                }
431 432
                /*保养通知设定 更换机油&机油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
hu's avatar
hu committed
433
                {
hu's avatar
hu committed
434
                    if (User_set_Num.User_FDJYLQQ == 0u)
hu's avatar
hu committed
435
                    {
hu's avatar
hu committed
436
                        User_set_Num.User_FDJYLQQ = (uint32_t)K_Line_Set.K_Line_LID4F * 1000u;
hu's avatar
hu committed
437
                    }
hu's avatar
hu committed
438
                }
439 440
                /*保养通知设定 更换燃油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
hu's avatar
hu committed
441
                {
hu's avatar
hu committed
442
                    if (User_set_Num.User_RYLQQ == 0u)
hu's avatar
hu committed
443
                    {
hu's avatar
hu committed
444
                        User_set_Num.User_RYLQQ = (uint32_t)K_Line_User_RYLQQ * 1000u;
hu's avatar
hu committed
445
                    }
hu's avatar
hu committed
446
                }
447 448
                /*保养通知设定 更换变速箱油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
hu's avatar
hu committed
449
                {
hu's avatar
hu committed
450
                    if (User_set_Num.User_BSXY == 0u)
hu's avatar
hu committed
451
                    {
hu's avatar
hu committed
452
                        User_set_Num.User_BSXY = (uint32_t)K_Line_Set.K_Line_LID4A * 1000u;
hu's avatar
hu committed
453
                    }
hu's avatar
hu committed
454
                }
455 456 457
                /*保养通知设定 更换差速器油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
                {
hu's avatar
hu committed
458
                    if (User_set_Num.User_CSQY == 0u)
hu's avatar
hu committed
459
                    {
hu's avatar
hu committed
460
                        User_set_Num.User_CSQY = (uint32_t)K_Line_Set.K_Line_LID4B * 1000u;
hu's avatar
hu committed
461
                    }
462 463 464 465
                }
                /*保养通知设定 更换动力转向液*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
                {
hu's avatar
hu committed
466
                    if (User_set_Num.User_DLZXY == 0u)
hu's avatar
hu committed
467
                    {
hu's avatar
hu committed
468
                        User_set_Num.User_DLZXY = (uint32_t)K_Line_Set.K_Line_LID4D * 1000u;
hu's avatar
hu committed
469
                    }
470 471 472
                }
                /*保养通知设定 轮胎换位.更换*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
hu's avatar
hu committed
473
                {
hu's avatar
hu committed
474
                    if (User_set_Num.User_LT == 0u)
hu's avatar
hu committed
475
                    {
hu's avatar
hu committed
476
                        User_set_Num.User_LT = (uint32_t)K_Line_Set.K_Line_LID4E * 1000u;
hu's avatar
hu committed
477
                    }
478 479 480 481
                }
                /*设置日期-年*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
                {
hu's avatar
hu committed
482
                    if (User_set_Num.Year > 0u)
hu's avatar
hu committed
483
                    {
484
                        User_set_Num.Year--;
hu's avatar
hu committed
485
                    }
486
                    else
hu's avatar
hu committed
487
                    {
488
                        User_set_Num.Year = 99u;
hu's avatar
hu committed
489
                    }
490 491 492 493 494
                }
                /*设置日期-月*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
                {
                    if (User_set_Num.Month > 1u)
hu's avatar
hu committed
495
                    {
496
                        User_set_Num.Month--;
hu's avatar
hu committed
497 498 499
                    }
                    else
                    {
500
                        User_set_Num.Month = 12u;
hu's avatar
hu committed
501
                    }
502 503 504 505 506 507
                }
                /*设置日期-日*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
                {
                    User_set_Num.Date--;
                    switch (User_set_Num.Month)
hu's avatar
hu committed
508
                    {
509 510 511 512 513 514 515
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
hu's avatar
hu committed
516 517
                        if (User_set_Num.Date < 1u)
                        {
518
                            User_set_Num.Date = 31u;
hu's avatar
hu committed
519
                        }
520 521 522 523 524
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
hu's avatar
hu committed
525 526
                        if (User_set_Num.Date < 1u)
                        {
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
                            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
553
                        }
554 555 556
                        break;
                    default:
                        break;
hu's avatar
hu committed
557 558
                    }
                }
559 560
                /*设置时间-时*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
hu's avatar
hu committed
561
                {
562 563 564 565 566 567
                    if (User_set_Num.Hour > 0u)
                    {
                        User_set_Num.Hour--;
                    }
                    else
                    {
hu's avatar
hu committed
568
                        User_set_Num.Hour = 23u;
569
                    }
hu's avatar
hu committed
570
                }
571 572
                /*设置时间-分*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
hu's avatar
hu committed
573
                {
574 575
                    if (User_set_Num.Minute > 0u)
                    {
hu's avatar
hu committed
576
                        User_set_Num.Minute--;
577 578 579
                    }
                    else
                    {
hu's avatar
hu committed
580
                        User_set_Num.Minute = 59u;
581
                    }
hu's avatar
hu committed
582
                }
583 584
                /*语言设置 ----反*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
hu's avatar
hu committed
585
                {
hu's avatar
hu committed
586 587
                    if (User_set_Num.User_Language < 1)
                        User_set_Num.User_Language++;
hu's avatar
hu committed
588
                }
hu's avatar
hu committed
589 590 591 592 593 594 595 596 597 598 599 600 601 602
                /*胎压匹配界面*/
                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--;
                }
603 604
                /*高速路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
hu's avatar
hu committed
605
                {
606 607 608 609 610 611 612 613
                    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
614
                }
615 616
                /*一般路*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
hu's avatar
hu committed
617
                {
618 619 620 621 622 623 624 625
                    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
626
                }
627 628
                /*发动机转速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
hu's avatar
hu committed
629
                {
630 631 632 633
                    if ((User_set_Num.User_Speed >= 0) && (User_set_Num.User_Speed <= 99))
                    {
                        User_set_Num.User_Speed--;
                    }
hu's avatar
hu committed
634
                }
635 636
                /*急加速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
hu's avatar
hu committed
637
                {
638 639 640 641 642 643 644 645
                    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
646
                }
647 648
                /*急减速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
hu's avatar
hu committed
649
                {
650 651 652 653 654 655 656 657
                    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
658
                }
659 660
                /*长时间怠速*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
hu's avatar
hu committed
661
                {
662 663 664 665
                    if (User_set_Num.User_IDLING == 0u)
                    {
                        User_set_Num.User_IDLING = 0xFFu;
                    }
hu's avatar
hu committed
666
                }
667 668
                /*辅助驻车解除*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
hu's avatar
hu committed
669
                {
670 671 672 673
                    if (User_set_Num.User_Parking == 0u)
                    {
                        User_set_Num.User_Parking = 0xFFu;
                    }
hu's avatar
hu committed
674 675
                }
            }
676
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
677
            {
hu's avatar
hu committed
678
                ; /*D0 Nothing!*/
hu's avatar
hu committed
679
            }
680 681 682 683 684
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
685
            {
hu's avatar
hu committed
686
                ; /*D0 Nothing!*/
hu's avatar
hu committed
687
            }
688
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
689
            {
hu's avatar
hu committed
690
                ; /*D0 Nothing!*/
hu's avatar
hu committed
691
            }
692 693 694 695
        }
    }
    else
    {
696
        /*----有车速,无报警----*/
hu's avatar
hu committed
697
        if (HMI_MENU_Sta != Display_Alarm)
698
        {
699 700
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
701
                ; /*D0 Nothing!*/
702 703 704
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
705
                ; /*D0 Nothing!*/
706 707 708 709 710 711 712
            }
        }
        /*----有车速,有报警----*/
        else
        {
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
713
                ; /*D0 Nothing!*/
714 715 716
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
717
                ; /*D0 Nothing!*/
718
            }
719 720
        }
    }
hu's avatar
hu committed
721 722 723 724 725 726 727 728 729
}
/*******************************ENTER***********************************************
  Function: Key_Operation_Enter
  Description:
  Input:
  Output:
 *******************************ENTER***********************************************/
void Key_Operation_Enter(Key_Event_en_t enKeyEvent)
{
730
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
731
    UElib_uint16_t HMI_MENU_Sta = 0u;
732

733
    HMI_Set_KEY_CONFIRM(enKeyEvent);
hu's avatar
hu committed
734

hu's avatar
hu committed
735 736
    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
737 738 739

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
740
        /*----无车速,无报警----*/
hu's avatar
hu committed
741
        if (HMI_MENU_Sta != Display_Alarm)
742
        {
743
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
744
            {
745
                if (((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
746
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
747
                {
hu's avatar
hu committed
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
                    /*系统演示模式*/
                    if (bCurMenuIDX == _MN_DSP_LEVEL2MENU_5)
                    {
                        if (K_Line_Set.K_Line_LID27 == 0x01u)
                        {
                            NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                        }
                        else
                        {
                            NextMenu(_MN_DSP_LEVEL2_5_MENU_2);
                        }
                    }
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                    }
764 765 766 767 768 769 770 771 772 773
                }
                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
774 775 776 777 778 779
                    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; /*清空取消标记位*/
                    }
780 781 782 783 784 785 786
                }
                /*Go Return*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 1;
                    NextMenu(_MN_DSP_RETURN_MENU);
                }
hu's avatar
hu committed
787
            }
788
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
789
            {
790 791 792
                /*Go Enter*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL3_2_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_2_MENU_8))
                {
hu's avatar
hu committed
793
                    MenuFlag.Menu_Enter_Return = bCurMenuIDX;
794 795
                    NextMenu(_MN_DSP_ENTER_MENU);
                }
796 797
            }
        }
798
        else
hu's avatar
hu committed
799
        {
800 801 802
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
803
                ; /*D0 Nothing!*/
804 805
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
806
            {
hu's avatar
hu committed
807
                ; /*D0 Nothing!*/
hu's avatar
hu committed
808 809
            }
        }
810 811 812
    }
    else
    {
813
        /*----有车速,无报警----*/
hu's avatar
hu committed
814
        if (HMI_MENU_Sta != Display_Alarm)
815
        {
816 817
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
818
                ; /*D0 Nothing!*/
819 820 821
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
822
                ; /*D0 Nothing!*/
823
            }
824
        }
825 826
        /*----有车速,有报警----*/
        else
hu's avatar
hu committed
827
        {
828 829
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
830
                ; /*D0 Nothing!*/
831 832 833
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
834
                ; /*D0 Nothing!*/
835
            }
hu's avatar
hu committed
836
        }
837
    }
hu's avatar
hu committed
838 839 840 841 842 843 844 845 846 847
}

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

851
    HMI_Set_KEY_CANCEL(enKeyEvent);
hu's avatar
hu committed
852 853 854

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
855 856 857

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
858
        /*----无车速,无报警----*/
hu's avatar
hu committed
859
        if (HMI_MENU_Sta != Display_Alarm)
860
        {
861
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
862
            {
863
                if ((bCurMenuIDX >= _MN_DSP_LEVEL2_1_MENU_1) && (bCurMenuIDX < _MN_DSP_ENTER_MENU))
hu's avatar
hu committed
864
                {
865
                    if (
hu's avatar
hu committed
866
                        (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3) ||                                              /*语言设定*/
867
                        (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1) ||                                              /*亮度调节*/
hu's avatar
hu committed
868
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)) /*省油设定子菜单*/
869
                    )
hu's avatar
hu committed
870
                    {
871
                        MenuFlag.Menu_Return = 0u;
hu's avatar
hu committed
872 873
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
874
                    else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5) /*胎压设置界面返回操作*/
hu's avatar
hu committed
875
                    {
876
                        if (User_set_Num.User_TpmsStatus != 2u) /*不是正在匹配状态*/
hu's avatar
hu committed
877
                        {
878
                            NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
hu's avatar
hu committed
879 880 881
                        }
                        else
                        {
882 883
                            User_set_Num.User_TpmsStatus = 1u; /*退出匹配界面*/
                            if (User_set_Num.User_Temp_Return == 0u)
884
                            {
885 886
                                User_set_Num.User_Temp_Return = 1u; /*取消配对标记*/
                                User_set_Num.User_TpmsSend   = 3u;  /*报文外发状态*/
887 888 889 890 891
                            }
                            else
                            {
                                ; /* do nonthing*/
                            }
hu's avatar
hu committed
892 893
                        }
                    }
894 895 896 897
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
898
                }
899 900
                /*系统演示模式*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
901
                {
902
                    MenuFlag.Menu_Return = 0;
903 904
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
905 906 907 908 909 910 911 912
                /*Enter Go*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 0;
                    NextMenu(MenuFlag.Menu_Enter_Return);
                }
                else
                {
hu's avatar
hu committed
913
                    ; /*do nothing*/
914
                }
915
            }
916
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
917
            {
hu's avatar
hu committed
918
                ; /*D0 Nothing!*/
919
            }
920 921 922 923 924
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
925
            {
hu's avatar
hu committed
926
                ; /*Do Nothing!*/
927
            }
928
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
929
            {
930
                MenuFlag.Key_Menu_Popup_time = 6000u;
931 932 933 934 935
            }
        }
    }
    else
    {
hu's avatar
hu committed
936
        if (HMI_MENU_Sta != Display_Alarm)
937
        {
938 939 940
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
941
                ; /*Do Nothing!*/
942 943 944
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
945
                ; /*Do Nothing!*/
946 947 948 949 950 951 952
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
953
                ; /*Do Nothing!*/
954 955 956 957 958
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
                MenuFlag.Key_Menu_Popup_time = 6000u;
            }
959 960
        }
    }
hu's avatar
hu committed
961 962 963 964 965 966 967 968 969 970
}

/*******************************Menu***********************************************
  Function: Key_Operation_Menu
  Description:
  Input:
  Output:
 *******************************Menu***********************************************/
void Key_Operation_Menu(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
971
    uint8_t CanStatus1 = 0u;
972
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
973
    UElib_uint16_t HMI_MENU_Sta = 0u;
hu's avatar
hu committed
974

975
    HMI_Set_KEY_MENU(enKeyEvent);
hu's avatar
hu committed
976 977 978

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

hu's avatar
hu committed
980 981
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);

982 983
    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
984
        /*----无车速,无报警----*/
hu's avatar
hu committed
985
        if (HMI_MENU_Sta != Display_Alarm)
986
        {
987
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
988
            {
989 990
                /*记录进入menu菜单的位置*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL1MENU_6))
991
                {
hu's avatar
hu committed
992
                    MenuFlag.Menu_Flag = bCurMenuIDX;
993 994 995 996 997 998 999 1000 1001 1002 1003

                    /*有故障码*/
                    if (CanStatus1 == CAN_SIG_LOST)
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_1);
                    }
                    /*无故障码*/
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                    }
1004
                }
1005 1006
                /*无论从哪里都能回去*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_RETURN_MENU))
1007
                {
hu's avatar
hu committed
1008
                    // if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_A) /*胎压设置界面*/
1009
                    //{
hu's avatar
hu committed
1010 1011 1012
                    //     NextMenu(_MN_DSP_LEVEL2MENU_4);           /*menu回到用户设置界面*/
                    // }
                    // else
1013 1014 1015
                    {
                        NextMenu(MenuFlag.Menu_Flag);
                    }
1016
                }
1017
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
hu's avatar
hu committed
1018 1019 1020 1021
                {
                    NextMenu(MenuFlag.Menu_Flag);
                }
            }
1022
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
1023
            {
hu's avatar
hu committed
1024
                ; /*Do Nothing!*/
1025 1026 1027 1028 1029 1030 1031
            }
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1032
                ; /*Do Nothing!*/
1033 1034 1035
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1036
                ; /*Do Nothing!*/
1037
            }
1038 1039 1040 1041
        }
    }
    else
    {
hu's avatar
hu committed
1042
        if (HMI_MENU_Sta != Display_Alarm)
1043
        {
1044 1045 1046
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1047
                ; /*Do Nothing!*/
1048 1049 1050
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1051
                ; /*Do Nothing!*/
1052 1053 1054 1055 1056 1057 1058
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1059
                ; /*Do Nothing!*/
1060 1061 1062
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1063
                ; /*Do Nothing!*/
1064
            }
1065 1066
        }
    }
hu's avatar
hu committed
1067 1068
}

hu's avatar
hu committed
1069 1070 1071 1072
uint8_t Common_Get_RetMenu_Flag(void)
{
    return MenuFlag.Menu_Flag;
}
hu's avatar
hu committed
1073 1074 1075 1076 1077
/*------------读按键实时状态的回调函数-------------------------------------------*/
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
1078
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void);
hu's avatar
hu committed
1079 1080
/*-------------------------------------------------*/

hu's avatar
hu committed
1081 1082 1083 1084 1085
// 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
1086

hu's avatar
hu committed
1087 1088 1089 1090 1091
// 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
1092 1093

//实际按键测试
1094
//无操作     21000~24000Ω
hu's avatar
hu committed
1095 1096 1097 1098 1099
// Menu_R        640~680Ω
// Enter_R       5300~5700Ω
// Return_R      9000~9500Ω
// Up_R          1300~1400Ω
// Down_R        3000~3200Ω
1100 1101 1102

/*上*/
Key_Real_Status_en_t Key_Real_Status_Read_Up(void)
hu's avatar
hu committed
1103 1104 1105
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1106 1107 1108 1109 1110 1111 1112 1113 1114

    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
1115
        if ((Key_R >= (1250 - 400)) && (Key_R <= (1250 + 400)))
1116 1117 1118 1119 1120 1121 1122 1123
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1124 1125 1126 1127

    return enKeyRealStatus;
}

1128 1129
/*下*/
Key_Real_Status_en_t Key_Real_Status_Read_Down(void)
hu's avatar
hu committed
1130 1131 1132
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1133 1134 1135 1136 1137 1138 1139 1140 1141

    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
1142
        if ((Key_R >= (2900 - 400)) && (Key_R <= (2900 + 400)))
1143 1144 1145 1146 1147 1148 1149 1150 1151
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }

hu's avatar
hu committed
1152 1153 1154
    return enKeyRealStatus;
}

1155 1156
/*Enter*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void)
hu's avatar
hu committed
1157 1158 1159 1160
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;

1161 1162 1163 1164 1165 1166 1167 1168
    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
1169
        if ((Key_R >= (4800 - 400)) && (Key_R <= (4800 + 400)))
1170 1171 1172 1173 1174 1175 1176 1177
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1178 1179 1180
    return enKeyRealStatus;
}

1181 1182
/*Return*/
Key_Real_Status_en_t Key_Real_Status_Read_Return(void)
hu's avatar
hu committed
1183 1184 1185
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1186 1187 1188 1189 1190 1191 1192 1193 1194

    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
1195
        if ((Key_R >= (7800 - 400)) && (Key_R <= (7800 + 400)))
1196 1197 1198 1199 1200 1201 1202 1203
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1204 1205 1206 1207

    return enKeyRealStatus;
}

1208 1209
/*Menu*/
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void)
hu's avatar
hu committed
1210 1211 1212
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1213 1214 1215 1216 1217 1218 1219 1220 1221

    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
1222
        if ((Key_R >= (500 - 300)) && (Key_R <= (500 + 300)))
1223 1224 1225 1226 1227 1228 1229 1230
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1231 1232 1233 1234 1235 1236

    return enKeyRealStatus;
}

/*---------------------------------------------------------------------------------------*/
const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] =
1237 1238 1239 1240 1241 1242
{
    {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
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
};

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