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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright 2022 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include QMK_KEYBOARD_H
enum custom_keycodes {
LED_LEVEL = SAFE_RANGE,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT(
KC_MPLY, KC_9, KC_0, KC_NO,
KC_5, KC_6, KC_7, KC_8,
KC_1, KC_2, KC_3, KC_4,
TO(1), KC_DOT, KC_COMM, LED_LEVEL
),
LAYOUT(
KC_1, KC_2, KC_3, KC_4,
KC_5, KC_6, KC_7, KC_8,
KC_9, KC_0, KC_A, KC_B,
TO(2), KC_C, KC_D, KC_E
),
LAYOUT(
KC_1, KC_2, KC_3, KC_4,
KC_5, KC_6, KC_7, KC_8,
KC_9, KC_0, KC_A, KC_B,
TO(3), KC_C, KC_D, KC_E
),
LAYOUT(
KC_1, KC_2, KC_3, KC_4,
KC_5, KC_6, KC_7, KC_8,
KC_9, KC_0, KC_A, KC_B,
TO(0), KC_C, LED_LEVEL,KC_E
),
};
typedef union {
uint32_t raw;
struct {
uint8_t led_level : 3;
};
} work_louder_config_t;
work_louder_config_t work_louder_config;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LED_LEVEL:
if (record->event.pressed) {
work_louder_config.led_level++;
if (work_louder_config.led_level > 4) {
work_louder_config.led_level = 0;
}
work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
eeconfig_update_user(work_louder_config.raw);
layer_state_set_kb(layer_state);
}
break;
}
return true;
}
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
{ ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(C(KC_Z), C(KC_Y)) },
{ ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) },
{ ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) },
{ ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) },
};
#endif
layer_state_t layer_state_set_user(layer_state_t state) {
layer_state_cmp(state, 1) ? work_louder_micro_led_1_on(): work_louder_micro_led_1_off();
layer_state_cmp(state, 2) ? work_louder_micro_led_2_on(): work_louder_micro_led_2_off();
layer_state_cmp(state, 3) ? work_louder_micro_led_3_on(): work_louder_micro_led_3_off();
return state;
}
void eeconfig_init_user(void) {
work_louder_config.raw = 0;
work_louder_config.led_level = 1;
eeconfig_update_user(work_louder_config.raw);
}
void matrix_init_user(void) {
work_louder_config.raw = eeconfig_read_user();
work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
}
|