diff options
Diffstat (limited to 'keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c')
-rw-r--r-- | keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c b/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c new file mode 100644 index 000000000..e782acba0 --- /dev/null +++ b/keyboards/doodboard/duckboard_r2/keymaps/default/keymap.c | |||
@@ -0,0 +1,120 @@ | |||
1 | /* Copyright 2020-2021 doodboard | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include QMK_KEYBOARD_H | ||
18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
19 | [0] = LAYOUT( | ||
20 | TG(1), KC_PSLS, KC_PAST, KC_PMNS, | ||
21 | KC_7, KC_8, KC_9, KC_PPLS, | ||
22 | KC_4, KC_5, KC_6, KC_PPLS, | ||
23 | KC_MUTE, KC_1, KC_2, KC_3, KC_ENT, | ||
24 | KC_BSPC, KC_0, KC_0, KC_DOT, KC_ENT), | ||
25 | |||
26 | [1] = LAYOUT( | ||
27 | TG(1), KC_TRNS, KC_TRNS, KC_TRNS, | ||
28 | KC_HOME, KC_UP, KC_PGUP, KC_TRNS, | ||
29 | KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS, | ||
30 | KC_TRNS, KC_END, KC_DOWN, KC_PGDN, KC_TRNS, | ||
31 | TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS), | ||
32 | |||
33 | [2] = LAYOUT( | ||
34 | KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS, | ||
35 | RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, | ||
36 | RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, | ||
37 | RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
38 | TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS), | ||
39 | }; | ||
40 | |||
41 | void encoder_update_user(uint8_t index, bool clockwise) { | ||
42 | if (index == 0) { /* First encoder */ | ||
43 | if (clockwise) { | ||
44 | tap_code(KC_VOLU); | ||
45 | } else { | ||
46 | tap_code(KC_VOLD); | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
51 | |||
52 | #ifdef OLED_DRIVER_ENABLE | ||
53 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } | ||
54 | |||
55 | |||
56 | // WPM-responsive animation stuff here | ||
57 | #define IDLE_FRAMES 2 | ||
58 | #define IDLE_SPEED 40 // below this wpm value your animation will idle | ||
59 | |||
60 | #define ANIM_FRAME_DURATION 200 // how long each frame lasts in ms | ||
61 | // #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing | ||
62 | #define ANIM_SIZE 636 // number of bytes in array, minimize for adequate firmware size, max is 1024 | ||
63 | |||
64 | uint32_t anim_timer = 0; | ||
65 | uint32_t anim_sleep = 0; | ||
66 | uint8_t current_idle_frame = 0; | ||
67 | |||
68 | // Credit to u/Pop-X- for the initial code. You can find his commit here https://github.com/qmk/qmk_firmware/pull/9264/files#diff-303f6e3a7a5ee54be0a9a13630842956R196-R333. | ||
69 | static void render_anim(void) { | ||
70 | static const char PROGMEM idle[IDLE_FRAMES][ANIM_SIZE] = { | ||
71 | { | ||
72 | 0, 0,192,192,192,192,192,192,192,248,248, 30, 30,254,254,248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3,255,255,255,255,255,255,255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127,255,255,255,255,255,159,159,135,135,129,129,129, 97, 97, 25, 25, 7, 7, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 97, 97,127, 1, 1, 97, 97,127, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
73 | }, | ||
74 | { | ||
75 | 0, 0,128,128,128,128,128,128,128,240,240, 60, 60,252,252,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 7, 7, 7, 7, 7,255,255,254,254,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,255,255,255,255, 63, 63, 15, 15, 3, 3, 3,195,195, 51, 51, 15, 15, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 99, 99,127, 3, 3, 99, 99,127, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
76 | } | ||
77 | }; | ||
78 | |||
79 | //assumes 1 frame prep stage | ||
80 | void animation_phase(void) { | ||
81 | current_idle_frame = (current_idle_frame + 1) % IDLE_FRAMES; | ||
82 | oled_write_raw_P(idle[abs((IDLE_FRAMES-1)-current_idle_frame)], ANIM_SIZE); | ||
83 | } | ||
84 | |||
85 | if(timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) { | ||
86 | anim_timer = timer_read32(); | ||
87 | animation_phase(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void oled_task_user(void) { | ||
92 | render_anim(); | ||
93 | oled_set_cursor(0,6); | ||
94 | oled_write_P(PSTR("DUCK\nBOARD\n"), false); | ||
95 | oled_write_P(PSTR("-----\n"), false); | ||
96 | // Host Keyboard Layer Status | ||
97 | oled_write_P(PSTR("MODE\n"), false); | ||
98 | oled_write_P(PSTR("\n"), false); | ||
99 | |||
100 | switch (get_highest_layer(layer_state)) { | ||
101 | case 0: | ||
102 | oled_write_P(PSTR("BASE\n"), false); | ||
103 | break; | ||
104 | case 1: | ||
105 | oled_write_P(PSTR("FUNC\n"), false); | ||
106 | break; | ||
107 | case 2: | ||
108 | oled_write_P(PSTR("RGB\n"), false); | ||
109 | break; | ||
110 | } | ||
111 | } | ||
112 | #endif | ||
113 | |||
114 | void keyboard_post_init_user(void) { | ||
115 | //Customise these values to debug | ||
116 | debug_enable=true; | ||
117 | debug_matrix=true; | ||
118 | //debug_keyboard=true; | ||
119 | //debug_mouse=true; | ||
120 | } | ||