summaryrefslogtreecommitdiff
path: root/keyboards/xelus/la_plus/la_plus.c
blob: 81aec5d547d104748ccca07d391575f76c164fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* Copyright 2021 Harrison Chan (Xelus)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "la_plus.h"
#include "print.h"

#define _____ NO_LED

keyboard_config_t keyboard_config;

led_config_t g_led_config = { {
  // Key Matrix to LED Index
  { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
  { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
  { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
  { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
  { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ }
}, {
  // LED Index to Physical Position
    {  2, 38 },
    {  0, 31 },
    {  2, 24 },
    {  0, 17 },
    {  2, 10 },
    {  0, 4  },
    {  4, 1  },
    { 14, 1  },
    { 30, 1  },
    { 47, 1  },
    { 63, 1  },
    { 79, 1  },
    { 95, 1  },
    {111, 1  },
    {144, 1  },
    {159, 1  },
    {176, 1  },
    {192, 1  },
    {208, 1  },
    {224, 1  },
    {241, 1  },
    {250, 0  },
    {255, 4  },
    {253, 10 },
    {255, 17 },
    {253, 24 },
    {255, 31 },
    {253, 38 },
    {241, 64 },
    {165, 64 },
    { 90, 64 },
    { 14, 64 }
}, {
  // LED Index to Flag
  8, 8, 8, 8, 8, 8, 8, 8,
  8, 8, 8, 8, 8, 8, 8, 8,
  8, 8, 8, 8, 8, 8, 8, 8,
  8, 8, 8, 8, 8, 8, 8, 8
} };

void keyboard_post_init_kb(void) {
    // Call the post init code.
    // debug_enable=true;

    keyboard_config.raw = eeconfig_read_kb();
    if (keyboard_config.startup_animation_dots) {
        rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_startup_animation_dots);
    } else {
        rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_startup_animation_solid);
    }

    keyboard_post_init_user();
}

void eeconfig_init_kb(void) {
#ifdef STARTUP_ANIMATION_DOTS
    keyboard_config.startup_animation_dots = false;
#else
    keyboard_config.startup_animation_dots = true;
#endif
    eeconfig_update_kb(keyboard_config.raw);
    eeconfig_init_user();
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
    if (!process_record_user(keycode, record)) {
        return false;
    }

    if (keycode == STARTUP_ANIMATION_CONFIG && record->event.pressed) {
        keyboard_config.startup_animation_dots = !(keyboard_config.startup_animation_dots);
#ifdef CONSOLE_ENABLE
        uprintf("keyboard_config startup_animation_dots: %b\n", keyboard_config.startup_animation_dots);
#endif
        eeconfig_update_kb(keyboard_config.raw);
    }

    return true;
}