Key_user.c 42.2 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
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL2_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_5_MENU_4))
hu's avatar
hu committed
87
                {
88
                    if ((K_Line_Set.K_Line_LID27 != 0x01u) && (bCurMenuIDX == _MN_DSP_LEVEL2_5_MENU_2))
hu's avatar
hu committed
89
                    {
90
                        ; /*Do Nothing!*/
hu's avatar
hu committed
91 92 93
                    }
                    else
                    {
94 95
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_UP);
                    }
hu's avatar
hu committed
96
                }
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
                /*背光调节*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1)
                {
                    if (User_set_Num.User_Light1 < 16u)
                    {
                        User_set_Num.User_Light1++;
                    }
                }
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_2)
                {
                    if (User_set_Num.User_Light2 < 16u)
                    {
                        User_set_Num.User_Light2++;
                    }
                }
112 113
                /*保养通知设定 更换机油&机油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
hu's avatar
hu committed
114
                {
115
                    if (User_set_Num.User_FDJYLQQ == (uint32_t)K_Line_Set.K_Line_LID4F * 1000u)
hu's avatar
hu committed
116
                    {
hu's avatar
hu committed
117
                        User_set_Num.User_FDJYLQQ = 0u;
hu's avatar
hu committed
118
                    }
hu's avatar
hu committed
119
                }
120 121
                /*保养通知设定 更换燃油滤清器*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
hu's avatar
hu committed
122
                {
123
                    if (User_set_Num.User_RYLQQ == (uint32_t)K_Line_User_RYLQQ * 1000u)
hu's avatar
hu committed
124
                    {
hu's avatar
hu committed
125
                        User_set_Num.User_RYLQQ = 0u;
hu's avatar
hu committed
126
                    }
hu's avatar
hu committed
127
                }
128 129
                /*保养通知设定 更换变速箱油*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
hu's avatar
hu committed
130
                {
131
                    if (User_set_Num.User_BSXY == (uint32_t)K_Line_Set.K_Line_LID4A * 1000u)
hu's avatar
hu committed
132
                    {
133
                        User_set_Num.User_BSXY = 0u;
hu's avatar
hu committed
134
                    }
hu's avatar
hu committed
135
                }
136 137
                /*保养通知设定 更换差速器右*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
hu's avatar
hu committed
138
                {
139
                    if (User_set_Num.User_CSQY == (uint32_t)K_Line_Set.K_Line_LID4B * 1000u)
hu's avatar
hu committed
140
                    {
hu's avatar
hu committed
141
                        User_set_Num.User_CSQY = 0u;
hu's avatar
hu committed
142
                    }
143 144 145 146 147
                }
                /*保养通知设定 更换动力转向油*/
                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
148
                    {
hu's avatar
hu committed
149
                        User_set_Num.User_DLZXY = 0u;
hu's avatar
hu committed
150
                    }
151 152 153 154 155
                }
                /*保养通知设定 轮胎换位.更换*/
                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
156
                    {
hu's avatar
hu committed
157
                        User_set_Num.User_LT = 0u;
hu's avatar
hu committed
158
                    }
159 160 161 162
                }
                /*设置日期-年*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
                {
hu's avatar
hu committed
163
                    User_set_Num.Year++;
164

hu's avatar
hu committed
165
                    if (User_set_Num.Year > 99u)
hu's avatar
hu committed
166
                    {
167
                        User_set_Num.Year = 0u;
hu's avatar
hu committed
168
                    }
169 170 171 172 173 174 175
                }
                /*设置日期-月*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
                {
                    User_set_Num.Month++;

                    if (User_set_Num.Month > 12u)
hu's avatar
hu committed
176
                    {
177
                        User_set_Num.Month = 1u;
hu's avatar
hu committed
178
                    }
179 180 181 182 183
                }
                /*设置日期-日*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
                {
                    User_set_Num.Date++;
hu's avatar
hu committed
184

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

242 243
                    if (User_set_Num.Hour > 23u)
                    {
hu's avatar
hu committed
244
                        User_set_Num.Hour = 0u;
245
                    }
hu's avatar
hu committed
246
                }
247 248
                /*设置时间-分*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
hu's avatar
hu committed
249
                {
250 251 252 253
                    User_set_Num.Minute++;

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

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

412
    HMI_Set_KEY_DOWN(enKeyEvent);
hu's avatar
hu committed
413 414 415

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
416 417 418

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

767
    HMI_Set_KEY_CONFIRM(enKeyEvent);
hu's avatar
hu committed
768

hu's avatar
hu committed
769 770
    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
771 772 773

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
774
        /*----无车速,无报警----*/
hu's avatar
hu committed
775
        if (HMI_MENU_Sta != Display_Alarm)
776
        {
777
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
hu's avatar
hu committed
778
            {
779
                if (((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_5_MENU_4)) ||
780
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
781
                {
hu's avatar
hu committed
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
                    /*系统演示模式*/
                    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);
                    }
798 799 800 801 802 803 804
                }
                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);
                }
805 806 807 808 809
                /*背光调节*/
                else if ((bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1) || (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_2))
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                }
810 811 812
                /*轮胎匹配界面*/
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
                {
hu's avatar
hu committed
813 814 815 816 817 818
                    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; /*清空取消标记位*/
                    }
819 820 821 822 823 824 825
                }
                /*Go Return*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 1;
                    NextMenu(_MN_DSP_RETURN_MENU);
                }
hu's avatar
hu committed
826
            }
827
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
828
            {
829 830 831
                /*Go Enter*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL3_2_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_2_MENU_8))
                {
hu's avatar
hu committed
832
                    MenuFlag.Menu_Enter_Return = bCurMenuIDX;
833 834
                    NextMenu(_MN_DSP_ENTER_MENU);
                }
835 836
            }
        }
837
        else
hu's avatar
hu committed
838
        {
839 840 841
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
842
                ; /*D0 Nothing!*/
843 844
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
hu's avatar
hu committed
845
            {
hu's avatar
hu committed
846
                ; /*D0 Nothing!*/
hu's avatar
hu committed
847 848
            }
        }
849 850 851
    }
    else
    {
852
        /*----有车速,无报警----*/
hu's avatar
hu committed
853
        if (HMI_MENU_Sta != Display_Alarm)
854
        {
855 856
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
857
                ; /*D0 Nothing!*/
858 859 860
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
861
                ; /*D0 Nothing!*/
862
            }
863
        }
864 865
        /*----有车速,有报警----*/
        else
hu's avatar
hu committed
866
        {
867 868
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
869
                ; /*D0 Nothing!*/
870 871 872
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
873
                ; /*D0 Nothing!*/
874
            }
hu's avatar
hu committed
875
        }
876
    }
hu's avatar
hu committed
877 878 879 880 881 882 883 884 885 886
}

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

890
    HMI_Set_KEY_CANCEL(enKeyEvent);
hu's avatar
hu committed
891 892 893

    HMI_MENU_Sta = Get_Cur_HMI();
    DispVSpeed = Common_Get_Disp_V_Speed();
894 895 896

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
897
        /*----无车速,无报警----*/
hu's avatar
hu committed
898
        if (HMI_MENU_Sta != Display_Alarm)
899
        {
900
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
901
            {
902
                if ((bCurMenuIDX >= _MN_DSP_LEVEL2_1_MENU_1) && (bCurMenuIDX < _MN_DSP_ENTER_MENU))
hu's avatar
hu committed
903
                {
904
                    if (
hu's avatar
hu committed
905
                        (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3) ||                                              /*语言设定*/
906
                        (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1) ||                                              /*亮度调节*/
hu's avatar
hu committed
907
                        ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)) /*省油设定子菜单*/
908
                    )
hu's avatar
hu committed
909
                    {
910
                        MenuFlag.Menu_Return = 0u;
hu's avatar
hu committed
911 912
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
913
                    else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5) /*胎压设置界面返回操作*/
hu's avatar
hu committed
914
                    {
915
                        if (User_set_Num.User_TpmsStatus != 2u) /*不是正在匹配状态*/
hu's avatar
hu committed
916
                        {
917
                            NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
hu's avatar
hu committed
918 919 920
                        }
                        else
                        {
921 922
                            User_set_Num.User_TpmsStatus = 1u; /*退出匹配界面*/
                            if (User_set_Num.User_Temp_Return == 0u)
923
                            {
924 925
                                User_set_Num.User_Temp_Return = 1u; /*取消配对标记*/
                                User_set_Num.User_TpmsSend   = 3u;  /*报文外发状态*/
926 927 928 929 930
                            }
                            else
                            {
                                ; /* do nonthing*/
                            }
hu's avatar
hu committed
931 932
                        }
                    }
933 934 935 936
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
hu's avatar
hu committed
937
                }
938 939
                /*系统演示模式*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
940
                {
941
                    MenuFlag.Menu_Return = 0;
942 943
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
944 945 946 947 948 949 950 951
                /*Enter Go*/
                else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
                {
                    MenuFlag.Menu_Return = 0;
                    NextMenu(MenuFlag.Menu_Enter_Return);
                }
                else
                {
hu's avatar
hu committed
952
                    ; /*do nothing*/
953
                }
954
            }
955
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
956
            {
hu's avatar
hu committed
957
                ; /*D0 Nothing!*/
958
            }
959 960 961 962 963
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
964
            {
hu's avatar
hu committed
965
                ; /*Do Nothing!*/
966
            }
967
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
968
            {
969
                MenuFlag.Key_Menu_Popup_time = 6000u;
970 971 972 973 974
            }
        }
    }
    else
    {
hu's avatar
hu committed
975
        if (HMI_MENU_Sta != Display_Alarm)
976
        {
977 978 979
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
980
                ; /*Do Nothing!*/
981 982 983
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
984
                ; /*Do Nothing!*/
985 986 987 988 989 990 991
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
992
                ; /*Do Nothing!*/
993 994 995 996 997
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
                MenuFlag.Key_Menu_Popup_time = 6000u;
            }
998 999
        }
    }
hu's avatar
hu committed
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
}

/*******************************Menu***********************************************
  Function: Key_Operation_Menu
  Description:
  Input:
  Output:
 *******************************Menu***********************************************/
void Key_Operation_Menu(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
1010
    uint8_t CanStatus1 = 0u;
1011
    uint16_t DispVSpeed = 0u;
hu's avatar
hu committed
1012
    UElib_uint16_t HMI_MENU_Sta = 0u;
hu's avatar
hu committed
1013

1014
    HMI_Set_KEY_MENU(enKeyEvent);
hu's avatar
hu committed
1015 1016 1017

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

hu's avatar
hu committed
1019 1020
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);

1021 1022
    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
1023
        /*----无车速,无报警----*/
hu's avatar
hu committed
1024
        if (HMI_MENU_Sta != Display_Alarm)
1025
        {
1026
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
1027
            {
1028 1029
                /*记录进入menu菜单的位置*/
                if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL1MENU_6))
1030
                {
hu's avatar
hu committed
1031
                    MenuFlag.Menu_Flag = bCurMenuIDX;
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042

                    /*有故障码*/
                    if (CanStatus1 == CAN_SIG_LOST)
                    {
                        NextMenu(_MN_DSP_LEVEL2MENU_1);
                    }
                    /*无故障码*/
                    else
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                    }
1043
                }
1044 1045
                /*无论从哪里都能回去*/
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_RETURN_MENU))
1046
                {
hu's avatar
hu committed
1047
                    // if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_A) /*胎压设置界面*/
1048
                    //{
hu's avatar
hu committed
1049 1050 1051
                    //     NextMenu(_MN_DSP_LEVEL2MENU_4);           /*menu回到用户设置界面*/
                    // }
                    // else
1052 1053 1054
                    {
                        NextMenu(MenuFlag.Menu_Flag);
                    }
1055
                }
1056
                else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
hu's avatar
hu committed
1057 1058 1059 1060
                {
                    NextMenu(MenuFlag.Menu_Flag);
                }
            }
1061
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
1062
            {
hu's avatar
hu committed
1063
                ; /*Do Nothing!*/
1064 1065 1066 1067 1068 1069 1070
            }
        }
        else
        {
            /*----无车速,有报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1071
                ; /*Do Nothing!*/
1072 1073 1074
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1075
                ; /*Do Nothing!*/
1076
            }
1077 1078 1079 1080
        }
    }
    else
    {
hu's avatar
hu committed
1081
        if (HMI_MENU_Sta != Display_Alarm)
1082
        {
1083 1084 1085
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1086
                ; /*Do Nothing!*/
1087 1088 1089
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1090
                ; /*Do Nothing!*/
1091 1092 1093 1094 1095 1096 1097
            }
        }
        else
        {
            /*----有车速,无报警----*/
            if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
            {
hu's avatar
hu committed
1098
                ; /*Do Nothing!*/
1099 1100 1101
            }
            else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
            {
hu's avatar
hu committed
1102
                ; /*Do Nothing!*/
1103
            }
1104 1105
        }
    }
hu's avatar
hu committed
1106 1107
}

hu's avatar
hu committed
1108 1109 1110 1111
uint8_t Common_Get_RetMenu_Flag(void)
{
    return MenuFlag.Menu_Flag;
}
hu's avatar
hu committed
1112 1113 1114 1115 1116
/*------------读按键实时状态的回调函数-------------------------------------------*/
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
1117
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void);
hu's avatar
hu committed
1118 1119
/*-------------------------------------------------*/

hu's avatar
hu committed
1120 1121 1122 1123 1124
// 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
1125

hu's avatar
hu committed
1126 1127 1128 1129 1130
// 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
1131 1132

//实际按键测试
1133
//无操作     21000~24000Ω
hu's avatar
hu committed
1134 1135 1136 1137 1138
// Menu_R        640~680Ω
// Enter_R       5300~5700Ω
// Return_R      9000~9500Ω
// Up_R          1300~1400Ω
// Down_R        3000~3200Ω
1139 1140 1141

/*上*/
Key_Real_Status_en_t Key_Real_Status_Read_Up(void)
hu's avatar
hu committed
1142 1143 1144
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1145 1146 1147 1148 1149 1150 1151 1152 1153

    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
1154
        if ((Key_R >= (1250 - 400)) && (Key_R <= (1250 + 400)))
1155 1156 1157 1158 1159 1160 1161 1162
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1163 1164 1165 1166

    return enKeyRealStatus;
}

1167 1168
/*下*/
Key_Real_Status_en_t Key_Real_Status_Read_Down(void)
hu's avatar
hu committed
1169 1170 1171
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1172 1173 1174 1175 1176 1177 1178 1179 1180

    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
1181
        if ((Key_R >= (2900 - 400)) && (Key_R <= (2900 + 400)))
1182 1183 1184 1185 1186 1187 1188 1189 1190
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }

hu's avatar
hu committed
1191 1192 1193
    return enKeyRealStatus;
}

1194 1195
/*Enter*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void)
hu's avatar
hu committed
1196 1197 1198 1199
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;

1200 1201 1202 1203 1204 1205 1206 1207
    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
1208
        if ((Key_R >= (4800 - 400)) && (Key_R <= (4800 + 400)))
1209 1210 1211 1212 1213 1214 1215 1216
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1217 1218 1219
    return enKeyRealStatus;
}

1220 1221
/*Return*/
Key_Real_Status_en_t Key_Real_Status_Read_Return(void)
hu's avatar
hu committed
1222 1223 1224
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1225 1226 1227 1228 1229 1230 1231 1232 1233

    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
1234
        if ((Key_R >= (7800 - 400)) && (Key_R <= (7800 + 400)))
1235 1236 1237 1238 1239 1240 1241 1242
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1243 1244 1245 1246

    return enKeyRealStatus;
}

1247 1248
/*Menu*/
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void)
hu's avatar
hu committed
1249 1250 1251
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
1252 1253 1254 1255 1256 1257 1258 1259 1260

    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
1261
        if ((Key_R >= (500 - 300)) && (Key_R <= (500 + 300)))
1262 1263 1264 1265 1266 1267 1268 1269
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
1270 1271 1272 1273 1274 1275

    return enKeyRealStatus;
}

/*---------------------------------------------------------------------------------------*/
const Key_Attribute_st_t stKeyAttribute[KEY_NUM_MAX] =
1276 1277 1278 1279 1280 1281
{
    {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
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
};

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