aboutsummaryrefslogtreecommitdiff
path: root/keyboards/acheron/elongate/delta/delta.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/acheron/elongate/delta/delta.c')
-rwxr-xr-xkeyboards/acheron/elongate/delta/delta.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/keyboards/acheron/elongate/delta/delta.c b/keyboards/acheron/elongate/delta/delta.c
new file mode 100755
index 000000000..520dde4e2
--- /dev/null
+++ b/keyboards/acheron/elongate/delta/delta.c
@@ -0,0 +1,78 @@
1/* Copyright 2021 Gondolindrim
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "delta.h"
18
19#define LED_PIN_ON_STATE 1
20// Inits all indicator LEDs as push-pull outputs
21void led_init_ports(void) {
22 palSetLineMode(LED1_PIN, PAL_MODE_OUTPUT_PUSHPULL);
23 palSetLineMode(LED2_PIN, PAL_MODE_OUTPUT_PUSHPULL);
24 palSetLineMode(LED3_PIN, PAL_MODE_OUTPUT_PUSHPULL);
25 palSetLineMode(LED4_PIN, PAL_MODE_OUTPUT_PUSHPULL);
26 palSetLineMode(LED5_PIN, PAL_MODE_OUTPUT_PUSHPULL);
27 palSetLineMode(LED6_PIN, PAL_MODE_OUTPUT_PUSHPULL);
28}
29
30// This function updates LEDs 1, 2 and 3 according to num, caps and scroll lock states
31bool led_update_kb(led_t led_state) {
32 bool res = led_update_user(led_state);
33 if(res) {
34 writePin(LED1_PIN, !led_state.num_lock);
35 writePin(LED2_PIN, !led_state.caps_lock);
36 writePin(LED3_PIN, !led_state.scroll_lock);
37 }
38 return res;
39}
40
41// Turns off all bottom LEDs
42void turn_off_bottom_leds(void){
43 writePin(LED4_PIN, 1);
44 writePin(LED5_PIN, 1);
45 writePin(LED6_PIN, 1);
46}
47
48/*
49Here the bottom LEDs get updated. The idea being that LED4 is lit when the default layer is active, LED5 when layer 1 is active and LED6 when layer 2.
50Before updating, however, all bottom LEDs are turned off.
51*/
52layer_state_t layer_state_set_kb(layer_state_t state) {
53 turn_off_bottom_leds();
54 switch (get_highest_layer(state)) {
55// The base layer, or layer zero, will be handled by the default case.
56 case 1:
57 writePin(LED4_PIN, 1);
58 writePin(LED5_PIN, 0);
59 writePin(LED6_PIN, 1);
60 break;
61 case 2:
62 writePin(LED4_PIN, 1);
63 writePin(LED5_PIN, 1);
64 writePin(LED6_PIN, 0);
65 break;
66 default:
67 writePin(LED4_PIN, 0);
68 writePin(LED5_PIN, 1);
69 writePin(LED6_PIN, 1);
70 break;
71 }
72 return state;
73}
74
75// Since the keyboard starts at layer 0, the init function starts LED4 as lit up.
76void keyboard_post_init_kb(void){
77 writePin(LED4_PIN, 0);
78}