Author Topic: Using Lock LEDs to indicate Current Layers on ErgoDox  (Read 1319 times)

0 Members and 1 Guest are viewing this topic.

Offline duq

  • Thread Starter
  • Posts: 288
  • Location: West Coast
  • Connoisseur
Using Lock LEDs to indicate Current Layers on ErgoDox
« on: Sat, 14 June 2014, 00:45:50 »
Hello!

Upon constructing my ergodox and using it for a bit I found that it would be useful to have a layer indicator because how I appropriated my layers.

https://www.massdrop.com/ext/ergodox/?referer=ZXKRQ7&hash=b209b02042f5ab4d3b372634dcbdd187

I play random for SC2 and there were some keys that were particularly terrible to get to because of the split configuration. I haven't hashed through everything yet, but the main ones were these:

zerg: 'h' for hatcheries
protoss: 'y' for cybernetics core
terran: 'u' for bunker and 'l' for lift

I still have more discovery to do, but it already made it apparent that I would have to do this if I were to make a right attempt at making the ergodox work on the regular.

Anyway, I have a layer for each race[layer 1, layer 2, layer 3] and brought over the offending keys  to the 1.5 unit keys on the left hand.

Now, the meat of this post... how to enable the LED indicators existing(LEDa, LEDb, and LEDc) to indicate what layer you are on.

I used this to base how I did it:
http://moazzam-khan.com/blog/?p=885

It did not work for me... It did turn the LEDs on for me but it would not turn them off...

His current construct for turning off the LEDs is(placed in the 'pop' function of the desired layer):
keyboard_leds = keyboard_leds & 0x01;

The following does not work either:
keyboard_leds = keyboard_leds & 0x01;
 
There is comment to use:
keyboard_leds &= (uint8_t) ~(0×01); or keyboard_leds &= (0×01)

Does not work either.

What I found that works is this line:
keyboard_leds = 0x00;

The final source should look similar to this:
Code: [Select]
void kbfun_layer_push_1(void) {
keyboard_leds = keyboard_leds | 0x01;
layer_push(1);
}

/*
 * [name]
 *   Layer pop #1
 *
 * [description]
 *   Pop the layer element created by the corresponding "layer push" function
 *   out of the layer stack (no matter where it is in the stack, without
 *   touching any other elements)
 */
void kbfun_layer_pop_1(void) {
keyboard_leds = 0x00;
layer_pop(1);
}

It should be noted that:
CAPS = 0x02
SCR = 0x04
NUM = 0x01

AND, if you pay attention to how I did my layers you should always have an appropriate pop button to go back to the base layer to clear the LED and bring you back to the base layer.

Hope this helps someone, because it took a bit of tinkering. Big thanks to Moazzam for getting me started.

Regards,
Duq