Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SnailMap port for the Kintsugi keyboard. #17341

Merged
merged 7 commits into from
Jun 15, 2022
Merged
Prev Previous commit
Next Next commit
Added working port of the snailmap keymap. README pending.
  • Loading branch information
ADPenrose committed Jun 7, 2022
commit 0bf73cd3caf8a610c36170a0180039195a6b6534
258 changes: 200 additions & 58 deletions keyboards/adpenrose/kintsugi/keymaps/type_matrix/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,31 @@ bool encoder_update_user(uint8_t index, bool clockwise) {

#ifdef OLED_ENABLE
/*=========================================== OLED CONFIGURATION ===========================================*/
bool oled_horizontal = false; // OLED rotation (true = horizontal, false = vertical)
bool graph_direction = true; // Graph movement (true = right to left, false = left to right)
bool oled_horizontal = true; // OLED rotation (true = horizontal, false = vertical)
bool graph_direction = false; // Graph movement (true = right to left, false = left to right)
float graph_top_wpm = 100.0; // Minimum WPM required to reach the top of the graph
int graph_refresh = 1000; // In milliseconds, determines the graph-line frequency
int icon_med_wpm = 50; // WPM required to display the medium snail
int icon_fast_wpm = 72; // WPM required to display the fast snail
// Layer names: Should be exactly 5 characters in length if vertical display, or 6 characters if horizontal
#define MA_LAYER_NAME "_BASE" // Layer _MA name
#define L1_LAYER_NAME "_KCAD" // Layer _L1 name
#define L2_LAYER_NAME "_NMPD" // Layer _L2 name
#define L3_LAYER_NAME "_FNCT" // Layer _L3 name
#define MA_LAYER_NAME "QWRTY" // Layer 0 name
#define L1_LAYER_NAME "KICAD" // Layer 1 name
#define L2_LAYER_NAME "NMPAD" // Layer 2 name
#define L3_LAYER_NAME "FUNCT" // Layer 3 name
/*================================================================================================================*/
bool first_loop = true;
int timer = 0;
int wpm_limit = 20;
int max_wpm = -1;
int wpm_icon = -1;
int graph_lines[64];
int graph_lines[65];

/* Rotation of the OLED: */
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (oled_horizontal) {
return OLED_ROTATION_180;
} else {
return OLED_ROTATION_90;
return OLED_ROTATION_270;
}
}

Expand All @@ -149,39 +149,59 @@ static void render_background(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x84, 0x80, 0x80, 0x80, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04,
0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00,
0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00,
0x80, 0x04, 0x04, 0x04, 0x04, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x08, 0x61, 0x87, 0xff, 0xff, 0xff, 0xfc, 0x30, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x42, 0x02, 0x02, 0x02, 0x02, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x42, 0x40, 0x00, 0x00,
0x00, 0x02, 0x40, 0x40, 0x40, 0x40, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x40, 0x40, 0x40, 0x40,
0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42,
0x40, 0x40, 0x40, 0x00, 0x02, 0x00, 0x00, 0x40, 0x40, 0x02, 0x00, 0x00, 0x00, 0x40, 0x42, 0x02,
0x02, 0x02, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x0f, 0xc2, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0xfe, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xe1, 0x08, 0x42, 0x10, 0x84, 0x21, 0x08, 0x42, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xfe, 0x10, 0x84, 0x21, 0x08, 0x42, 0x10, 0x84, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
oled_write_raw_P(oled_keymap_horizontal, sizeof(oled_keymap_horizontal));
} else {
static const char PROGMEM oled_keymap_vertical[] = {
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand All @@ -193,46 +213,26 @@ static void render_background(void) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00,
0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00,
0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
oled_write_raw_P(oled_keymap_vertical, sizeof(oled_keymap_vertical));
}
}

// Location of OLED keyboard's top left pixel, relative to the display
static const int keymap_template[2] = {95, 31};
static const int keymap_template[2] = {46, 0};
// Location of key highlights top left pixels, relative to keymap_template {X, Y, Key length in px}
static int keymap_coords[MATRIX_ROWS][MATRIX_COLS][3] = {
{ {-18, -4, 1}, {-23, -4, 1}, {-28, -4, 1}, {-33, -4, 1}, {-38, -4, 1}, {-43, -4, 1}, {-48, -4, 1} },
{ {-22, -9, 5}, {-27, -9, 1}, {-32, -9, 1}, {-37, -9, 1}, {-42, -9, 1}, {-47, -9, 1}, {-52, -9, 1} },
{ {-23, -14, 6}, {-28, -14, 1}, {-33, -14, 1}, {-38, -14, 1}, {-43, -14, 1}, {-48, -14, 1}, {-53, -14, 1} },
{ {-25, -19, 8}, {-30, -19, 1}, {-35, -19, 1}, {-40, -19, 1}, {-45, -19, 1}, {-50, -19, 1}, {-55, -19, 1} },
{ {-19, -24, 2}, {-25, -24, 2}, {-31, -24, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {-68, -24, 33} },
{ {-53, -4, 1}, {-58, -4, 1}, {-63, -4, 1}, {-68, -4, 1}, {-73, -4, 1}, {-78, -4, 1}, {-90, -4, 8} },
{ {-57, -9, 1}, {-62, -9, 1}, {-67, -9, 1}, {-72, -9, 1}, {-77, -9, 1}, {-82, -9, 1}, {-90, -9, 4} },
{ {-58, -14, 1}, {-63, -14, 1}, {-68, -14, 1}, {-73, -14, 1}, {-78, -14, 1}, {-90, -14, 8}, {-95, -14, 1} },
{ {-60, -19, 1}, {-65, -19, 1}, {-70, -19, 1}, {-75, -19, 1}, {-85, -19, 6}, {-90, -19, 1}, {-95, -19, 1} },
{ {0, 0, 0}, {0, 0, 0}, {-74, -24, 2}, {-80, -24, 2}, {-85, -24, 1}, {-90, -24, 1}, {-95, -24, 1} },
{ {0, 0, 1}, {5, 0, 1}, {10, 0, 1}, {15, 0, 1}, {20, 0, 1}, {25, 0, 1}, {30, 0, 1} },
{ {0, 5, 5}, {9, 5, 1}, {14, 5, 1}, {19, 5, 1}, {24, 5, 1}, {29, 5, 1}, {34, 5, 1} },
{ {0, 10, 6}, {10, 10, 1}, {15, 10, 1}, {20, 10, 1}, {25, 10, 1}, {30, 10, 1}, {35, 10, 1} },
{ {0, 15, 8}, {12, 15, 1}, {17, 15, 1}, {22, 15, 1}, {27, 15, 1}, {32, 15, 1}, {37, 15, 1} },
{ {0, 20, 2}, {6, 20, 2}, {12, 20, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {18, 20, 33} },
{ {35, 0, 1}, {40, 0, 1}, {45, 0, 1}, {50, 0, 1}, {55, 0, 1}, {60, 0, 1}, {65, 0, 8} },
{ {39, 5, 1}, {44, 5, 1}, {49, 5, 1}, {54, 5, 1}, {59, 5, 1}, {64, 5, 1}, {69, 5, 4} },
{ {40, 10, 1}, {45, 10, 1}, {50, 10, 1}, {55, 10, 1}, {60, 10, 1}, {65, 10, 8}, {77, 10, 1} },
{ {42, 15, 1}, {47, 15, 1}, {52, 15, 1}, {57, 15, 1}, {62, 15, 6}, {72, 15, 1}, {77, 15, 1} },
{ {0, 0, 0}, {0, 0, 0}, {55, 20, 2}, {61, 20, 2}, {67, 20, 1}, {72, 20, 1}, {77, 20, 1} },
};

// Toggles pixels surrounding key
Expand All @@ -255,14 +255,156 @@ static void render_keymap(uint8_t key_row, uint8_t key_col, bool onoff) {
}
}

// Write active layer name
static void render_layer_state(void) {
if (oled_horizontal) {
oled_set_cursor(0, 0);
} else {
oled_set_cursor(0, 15);
}
switch (get_highest_layer(layer_state)) {
case 0:
oled_write_P(PSTR(MA_LAYER_NAME), false);
break;
case 1:
oled_write_P(PSTR(L1_LAYER_NAME), false);
break;
case 2:
oled_write_P(PSTR(L2_LAYER_NAME), false);
break;
case 3:
oled_write_P(PSTR(L3_LAYER_NAME), false);
break;
default:
oled_write("ERROR", false);
break;
}
}


// Update WPM counters
static void render_wpm_counters(int current_wpm) {
int cursorposition_cur = 2;
int cursorposition_max = 1;
if (oled_horizontal == false) {
cursorposition_cur = 13;
cursorposition_max = 14;
}

oled_set_cursor(0, cursorposition_cur);
oled_write(get_u8_str(get_current_wpm(), '0'), false);

char wpm_counter[4];
wpm_counter[3] = '\0';
wpm_counter[2] = '0' + current_wpm % 10;
wpm_counter[1] = '0' + (current_wpm / 10) % 10;
wpm_counter[0] = '0' + (current_wpm / 100) % 10;

if (current_wpm > max_wpm) {
max_wpm = current_wpm;
wpm_limit = max_wpm + 20;
oled_set_cursor(0, cursorposition_max);
oled_write(wpm_counter, false);
}
}

// Update WPM graph
static void render_wpm_graph(int current_wpm) {
int line_height = ((current_wpm / graph_top_wpm) * 7);
if (line_height > 7) {
line_height = 7;
}
// Count graph line pixels, return if nothing to draw
int pixel_count = line_height;
for (int i = 0; i < 64; i++) {
pixel_count += graph_lines[i];
}
if (pixel_count == 0) {
return;
}
// Shift array elements left or right depending on graph_direction, append new graph line
if (graph_direction) {
for (int i = 0; i < 64; i++) {
graph_lines[i] = graph_lines[i + 1];
}
graph_lines[64] = line_height;
} else {
for (int i = 64; i > 0; i--) {
graph_lines[i] = graph_lines[i - 1];
}
graph_lines[0] = line_height;
}
// Draw all graph lines (left to right, bottom to top)
int draw_count, arrpos;
for (int x = 1; x <= 127; x += 2) {
arrpos = x / 2;
draw_count = graph_lines[arrpos];
for (int y = 31; y >= 25; y--) {
if (draw_count > 0) {
write_pixel(x, y, true);
draw_count--;
} else {
write_pixel(x, y, false);
}
}
}
}

// Update WPM snail icon
static void render_wpm_icon(int current_wpm) {
// wpm_icon is used to prevent unnecessary redraw
if ((current_wpm < icon_med_wpm) && (wpm_icon != 0)) {
wpm_icon = 0;
} else if ((current_wpm >= icon_med_wpm) && (current_wpm < icon_fast_wpm) && (wpm_icon != 1)) {
wpm_icon = 1;
} else if ((current_wpm >= icon_fast_wpm) && (wpm_icon != 2)) {
wpm_icon = 2;
} else {
return;
}
static const char PROGMEM snails[][2][24] = {
{{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0xA0, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x50, 0x88, 0x04, 0x00, 0x00},
{0x40, 0x60, 0x50, 0x4E, 0x51, 0x64, 0x4A, 0x51, 0x54, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x40, 0x30, 0x09, 0x04, 0x02, 0x01, 0x00, 0x00}},
{{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x04, 0x98, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00},
{0x60, 0x50, 0x54, 0x4A, 0x51, 0x64, 0x4A, 0x51, 0x55, 0x49, 0x41, 0x62, 0x54, 0x49, 0x46, 0x41, 0x21, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00, 0x00}},
{{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x10, 0x10, 0x10, 0x20, 0x40, 0x40, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00},
{0x60, 0x58, 0x54, 0x62, 0x49, 0x54, 0x52, 0x51, 0x55, 0x49, 0x62, 0x52, 0x4D, 0x45, 0x46, 0x22, 0x21, 0x11, 0x10, 0x0A, 0x08, 0x05, 0x02, 0x00}}
};
if (oled_horizontal) {
oled_set_cursor(3, 1);
oled_write_raw_P(snails[wpm_icon][0], sizeof(snails[wpm_icon][0]));
oled_set_cursor(3, 2);
oled_write_raw_P(snails[wpm_icon][1], sizeof(snails[wpm_icon][1]));
} else {
oled_set_cursor(0, 11);
oled_write_raw_P(snails[wpm_icon][0], sizeof(snails[wpm_icon][0]));
oled_set_cursor(0, 12);
oled_write_raw_P(snails[wpm_icon][1], sizeof(snails[wpm_icon][1]));
}
}

/* Function that renders stuff on the oled: */
bool oled_task_user(void) {
// Draw OLED keyboard, preventing redraw.
if (first_loop) {
render_background();
first_loop = false;
}

// Get current WPM
int current_wpm = get_current_wpm();
// Write active layer name to display
render_layer_state();
// Update WPM counters
render_wpm_counters(current_wpm);
// Update WPM snail icon
render_wpm_icon(current_wpm);
// Update WPM graph every graph_refresh milliseconds
if (timer_elapsed(timer) > graph_refresh) {
render_wpm_graph(current_wpm);
timer = timer_read();
}

first_loop = false;
return false;
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions keyboards/adpenrose/kintsugi/keymaps/type_matrix/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
WPM_ENABLE = yes
SPACE_CADET_ENABLE = no
MAGIC_ENABLE = no