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

Allow turning on LEDs while within layer. #198

Closed
wants to merge 2 commits into from

Conversation

jonhiggs
Copy link

First up, let me state that I'm not much of a C programmer so I've done anything stupid let me know and I'll fix it up.

This PR will allow you to turn on an LED while a layer is active. I found that tapping was difficult to use without an indicator.

To use it, you need to add something like this into your led.c file.

void led_layer_set(uint32_t state) {
    DDRD |= (1<<5);
    dprint("Set LEDs for layer change\n");

    /* Led for Layer 2 */
    if ((1<<2 & state) != 0) {
        dprint("Layer 2: on\n");
        PORTD |= (1<<5);
    } else {
        dprint("Layer 2: off\n");
        PORTD &= ~(1<<5);
    }
}

Cheers.

@tmk
Copy link
Owner

tmk commented Mar 22, 2015

Your code seems to be fine.
I have also had some ideas to improve LED API at issue #174, your change is viable option.

Thank you.

@tmk tmk added the TODO label Mar 22, 2015
@mrlinuxfish
Copy link

I tried using this code with an extended keymap (from Jack Humbert's planck keyboard firmware) and the code does not seem to work there. Is there any code required for common/led.h or does led.c need to be included in the keymap?

@jonhiggs
Copy link
Author

I just took a look and there has been a big refactor to move all the core stuff into tmk_core. I've fixed it up and it should apply cleanly to the tip of master again.

Give it another go and let me know if it works better now.

@mrlinuxfish
Copy link

That works perfect, thanks so much.

@jonhiggs
Copy link
Author

No worries. Hopefully it'll get merged into core soon so it won't fall out of sync again. ;)

Btw, thanks heaps @tmk for breaking apart the core and the keyboards. I've been looking forward to #173 getting resolved.

@tmk tmk mentioned this pull request Feb 9, 2016
17 tasks
@eltang
Copy link

eltang commented Feb 28, 2016

This is supported in QMK by default. Take a look at the default Ergodox EZ keymap.

@tmk
Copy link
Owner

tmk commented Apr 21, 2016

I think this can be replaced with #304 hook_layer_change().

@tmk tmk closed this Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants