diff options
author | Takuya Urakawa <urkwtky@gmail.com> | 2022-03-07 12:27:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-06 19:27:41 -0800 |
commit | 5de86a05c31482b5c770888e33c98d933c42b34c (patch) | |
tree | 6c314f1e5d33fafe53c0ac76d14f4cc5f06600ce /keyboards/dm9records/lain/lain.c | |
parent | de10757f057d31a148d0b881535d875ff4af5c9c (diff) |
[Keyboard] Add Lain keyboard (#16345)
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'keyboards/dm9records/lain/lain.c')
-rw-r--r-- | keyboards/dm9records/lain/lain.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/keyboards/dm9records/lain/lain.c b/keyboards/dm9records/lain/lain.c new file mode 100644 index 0000000000..cb8354e5c2 --- /dev/null +++ b/keyboards/dm9records/lain/lain.c @@ -0,0 +1,49 @@ +// Copyright 2022 Takuya Urakawa @hsgw (dm9records.com, 5z6p.com) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "lain.h" + +keyboard_config_t lain_config; + +static const pin_t leds[LED_NUM] = LED_PINS; +bool led_states[LED_NUM] = {0}; + +void lain_eeconfig_update_kb(void) { eeconfig_update_kb(lain_config.raw); } + +void lain_set_led(uint8_t no, bool flag) { + led_states[no] = flag; + writePin(leds[no], lain_config.led_enabled ? flag : false); +} + +void lain_enable_leds(bool flag) { + lain_config.led_enabled = flag; + lain_eeconfig_update_kb(); + + for (int i = 0; i < LED_NUM; i++) { + writePin(leds[i], lain_config.led_enabled ? led_states[i] : false); + } +} + +void lain_enable_leds_toggle(void) { lain_enable_leds(!lain_config.led_enabled); } + +void led_init_ports(void) { + for (uint8_t i = 0; i < LED_NUM; i++) { + setPinOutput(leds[i]); + lain_set_led(leds[i], 0); + } +} + +void eeconfig_init_kb(void) { + // set default config + lain_config.led_enabled = true; + lain_eeconfig_update_kb(); + + eeconfig_init_user(); +} + +void keyboard_post_init_kb(void) { + // read stored config + lain_config.raw = eeconfig_read_kb(); + + keyboard_post_init_user(); +} |