kinx-project / kint

kinT keyboard controller (Kinesis controller replacement)
Other
317 stars 39 forks source link

Teensy LC pins 24, 25 for controlling LEDs #55

Open aleb opened 2 years ago

aleb commented 2 years ago

I see the Teensy-LC has pin 24 and 25 which seem unused. Can these be routed to control two more leds?

PXL_20220601_045426361 MP

stapelberg commented 2 years ago

I think they could be used to control LEDs.

They’re only available on the Teensy LC, 3.2, 3.5, 3.6, though.

Notably, they’re missing from the Teensy++ 2.0, Teensy 4.0, Teensy 4.1.

So, I don’t think kinT should be changed to route these by default, but you’re free to make a variant in which you route the pins :)

aleb commented 2 years ago

I was referring to "The kinT makes possible lower-cost builds: if you don’t need the scroll lock, num lock and keypad LEDs, you can use a Teensy LC for merely 11 USD". If we simply add two more holes for these Teensy LC pins 24 and 25 and route these doppleganger pins to the original 24 and 25, it might work: teensy-lc

I'll give it a try on a breadboard to see how it works.

aleb commented 2 years ago

I tried on a breadboard and pin 24 and 25 can be used for keyboard LEDs on Teensy LC!

In the other kint* keyboards pin 24 (AKA "keypad") is assigned to the Compose LED and pin 25 is assigned to the Scroll-Lock LED.

Screenshot from 2022-06-03 08-59-54

This means only the Num-Lock LED would remain unconnected. Given the original keypad/numpad functionality of the keyboard is gone, there should be no problem that the Num-Lock LED remains unconnected. I did not try, but I guess LINE_PIN13 which is currently used to keep the LED on the Teensy board always on, to signal that the board is powered, could be used instead to drive the Num-Lock LED.

This is what https://www.pjrc.com/store/teensylc.html says about Pin 13:

LED Pin: Pin 13 has an orange LED connected. The LED can be very convenient to show status info. When pin 13 is used as an input, the external signal must be able to drive the LED when logic HIGH. pinMode INPUT_PULLUP should not be used with pin 13.

This would require changing the common kint* keyboards LED config and seems a lot of effort for little to no gain:

#define LED_PIN_ON_STATE 0
#define LED_NUM_LOCK_PIN LINE_PIN26
#define LED_CAPS_LOCK_PIN LINE_PIN12
#define LED_SCROLL_LOCK_PIN LINE_PIN25
#define LED_COMPOSE_PIN LINE_PIN24

I did manage to toggle the Scroll-lock LED by going in the text-mode console and pressing the Scroll-lock key. Otherwise pressing the Scroll-lock key in GNOME does not do anything.

Three new holes on the board for pin 24, pin 25 and pin AREF (because it exists) would allow these Teensy LC pins to be connected to the board and routed to their Teensy 4.1 dopplegangers. But again, if anybody happens to wonder whether they need these LEDs, the answer is "no". :)

One could also easily solder two wires if you really want these Scroll-lock and Compose LEDs and the board has not been updated yet.

I'll make a QMK PR to add support for Teensy LC once I integrate it in a KB500 and check it works. Using this instead of the obsolete Teensy 2.0++ has advantages.

aleb commented 2 years ago

See https://github.com/qmk/qmk_firmware/pull/17301 for Teensy LC support. At the moment I only tested that the Caps-lock and Scroll-lock LEDs are updated. To be tested once I integrate it into a KB500.

stapelberg commented 2 years ago

Thanks for taking a look at this and sending the QMK pull request!

I found some documentation about the different LEDs at https://github.com/qmk/qmk_firmware/blob/master/docs/feature_led_indicators.md

It seems like the compose LED is entirely unused within QMK by default. I only wired it up so that users have the option of using the LED for their own custom purpose, if they need it :)

sigprof commented 2 years ago

The compose LED support in QMK works… if you actually find a way to control it from the host side. I'm not sure whether it is possible to control it from Windows at all (there might be a way to do something with the Kana LED though, but nothing that looks like Compose). And recent Linux distros use the libinput driver for HID keyboards, which does not have support for any indicators outside the standard Caps/Num/Scroll Lock set. The evdev driver can control the Compose and Kana indicators, but there is a mismatch in the indicator numbering between the driver and the corresponding description in the xkeyboard-config package; I'm not sure whether there is any point to open a bug report for that though, because the evdev driver is deprecated in favor of libinput.

aleb commented 2 years ago

The Teensy (LC) LED light is quite visible when the room is dark, as the orange light reflects on keys 5 and T. Is this also an issue for Teensy 3.6 or 4.1? I see we do make an effort in kint41.c etc to turn it on.

https://user-images.githubusercontent.com/505582/172714774-dbdbb025-ab6e-4163-9630-486d61dc1b69.mp4

stapelberg commented 2 years ago

It’s not as pronounced in my teensy 4.1 build:

https://user-images.githubusercontent.com/55506/172718612-94445b54-6213-46b7-8d80-29be3550e178.MOV