190 lines
9.6 KiB
C
190 lines
9.6 KiB
C
|
/*
|
||
|
Copyright 2021 0xCB - Conor Burns
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 2 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
#include QMK_KEYBOARD_H
|
||
|
|
||
|
enum layer_names {
|
||
|
_HOME,
|
||
|
_MISC,
|
||
|
_RGB,
|
||
|
_BLED
|
||
|
};
|
||
|
|
||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||
|
[_HOME] = LAYOUT(
|
||
|
KC_MPRV, KC_MNXT, KC_MPLY,
|
||
|
KC_PGUP, KC_PGDN, TO(3),
|
||
|
KC_HOME, KC_END, TO(1)
|
||
|
),
|
||
|
[_MISC] = LAYOUT(
|
||
|
_______, _______, _______,
|
||
|
_______, _______, TO(0),
|
||
|
_______, _______, TO(2)
|
||
|
),
|
||
|
[_RGB] = LAYOUT(
|
||
|
RGB_HUI, RGB_HUD, RGB_MOD,
|
||
|
RGB_SAI, RGB_SAD, TO(1),
|
||
|
RGB_SPI, RGB_SPD, TO(3)
|
||
|
),
|
||
|
[_BLED] = LAYOUT(
|
||
|
BL_STEP, BL_BRTG, BL_TOGG,
|
||
|
BL_ON, BL_OFF, TO(2),
|
||
|
BL_INC, BL_DEC, TO(0)
|
||
|
)
|
||
|
};
|
||
|
|
||
|
|
||
|
/* rotary encoder (SW3) - add more else if blocks for more granular layer control */
|
||
|
#ifdef ENCODER_ENABLE
|
||
|
void encoder_update_user(uint8_t index, bool clockwise) {
|
||
|
if (IS_LAYER_ON(_RGB)) {
|
||
|
if (clockwise) {
|
||
|
rgblight_increase_val();
|
||
|
} else {
|
||
|
rgblight_decrease_val();
|
||
|
}
|
||
|
} else if (IS_LAYER_ON(_BLED)) {
|
||
|
if (clockwise) {
|
||
|
backlight_increase();
|
||
|
} else {
|
||
|
backlight_decrease();
|
||
|
}
|
||
|
} else {
|
||
|
if (clockwise) {
|
||
|
tap_code(KC_VOLU);
|
||
|
} else {
|
||
|
tap_code(KC_VOLD);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
/* oled stuff :) */
|
||
|
#ifdef OLED_DRIVER_ENABLE
|
||
|
uint16_t startup_timer;
|
||
|
|
||
|
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||
|
startup_timer = timer_read();
|
||
|
return rotation;
|
||
|
}
|
||
|
|
||
|
static void render_logo(void) {
|
||
|
static const char PROGMEM logo[] = {
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x80, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||
|
0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x01, 0x01, 0x01,
|
||
|
0x01, 0x01, 0x02, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05,
|
||
|
0xf8, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xe0, 0xe0, 0x70, 0x78,
|
||
|
0x38, 0x3f, 0x1c, 0x0e, 0x0e, 0x0e, 0xfe, 0x0e, 0x0e, 0x1e, 0x1c, 0x3f, 0x38, 0x78, 0x70, 0xe0,
|
||
|
0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05, 0xf8, 0x05, 0x02, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xa0,
|
||
|
0x13, 0xa2, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc,
|
||
|
0xfe, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3c, 0x3c, 0x00, 0x00,
|
||
|
0x01, 0xff, 0xff, 0xff, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0xa2, 0x13, 0xa0, 0x40, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x80, 0xc0, 0x40, 0x40, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x40, 0x40, 0xc0, 0x80,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0xc0,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x40, 0x40, 0xc0, 0x80, 0x00, 0x00, 0x80, 0xc0, 0x40,
|
||
|
0x40, 0xc0, 0x80, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0xf9, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x7f, 0xff, 0xff, 0xc0, 0x80, 0x80, 0x0f,
|
||
|
0x1f, 0x1f, 0x01, 0x01, 0x01, 0x01, 0xff, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x0e, 0x0e, 0x80, 0xc0,
|
||
|
0xc0, 0xff, 0xff, 0x7f, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xf9, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x1f, 0x31, 0x40, 0x4e, 0x40, 0x31, 0x1f, 0x00, 0x00, 0x61, 0x16, 0x08, 0x16, 0x61,
|
||
|
0x00, 0x00, 0x1f, 0x31, 0x60, 0x40, 0x40, 0x60, 0x20, 0x00, 0x00, 0x7f, 0x44, 0x44, 0x64, 0x3b,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x7f,
|
||
|
0x40, 0x40, 0x00, 0x00, 0x00, 0x20, 0x64, 0x44, 0x44, 0x6e, 0x3b, 0x00, 0x00, 0x20, 0x64, 0x44,
|
||
|
0x44, 0x6e, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x03, 0x01, 0x00, 0x00, 0x00, 0x08, 0x14,
|
||
|
0x23, 0x14, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x07,
|
||
|
0x0f, 0xfe, 0x1e, 0x1c, 0x1c, 0x1c, 0xff, 0x1c, 0x1c, 0x1c, 0x1e, 0xfe, 0x0f, 0x07, 0x03, 0x03,
|
||
|
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0a, 0x11, 0x0a, 0x04, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x28, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10,
|
||
|
0x10, 0x1f, 0x00, 0x00, 0x10, 0x28, 0x47, 0x28, 0x10, 0x00, 0x00, 0x1f, 0x10, 0x10, 0x10, 0x10,
|
||
|
0x10, 0x10, 0x28, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||
|
};
|
||
|
|
||
|
oled_write_raw_P(logo, sizeof(logo));
|
||
|
}
|
||
|
/* Shows the name of the current layer and locks for the host (CAPS etc.) */
|
||
|
static void render_info(void) {
|
||
|
oled_write_P(PSTR("Layer: "), false);
|
||
|
|
||
|
switch (get_highest_layer(layer_state)) {
|
||
|
case _HOME:
|
||
|
oled_write_ln_P(PSTR("HOME"), false);
|
||
|
break;
|
||
|
case _MISC:
|
||
|
oled_write_ln_P(PSTR("MISC"), false);
|
||
|
break;
|
||
|
case _RGB:
|
||
|
oled_write_ln_P(PSTR("RGB"), false);
|
||
|
break;
|
||
|
case _BLED:
|
||
|
oled_write_ln_P(PSTR("Backlight"), false);
|
||
|
break;
|
||
|
default:
|
||
|
oled_write_ln_P(PSTR("Undefined"), false);
|
||
|
}
|
||
|
led_t led_state = host_keyboard_led_state();
|
||
|
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
|
||
|
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
|
||
|
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
|
||
|
}
|
||
|
|
||
|
void oled_task_user(void) {
|
||
|
static bool finished_timer = false;
|
||
|
if ((timer_elapsed(startup_timer) < 3000) && !finished_timer) {
|
||
|
render_logo();
|
||
|
} else {
|
||
|
finished_timer = true;
|
||
|
render_info();
|
||
|
}
|
||
|
}
|
||
|
#endif
|