summaryrefslogtreecommitdiff
path: root/keyboards/dm9records/lain/lain.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dm9records/lain/lain.c')
-rw-r--r--keyboards/dm9records/lain/lain.c49
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();
+}