summaryrefslogtreecommitdiff
path: root/keyboards/fallacy/indicators.c
blob: a8630d2e113d96091b10614e7d1c96f81ecfb0ae (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
/* Copyright 2020 B. Fletcher (toraifu) <typefast@kyaa.gg>
 *
 * 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 "indicators.h"
#include "drivers/led/issi/is31fl3731-simple.h"
#include "i2c_master.h"

/* Set up IS31FL3731 for use in powering indicator LEDs. Absolutely overkill for this job but it was already in the design.
 * init IS31FL3731 and i2c
 */
void init_fallacy_leds(void) {
    i2c_init();
    is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);

    for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
        is31fl3731_set_led_control_register(i, true);
    }

    is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
}


/* update the buffer
 */
void update_fallacy_leds(void) {
    is31fl3731_flush();
}


/* wrapper to actually set the LED PWM
 */
void set_fallacy_led(int index, bool state) {
    if (state) {
        is31fl3731_set_value(index, 128);
    } 
    else {
        is31fl3731_set_value(index, 0);
    }
}


/* define LED matrix
 */
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT] = {
    {0, C1_1},
    {0, C2_1},
    {0, C3_1},
};