aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ymdk_np21/ymdk_np21.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ymdk_np21/ymdk_np21.c')
-rw-r--r--keyboards/ymdk_np21/ymdk_np21.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/keyboards/ymdk_np21/ymdk_np21.c b/keyboards/ymdk_np21/ymdk_np21.c
new file mode 100644
index 000000000..670083a11
--- /dev/null
+++ b/keyboards/ymdk_np21/ymdk_np21.c
@@ -0,0 +1,80 @@
1/*
2Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
3Modified 2018 Kenneth A. <github.com/krusli>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "ymdk_np21.h"
20
21#include <avr/pgmspace.h>
22
23#include "action_layer.h"
24#include "quantum.h"
25
26#include "i2c.h"
27
28#include "backlight.h"
29#include "backlight_custom.h"
30
31extern rgblight_config_t rgblight_config;
32
33// for keyboard subdirectory level init functions
34// @Override
35void matrix_init_kb(void) {
36 // call user level keymaps, if any
37 // matrix_init_user();
38}
39
40#ifdef BACKLIGHT_ENABLE
41/// Overrides functions in `quantum.c`
42void backlight_init_ports(void) {
43 b_led_init_ports();
44}
45
46void backlight_task(void) {
47 b_led_task();
48}
49
50void backlight_set(uint8_t level) {
51 b_led_set(level);
52}
53#endif
54
55// custom RGB driver
56void rgblight_set(void) {
57 if (!rgblight_config.enable) {
58 for (uint8_t i=0; i<RGBLED_NUM; i++) {
59 led[i].r = 0;
60 led[i].g = 0;
61 led[i].b = 0;
62 }
63 }
64
65 i2c_init();
66 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
67}
68
69bool rgb_init = false;
70void matrix_scan_user(void) {
71 // if LEDs were previously on before poweroff, turn them back on
72 if (rgb_init == false && rgblight_config.enable) {
73 i2c_init();
74 i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
75 rgb_init = true;
76 }
77
78 rgblight_task();
79 /* Nothing else for now. */
80}