]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/gray_studio/hb85/hb85.c
Update KBD67 readme so that it mentions the KBD65 PCB (#5143)
[qmk_firmware.git] / keyboards / gray_studio / hb85 / hb85.c
1 /*
2 Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, 
3           2019 fcoury <felipe.coury@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <string.h>
20
21 #include "rgblight.h"
22
23 #include "i2c.h"
24 #include "quantum.h"
25
26 #ifdef RGBLIGHT_ENABLE
27 extern rgblight_config_t rgblight_config;
28
29 void rgblight_set(void) {
30     if (!rgblight_config.enable) {
31         for (uint8_t i = 0; i < RGBLED_NUM; i++) {
32             led[i].r = 0;
33             led[i].g = 0;
34             led[i].b = 0;
35         }
36     }
37
38     i2c_init();
39     i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
40 }
41 #endif
42
43 __attribute__ ((weak))
44 void matrix_scan_user(void) {
45 }
46
47 void backlight_init_ports(void) {
48     // initialize pins D0, D1, D4 and D6 as output
49     setPinOutput(D0);
50     setPinOutput(D1);
51     setPinOutput(D4);
52     setPinOutput(D6);
53
54     // turn RGB LEDs on
55     writePinHigh(D0);
56     writePinHigh(D1);
57     writePinHigh(D4);
58     writePinHigh(D6);
59 }
60
61 void backlight_set(uint8_t level) {
62         if (level == 0) {
63         // turn RGB LEDs off
64         writePinLow(D0);
65         writePinLow(D1);
66         writePinLow(D4);
67         writePinLow(D6);
68         } else {
69         // turn RGB LEDs on
70         writePinHigh(D0);
71         writePinHigh(D1);
72         writePinHigh(D4);
73         writePinHigh(D6);
74         }
75 }