Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ble): Fast switching between two recent profiles #2278

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Dimentium
Copy link

@Dimentium Dimentium commented Apr 18, 2024

related to #767

I'm not a developer, so this implementation is quite basic, but it works perfectly for me.

This update introduces the ability to switch back to the previously active bluetooth profile by passing index 255 to the profile selection function. This feature facilitates quick toggling between two frequently used Bluetooth devices.

…ted to zmkfirmware#767)

Add functionality to revert to the last used BLE profile via special index

This update introduces the ability to switch back to the previously active Bluetooth Low Energy (BLE) profile by passing index 255 to the profile selection function. 
This feature facilitates quick toggling between two frequently used profiles, enhancing user convenience and efficiency in scenarios requiring regular switching between different BLE configurations.
@Dimentium Dimentium requested a review from a team as a code owner April 18, 2024 16:07
@Dimentium Dimentium changed the title Enable Swapping to Previously Active Bluetooth Profile feat(ble): Fast switching between two recent profiles Apr 18, 2024
@huber-th
Copy link
Contributor

huber-th commented Apr 25, 2024

This is a great idea. I personally switch between two profiles a lot and can see the benefit of being able to only use a single key binding on the base layer rather than having to have two key bindings to swap between profiles.

I would recommend to add a new command, e.g. &bt BT_ALT (short for alternate), instead of using &bt BT_SEL 255 for this.

You could also extend the code to ensure the previous profile is persisted along side the active profile, so that swapping also works directly after startup.

@caksoylar caksoylar added enhancement New feature or request behaviors labels Apr 25, 2024
@Dimentium
Copy link
Author

Hi @caksoylar,
Is there anything I need to do with this MR?

@caksoylar
Copy link
Contributor

I am not making the merge decision for this, but I don't see this being useful without the alias BT_ALT like @huber-th suggested. Then it also needs to be documented.

@huber-th
Copy link
Contributor

huber-th commented May 2, 2024

@Dimentium I really love the idea of this feature, especially since I switch between two profiles frequently.

Since you mentioned that you're not a developer, I'd be happy to implement the improvements I suggested above as well as document the feature. We can then review the changes together.

What do you think?

@Nick-Munnich
Copy link
Contributor

#1413 is meant to implement the same thing, but a more recent implementation would be good. I like the naming used there though, BT_LAST_DEV.

@huber-th
Copy link
Contributor

I implemented this feature over the weekend for myself, including persisting both profiles to ensure alternating works immediately after startup. You can find the code here. Feel free to copy code as you see fit @Dimentium or I can also create a new PR.

For completeness, the goal of only needing a single key binding to switch between BT profiles can also be achieved using tap-dance.

  behaviors {
    td_bt: tap_dance_bluetooth {
        compatible = "zmk,behavior-tap-dance";
        #binding-cells = <0>;
        tapping-term-ms = <500>;
        bindings = <&bt BT_SEL X>, <&bt BT_SEL Y>;
    };
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behaviors enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants