159 lines
6.9 KiB
C
159 lines
6.9 KiB
C
/*
|
|
* Copyright 2022 Thomas.Haukland@gmail.com
|
|
*
|
|
* 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 "zompi.h"
|
|
|
|
#ifdef RGB_MATRIX
|
|
led_config_t g_led_config = { {
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 },
|
|
{ 1, 2, 1, 1, 1 }
|
|
}, {
|
|
{ 85, 16 }, { 50, 13 }, { 16, 20 }, { 16, 38 }, { 50, 48 }, { 85, 52 }
|
|
}, {
|
|
4, 4, 4, 4, 4, 4
|
|
} };
|
|
#endif
|
|
|
|
|
|
#ifdef OLED_ENABLE
|
|
static void render_logo(void) {
|
|
static const char PROGMEM raw_logo[] = {
|
|
0x00, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8,
|
|
0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,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fe, 0xfe, 0xfc, 0x7c, 0x7e, 0x7e, 0x3e, 0x7e, 0x7e, 0x7e, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8,
|
|
0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0x00,
|
|
0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf3, 0xf0, 0xf0,
|
|
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x02, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xe0, 0xf0, 0xf0, 0xf0, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f,
|
|
0x1f, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf8, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0x7f, 0x3f, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
|
|
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
|
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
|
0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00
|
|
};
|
|
oled_write_raw_P(raw_logo, sizeof(raw_logo));
|
|
}
|
|
|
|
enum layers {
|
|
_QWERTY = 0,
|
|
_LOWER,
|
|
_RAISE,
|
|
_ADJUST,
|
|
};
|
|
|
|
static void render_status(void) {
|
|
render_logo();
|
|
return;
|
|
// Host Keyboard Layer Status
|
|
oled_write_P(PSTR("Layer: "), false);
|
|
switch (get_highest_layer(layer_state)) {
|
|
case _QWERTY:
|
|
oled_write_P(PSTR("Default\n"), false);
|
|
break;
|
|
case _LOWER:
|
|
oled_write_P(PSTR("Lower\n"), false);
|
|
break;
|
|
case _RAISE:
|
|
oled_write_P(PSTR("Raise\n"), false);
|
|
break;
|
|
case _ADJUST:
|
|
oled_write_P(PSTR("Adjust\n"), false);
|
|
break;
|
|
default:
|
|
oled_write_P(PSTR("Undefined\n"), false);
|
|
}
|
|
|
|
// Host Keyboard LED Status
|
|
led_t led_state = host_keyboard_led_state();
|
|
oled_write_P(led_state.num_lock ? PSTR("NUMLCK ") : PSTR(" "), false);
|
|
oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR(" "), false);
|
|
oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK ") : PSTR(" "), false);
|
|
}
|
|
|
|
bool oled_task_kb(void) {
|
|
if (!oled_task_user()) { return false; }
|
|
if (is_keyboard_left()) {
|
|
render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
|
|
} else {
|
|
render_logo();
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
/* The encoder_update_user is a function.
|
|
* It'll be called by QMK every time you turn the encoder.
|
|
*
|
|
* The index parameter tells you which encoder was turned. If you only have
|
|
* one encoder, the index will always be zero.
|
|
*
|
|
* The clockwise parameter tells you the direction of the encoder. It'll be
|
|
* true when you turned the encoder clockwise, and false otherwise.
|
|
*/
|
|
bool encoder_update_user(uint8_t index, bool clockwise) {
|
|
/* With an if statement we can check which encoder was turned. */
|
|
if (index == 0) { /* First encoder */
|
|
/* And with another if statement we can check the direction. */
|
|
if (clockwise) {
|
|
/* This is where the actual magic happens: this bit of code taps on the
|
|
Page Down key. You can do anything QMK allows you to do here.
|
|
You'll want to replace these lines with the things you want your
|
|
encoders to do. */
|
|
tap_code(KC_PGDN);
|
|
} else {
|
|
/* And likewise for the other direction, this time Page Down is pressed. */
|
|
tap_code(KC_PGUP);
|
|
}
|
|
/* You can copy the code and change the index for every encoder you have. Most
|
|
keyboards will only have two, so this piece of code will suffice. */
|
|
} else if (index == 1) { /* Second encoder */
|
|
if (clockwise) {
|
|
tap_code(KC_UP);
|
|
} else {
|
|
tap_code(KC_DOWN);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|