diff options
Diffstat (limited to 'readme.md')
| -rw-r--r-- | readme.md | 48 |
1 files changed, 45 insertions, 3 deletions
| @@ -387,10 +387,11 @@ But lets start with how to use it, first! | |||
| 387 | 387 | ||
| 388 | First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array. | 388 | First, you will need `TAP_DANCE_ENABLE=yes` in your `Makefile`, because the feature is disabled by default. This adds a little less than 1k to the firmware size. Next, you will want to define some tap-dance keys, which is easiest to do with the `TD()` macro, that - similar to `F()`, takes a number, which will later be used as an index into the `tap_dance_actions` array. |
| 389 | 389 | ||
| 390 | This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options: | 390 | This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are three possible options: |
| 391 | 391 | ||
| 392 | * `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise. | 392 | * `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise. |
| 393 | * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action. | 393 | * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the final tap count of the tap dance action. |
| 394 | * `ACTION_TAP_DANCE_FN_ADVANCED(on_each_tap_fn, on_dance_finished_fn, on_reset_fn)`: Calls the first specified function - defined in the user keymap - on every tap, the second function on when the dance action finishes (like the previous option), and the last function when the tap dance action resets. | ||
| 394 | 395 | ||
| 395 | The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. | 396 | The first option is enough for a lot of cases, that just want dual roles. For example, `ACTION_TAP_DANCE(KC_SPC, KC_ENT)` will result in `Space` being sent on single-tap, `Enter` otherwise. |
| 396 | 397 | ||
| @@ -414,7 +415,8 @@ In the end, let's see a full example! | |||
| 414 | enum { | 415 | enum { |
| 415 | CT_SE = 0, | 416 | CT_SE = 0, |
| 416 | CT_CLN, | 417 | CT_CLN, |
| 417 | CT_EGG | 418 | CT_EGG, |
| 419 | CT_FLSH, | ||
| 418 | }; | 420 | }; |
| 419 | 421 | ||
| 420 | /* Have the above three on the keymap, TD(CT_SE), etc... */ | 422 | /* Have the above three on the keymap, TD(CT_SE), etc... */ |
| @@ -439,10 +441,50 @@ void dance_egg (qk_tap_dance_state_t *state) { | |||
| 439 | } | 441 | } |
| 440 | } | 442 | } |
| 441 | 443 | ||
| 444 | // on each tap, light up one led, from right to left | ||
| 445 | // on the forth tap, turn them off from right to left | ||
| 446 | void dance_flsh_each(qk_tap_dance_state_t *state) { | ||
| 447 | switch (state->count) { | ||
| 448 | case 1: | ||
| 449 | ergodox_right_led_3_on(); | ||
| 450 | break; | ||
| 451 | case 2: | ||
| 452 | ergodox_right_led_2_on(); | ||
| 453 | break; | ||
| 454 | case 3: | ||
| 455 | ergodox_right_led_1_on(); | ||
| 456 | break; | ||
| 457 | case 4: | ||
| 458 | ergodox_right_led_3_off(); | ||
| 459 | _delay_ms(50); | ||
| 460 | ergodox_right_led_2_off(); | ||
| 461 | _delay_ms(50); | ||
| 462 | ergodox_right_led_1_off(); | ||
| 463 | } | ||
| 464 | } | ||
| 465 | |||
| 466 | // on the fourth tap, set the keyboard on flash state | ||
| 467 | void dance_flsh_finished(qk_tap_dance_state_t *state) { | ||
| 468 | if (state->count >= 4) { | ||
| 469 | reset_keyboard(); | ||
| 470 | reset_tap_dance(state); | ||
| 471 | } | ||
| 472 | } | ||
| 473 | |||
| 474 | // if the flash state didnt happen, then turn off leds, left to right | ||
| 475 | void dance_flsh_reset(qk_tap_dance_state_t *state) { | ||
| 476 | ergodox_right_led_1_off(); | ||
| 477 | _delay_ms(50); | ||
| 478 | ergodox_right_led_2_off(); | ||
| 479 | _delay_ms(50); | ||
| 480 | ergodox_right_led_3_off(); | ||
| 481 | } | ||
| 482 | |||
| 442 | const qk_tap_dance_action_t tap_dance_actions[] = { | 483 | const qk_tap_dance_action_t tap_dance_actions[] = { |
| 443 | [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT) | 484 | [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT) |
| 444 | ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln) | 485 | ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln) |
| 445 | ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg) | 486 | ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg) |
| 487 | ,[CT_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED (dance_flsh_each, dance_flsh_finished, dance_flsh_reset) | ||
| 446 | }; | 488 | }; |
| 447 | ``` | 489 | ``` |
| 448 | 490 | ||
