#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
TG(1), KC_PSLS, KC_PAST, KC_PMNS,
KC_7, KC_8, KC_9,
KC_4, KC_5, KC_6, KC_PPLS,
KC_1, KC_2, KC_3,
KC_BSPC, KC_0, KC_0, KC_DOT, KC_ENT),
[1] = LAYOUT(
TG(1), KC_TRNS, KC_TRNS, KC_TRNS,
KC_HOME, KC_UP, KC_PGUP,
KC_LEFT, KC_TRNS, KC_RGHT, KC_TRNS,
KC_END, KC_DOWN, KC_PGDN,
TG(2), KC_TRNS, KC_INS, KC_DEL, KC_TRNS),
[2] = LAYOUT(
KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS,
RGB_HUI, RGB_SAI, RGB_VAI,
RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
TG(2), RESET, KC_TRNS, KC_TRNS, KC_TRNS),
};
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
return true;
}
#ifdef OLED_DRIVER_ENABLE
oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }
#define IDLE_FRAMES 2
#define IDLE_SPEED 40
#define ANIM_FRAME_DURATION 200
#define ANIM_SIZE 636
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;
uint8_t current_idle_frame = 0;
static void render_anim(void) {
static const char PROGMEM idle[IDLE_FRAMES][ANIM_SIZE] = {
{
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
},
{
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
}
};
void animation_phase(void) {
current_idle_frame = (current_idle_frame + 1) % IDLE_FRAMES;
oled_write_raw_P(idle[abs((IDLE_FRAMES-1)-current_idle_frame)], ANIM_SIZE);
}
if(timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
anim_timer = timer_read32();
animation_phase();
}
}
void oled_task_user(void) {
render_anim();
oled_set_cursor(0,6);
oled_write_P(PSTR("DUCK\nBOARD\n"), false);
oled_write_P(PSTR("-----\n"), false);
oled_write_P(PSTR("MODE\n"), false);
oled_write_P(PSTR("\n"), false);
switch (get_highest_layer(layer_state)) {
case 0:
oled_write_P(PSTR("BASE\n"), false);
break;
case 1:
oled_write_P(PSTR("FUNC\n"), false);
break;
case 2:
oled_write_P(PSTR("RGB\n"), false);
break;
}
}
#endif
void keyboard_post_init_user(void) {
debug_enable=true;
debug_matrix=true;
}