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

Layer display on LED segment #775

Closed
tobsn opened this issue Sep 22, 2016 · 11 comments
Closed

Layer display on LED segment #775

tobsn opened this issue Sep 22, 2016 · 11 comments

Comments

@tobsn
Copy link
Contributor

tobsn commented Sep 22, 2016

Would it be possible with a teensy/teensy++ to display the function layer on a LED segment?
This came to me last night after looking at the ergodox infinity... it would be fairly easy to put a 1 digit LED segment block into common keyboard layouts and it would help a lot navigating the layers.

@mecanogrh
Copy link

MAX7219

@mecanogrh
Copy link

Then have a look at led control code from Eberhard Fahle

@tobsn
Copy link
Contributor Author

tobsn commented Sep 23, 2016

Fahle's LedControl code says "The code also works with the Teensy (3.1)"

@mecanogrh
Copy link

Problem here is power consumption vs led brightness.

@fredizzimo
Copy link
Contributor

One goal of the Effect System, is to be able to do that. The keyboard will need some sort of LED controller though. The Infinity uses the 31FL3731C, but that's for monochrome LEDs. The MAX7219 is another option. For RGB LEDs, you need something else.

The effect system will most likely expose the LEDs as an abstract display with individually addressable pixlels, so you could use for example normal font drawing algorithms to display some characters on them.

@violet-fish
Copy link
Contributor

I have modified an older version of the firmware to utilize a caps lock led as well as layer indication leds by putting this code in led.c and adding led.c to the sources:

#include <avr/io.h>
#include "stdint.h"
#include "led.h"


// Caps Lock led settings (set to B0)
void led_set(uint8_t usb_led)
{
    // Using B7 Caps Lock LED
    if (usb_led & (1<<USB_LED_CAPS_LOCK))
    {
        // Output high.
        DDRB |= (1<<0);
        PORTB |= (1<<0);
    }
    else
    {
        // Output low.
        DDRB &= ~(1<<0);
        PORTB &= ~(1<<0);
    }
}



// Led layer toggle
void led_layer_set(uint32_t state) {
    DDRB |= (1<<7); //led 0 (B7)
    //dprint("Set LEDs for layer change\n");

    // Led for Layer 1
    if ((1<<1 & state) != 0) {
        //dprint("Layer 2: on\n");
        PORTB |= (1<<7);
    } else {
        //dprint("Layer 2: off\n");
        PORTB &= ~(1<<7);
    }
	
    DDRB |= (1<<3); //led 1 (B3)
    //dprint("Set LEDs for layer change\n");

    // Led for Layer 4
    if ((1<<4 & state) != 0) {
        //dprint("Layer 2: on\n");
        PORTB |= (1<<3);
    } else {
        //dprint("Layer 2: off\n");
        PORTB &= ~(1<<3);
    }
	
    DDRB |= (1<<2); //led 2 (B2)
    //dprint("Set LEDs for layer change\n");

    // Led for Layer 2
    if ((1<<2 & state) != 0) {
        //dprint("Layer 2: on\n");
        PORTB |= (1<<2);
    } else {
        //dprint("Layer 2: off\n");
        PORTB &= ~(1<<2);
    }
	
    DDRB |= (1<<1); //led 3 (B1)
    //dprint("Set LEDs for layer change\n");

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

I actually don't know the exact terminology for adding source files, this is how my old makefile handled importing files:

# project specific files
SRC +=	extended_keymap_common.c \
	matrix_handwire.c \
	led.c \
	backlight.c \
	extended_keymap_dustin.c
	
CONFIG_H = config.h

@drashna
Copy link
Member

drashna commented Mar 25, 2018

Ergodox does this by default now, with the option to do so with RGB underglow.

uint32_t layer_state_set_user(uint32_t state) {
ergodox_board_led_off();
ergodox_right_led_1_off();
ergodox_right_led_2_off();
ergodox_right_led_3_off();
uint8_t layer = biton32(state);
switch (layer) {
case 0:
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#else
#ifdef RGBLIGHT_ENABLE
rgblight_init();
#endif
#endif
break;
case 1:
ergodox_right_led_1_on();
#ifdef RGBLIGHT_COLOR_LAYER_1
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
#endif
break;
case 2:
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_2
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
#endif
break;
case 3:
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_3
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
#endif
break;
case 4:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_4
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
#endif
break;
case 5:
ergodox_right_led_1_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_5
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
#endif
break;
case 6:
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_6
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
#endif
break;
case 7:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_7
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
#endif
break;
default:
break;
}
return state;
};

Closing. Please reopen or open a new issue, if this is still an issue.

@drashna drashna closed this as completed Mar 25, 2018
@mecanogrh
Copy link

Yes please reopen, totally different issue that mrlinuxfish and you are considering.
We are talking about LED SEGMENT here not single LEDs.

@drashna drashna reopened this Jun 21, 2018
@drashna
Copy link
Member

drashna commented Oct 21, 2018

This should be possible, in theory. Though it depends on the hardware.

The Helix board uses an LCD display and can display the current layer.
And I use layer indication via rgb LEDs on several boards (underglow and matrix).

@drashna
Copy link
Member

drashna commented Mar 29, 2019

@mecanogrh just an update on this. Yes, this should be possible, ESPECIALLY with the new LED Matrix feature. The only caveat is that the Ergodox Infinity would need to be converted to this code.

https://docs.qmk.fm/#/feature_led_matrix?id=custom-layer-effects

I'm using the equivalent for the RGB Matrix on my ergodox ez glow, and planck light. So it is definitely possible with the newer code.

@jackhumbert
Copy link
Member

I think we can close this now - the implementation of this seems pretty straight-forward for personal cases. If anyone has code they can share, we can open a new issue/PR about how we can generalise it for a driver/etc in QMK.

BlueTufa pushed a commit to BlueTufa/qmk_firmware that referenced this issue Aug 6, 2021
* colorway: add Deku, HammerHead, HyperFuse, Mecha-01, Suited Assassin

* fix: code style issues

* add: kat oasis, kat hyperfuse. remove gmk hyperfuse

* remove: GMK Mecha-01, update key-contents

* update: GMK Camping
bdjohnson79 pushed a commit to bdjohnson79/qmk_firmware that referenced this issue Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants