|
11 | 11 | * 2022-08-05 smartmx add reset params function.
|
12 | 12 | * 2023-03-15 smartmx add state declaration.
|
13 | 13 | * 2023-07-03 smartmx add Section Definition option.
|
| 14 | + * 2023-07-15 smartmx add skip function. |
14 | 15 | *
|
15 | 16 | */
|
16 | 17 |
|
@@ -230,6 +231,59 @@ void mfbd_nbtn_scan(const mfbd_group_t *_pbtn_group)
|
230 | 231 | }
|
231 | 232 | }
|
232 | 233 |
|
| 234 | +/** |
| 235 | + * @brief skip some times of mfbd_btn_count_t with last state. |
| 236 | + * |
| 237 | + * @param _pbtn_group is a pointer of mfbd_group_t. |
| 238 | + * @param times is times need to skip. |
| 239 | + * |
| 240 | + * @return None. |
| 241 | + */ |
| 242 | +void mfbd_nbtn_skip(const mfbd_group_t *_pbtn_group, mfbd_btn_count_t times) |
| 243 | +{ |
| 244 | + mfbd_nbtn_t **_ppbtn = _pbtn_group->nbtns; |
| 245 | + mfbd_nbtn_t *_pbtn = *_ppbtn; |
| 246 | + |
| 247 | + while (_pbtn != NULL) |
| 248 | + { |
| 249 | + if(_pbtn->state == MFBD_BTN_STATE_DOWN) |
| 250 | + { |
| 251 | + if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn->btn_info->btn_long_code != 0)) |
| 252 | + { |
| 253 | + /* if long_time is 0 or long_code is 0, disable long and repeat check. */ |
| 254 | + if (_pbtn->long_count < (MFBD_LONG_TIME_IN_FUC)) |
| 255 | + { |
| 256 | + if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn->long_count) > times) |
| 257 | + { |
| 258 | + _pbtn->long_count = _pbtn->long_count + times; |
| 259 | + } |
| 260 | + else |
| 261 | + { |
| 262 | + _pbtn->long_count = MFBD_LONG_TIME_IN_FUC - 1; |
| 263 | + } |
| 264 | + } |
| 265 | + } |
| 266 | + } |
| 267 | + else if(_pbtn->state == MFBD_BTN_STATE_LONG) |
| 268 | + { |
| 269 | + if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn->btn_info->btn_down_code[0] != 0)) |
| 270 | + { |
| 271 | + if(((MFBD_REPEAT_TIME_IN_FUC) - 1 - _pbtn->repeat_count) > times) |
| 272 | + { |
| 273 | + _pbtn->repeat_count = _pbtn->repeat_count + times; |
| 274 | + } |
| 275 | + else |
| 276 | + { |
| 277 | + _pbtn->repeat_count = MFBD_REPEAT_TIME_IN_FUC - 1; |
| 278 | + } |
| 279 | + } |
| 280 | + } |
| 281 | + |
| 282 | + _ppbtn++; |
| 283 | + _pbtn = *_ppbtn; |
| 284 | + } |
| 285 | +} |
| 286 | + |
233 | 287 | /**
|
234 | 288 | * @brief reset all normal buttons' params.
|
235 | 289 | *
|
@@ -393,6 +447,79 @@ void mfbd_mbtn_scan(const mfbd_group_t *_pbtn_group)
|
393 | 447 | }
|
394 | 448 | }
|
395 | 449 |
|
| 450 | +/** |
| 451 | + * @brief skip some times of mfbd_btn_count_t with last state. |
| 452 | + * |
| 453 | + * @param _pbtn_group is a pointer of mfbd_group_t. |
| 454 | + * @param times is times need to skip. |
| 455 | + * |
| 456 | + * @return None. |
| 457 | + */ |
| 458 | +void mfbd_mbtn_skip(const mfbd_group_t *_pbtn_group, mfbd_btn_count_t times) |
| 459 | +{ |
| 460 | + mfbd_mbtn_t **_ppbtn = _pbtn_group->mbtns; |
| 461 | + mfbd_mbtn_t *_pbtn = *_ppbtn; |
| 462 | + |
| 463 | + while (_pbtn != NULL) |
| 464 | + { |
| 465 | + if(_pbtn->state == MFBD_BTN_STATE_UP) |
| 466 | + { |
| 467 | + if (_pbtn->multiclick_state != 0) |
| 468 | + { |
| 469 | + if (_pbtn->multiclick_count < (MFBD_MULTICLICK_TIME_IN_FUC)) |
| 470 | + { |
| 471 | + if(((MFBD_MULTICLICK_TIME_IN_FUC) - _pbtn->multiclick_count) > times) |
| 472 | + { |
| 473 | + _pbtn->multiclick_count = _pbtn->multiclick_count + times; |
| 474 | + } |
| 475 | + else |
| 476 | + { |
| 477 | + _pbtn->multiclick_state = 0; |
| 478 | + } |
| 479 | + } |
| 480 | + } |
| 481 | + } |
| 482 | + else if(_pbtn->state == MFBD_BTN_STATE_DOWN) |
| 483 | + { |
| 484 | + if (_pbtn->multiclick_state == 0) |
| 485 | + { |
| 486 | + if (((MFBD_LONG_TIME_IN_FUC) > 0) && (_pbtn->btn_info->btn_long_code != 0)) |
| 487 | + { |
| 488 | + /* if long_time is 0 or long_code is 0, disable long and repeat check. */ |
| 489 | + if (_pbtn->long_count < (MFBD_LONG_TIME_IN_FUC)) |
| 490 | + { |
| 491 | + if(((MFBD_LONG_TIME_IN_FUC) - 1 - _pbtn->long_count) > times) |
| 492 | + { |
| 493 | + _pbtn->long_count = _pbtn->long_count + times; |
| 494 | + } |
| 495 | + else |
| 496 | + { |
| 497 | + _pbtn->long_count = MFBD_LONG_TIME_IN_FUC - 1; |
| 498 | + } |
| 499 | + } |
| 500 | + } |
| 501 | + } |
| 502 | + } |
| 503 | + else if(_pbtn->state == MFBD_BTN_STATE_LONG) |
| 504 | + { |
| 505 | + if (((MFBD_REPEAT_TIME_IN_FUC) > 0) && (_pbtn->btn_info->btn_down_code[0] != 0)) |
| 506 | + { |
| 507 | + if(((MFBD_REPEAT_TIME_IN_FUC) - 1 - _pbtn->repeat_count) > times) |
| 508 | + { |
| 509 | + _pbtn->repeat_count = _pbtn->repeat_count + times; |
| 510 | + } |
| 511 | + else |
| 512 | + { |
| 513 | + _pbtn->repeat_count = MFBD_REPEAT_TIME_IN_FUC - 1; |
| 514 | + } |
| 515 | + } |
| 516 | + } |
| 517 | + |
| 518 | + _ppbtn++; |
| 519 | + _pbtn = *_ppbtn; |
| 520 | + } |
| 521 | +} |
| 522 | + |
396 | 523 | /**
|
397 | 524 | * @brief reset all multi-function buttons' params.
|
398 | 525 | *
|
@@ -473,6 +600,37 @@ void mfbd_group_scan(const mfbd_group_t *_pbtn_group)
|
473 | 600 | }
|
474 | 601 |
|
475 | 602 |
|
| 603 | +/** |
| 604 | + * @brief skip some times with last state. |
| 605 | + * |
| 606 | + * @param _pbtn_group is a pointer of mfbd_group_t. |
| 607 | + * @param times is times need to skip. |
| 608 | + * |
| 609 | + * @return None. |
| 610 | + */ |
| 611 | +void mfbd_group_skip(const mfbd_group_t *_pbtn_group, mfbd_btn_count_t times) |
| 612 | +{ |
| 613 | + /* tbtn doesn't need to skip times. */ |
| 614 | + |
| 615 | +#if MFBD_USE_NORMAL_BUTTON |
| 616 | + if (_pbtn_group->nbtns != NULL) |
| 617 | + { |
| 618 | + /* skip times of normal buttons in group.*/ |
| 619 | + mfbd_nbtn_skip(_pbtn_group, times); |
| 620 | + } |
| 621 | +#endif |
| 622 | + |
| 623 | +#if MFBD_USE_MULTIFUCNTION_BUTTON |
| 624 | + if (_pbtn_group->mbtns != NULL) |
| 625 | + { |
| 626 | + /* skip times of multifunction buttons in group.*/ |
| 627 | + mfbd_mbtn_skip(_pbtn_group, times); |
| 628 | + } |
| 629 | +#endif |
| 630 | + |
| 631 | +} |
| 632 | + |
| 633 | + |
476 | 634 | /**
|
477 | 635 | * @brief reset all buttons params in the group.
|
478 | 636 | *
|
|
0 commit comments