diff options
Diffstat (limited to 'readme.md')
| -rw-r--r-- | readme.md | 48 |
1 files changed, 45 insertions, 3 deletions
| @@ -372,10 +372,11 @@ But lets start with how to use it, first! | |||
| 372 | 372 | ||
| 373 | 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. | 373 | 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. |
| 374 | 374 | ||
| 375 | This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are two possible options: | 375 | This array specifies what actions shall be taken when a tap-dance key is in action. Currently, there are three possible options: |
| 376 | 376 | ||
| 377 | * `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise. | 377 | * `ACTION_TAP_DANCE_DOUBLE(kc1, kc2)`: Sends the `kc1` keycode when tapped once, `kc2` otherwise. |
| 378 | * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the current state of the tap-dance action. | 378 | * `ACTION_TAP_DANCE_FN(fn)`: Calls the specified function - defined in the user keymap - with the final tap count of the tap dance action. |
| 379 | * `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. | ||
| 379 | 380 | ||
| 380 | 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. | 381 | 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. |
| 381 | 382 | ||
| @@ -399,7 +400,8 @@ In the end, let's see a full example! | |||
| 399 | enum { | 400 | enum { |
| 400 | CT_SE = 0, | 401 | CT_SE = 0, |
| 401 | CT_CLN, | 402 | CT_CLN, |
| 402 | CT_EGG | 403 | CT_EGG, |
| 404 | CT_FLSH, | ||
| 403 | }; | 405 | }; |
| 404 | 406 | ||
| 405 | /* Have the above three on the keymap, TD(CT_SE), etc... */ | 407 | /* Have the above three on the keymap, TD(CT_SE), etc... */ |
| @@ -424,10 +426,50 @@ void dance_egg (qk_tap_dance_state_t *state) { | |||
| 424 | } | 426 | } |
| 425 | } | 427 | } |
| 426 | 428 | ||
| 429 | // on each tap, light up one led, from right to left | ||
| 430 | // on the forth tap, turn them off from right to left | ||
| 431 | void dance_flsh_each(qk_tap_dance_state_t *state) { | ||
| 432 | switch (state->count) { | ||
| 433 | case 1: | ||
| 434 | ergodox_right_led_3_on(); | ||
| 435 | break; | ||
| 436 | case 2: | ||
| 437 | ergodox_right_led_2_on(); | ||
| 438 | break; | ||
| 439 | case 3: | ||
| 440 | ergodox_right_led_1_on(); | ||
| 441 | break; | ||
| 442 | case 4: | ||
| 443 | ergodox_right_led_3_off(); | ||
| 444 | _delay_ms(50); | ||
| 445 | ergodox_right_led_2_off(); | ||
| 446 | _delay_ms(50); | ||
| 447 | ergodox_right_led_1_off(); | ||
| 448 | } | ||
| 449 | } | ||
| 450 | |||
| 451 | // on the fourth tap, set the keyboard on flash state | ||
| 452 | void dance_flsh_finished(qk_tap_dance_state_t *state) { | ||
| 453 | if (state->count >= 4) { | ||
| 454 | reset_keyboard(); | ||
| 455 | reset_tap_dance(state); | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | // if the flash state didnt happen, then turn off leds, left to right | ||
| 460 | void dance_flsh_reset(qk_tap_dance_state_t *state) { | ||
| 461 | ergodox_right_led_1_off(); | ||
| 462 | _delay_ms(50); | ||
| 463 | ergodox_right_led_2_off(); | ||
| 464 | _delay_ms(50); | ||
| 465 | ergodox_right_led_3_off(); | ||
| 466 | } | ||
| 467 | |||
| 427 | const qk_tap_dance_action_t tap_dance_actions[] = { | 468 | const qk_tap_dance_action_t tap_dance_actions[] = { |
| 428 | [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT) | 469 | [CT_SE] = ACTION_TAP_DANCE_DOUBLE (KC_SPC, KC_ENT) |
| 429 | ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln) | 470 | ,[CT_CLN] = ACTION_TAP_DANCE_FN (dance_cln) |
| 430 | ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg) | 471 | ,[CT_EGG] = ACTION_TAP_DANCE_FN (dance_egg) |
| 472 | ,[CT_FLSH] = ACTION_TAP_DANCE_FN_ADVANCED (dance_flsh_each, dance_flsh_finished, dance_flsh_reset) | ||
| 431 | }; | 473 | }; |
| 432 | ``` | 474 | ``` |
| 433 | 475 | ||
