summaryrefslogtreecommitdiff
path: root/keyboards/inland/kb83/rgb_matrix_kb.inc
blob: 56e2bd31cbbd08b9a8d3503741b4edd1ac7793d2 (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
// !!! DO NOT ADD #pragma once !!! //

// Step 1.
// Declare custom effects using the RGB_MATRIX_EFFECT macro
// (note the lack of semicolon after the macro!)

RGB_MATRIX_EFFECT(turn_off_rgb)
RGB_MATRIX_EFFECT(kb_reset_rgb)

// Step 2.
// Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block

#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS

// e.g: A simple effect, self-contained within a single method
static bool turn_off_rgb(effect_params_t *params) {
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
  for (uint8_t i = led_min; i < led_max; i++) {
    rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
  }
  return rgb_matrix_check_finished_leds(led_max);
}

// e.g: A more complex effect, relying on external methods and state, with
// dedicated init and run methods
static uint8_t some_global_state;
static void kb_reset_rgb_init(effect_params_t* params) {
  some_global_state = 0;
}
static bool kb_reset_rgb_run(effect_params_t* params) {
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
  some_global_state++;
  if(some_global_state&0x01){
      for (uint8_t i = led_min; i < led_max; i++)
        rgb_matrix_set_color(i, 0, 0, 0);
  }
  else{
      for (uint8_t i = led_min; i < led_max; i++) 
        rgb_matrix_set_color(i, 0xc0, 0xc0, 0xc0);
  }
  if(some_global_state>=7)
    rgb_matrix_init();
  return rgb_matrix_check_finished_leds(led_max);
}

static bool kb_reset_rgb(effect_params_t* params) {
  if (params->init) kb_reset_rgb_init(params);
  return kb_reset_rgb_run(params);
}

#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS