Added comments to LED stuff and included .hex file
parent
5259f36d03
commit
dcc9948fae
|
@ -160,16 +160,28 @@ void * matrix_init_user(void) {
|
||||||
|
|
||||||
// Runs constantly in the background, in a loop.
|
// Runs constantly in the background, in a loop.
|
||||||
void * matrix_scan_user(void) {
|
void * matrix_scan_user(void) {
|
||||||
static uint8_t leds[4]; // Yes, I'm wasting a byte. Sue me.
|
/* leds is a static array holding the current brightness of each of the
|
||||||
|
* three keyboard LEDs. It's 4 long simply to avoid the ugliness of +1s and
|
||||||
|
* -1s in the code below, and because wasting a byte really doesn't matter
|
||||||
|
* that much (no, it *doesn't*, stop whinging!). Note that because it's
|
||||||
|
* static it'll maintain state across invocations of this routine.
|
||||||
|
*/
|
||||||
|
static uint8_t leds[4];
|
||||||
uint8_t led;
|
uint8_t led;
|
||||||
uint8_t layer = biton32(layer_state);
|
uint8_t layer = biton32(layer_state);
|
||||||
|
|
||||||
ergodox_board_led_off();
|
ergodox_board_led_off();
|
||||||
|
|
||||||
|
/* Loop over each LED/layer */
|
||||||
for (led = 1; led <= 3; ++led) {
|
for (led = 1; led <= 3; ++led) {
|
||||||
|
/* If the current layer matches the current LED, increment its
|
||||||
|
* brightness by 1 up to a maximum of 255. If the current layer doesn't
|
||||||
|
* match, decrement its brightness by 1 down to a minimum of zero.
|
||||||
|
*/
|
||||||
leds[led] += (layer == led) ?
|
leds[led] += (layer == led) ?
|
||||||
(leds[led] < 255 ? 1 : 0):
|
(leds[led] < 255 ? 1 : 0):
|
||||||
(leds[led] > 0 ? -1 : 0);
|
(leds[led] > 0 ? -1 : 0);
|
||||||
|
/* Set LED state according to the new brightness */
|
||||||
if (leds[led]) {
|
if (leds[led]) {
|
||||||
ergodox_right_led_on(led);
|
ergodox_right_led_on(led);
|
||||||
ergodox_right_led_set(led, leds[led]);
|
ergodox_right_led_set(led, leds[led]);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue