Key_user.c 29.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 7 8 9

#include "DisplaySch_user.h"
#include "Sound_Scheduler.h"
#include "System_Monitor.h"
#include "RTE_ADC.h"
10
#include "Popup_Scheduler.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 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 29
/*----------按键具体功能执行的回调函数-----------------------*/


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

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

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

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

    popupID = Popup_Get_Current_Message( );
54
    HMI_Set_KEY_UP(enKeyEvent);
hu's avatar
hu committed
55

56
    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
        if ((enKeyEvent == KEY_EVENT_SHORT_PRESS) && (popupID == 0xffffu ))
62
        {
hu's avatar
hu committed
63
            /*主界面 一级菜单 二级菜单那*/
hu's avatar
hu committed
64 65
            if (((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
hu's avatar
hu committed
66
            {
hu's avatar
hu committed
67
                /*故障码*/
hu's avatar
hu committed
68
                if ((CanStatus1 == CAN_SIG_LOST) && (bCurMenuIDX == _MN_DSP_LEVEL2MENU_2))
hu's avatar
hu committed
69
                {
hu's avatar
hu committed
70
                    NextMenu(_MN_DSP_LEVEL2MENU_1);
hu's avatar
hu committed
71 72 73 74 75 76
                }
                else
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_UP);
                }
            }
hu's avatar
hu committed
77 78 79
            /*保养通知设定 更换机油&机油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
            {
hu's avatar
hu committed
80 81
                if (User_set_Num.User_FDJYLQQ == (uint32_t)K_Line_Set.K_Line_LID4F * 1000u)
                    User_set_Num.User_FDJYLQQ = 0u ;
hu's avatar
hu committed
82 83 84 85
            }
            /*保养通知设定 更换燃油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
            {
hu's avatar
hu committed
86 87
                if (User_set_Num.User_RYLQQ == (uint32_t)K_Line_User_RYLQQ * 1000u)
                    User_set_Num.User_RYLQQ = 0u ;
hu's avatar
hu committed
88 89 90 91
            }
            /*保养通知设定 更换变速箱油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
            {
hu's avatar
hu committed
92 93
                if (User_set_Num.User_BSXY == (uint32_t)K_Line_Set.K_Line_LID4A * 1000u)
                    User_set_Num.User_BSXY = 0u;
hu's avatar
hu committed
94 95 96 97
            }
            /*保养通知设定 更换差速器右*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
            {
hu's avatar
hu committed
98 99
                if (User_set_Num.User_CSQY == (uint32_t)K_Line_Set.K_Line_LID4B * 1000u)
                    User_set_Num.User_CSQY = 0u ;
hu's avatar
hu committed
100 101 102 103
            }
            /*保养通知设定 更换动力转向油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
            {
hu's avatar
hu committed
104 105
                if (User_set_Num.User_DLZXY == (uint32_t)K_Line_Set.K_Line_LID4D * 1000u)
                    User_set_Num.User_DLZXY = 0u ;
hu's avatar
hu committed
106 107 108 109
            }
            /*保养通知设定 轮胎换位.更换*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
            {
hu's avatar
hu committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
                if (User_set_Num.User_LT == (uint32_t)K_Line_Set.K_Line_LID4E * 1000u)
                    User_set_Num.User_LT = 0u ;
            }
            /*设置日期-年*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
            {
                User_set_Num.Year ++;

                if ( User_set_Num.Year > 99u)
                {
                    User_set_Num.Year = 0u;
                }
            }
            /*设置日期-月*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
            {
                User_set_Num.Month++;

                if (User_set_Num.Month > 12u)
                {
                    User_set_Num.Month = 1u;
                }
            }
            /*设置日期-日*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
            {
                User_set_Num.Date++;

                switch (User_set_Num.Month)
                {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    if (User_set_Num.Date > 31u)
                    {
                        User_set_Num.Date = 1u;
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    if (User_set_Num.Date > 30u)
                    {
                        User_set_Num.Date = 1u;
                    }
                    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;
                }
            }
            /*设置时间-时*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
            {
                User_set_Num.Hour++ ;

                if (User_set_Num.Hour > 23u)
                {
                    User_set_Num.Hour = 0u ;
                }
            }
            /*设置时间-分*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
            {
                User_set_Num.Minute++;

                if (User_set_Num.Minute > 59u)
                {
                    User_set_Num.Minute = 0u ;
                }
hu's avatar
hu committed
209 210 211 212
            }
            /*语言设置 ----反*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
            {
hu's avatar
hu committed
213
                if (User_set_Num.User_Language > 0u)
hu's avatar
hu committed
214
                {
hu's avatar
hu committed
215
                    User_set_Num.User_Language-- ;
hu's avatar
hu committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
                }
            }
            /*高速路*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
            {
                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;
                }
            }
            /*一般路*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
            {
                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;
                }
            }
            /*发动机转速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
            {
                if (User_set_Num.User_Speed < 99)
                {
                    User_set_Num.User_Speed ++;
                }
                else if (User_set_Num.User_Speed == 0xFF)
                {
                    User_set_Num.User_Speed = 0;
                }
            }
            /*急加速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
            {
                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;
                }
            }
            /*急减速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
            {
                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;
                }
            }
            /*长时间怠速设定*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
            {
                if (User_set_Num.User_IDLING == 0xFFu)
                {
                    User_set_Num.User_IDLING = 0u;
                }
            }
            /*辅助驻车解除设定*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
            {
                if (User_set_Num.User_Parking  == 0xFFu)
                {
                    User_set_Num.User_Parking = 0u;
                }
hu's avatar
hu committed
293 294
            }

295 296 297 298 299 300 301 302
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
303 304 305 306 307 308 309 310 311 312
}

/*******************************DOWN***********************************************
  Function: Key_Operation_Down
  Description:
  Input:
  Output:
 *******************************DOWN***********************************************/
void Key_Operation_Down(Key_Event_en_t enKeyEvent)
{
313
    uint16_t DispVSpeed = 0u;
314 315 316
    uint16_t popupID = 0U;

    popupID = Popup_Get_Current_Message( );
317 318 319 320 321
    HMI_Set_KEY_DOWN(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
322
        if ((enKeyEvent == KEY_EVENT_SHORT_PRESS) && (popupID == 0xffffu ))
323
        {
hu's avatar
hu committed
324
            /*主界面 一级菜单 二级菜单*/
hu's avatar
hu committed
325 326
            if (((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
327 328 329
            {
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_DOWN);
            }
hu's avatar
hu committed
330 331 332
            /*保养通知设定 更换机油&机油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_1)
            {
hu's avatar
hu committed
333 334
                if (User_set_Num.User_FDJYLQQ == 0u )
                    User_set_Num.User_FDJYLQQ = (uint32_t)K_Line_Set.K_Line_LID4F * 1000u ;
hu's avatar
hu committed
335 336 337 338
            }
            /*保养通知设定 更换燃油滤清器*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_2)
            {
hu's avatar
hu committed
339 340
                if (User_set_Num.User_RYLQQ == 0u )
                    User_set_Num.User_RYLQQ = (uint32_t)K_Line_User_RYLQQ * 1000u ;
hu's avatar
hu committed
341 342 343 344
            }
            /*保养通知设定 更换变速箱油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_3)
            {
hu's avatar
hu committed
345 346
                if (User_set_Num.User_BSXY == 0u )
                    User_set_Num.User_BSXY = (uint32_t)K_Line_Set.K_Line_LID4A * 1000u ;
hu's avatar
hu committed
347 348 349 350
            }
            /*保养通知设定 更换差速器油*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_4)
            {
hu's avatar
hu committed
351 352
                if (User_set_Num.User_CSQY == 0u )
                    User_set_Num.User_CSQY = (uint32_t)K_Line_Set.K_Line_LID4B * 1000u ;
hu's avatar
hu committed
353 354 355 356
            }
            /*保养通知设定 更换动力转向液*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_6)
            {
hu's avatar
hu committed
357 358
                if (User_set_Num.User_DLZXY == 0u )
                    User_set_Num.User_DLZXY = (uint32_t)K_Line_Set.K_Line_LID4D * 1000u ;
hu's avatar
hu committed
359 360 361 362
            }
            /*保养通知设定 轮胎换位.更换*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_3_MENU_7)
            {
hu's avatar
hu committed
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
                if (User_set_Num.User_LT == 0u )
                    User_set_Num.User_LT = (uint32_t)K_Line_Set.K_Line_LID4E * 1000u ;
            }
            /*设置日期-年*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_11)
            {
                if ( User_set_Num.Year > 0u)
                {
                    User_set_Num.Year--;
                }
                else
                {
                    User_set_Num.Year = 99u;
                }
            }
            /*设置日期-月*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_12)
            {
                if (User_set_Num.Month > 1u)
                {
                    User_set_Num.Month--;
                }
                else
                {
                    User_set_Num.Month = 12u;
                }
            }
            /*设置日期-日*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_13)
            {
                User_set_Num.Date--;
                switch (User_set_Num.Month)
                {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    if (User_set_Num.Date < 1u)
                    {
                        User_set_Num.Date = 31u;
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    if (User_set_Num.Date < 1u)
                    {
                        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;
                        }
                    }
                    break;
                default:
                    break;
                }
            }
            /*设置时间-时*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_21)
            {
                if (User_set_Num.Hour > 0u)
                {
                    User_set_Num.Hour--;
                }
                else
                {
                    User_set_Num.Hour = 23u ;
                }
            }
            /*设置时间-分*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_22)
            {
                if (User_set_Num.Minute > 0u)
                {
                    User_set_Num.Minute-- ;
                }
                else
                {
                    User_set_Num.Minute = 59u ;
                }
hu's avatar
hu committed
469 470 471 472
            }
            /*语言设置 ----反*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3)
            {
hu's avatar
hu committed
473
                if (User_set_Num.User_Language < 1 )
hu's avatar
hu committed
474 475
                    User_set_Num.User_Language++ ;
            }
hu's avatar
hu committed
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
            /*高速路*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_1)
            {
                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;
                }
            }
            /*一般路*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_2)
            {
                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;
                }
            }
            /*发动机转速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_3)
            {
                if ((User_set_Num.User_Speed >= 0) && (User_set_Num.User_Speed <= 99))
                {
                    User_set_Num.User_Speed--;
                }
            }
            /*急加速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_4)
            {
                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;
                }
            }
            /*急减速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_5)
            {
                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;
                }
            }
            /*长时间怠速*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_6)
            {
                if (User_set_Num.User_IDLING == 0u)
                {
                    User_set_Num.User_IDLING = 0xFFu;
                }
            }
            /*辅助驻车解除*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL4_4_MENU_7)
            {
                if (User_set_Num.User_Parking == 0u)
                {
                    User_set_Num.User_Parking = 0xFFu;
                }
            }
548 549 550 551 552 553 554 555
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
556 557 558 559 560 561 562 563 564
}
/*******************************ENTER***********************************************
  Function: Key_Operation_Enter
  Description:
  Input:
  Output:
 *******************************ENTER***********************************************/
void Key_Operation_Enter(Key_Event_en_t enKeyEvent)
{
565
    uint16_t DispVSpeed = 0u;
566 567 568
    uint16_t popupID = 0U;

    popupID = Popup_Get_Current_Message( );
569
    HMI_Set_KEY_CONFIRM(enKeyEvent);
hu's avatar
hu committed
570

571 572 573 574
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
575
        if ((enKeyEvent == KEY_EVENT_SHORT_PRESS) && (popupID == 0xffffu ))
576
        {
hu's avatar
hu committed
577
            if (((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL2_6_MENU_2)) ||
hu's avatar
hu committed
578
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47)))
hu's avatar
hu committed
579
            {
hu's avatar
hu committed
580
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
hu's avatar
hu committed
581
            }
hu's avatar
hu committed
582
            else if (((bCurMenuIDX >= _MN_DSP_LEVEL3_3_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_3)) ||
hu's avatar
hu committed
583
                     ((bCurMenuIDX >= _MN_DSP_LEVEL4_4_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL4_4_MENU_7)))
584
            {
hu's avatar
hu committed
585
                MenuFlag.Menu_Return = 1u;
hu's avatar
hu committed
586
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
hu's avatar
hu committed
587 588 589 590 591
            }
            /*轮胎匹配界面*/
            else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5)
            {

hu's avatar
hu committed
592 593 594 595 596 597
            }
            /*Go Return*/
            else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
            {
                MenuFlag.Menu_Return = 1;
                NextMenu(_MN_DSP_RETURN_MENU);
598 599
            }
        }
hu's avatar
hu committed
600 601 602 603 604 605 606 607 608
        else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
        {
            /*Go Enter*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL3_2_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_2_MENU_8))
            {
                MenuFlag.Menu_Enter_Return = bCurMenuIDX ;
                NextMenu(_MN_DSP_ENTER_MENU);
            }
        }
609 610 611 612 613 614
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
hu's avatar
hu committed
615 616 617
        else if (enKeyEvent == KEY_EVENT_LONG_PRESS)
        {
        }
618
    }
hu's avatar
hu committed
619 620 621 622 623 624 625 626 627 628
}

/*******************************RETURN***********************************************
  Function: Key_Operation_Return
  Description:
  Input:
  Output:
 *******************************RETURN***********************************************/
void Key_Operation_Return(Key_Event_en_t enKeyEvent)
{
629
    uint16_t DispVSpeed = 0u;
630 631 632
    uint16_t popupID = 0U;

    popupID = Popup_Get_Current_Message( );
633 634 635 636 637
    HMI_Set_KEY_CANCEL(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();

    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
638
        if ((enKeyEvent == KEY_EVENT_SHORT_PRESS) && (popupID == 0xffffu ))
639 640 641 642
        {
            if ((bCurMenuIDX >= _MN_DSP_LEVEL2_1_MENU_1) && (bCurMenuIDX < _MN_DSP_ENTER_MENU))
            {
                if (
hu's avatar
hu committed
643
                    ( bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_3 ) ||                                            /*语言设定*/
hu's avatar
hu committed
644
                    ((bCurMenuIDX >= _MN_DSP_LEVEL3_4_MENU_41 ) && (bCurMenuIDX <= _MN_DSP_LEVEL3_4_MENU_47))  /*省油设定子菜单*/
645 646 647 648 649
                )
                {
                    MenuFlag.Menu_Return = 0;
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
hu's avatar
hu committed
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
                else if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_5 )                /*胎压设置界面返回操作*/
                {
                    if (User_set_Num.User_TpmsStatus != 2)                      /*不是正在匹配状态*/
                    {
                        NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                    }
                    else
                    {
                        User_set_Num.User_TpmsStatus  = 1;                      /*退出匹配界面*/
                        if (User_set_Num.User_Temp_Return == 0)
                        {
                            User_set_Num.User_Temp_Return = 1;                    /*取消配对标记*/
                            User_set_Num.User_TpmsSend = 3;                       /*报文外发次数*/
                        }
                        else
                        {
                            ; /* do nonthing*/
                        }
                    }
                }
670 671 672 673 674
                else
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
                }
            }
675 676 677 678 679 680
            /*系统演示模式*/
            else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
            {
                MenuFlag.Menu_Return = 0;
                NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_EXIT);
            }
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
            /*Enter Go*/
            else if (bCurMenuIDX == _MN_DSP_ENTER_MENU)
            {
                MenuFlag.Menu_Return = 0;
                NextMenu(MenuFlag.Menu_Enter_Return);
            }
            else
            {
                ;/*do nothing*/
            }
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
699 700 701 702 703 704 705 706 707 708
}

/*******************************Menu***********************************************
  Function: Key_Operation_Menu
  Description:
  Input:
  Output:
 *******************************Menu***********************************************/
void Key_Operation_Menu(Key_Event_en_t enKeyEvent)
{
hu's avatar
hu committed
709
    uint8_t CanStatus1 = 0u;
710
    uint16_t DispVSpeed = 0u;
711
    uint16_t popupID = 0U;
hu's avatar
hu committed
712

713
    popupID = Popup_Get_Current_Message( );
714 715
    HMI_Set_KEY_MENU(enKeyEvent);
    DispVSpeed =  Common_Get_Disp_V_Speed();
hu's avatar
hu committed
716

hu's avatar
hu committed
717 718
    CanStatus1 = CAN_MSG_Status(ID_CanMsg0CF00400_Msg_Count);

719 720
    if (DispVSpeed <= DISPSPEEDNULLMAX)
    {
721
        if ((enKeyEvent == KEY_EVENT_SHORT_PRESS) && (popupID == 0xffffu ))
722 723 724 725 726 727
        {
            /*记录进入menu菜单的位置*/
            if ((bCurMenuIDX >= _MN_DSP_LEVEL1MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL1MENU_6))
            {
                MenuFlag.Menu_Flag =  bCurMenuIDX;

hu's avatar
hu committed
728 729
                /*有故障码*/
                if (CanStatus1 == CAN_SIG_LOST)
730
                {
hu's avatar
hu committed
731
                    NextMenu(_MN_DSP_LEVEL2MENU_1);
732
                }
hu's avatar
hu committed
733 734
                /*无故障码*/
                else
735 736 737 738 739
                {
                    NextMenu(MenuOptTab[bCurMenuIDX].VK_IDX_ENTER);
                }
            }
            /*无论从哪里都能回去*/
hu's avatar
hu committed
740 741
            else if ((bCurMenuIDX >= _MN_DSP_LEVEL2MENU_1) && (bCurMenuIDX <= _MN_DSP_RETURN_MENU))
            {
hu's avatar
hu committed
742 743 744 745 746
                //if (bCurMenuIDX == _MN_DSP_LEVEL3_4_MENU_A) /*胎压设置界面*/
                //{
                //    NextMenu(_MN_DSP_LEVEL2MENU_4);           /*menu回到用户设置界面*/
                //}
                //else
hu's avatar
hu committed
747 748 749 750
                {
                    NextMenu(MenuFlag.Menu_Flag);
                }
            }
751 752 753 754
            else if ((bCurMenuIDX >= _MN_DSP_LEVEL3_5_MENU_1) && (bCurMenuIDX <= _MN_DSP_LEVEL3_5_MENU_4))
            {
                NextMenu(MenuFlag.Menu_Flag);
            }
755 756 757 758 759 760 761 762
        }
    }
    else
    {
        if (enKeyEvent == KEY_EVENT_SHORT_PRESS)
        {
        }
    }
hu's avatar
hu committed
763 764
}

hu's avatar
hu committed
765 766 767 768
uint8_t Common_Get_RetMenu_Flag(void)
{
    return MenuFlag.Menu_Flag;
}
hu's avatar
hu committed
769 770 771 772 773 774 775 776 777 778 779
/*------------读按键实时状态的回调函数-------------------------------------------*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void);
Key_Real_Status_en_t Key_Real_Status_Read_Return(void);
Key_Real_Status_en_t Key_Real_Status_Read_Up(void);
Key_Real_Status_en_t Key_Real_Status_Read_Down(void);
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void) ;
/*-------------------------------------------------*/

//Menu_R   = 24000*470 / (24000 + 470) =  460.97Ω
//Enter_R  = 24000*6800 / (24000 + 6800) =  5298.7Ω
//Return_R = 24000*15000 / (24000 + 15000) =  9230.77Ω
780
//Up_R     = 24000*1200 / (24000 + 1200) =  1142.86Ω
hu's avatar
hu committed
781 782 783 784 785
//Down_R   = 24000*3300 / (24000 + 3300) =  2901.1Ω

//Menu_R   = 16000*470 / (16000 + 470) =  456.59Ω
//Enter_R  = 16000*6800 / (16000 + 6800) =  4771.9Ω
//Return_R = 16000*15000 / (16000 + 15000) =  7741.94Ω
786
//Up_R     = 16000*1200 / (16000 + 1200) =  1116.28Ω
hu's avatar
hu committed
787 788 789
//Down_R   = 16000*3300 / (16000 + 3300) =  2736Ω

//实际按键测试
790 791 792 793 794 795
//无操作     21000~24000Ω
//Menu_R        640~680Ω
//Enter_R       5300~5700Ω
//Return_R      9000~9500Ω
//Up_R          1300~1400Ω
//Down_R        3000~3200Ω
hu's avatar
hu committed
796

797 798 799

/*上*/
Key_Real_Status_en_t Key_Real_Status_Read_Up(void)
hu's avatar
hu committed
800 801 802
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
803 804 805 806 807 808 809 810 811

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
812
        if ((Key_R >= (1200 - 400)) && (Key_R <= (1200 + 400)))
813 814 815 816 817 818 819 820
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
821 822 823 824

    return enKeyRealStatus;
}

825 826
/*下*/
Key_Real_Status_en_t Key_Real_Status_Read_Down(void)
hu's avatar
hu committed
827 828 829
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
830 831 832 833 834 835 836 837 838

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
839
        if ((Key_R >= (2700 - 400)) && (Key_R <= (2700 + 400)))
840 841 842 843 844 845 846 847 848
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }

hu's avatar
hu committed
849 850 851
    return enKeyRealStatus;
}

852 853
/*Enter*/
Key_Real_Status_en_t Key_Real_Status_Read_Enter(void)
hu's avatar
hu committed
854 855 856 857
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;

858 859 860 861 862 863 864 865
    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
866
        if ((Key_R >= (4800 - 400)) && (Key_R <= (5000 + 400)))
867 868 869 870 871 872 873 874
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
875 876 877
    return enKeyRealStatus;
}

878 879
/*Return*/
Key_Real_Status_en_t Key_Real_Status_Read_Return(void)
hu's avatar
hu committed
880 881 882
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
883 884 885 886 887 888 889 890 891

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
892
        if ((Key_R >= (8000 - 400)) && (Key_R <= (8000 + 400)))
893 894 895 896 897 898 899 900
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
901 902 903 904

    return enKeyRealStatus;
}

905 906
/*Menu*/
Key_Real_Status_en_t Key_Real_Status_Read_Menu(void)
hu's avatar
hu committed
907 908 909
{
    Key_Real_Status_en_t enKeyRealStatus = KEY_LINE_LOOSEN;
    uint16_t Key_R = 0;
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927

    Key_R = (uint16_t)RTE_Read_KEY_R();

    if (RTE_Read_KEY_R_Valid() == 0)
    {
        enKeyRealStatus = KEY_LINE_LOOSEN;
    }
    else
    {
        if ((Key_R >= (550 - 300)) && (Key_R <= (550 + 300)))
        {
            enKeyRealStatus = KEY_LINE_PRESS;
        }
        else
        {
            enKeyRealStatus = KEY_LINE_LOOSEN;
        }
    }
hu's avatar
hu committed
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954

    return enKeyRealStatus;
}

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

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