#include QMK_KEYBOARD_H
enum layer_names {
_BASE = 0,
_FN
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT_4x4_encoders(
KC_MUTE, KC_MPLY,
KC_PMNS, KC_P7, KC_P8, KC_P9,
KC_PPLS, KC_P4, KC_P5, KC_P6,
KC_BSPC, KC_P1, KC_P2, KC_P3,
KC_PENT, MO(_FN), KC_P0, KC_PDOT
),
[_FN] = LAYOUT_4x4_encoders(
_______, _______,
KC_PSLS, KC_F21, KC_F22, KC_F23,
KC_PAST, KC_F18, KC_F19, KC_F20,
KC_NLCK, KC_F15, KC_F16, KC_F17,
RESET, _______, KC_F13, KC_F14
)
};
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
if (clockwise) {
tap_code16(KC_VOLU);
} else {
tap_code16(KC_VOLD);
}
} else if (index == 1) {
if (clockwise) {
tap_code16(KC_MNXT);
} else {
tap_code16(KC_MPRV);
}
}
return true;
}
#ifdef OLED_DRIVER_ENABLE
static uint32_t oled_logo_timer = 0;
bool oled_logo_cleared = false;
static void render_status(void) {
oled_write_P(PSTR("Layer: "), false);
switch (get_highest_layer(layer_state)) {
case _BASE:
oled_write_P(PSTR("Numpad\n"), false);
break;
case _FN:
oled_write_P(PSTR("Macropad\n"), false);
break;
default:
oled_write_ln_P(PSTR("Some Other Layer"), false);
}
oled_write_ln_P(PSTR(" "), false);
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR(" NUM ") : PSTR(" "), led_state.num_lock);
oled_write_P(led_state.caps_lock ? PSTR(" CAP ") : PSTR(" "), led_state.caps_lock);
oled_write_P(led_state.scroll_lock ? PSTR(" SCR ") : PSTR(" "), led_state.scroll_lock);
}
static void render_logo(void) {
static const char radpad_logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8,
0xf8, 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0x00, 0x03, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x00, 0x01, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x03,
0x07, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1f, 0x1f, 0x0f,
0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
oled_write_raw_P(radpad_logo, sizeof(radpad_logo));
}
void oled_task_user(void) {
if (oled_logo_cleared) {
render_status();
} else {
if (timer_elapsed32(oled_logo_timer) > OLED_LOGO_TIMEOUT) {
oled_clear();
oled_logo_cleared = true;
render_status();
} else {
render_logo();
}
}
}
#endif