Author Topic: Strange Issue with Status LED's QMK Firmware.  (Read 2529 times)

0 Members and 1 Guest are viewing this topic.

Offline CodeMonkeyX

  • Thread Starter
  • Posts: 16
Strange Issue with Status LED's QMK Firmware.
« on: Sun, 25 November 2018, 19:28:06 »
Hi all,
So I have been working on retrofitting my DasKeyboard 4 Pro with a Teensy++ and QMK firmware. I currently have a working controller, got it all wired up to the ribbon came in the keyboard, and it all seems to work. Then I decided to add in 3 status LED's for Caps, Num and Scroll locks. That is kind of working, but is behaving strangely and I am hoping someone with more experience might see my problem right off the bat.

Sometimes the status LED's will work as expected. But other times (like if I turn on all 3 at the same time) then Caps lock will flash all 3 status lights on and off at the same time. Also sometimes the Num and Scroll lights will switch around.

Here's how I set it up.

So to add my LED's I soldered a resistor to pins C5, C6, and C7 of the Teensy++ and that to the long leg of each of the 3 LED's. Then I soldered all the short legs to the ground on the Teensy++. I have checked the wiring and I do not believe there is an issue there. Also I feel like if I shorted something, or wired the LED's wrong then they would not work at all, not just sometimes. Some photos for a general idea before I wired up the LED's





Here is the code I used in the QMK firmware.

Code: [Select]
void led_init_ports(void) {
    DDRC |= (1<<5) | (1<<6) | (1<<7); // Set direction on Port C to out on pins 5, 6, and 7.
}

void led_set_kb(uint8_t usb_led) {
    // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
    led_set_user(usb_led);

    if (usb_led & (1 << USB_LED_NUM_LOCK)) {
        // Turn numlock on
        PORTC |= (1 << 7);
    } else {
        // Turn numlock off
        PORTC &= ~(1 << 7);
    }

    if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
        // Turn capslock on
        PORTC |= (1 << 6);
    } else {
        // Turn capslock off
        PORTC &= ~(1 << 6);
    }

    if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
        // Turn scrolllock on
        PORTC |= (1 << 5);
    } else {
        // Turn scrolllock off
        PORTC &= ~(1 << 5);
    }

}

I am hoping that I am just missing something simple... ;) Any help would be appreciated.

Offline BlindAssassin111

  • Posts: 1107
  • Location: Behind you
  • I design keyboards and stuff.
    • Viktus
Re: Strange Issue with Status LED's QMK Firmware.
« Reply #1 on: Sun, 25 November 2018, 19:41:16 »
Here is what I did for a different keyboard with the same wiring.

I believe the issue is you have this:
Code: [Select]
led_set_user(usb_led);When you shouldn't, the below does everything all in one go and works(just change port and pin obviously)

Code: [Select]
void led_set_kb(uint8_t usb_led) {
  DDRB |= (1 << 4) | (1 << 5) | (1 << 6);

  if (usb_led & (1 << USB_LED_NUM_LOCK)) {
    PORTB |= (1 << 4);
  } else {
    PORTB &= ~(1 << 4);
  }

  if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
    PORTB |= (1 << 5);
  } else {
    PORTB &= ~(1 << 5);
  }

  if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
    PORTB |= (1 << 6);
  } else {
    PORTB &= ~(1 << 6);
  }
}