Enable LED Light level control for Ergodox EZ

pull/6512/head
Drashna Jael're 5 years ago committed by Florian Didron
parent d2100ba45d
commit 927969d6cb

@ -22,6 +22,7 @@ extern inline void ergodox_right_led_set(uint8_t led, uint8_t n);
extern inline void ergodox_led_all_set(uint8_t n);
keyboard_config_t keyboard_config;
bool i2c_initialized = 0;
i2c_status_t mcp23018_status = 0x20;
@ -43,6 +44,9 @@ void matrix_init_kb(void) {
PORTD |= (1<<5 | 1<<4);
PORTE |= (1<<6);
keyboard_config.raw = eeconfig_read_kb();
ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
ergodox_blink_all_leds();
matrix_init_user();
@ -316,3 +320,28 @@ led_config_t g_led_config = { {
} };
#endif
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LED_LEVEL:
if (record->event.pressed) {
keyboard_config.led_level++;
if (keyboard_config.led_level > 4) {
keyboard_config.led_level = 0;
}
ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
eeconfig_update_kb(keyboard_config.raw);
layer_state_set_kb(layer_state);
}
break;
}
return process_record_user(keycode, record);
}
void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.led_level = 4;
eeconfig_update_kb(keyboard_config.raw);
eeconfig_init_user();
}

@ -107,6 +107,20 @@ inline void ergodox_led_all_set(uint8_t n)
ergodox_right_led_3_set(n);
}
enum ergodox_ez_keycodes {
LED_LEVEL = SAFE_RANGE,
EZ_SAFE_RANGE,
};
typedef union {
uint32_t raw;
struct {
uint8_t led_level :3;
};
} keyboard_config_t;
extern keyboard_config_t keyboard_config;
/*
* LEFT HAND: LINES 115-122
* RIGHT HAND: LINES 124-131

Loading…
Cancel
Save