summaryrefslogtreecommitdiffstats
path: root/users/stanrc85/startup_fanfare.c
blob: 507d9e389ca825de9a81c946495b540b63e05470 (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
#include "stanrc85.h"

static uint8_t top = 0;
static uint8_t middle = 0;
static uint8_t bottom = 0;

static bool is_enabled = true;
static bool is_rgblight_startup = true;
static uint16_t rgblight_startup_loop_timer;

void matrix_scan_user(void) {
    // Boot up "fanfare"
    if (is_rgblight_startup && is_keyboard_master()) {
        if (timer_elapsed(rgblight_startup_loop_timer) > 10) {
            static uint8_t counter;
            counter++;
            if (counter == 1) {
                top = 1;
                writePin(INDICATOR_PIN_0, !top);
                wait_ms(200);
                top = 0;
                writePin(INDICATOR_PIN_0, !top);
            }
            if (counter == 2) {
                middle = 1;
                writePin(INDICATOR_PIN_1, !middle);
                wait_ms(200);
                middle = 0;
                writePin(INDICATOR_PIN_1, !middle);
            }
            if (counter == 3) {
                bottom = 1;
                writePin(INDICATOR_PIN_2, !bottom);
                wait_ms(200);
                bottom = 0;
                writePin(INDICATOR_PIN_2, !bottom);
            }
            if (counter == 4) {
                is_enabled = is_rgblight_startup = false;
            }
        }
    }
}