From 5e86a11a8d49928f06609e9ee1b9ef86c45f3f2e Mon Sep 17 00:00:00 2001 From: Jose Luis Adelantado Torres Date: Thu, 24 Jun 2021 11:24:11 +0900 Subject: [PATCH 1/2] [keymap] Added new `oled_status` keymap to `nullbitsco/nibble` keyboard (#12824) * Added new oled_status keymap to nullbitsco/nibble keyboard * rm: Removed font from src imports --- .../nibble/keymaps/oled_status/config.h | 21 ++ .../nibble/keymaps/oled_status/glcdfont.c | 245 ++++++++++++++++++ .../nibble/keymaps/oled_status/keymap.c | 106 ++++++++ .../nibble/keymaps/oled_status/oled_display.c | 117 +++++++++ .../nibble/keymaps/oled_status/oled_display.h | 41 +++ .../nibble/keymaps/oled_status/readme.md | 29 +++ .../nibble/keymaps/oled_status/rules.mk | 7 + 7 files changed, 566 insertions(+) create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/config.h create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/glcdfont.c create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/keymap.c create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.c create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.h create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/readme.md create mode 100644 keyboards/nullbitsco/nibble/keymaps/oled_status/rules.mk diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/config.h b/keyboards/nullbitsco/nibble/keymaps/oled_status/config.h new file mode 100644 index 000000000..bdb970ff5 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/config.h @@ -0,0 +1,21 @@ +/* Copyright 2021 Jose Luis Adelantado Torres + * + * 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 . + */ +#pragma once + +// Referenced custom font +#ifdef OLED_DRIVER_ENABLE +# define OLED_FONT_H "keyboards/nullbitsco/nibble/keymaps/oled_status/glcdfont.c" +#endif diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/glcdfont.c b/keyboards/nullbitsco/nibble/keymaps/oled_status/glcdfont.c new file mode 100644 index 000000000..1435bf730 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/glcdfont.c @@ -0,0 +1,245 @@ +/* Copyright 2021 Jose Luis Adelantado Torres + * + * 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 . + */ +#include "progmem.h" + +// Standard ASCII 5x7 font + +static const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, + 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, + 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, + 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, + 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, + 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, + 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, + 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, + 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, + 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, + 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, + 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, + 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, + 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, + 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, + 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, + 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, + 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, + 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, + 0x18, 0x24, 0x24, 0x1C, 0x78, 0x00, + 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, + 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0x7C, 0x18, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0x7C, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, + 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, + 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, + 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, + 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFC, + 0xFC, 0xFC, 0x00, 0x7C, 0x7C, 0x7C, + 0x7C, 0x7C, 0x7C, 0xFC, 0xF8, 0xF0, + 0xE0, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xC0, 0x40, 0xC0, + 0x40, 0x40, 0x40, 0x60, 0x30, 0x18, + 0x0C, 0x04, 0x04, 0xCC, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xC0, 0x40, 0xC0, + 0x40, 0x40, 0x40, 0x60, 0x30, 0x18, + 0x0C, 0x04, 0x04, 0xFC, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xF0, 0x10, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x50, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x50, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x10, 0x10, 0xF0, 0x00, + 0x00, 0xF0, 0x10, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x50, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x50, 0x10, 0x50, 0x10, + 0x50, 0x10, 0x10, 0x10, 0xF0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC, + 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00, + 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E, + 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x00, + 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, + 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, + 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, + 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x99, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x1F, 0x10, 0x90, 0xD0, 0xD1, + 0x50, 0x11, 0x14, 0x15, 0x14, 0x15, + 0x14, 0x15, 0x14, 0x15, 0x50, 0xD1, + 0xD0, 0x91, 0x10, 0x10, 0x1F, 0x00, + 0x00, 0x1F, 0x10, 0x10, 0x10, 0x11, + 0x10, 0x11, 0x54, 0xD5, 0x94, 0x15, + 0x94, 0xD5, 0x54, 0x15, 0x10, 0x11, + 0x10, 0x11, 0x10, 0x10, 0x1F, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00, + 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F, + 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00, + 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, + 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, + 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, + 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, + 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x3F, + 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x03, 0x02, 0x03, + 0x02, 0x02, 0x02, 0x06, 0x0C, 0x18, + 0x30, 0x20, 0x20, 0x33, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x03, 0x02, 0x03, + 0x02, 0x02, 0x02, 0x06, 0x0C, 0x18, + 0x30, 0x20, 0x20, 0x3F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x03, 0x01, 0x08, + 0x1C, 0x0E, 0x07, 0x00, 0x1C, 0x7E, + 0x1C, 0x00, 0x07, 0x0E, 0x1C, 0x0C, + 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x0C, 0x07, 0x03, + 0x07, 0x0C, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/keymap.c b/keyboards/nullbitsco/nibble/keymaps/oled_status/keymap.c new file mode 100644 index 000000000..c39f42b36 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/keymap.c @@ -0,0 +1,106 @@ +/* Copyright 2021 Jose Luis Adelantado Torres + * + * 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 . + */ +#include QMK_KEYBOARD_H + +#ifdef OLED_DRIVER_ENABLE +# include "oled_display.h" +#endif + +enum layer_names { + _MA, + _FN +}; + +enum custom_keycodes { + KC_CUST = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_MA] = LAYOUT_ansi( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_F13, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, + KC_F14, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_F15, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_F16, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + [_FN] = LAYOUT_ansi( + RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_END, + RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), +}; + +#ifdef OLED_DRIVER_ENABLE +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + oled_timer = timer_read32(); + set_oled_mode(OLED_MODE_IDLE); + return OLED_ROTATION_180; +} + +void oled_task_user(void) { + if (timer_elapsed(oled_timer) >= 3000) { + set_oled_mode(OLED_MODE_IDLE); + } + render_frame(); +} +#endif + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // Send keystrokes to host keyboard, if connected (see readme) + process_record_remote_kb(keycode, record); + + switch(keycode) { + case RGB_TOG: + if (record->event.pressed) { +#ifdef OLED_DRIVER_ENABLE + process_record_keymap_oled(keycode); +#endif + } + break; + case KC_CUST: //custom macro + if (record->event.pressed) { + } + break; + } + return true; +} + + +void encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) { + tap_code(KC_VOLU); +#ifdef OLED_DRIVER_ENABLE + process_record_encoder_oled(KC_VOLU); +#endif + } else { + tap_code(KC_VOLD); +#ifdef OLED_DRIVER_ENABLE + process_record_encoder_oled(KC_VOLD); +#endif + } +} + +void matrix_init_user(void) { + // Initialize remote keyboard, if connected (see readme) + matrix_init_remote_kb(); +} + +void matrix_scan_user(void) { + // Scan and parse keystrokes from remote keyboard, if connected (see readme) + matrix_scan_remote_kb(); +} diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.c b/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.c new file mode 100644 index 000000000..1b132a9e6 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.c @@ -0,0 +1,117 @@ +/* Copyright 2021 Jose Luis Adelantado Torres + * + * 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 . + */ +#include +#include "quantum.h" +#include "oled_display.h" + +static const char PROGMEM oled_mode_messages[5][15] = { + "", + "Volume Up", + "Volume Down", + "RGB ON", + "RGB OFF" +}; + +static const char PROGMEM oled_mode_icons[5][3][5] = { + {{128,129,130,131,0},{160,161,162,163,0},{192,193,194,195,0}}, + {{132,133,134,135,0},{164,165,166,167,0},{196,197,198,199,0}}, + {{136,137,138,139,0},{168,169,170,171,0},{200,201,202,203,0}}, + {{140,141,142,143,0},{172,173,174,175,0},{204,205,206,207,0}}, + {{144,145,146,147,0},{176,177,178,179,0},{208,209,210,211,0}} +}; + +void set_oled_mode(oled_mode_t mode) { + oled_mode = mode; +} + +void process_record_encoder_oled(uint16_t keycode) { + oled_timer = timer_read32(); + switch (keycode) { + case KC_VOLU: + set_oled_mode(OLED_MODE_VOLUME_UP); + break; + case KC_VOLD: + set_oled_mode(OLED_MODE_VOLUME_DOWN); + break; + default: + set_oled_mode(OLED_MODE_IDLE); + break; + } +} + +void process_record_keymap_oled(uint16_t keycode) { + oled_timer = timer_read32(); + if(rgblight_is_enabled()) { + set_oled_mode(OLED_MODE_RGB_OFF); + } else { + set_oled_mode(OLED_MODE_RGB_ON); + } +} + +void render_wpm(void) { + char wpm_str[10]; + + sprintf(wpm_str, "%03d", get_current_wpm()); + oled_write_P(PSTR(" "), false); + oled_write(wpm_str, false); +} + +void render_idle(void) { + // Host Keyboard LED Status + led_t led_state = host_keyboard_led_state(); + + // Printing logo, state + oled_write_P(oled_mode_icons[0][0], false); + oled_write_P(PSTR(" "), false); + oled_write_P(led_state.scroll_lock ? PSTR("S ") : PSTR(" "), false); + oled_write_P(led_state.num_lock ? PSTR("N ") : PSTR(" "), false); + oled_write_P(led_state.caps_lock ? PSTR("C ") : PSTR(" "), false); + oled_write_P(PSTR("\n"), false); + oled_write_P(oled_mode_icons[0][1], false); + oled_write_P(PSTR(" Nibble"), false); + oled_write_P(PSTR("\n"), false); + oled_write_P(oled_mode_icons[0][2], false); + oled_write_P(PSTR("\n"), false); + + // Printing WPM + render_wpm(); +} + +void render_status_mode_message(void) { + // Printing state icon with message + oled_write_P(oled_mode_icons[oled_mode][0], false); + oled_write_P(PSTR("\n"), false); + oled_write_P(oled_mode_icons[oled_mode][1], false); + oled_write_P(PSTR(" "), false); + oled_write_P(oled_mode_messages[oled_mode], false); + oled_write_P(PSTR("\n"), false); + oled_write_P(oled_mode_icons[oled_mode][2], false); + oled_write_P(PSTR("\n\n"), false); +} + +void render_frame(void) { + switch (oled_mode) { + case OLED_MODE_VOLUME_UP: + case OLED_MODE_VOLUME_DOWN: + case OLED_MODE_RGB_ON: + case OLED_MODE_RGB_OFF: + render_status_mode_message(); + break; + default: + render_idle(); + break; + } +} diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.h b/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.h new file mode 100644 index 000000000..bd59d44b4 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/oled_display.h @@ -0,0 +1,41 @@ +/* Copyright 2021 Jose Luis Adelantado Torres + * + * 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 . + */ +#pragma once + +typedef enum { + OLED_MODE_IDLE = 0, + OLED_MODE_VOLUME_UP = 1, + OLED_MODE_VOLUME_DOWN = 2, + OLED_MODE_RGB_ON = 3, + OLED_MODE_RGB_OFF = 4, +} oled_mode_t; + +uint16_t oled_timer; +oled_mode_t oled_mode; + +void set_oled_mode(oled_mode_t mode); + +void process_record_encoder_oled(uint16_t keycode); + +void process_record_keymap_oled(uint16_t keycode); + +void render_wpm(void); + +void render_idle(void); + +void render_status_mode_message(void); + +void render_frame(void); diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/readme.md b/keyboards/nullbitsco/nibble/keymaps/oled_status/readme.md new file mode 100644 index 000000000..5b56e5a35 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/readme.md @@ -0,0 +1,29 @@ +# Oled Status + +This uses the [default keymap layout](#layout) and uses the oled to display some useful information. Also VIA is enabled by default! + +Oled displays + * [Led status](#idle) + * [WPM](#idle) + * [Volume Notifications](#volume-notification) + * [RGB Notifications](#rgb-notification) + + +## Layout +![Layout](https://i.imgur.com/XtxdHRH.png) + +## Display +### IDLE +![IDLE1](https://i.imgur.com/OzS3l6J.png) + +![IDLE2](https://i.imgur.com/KG03xkV.png) + +### Volume Notification +![VOL1](https://i.imgur.com/ZEMeme9.png) + +![VOL2](https://i.imgur.com/fQ14uhM.png) + +### RGB Notification +![RGB1](https://i.imgur.com/ILCMudA.png) + +![RGB2](https://i.imgur.com/V5v6PVq.png) diff --git a/keyboards/nullbitsco/nibble/keymaps/oled_status/rules.mk b/keyboards/nullbitsco/nibble/keymaps/oled_status/rules.mk new file mode 100644 index 000000000..51c47cff8 --- /dev/null +++ b/keyboards/nullbitsco/nibble/keymaps/oled_status/rules.mk @@ -0,0 +1,7 @@ +OLED_DRIVER_ENABLE = yes +WPM_ENABLE = yes +VIA_ENABLE = yes + +ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes) + SRC += oled_display.c +endif From f5cecffab2a32db5db9177aab79226a00013db81 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont" Date: Thu, 24 Jun 2021 04:24:31 +0200 Subject: [PATCH 2/2] keymap/ardumont: Fix substitute keycode reset step (#12675) It so happens that when releasing the control key prior to the main key (C-h, C-i, C-n, ...), the substituted keycode was continuously sent in a loop after that (even when releasing said key). The workaround so far was to type any other key to stop the loop. This commit fixes such behavior by resetting the substitution keycode sent when the ctrl released situation conditional is detected (and that the substitution keycode was on). --- keyboards/keyboardio/atreus/keymaps/ardumont/keymap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/keyboards/keyboardio/atreus/keymaps/ardumont/keymap.c b/keyboards/keyboardio/atreus/keymaps/ardumont/keymap.c index 3bde667ee..6faabbc3e 100644 --- a/keyboards/keyboardio/atreus/keymaps/ardumont/keymap.c +++ b/keyboards/keyboardio/atreus/keymaps/ardumont/keymap.c @@ -97,8 +97,7 @@ bool substitute_keycode(uint16_t keycode, keyrecord_t *record, uint8_t mod_state // Do not let QMK process the keycode further return false; } else { - // In case substitude_keycode is still being sent even after the release of - // the key + // In case substitude_keycode is still even after release of the key if (key_registered) { unregister_code(substitute_keycode); key_registered = false; @@ -106,6 +105,12 @@ bool substitute_keycode(uint16_t keycode, keyrecord_t *record, uint8_t mod_state return false; } } + } else { // ctrl got released + // In case substitude_keycode is still sent after release of the ctrl key + if (key_registered) { + unregister_code(substitute_keycode); + key_registered = false; + } } // Else, let QMK process the keycode as usual return true;