aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/handwired/d48/keymaps/anderson/lightmode.c
blob: bc059562144c4aca94ad6ea3d7fa0781f00d40f3 (plain) (blame)
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
#include "lightmode.h"

#ifdef LIGHTMODE_ENABLE

/* Light modes switcher */

uint8_t light_mode = SMOOTHLED;

void set_light_mode(light_mode_t value, uint32_t color) {
    light_mode = value;
    if (light_mode == SMOOTHLED) {
        smoothled_set(color);
    } else {
        dmc12_start(color, true);
    }
}

void process_light_mode(void) {
    if (light_mode == SMOOTHLED) {
        smoothled_process();
    } else {
        dmc12_process();
    }
}

void update_light_mode(uint32_t color) {
    if (light_mode == SMOOTHLED) {
        smoothled_set(color);
    } else {
        dmc12_start(color, false);
    }
}

void next_light_mode(uint32_t color) {
    light_mode = (light_mode + 1) % LIGHT_MODE_SIZE;
    set_light_mode(light_mode, color);
}

void matrix_scan_kb(void) {
    process_light_mode();
    matrix_scan_user();
}

#endif