From 8a330b33ff41ffc1ec3f8fa39722e93115ea3f0f Mon Sep 17 00:00:00 2001 From: Legonut Date: Tue, 4 Dec 2018 21:15:52 -0500 Subject: Keyboard: Add new keyboard "Sol" from RGBKB (#4497) * Add final RGBKB Sol firmware * Apply suggestions from code review Apply most of the changes noroadsleft has suggested Co-Authored-By: Legonut * Cleanup readme * Cleanup keymaps per @noroadslefts suggestions * Remove eeproms, use set_single_persistent_default_layer * Suggestions from @noroadsleft and @drashna some small cleanup * Change RGB_SMOD to RGB_RMOD * fix RGB_SMOD * Apply suggestions from code review Remove redundant lines Co-Authored-By: Legonut --- keyboards/sol/common/glcdfont.c | 244 +++++++++++++++++++ keyboards/sol/common/knob_v2.c | 71 ++++++ keyboards/sol/common/knob_v2.h | 28 +++ keyboards/sol/common/ssd1306.c | 329 +++++++++++++++++++++++++ keyboards/sol/common/ssd1306.h | 92 +++++++ keyboards/sol/config.h | 22 ++ keyboards/sol/i2c.c | 162 +++++++++++++ keyboards/sol/i2c.h | 49 ++++ keyboards/sol/keymaps/brianweyer/config.h | 27 +++ keyboards/sol/keymaps/brianweyer/keymap.c | 291 ++++++++++++++++++++++ keyboards/sol/keymaps/brianweyer/rules.mk | 46 ++++ keyboards/sol/keymaps/danielhklein/config.h | 25 ++ keyboards/sol/keymaps/danielhklein/keymap.c | 354 +++++++++++++++++++++++++++ keyboards/sol/keymaps/danielhklein/rules.mk | 50 ++++ keyboards/sol/keymaps/default/config.h | 25 ++ keyboards/sol/keymaps/default/keymap.c | 362 ++++++++++++++++++++++++++++ keyboards/sol/keymaps/default/readme.md | 133 ++++++++++ keyboards/sol/keymaps/default/rules.mk | 50 ++++ keyboards/sol/keymaps/kageurufu/config.h | 25 ++ keyboards/sol/keymaps/kageurufu/keymap.c | 335 +++++++++++++++++++++++++ keyboards/sol/keymaps/kageurufu/readme.md | 47 ++++ keyboards/sol/keymaps/kageurufu/rules.mk | 46 ++++ keyboards/sol/readme.md | 15 ++ keyboards/sol/rev1/config.h | 155 ++++++++++++ keyboards/sol/rev1/matrix.c | 304 +++++++++++++++++++++++ keyboards/sol/rev1/rev1.c | 15 ++ keyboards/sol/rev1/rev1.h | 70 ++++++ keyboards/sol/rev1/rules.mk | 2 + keyboards/sol/rev1/split_util.c | 54 +++++ keyboards/sol/rev1/split_util.h | 17 ++ keyboards/sol/rules.mk | 71 ++++++ keyboards/sol/serial.c | 288 ++++++++++++++++++++++ keyboards/sol/serial.h | 26 ++ keyboards/sol/sol.c | 1 + keyboards/sol/sol.h | 7 + 35 files changed, 3838 insertions(+) create mode 100644 keyboards/sol/common/glcdfont.c create mode 100644 keyboards/sol/common/knob_v2.c create mode 100644 keyboards/sol/common/knob_v2.h create mode 100644 keyboards/sol/common/ssd1306.c create mode 100644 keyboards/sol/common/ssd1306.h create mode 100644 keyboards/sol/config.h create mode 100644 keyboards/sol/i2c.c create mode 100644 keyboards/sol/i2c.h create mode 100755 keyboards/sol/keymaps/brianweyer/config.h create mode 100755 keyboards/sol/keymaps/brianweyer/keymap.c create mode 100755 keyboards/sol/keymaps/brianweyer/rules.mk create mode 100644 keyboards/sol/keymaps/danielhklein/config.h create mode 100644 keyboards/sol/keymaps/danielhklein/keymap.c create mode 100644 keyboards/sol/keymaps/danielhklein/rules.mk create mode 100644 keyboards/sol/keymaps/default/config.h create mode 100644 keyboards/sol/keymaps/default/keymap.c create mode 100644 keyboards/sol/keymaps/default/readme.md create mode 100644 keyboards/sol/keymaps/default/rules.mk create mode 100644 keyboards/sol/keymaps/kageurufu/config.h create mode 100644 keyboards/sol/keymaps/kageurufu/keymap.c create mode 100644 keyboards/sol/keymaps/kageurufu/readme.md create mode 100644 keyboards/sol/keymaps/kageurufu/rules.mk create mode 100644 keyboards/sol/readme.md create mode 100644 keyboards/sol/rev1/config.h create mode 100644 keyboards/sol/rev1/matrix.c create mode 100644 keyboards/sol/rev1/rev1.c create mode 100644 keyboards/sol/rev1/rev1.h create mode 100644 keyboards/sol/rev1/rules.mk create mode 100644 keyboards/sol/rev1/split_util.c create mode 100644 keyboards/sol/rev1/split_util.h create mode 100644 keyboards/sol/rules.mk create mode 100644 keyboards/sol/serial.c create mode 100644 keyboards/sol/serial.h create mode 100644 keyboards/sol/sol.c create mode 100644 keyboards/sol/sol.h diff --git a/keyboards/sol/common/glcdfont.c b/keyboards/sol/common/glcdfont.c new file mode 100644 index 0000000000..89665ba074 --- /dev/null +++ b/keyboards/sol/common/glcdfont.c @@ -0,0 +1,244 @@ +// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. +// See gfxfont.h for newer custom bitmap font info. + +#ifndef FONT5X7_H +#define FONT5X7_H + +#ifdef __AVR__ + #include + #include +#elif defined(ESP8266) + #include +#else + #define PROGMEM +#endif + +// 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, 0xA4, 0xA4, 0x9C, 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, + 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x18, 0xFC, 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, + 0x03, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, + 0xFE, 0xF8, 0xF0, 0xC0, 0x20, 0xF8, + 0xFE, 0xFF, 0xFE, 0x79, 0x27, 0x1F, + 0x7F, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, + 0xC0, 0x20, 0xF8, 0xFE, 0xFF, 0xFF, + 0x7F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFE, + 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x7F, 0x7F, 0x7F, + 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xE0, + 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, + 0xF8, 0x78, 0x78, 0x7C, 0x3C, 0x3C, + 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, + 0xBF, 0xBF, 0xDF, 0xDF, 0xEF, 0xEF, + 0x00, 0x03, 0x07, 0x1F, 0x7F, 0xFF, + 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0, + 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, + 0x7F, 0x1F, 0x07, 0x03, 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, 0xC1, 0xF3, + 0xCF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFC, + 0xFB, 0xE7, 0x81, 0x00, 0x00, 0x00, + 0x00, 0x80, 0xE3, 0xCF, 0x3F, 0xFF, + 0xFF, 0xFF, 0xFC, 0xFB, 0xE7, 0x81, + 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7, + 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x00, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xF8, 0xF8, 0xFC, 0x7C, 0x7E, + 0x7E, 0x3E, 0xFE, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xF7, 0xF7, 0xF7, 0xFB, + 0xFB, 0x7D, 0x7D, 0x7D, 0xBE, 0xBE, + 0xBE, 0xDF, 0xDF, 0xE0, 0xE0, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFC, 0xFC, 0x7C, 0x7E, 0x7E, + 0x3E, 0x3E, 0x1F, 0x1F, 0x1F, 0x0F, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, + 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x81, + 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, + 0x60, 0x70, 0x7C, 0x7F, 0x7F, 0x7F, + 0x7F, 0x1F, 0x06, 0x01, 0x03, 0x0F, + 0x3F, 0x7F, 0x7F, 0x7E, 0x7C, 0x7C, + 0x7E, 0x7F, 0x7F, 0x7F, 0x1F, 0x06, + 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0x7F, + 0x7E, 0x7C, 0x7C, 0x7E, 0x7F, 0x7F, + 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x7D, 0x7D, 0x3D, 0x3E, + 0x1E, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, + 0x07, 0x07, 0x07, 0x03, 0x03, 0x00, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, + 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x00, 0x40, 0x70, 0x78, 0x7E, 0x7F, + 0x7F, 0x7F, 0x3F, 0x0F, 0x03, 0x01, + 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0x7F, + 0x7E, 0x78, 0x70, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +#endif // FONT5X7_H diff --git a/keyboards/sol/common/knob_v2.c b/keyboards/sol/common/knob_v2.c new file mode 100644 index 0000000000..f22f7c5d86 --- /dev/null +++ b/keyboards/sol/common/knob_v2.c @@ -0,0 +1,71 @@ +#include "knob_v2.h" + +bool knob_prev_a = false; +static knob_report_t knob_report = {.dir = 0, .phase = 0}; + +void knob_init(void) { + // I use pins D1 (ISR1) & D4 for a knob. + + // Set pin mode for D4 as input. + DDRD &= ~(0UL << ENCODER_PIN_2); + + // Enable internal pull-up for D4. + // This is done by "writing" 1 to a pin that has its mode set to input. + PORTD |= (1 << ENCODER_PIN_2); + + // Enable interrupt for D1 + // For more info on the below flags see this awesome section 11.1 (pages 89-90) here: + // https://cdn-shop.adafruit.com/datasheets/atmel-7766-8-bit-avr-atmega16u4-32u4_datasheet.pdf + // Set pin mode & pull-up. + DDRD &= ~(0UL << ENCODER_PIN_1); + PORTD |= (1UL << ENCODER_PIN_1); + + // INT: 33221100 + EICRA |= 0b00010000; // 0b01 - any edge + // INT: 6 3210 + EIMSK |= 0b00000100; +} + +ISR(ENCODER_INT) { + bool a = PIND & (1 << ENCODER_PIN_1); + + if (knob_prev_a != a) { + // "A" channel has REALLY changed. + knob_report.phase = a; + knob_prev_a = a; + bool b = PIND & (1 << ENCODER_PIN_2); + if (a == b) { + // Halfway through CCW rotation (A == B) + // + // +---YOU ARE HERE (A=1, B=1) + // | +---OR HERE (A=0, B=0) + // | | + // v v + // A: _____/^^^^^\__ + // B: __/^^^^^\_____ + knob_report.dir++; + } else { + // Halfway through CW rotation (A != B) + // + // +---YOU ARE HERE (A=1, B=0) + // | +---OR HERE (A=0, B=1) + // | | + // v v + // A: _____/^^^^^\_____ + // B: ________/^^^^^\__ + knob_report.dir--; + } + } +} + +knob_report_t knob_report_read(void) { + // Return knob report. + return knob_report; +} + +void knob_report_reset(void) { + // Call this ASAP once you've processed the previous knob report. + // TODO: This should probably be called within `knob_report_read`. + knob_report.dir = 0; + knob_report.phase = 0; +} diff --git a/keyboards/sol/common/knob_v2.h b/keyboards/sol/common/knob_v2.h new file mode 100644 index 0000000000..45196eb1a6 --- /dev/null +++ b/keyboards/sol/common/knob_v2.h @@ -0,0 +1,28 @@ +// Rotary knob implementation - Version 2. +// Uses 2 digital pins - D2 (via interrupt) & D6. +// #include "rev1.h" +#include +#include +#include + +#ifndef ENCODER_PIN_1 + #define ENCODER_PIN_1 PD2 +#endif +#ifndef ENCODER_PIN_2 + #define ENCODER_PIN_2 PD6 +#endif +#ifndef ENCODER_INT + #define ENCODER_INT INT2_vect +#endif + +typedef struct knob_report_t { + int8_t dir; // Contains number of rotations that happened + int8_t phase; // Contains 0 if last rotation happened on 90 degrees, 1 if on 270 +} knob_report_t; + +void knob_init(void); +knob_report_t knob_report_read(void); +void knob_report_reset(void); + +bool knob_prev_a; +int8_t knob_dir; diff --git a/keyboards/sol/common/ssd1306.c b/keyboards/sol/common/ssd1306.c new file mode 100644 index 0000000000..b3e55a67c2 --- /dev/null +++ b/keyboards/sol/common/ssd1306.c @@ -0,0 +1,329 @@ +#ifdef SSD1306OLED + +#include "ssd1306.h" +#include "i2c.h" +#include +#include "print.h" +#ifndef LOCAL_GLCDFONT +#include "common/glcdfont.c" +#else +#include +#endif +#ifdef ADAFRUIT_BLE_ENABLE +#include "adafruit_ble.h" +#endif +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#endif +#include "sendchar.h" +#include "timer.h" + +// Set this to 1 to help diagnose early startup problems +// when testing power-on with ble. Turn it off otherwise, +// as the latency of printing most of the debug info messes +// with the matrix scan, causing keys to drop. +#define DEBUG_TO_SCREEN 0 + +//static uint16_t last_battery_update; +//static uint32_t vbat; +//#define BatteryUpdateInterval 10000 /* milliseconds */ +#define ScreenOffInterval 300000 /* milliseconds */ +#if DEBUG_TO_SCREEN +static uint8_t displaying; +#endif +static uint16_t last_flush; + +// Write command sequence. +// Returns true on success. +static inline bool _send_cmd1(uint8_t cmd) { + bool res = false; + + if (i2c_start_write(SSD1306_ADDRESS)) { + xprintf("failed to start write to %d\n", SSD1306_ADDRESS); + goto done; + } + + if (i2c_master_write(0x0 /* command byte follows */)) { + print("failed to write control byte\n"); + + goto done; + } + + if (i2c_master_write(cmd)) { + xprintf("failed to write command %d\n", cmd); + goto done; + } + res = true; +done: + i2c_master_stop(); + return res; +} + +// Write 2-byte command sequence. +// Returns true on success +static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { + if (!_send_cmd1(cmd)) { + return false; + } + return _send_cmd1(opr); +} + +// Write 3-byte command sequence. +// Returns true on success +static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { + if (!_send_cmd1(cmd)) { + return false; + } + if (!_send_cmd1(opr1)) { + return false; + } + return _send_cmd1(opr2); +} + +#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} +#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} +#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} + +static void clear_display(void) { + matrix_clear(&display); + + // Clear all of the display bits (there can be random noise + // in the RAM on startup) + send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); + send_cmd3(ColumnAddr, 0, DisplayWidth - 1); + + if (i2c_start_write(SSD1306_ADDRESS)) { + goto done; + } + if (i2c_master_write(0x40)) { + // Data mode + goto done; + } + for (uint8_t row = 0; row < MatrixRows; ++row) { + for (uint8_t col = 0; col < DisplayWidth; ++col) { + i2c_master_write(0); + } + } + + display.dirty = false; + +done: + i2c_master_stop(); +} + +#if DEBUG_TO_SCREEN +#undef sendchar +static int8_t capture_sendchar(uint8_t c) { + sendchar(c); + iota_gfx_write_char(c); + + if (!displaying) { + iota_gfx_flush(); + } + return 0; +} +#endif + +bool iota_gfx_init(bool rotate) { + bool success = false; + + i2c_master_init(); + send_cmd1(DisplayOff); + send_cmd2(SetDisplayClockDiv, 0x80); + send_cmd2(SetMultiPlex, DisplayHeight - 1); + + send_cmd2(SetDisplayOffset, 0); + + + send_cmd1(SetStartLine | 0x0); + send_cmd2(SetChargePump, 0x14 /* Enable */); + send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); + + if(rotate){ + // the following Flip the display orientation 180 degrees + send_cmd1(SegRemap); + send_cmd1(ComScanInc); + }else{ + // Flips the display orientation 0 degrees + send_cmd1(SegRemap | 0x1); + send_cmd1(ComScanDec); + } + + send_cmd2(SetComPins, 0x2); + send_cmd2(SetContrast, 0x8f); + send_cmd2(SetPreCharge, 0xf1); + send_cmd2(SetVComDetect, 0x40); + send_cmd1(DisplayAllOnResume); + send_cmd1(NormalDisplay); + send_cmd1(DeActivateScroll); + send_cmd1(DisplayOn); + + send_cmd2(SetContrast, 0); // Dim + + clear_display(); + + success = true; + + iota_gfx_flush(); + +#if DEBUG_TO_SCREEN + print_set_sendchar(capture_sendchar); +#endif + +done: + return success; +} + +bool iota_gfx_off(void) { + bool success = false; + + send_cmd1(DisplayOff); + success = true; + +done: + return success; +} + +bool iota_gfx_on(void) { + bool success = false; + + send_cmd1(DisplayOn); + success = true; + +done: + return success; +} + +void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { + *matrix->cursor = c; + ++matrix->cursor; + + if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { + // We went off the end; scroll the display upwards by one line + memmove(&matrix->display[0], &matrix->display[1], + MatrixCols * (MatrixRows - 1)); + matrix->cursor = &matrix->display[MatrixRows - 1][0]; + memset(matrix->cursor, ' ', MatrixCols); + } +} + +void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { + matrix->dirty = true; + + if (c == '\n') { + // Clear to end of line from the cursor and then move to the + // start of the next line + uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; + + while (cursor_col++ < MatrixCols) { + matrix_write_char_inner(matrix, ' '); + } + return; + } + + matrix_write_char_inner(matrix, c); +} + +void iota_gfx_write_char(uint8_t c) { + matrix_write_char(&display, c); +} + +void matrix_write(struct CharacterMatrix *matrix, const char *data) { + const char *end = data + strlen(data); + while (data < end) { + matrix_write_char(matrix, *data); + ++data; + } +} + +void iota_gfx_write(const char *data) { + matrix_write(&display, data); +} + +void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { + while (true) { + uint8_t c = pgm_read_byte(data); + if (c == 0) { + return; + } + matrix_write_char(matrix, c); + ++data; + } +} + +void iota_gfx_write_P(const char *data) { + matrix_write_P(&display, data); +} + +void matrix_clear(struct CharacterMatrix *matrix) { + memset(matrix->display, ' ', sizeof(matrix->display)); + matrix->cursor = &matrix->display[0][0]; + matrix->dirty = true; +} + +void iota_gfx_clear_screen(void) { + matrix_clear(&display); +} + +void matrix_render(struct CharacterMatrix *matrix) { + last_flush = timer_read(); + iota_gfx_on(); +#if DEBUG_TO_SCREEN + ++displaying; +#endif + + // Move to the home position + send_cmd3(PageAddr, 0, MatrixRows - 1); + send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); + + if (i2c_start_write(SSD1306_ADDRESS)) { + goto done; + } + if (i2c_master_write(0x40)) { + // Data mode + goto done; + } + + for (uint8_t row = 0; row < MatrixRows; ++row) { + for (uint8_t col = 0; col < MatrixCols; ++col) { + const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); + + for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { + uint8_t colBits = pgm_read_byte(glyph + glyphCol); + i2c_master_write(colBits); + } + + // 1 column of space between chars (it's not included in the glyph) + //i2c_master_write(0); + } + } + + matrix->dirty = false; + +done: + i2c_master_stop(); +#if DEBUG_TO_SCREEN + --displaying; +#endif +} + +void iota_gfx_flush(void) { + matrix_render(&display); +} + +__attribute__ ((weak)) +void iota_gfx_task_user(void) { +} + +void iota_gfx_task(void) { + iota_gfx_task_user(); + + if (display.dirty) { + iota_gfx_flush(); + } + + if (timer_elapsed(last_flush) > ScreenOffInterval) { + iota_gfx_off(); + } +} +#endif diff --git a/keyboards/sol/common/ssd1306.h b/keyboards/sol/common/ssd1306.h new file mode 100644 index 0000000000..77ce7c211a --- /dev/null +++ b/keyboards/sol/common/ssd1306.h @@ -0,0 +1,92 @@ +#ifndef SSD1306_H +#define SSD1306_H + +#include +#include +#include "pincontrol.h" + +enum ssd1306_cmds { + DisplayOff = 0xAE, + DisplayOn = 0xAF, + + SetContrast = 0x81, + DisplayAllOnResume = 0xA4, + + DisplayAllOn = 0xA5, + NormalDisplay = 0xA6, + InvertDisplay = 0xA7, + SetDisplayOffset = 0xD3, + SetComPins = 0xda, + SetVComDetect = 0xdb, + SetDisplayClockDiv = 0xD5, + SetPreCharge = 0xd9, + SetMultiPlex = 0xa8, + SetLowColumn = 0x00, + SetHighColumn = 0x10, + SetStartLine = 0x40, + + SetMemoryMode = 0x20, + ColumnAddr = 0x21, + PageAddr = 0x22, + + ComScanInc = 0xc0, + ComScanDec = 0xc8, + SegRemap = 0xa0, + SetChargePump = 0x8d, + ExternalVcc = 0x01, + SwitchCapVcc = 0x02, + + ActivateScroll = 0x2f, + DeActivateScroll = 0x2e, + SetVerticalScrollArea = 0xa3, + RightHorizontalScroll = 0x26, + LeftHorizontalScroll = 0x27, + VerticalAndRightHorizontalScroll = 0x29, + VerticalAndLeftHorizontalScroll = 0x2a, +}; + +// Controls the SSD1306 128x32 OLED display via i2c + +#ifndef SSD1306_ADDRESS +#define SSD1306_ADDRESS 0x3C +#endif + +#define DisplayHeight 32 +#define DisplayWidth 128 + +#define FontHeight 8 +#define FontWidth 6 + +#define MatrixRows (DisplayHeight / FontHeight) +#define MatrixCols (DisplayWidth / FontWidth) + +struct CharacterMatrix { + uint8_t display[MatrixRows][MatrixCols]; + uint8_t *cursor; + bool dirty; +}; + +struct CharacterMatrix display; + +bool iota_gfx_init(bool rotate); +void iota_gfx_task(void); +bool iota_gfx_off(void); +bool iota_gfx_on(void); +void iota_gfx_flush(void); +void iota_gfx_write_char(uint8_t c); +void iota_gfx_write(const char *data); +void iota_gfx_write_P(const char *data); +void iota_gfx_clear_screen(void); + +void iota_gfx_task_user(void); + +void matrix_clear(struct CharacterMatrix *matrix); +void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); +void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); +void matrix_write(struct CharacterMatrix *matrix, const char *data); +void matrix_write_P(struct CharacterMatrix *matrix, const char *data); +void matrix_render(struct CharacterMatrix *matrix); + + + +#endif diff --git a/keyboards/sol/config.h b/keyboards/sol/config.h new file mode 100644 index 0000000000..93fd2261b1 --- /dev/null +++ b/keyboards/sol/config.h @@ -0,0 +1,22 @@ +/* +Copyright 2012 Jun Wako +Copyright 2015 Jack Humbert + +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 + +#include "config_common.h" + diff --git a/keyboards/sol/i2c.c b/keyboards/sol/i2c.c new file mode 100644 index 0000000000..4bee5c6398 --- /dev/null +++ b/keyboards/sol/i2c.c @@ -0,0 +1,162 @@ +#include +#include +#include +#include +#include +#include +#include "i2c.h" + +#ifdef USE_I2C + +// Limits the amount of we wait for any one i2c transaction. +// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is +// 9 bits, a single transaction will take around 90μs to complete. +// +// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit +// poll loop takes at least 8 clock cycles to execute +#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 + +#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) + +volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; + +static volatile uint8_t slave_buffer_pos; +static volatile bool slave_has_register_set = false; + +// Wait for an i2c operation to finish +inline static +void i2c_delay(void) { + uint16_t lim = 0; + while(!(TWCR & (1<10. + // Check datasheets for more info. + TWBR = ((F_CPU/SCL_CLOCK)-16)/2; +} + +// Start a transaction with the given i2c slave address. The direction of the +// transfer is set with I2C_READ and I2C_WRITE. +// returns: 0 => success +// 1 => error +uint8_t i2c_master_start(uint8_t address) { + TWCR = (1< slave ACK +// 1 => slave NACK +uint8_t i2c_master_write(uint8_t data) { + TWDR = data; + TWCR = (1<= SLAVE_BUFFER_SIZE ) { + ack = 0; + slave_buffer_pos = 0; + } + slave_has_register_set = true; + } else { + i2c_slave_buffer[slave_buffer_pos] = TWDR; + BUFFER_POS_INC(); + } + break; + + case TW_ST_SLA_ACK: + case TW_ST_DATA_ACK: + // master has addressed this device as a slave transmitter and is + // requesting data. + TWDR = i2c_slave_buffer[slave_buffer_pos]; + BUFFER_POS_INC(); + break; + + case TW_BUS_ERROR: // something went wrong, reset twi state + TWCR = 0; + default: + break; + } + // Reset everything, so we are ready for the next TWI interrupt + TWCR |= (1< + +#ifndef F_CPU +#define F_CPU 16000000UL +#endif + +#define I2C_READ 1 +#define I2C_WRITE 0 + +#define I2C_ACK 1 +#define I2C_NACK 0 + +#define SLAVE_BUFFER_SIZE 0x10 + +// i2c SCL clock frequency 400kHz +#define SCL_CLOCK 400000L + +extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; + +void i2c_master_init(void); +uint8_t i2c_master_start(uint8_t address); +void i2c_master_stop(void); +uint8_t i2c_master_write(uint8_t data); +uint8_t i2c_master_read(int); +void i2c_reset_state(void); +void i2c_slave_init(uint8_t address); + + +static inline unsigned char i2c_start_read(unsigned char addr) { + return i2c_master_start((addr << 1) | I2C_READ); +} + +static inline unsigned char i2c_start_write(unsigned char addr) { + return i2c_master_start((addr << 1) | I2C_WRITE); +} + +// from SSD1306 scrips +extern unsigned char i2c_rep_start(unsigned char addr); +extern void i2c_start_wait(unsigned char addr); +extern unsigned char i2c_readAck(void); +extern unsigned char i2c_readNak(void); +extern unsigned char i2c_read(unsigned char ack); + +#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); + +#endif diff --git a/keyboards/sol/keymaps/brianweyer/config.h b/keyboards/sol/keymaps/brianweyer/config.h new file mode 100755 index 0000000000..87b7dd2ac0 --- /dev/null +++ b/keyboards/sol/keymaps/brianweyer/config.h @@ -0,0 +1,27 @@ +/* +This is the c configuration file for the keymap + +Copyright 2012 Jun Wako +Copyright 2015 Jack Humbert + +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 + +#define SSD1306OLED + + +// place overrides here + diff --git a/keyboards/sol/keymaps/brianweyer/keymap.c b/keyboards/sol/keymaps/brianweyer/keymap.c new file mode 100755 index 0000000000..2259e246d2 --- /dev/null +++ b/keyboards/sol/keymaps/brianweyer/keymap.c @@ -0,0 +1,291 @@ +#include QMK_KEYBOARD_H +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#include "split_util.h" +#endif +#ifdef SSD1306OLED + #include "common/ssd1306.h" +#endif + +extern keymap_config_t keymap_config; + +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +extern uint8_t is_master; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +enum layer_number { + _QWERTY = 0, + _FN, + _ADJ +}; + +enum custom_keycodes { + QWERTY = SAFE_RANGE, + FN, + ADJ, + RGBRST +}; + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* QWERTY + * ,------------------------------------------------. ,------------------------------------------------. + * | ` | 1 | 2 | 3 | 4 | 5 | - | | = | 6 | 7 | 8 | 9 | 0 | Bspc | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \ | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | Esc | A | S | D | F | G | | | | H | J | K | L | ; | ' | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | Shift| Z | X | C | V | B | | | | N | M | , | . | / | Shift| + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | Ctrl | Alt | FN | LGui | RGB | Spc | Del | | Bspc | Spc | Adj | LGui | FN | Alt | Ctrl | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | Spc | Ent | | Ent | Spc | + * `-------------' `-------------' + */ + [_QWERTY] = LAYOUT_kc( \ + //,--------+--------+--------+--------+--------+--------+--+--------+. ,--------+--+--------+--------+--------+--------+--------+--------+ + GRV, 1, 2, 3, 4, 5, MINS, EQL, 6, 7, 8, 9, 0, BSPC, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + TAB, Q, W, E, R, T, LBRC, RBRC, Y, U, I, O, P, BSLS, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + ESC, A, S, D, F, G, _______, _______, H, J, K, L, SCLN, QUOT, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + LSPO, Z, X, C, V, B, _______, _______, N, M, COMM, DOT, SLSH, RSPC, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + LCTL, LALT, FN, LGUI, RGB_MOD, SPC, DEL, BSPC, SPC, ADJ, LGUI, FN, LALT, LCTL, + //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--+--------+--------+--------+--------+--------+--------| + VOLD, VOLU, SPC, ENT, ENT, SPC, DOWN, UP + // Rotary Left |--------+--------| |--------+-----------+ Rotary Right + ), + + /* FN + * ,------------------------------------------------. ,------------------------------------------------. + * | F1 | F2 | F3 | F4 | F5 | F6 | | | | F7 | F8 | F9 | F10 | F11 | F12 | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | | | Up | | | | | | | | | | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | | Left | Down | Right| | | | | Play | Next | Mute | V-Up |V-Down| | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | + * `-------------' `-------------' + */ + [_FN] = LAYOUT_kc( \ + //,--------+--------+--------+--------+--------+--------+--+--------+. ,--------+--+--------+--------+--------+--------+--------+--------+ + F1, F2, F3, F4, F5, F6, _______, _______, F7, F8, F9, F10, F11, F12, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, _______, UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, LEFT, DOWN, RGHT, _______, _______, _______, MPLY, MNXT, MUTE, VOLD, VOLU, _______, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--+--------+--------+--------+--------+--------+--------| + VOLD, VOLU, _______, _______, _______, _______, UP, DOWN + // Rotary Left |--------+--------| |--------+-----------+ Rotary Right + ), + + /* ADJ + * ,------------------------------------------------. ,------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | Sat+ | Val+ | Hue+ |Speed+|Toggle| | | | | | | | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | Sat- | Val- | Hue- |Speed-|Reset | | | | |QWERTY| COLE | | | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | + * `-------------' `-------------' + */ + + [_ADJ] = LAYOUT( \ + //,--------+--------+--------+--------+--------+--------+--+--------+. ,--------+--+--------+--------+--------+--------+--------+--------+ + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET, \ + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, RGB_SAI, RGB_VAI, RGB_HUI, RGB_SPI, RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, \ + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, RGB_SAD, RGB_VAD, RGB_HUD, RGB_SPD, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, \ + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + //|--------+--------+--------+--------+--------+--------+--+--------| |--------+--+--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + //|--------+--------+--------+--------+--------+--+--------+--------| |--------+--------+--+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______ \ + // Rotary Left |--------+--------| |--------+--------+ Rotary Right + ) +}; + + +// define variables for reactive RGB +bool TOG_STATUS = false; +int RGB_current_mode; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + set_single_persistent_default_layer(_QWERTY); + } + return false; + break; + case FN: + if (record->event.pressed) { + layer_on(_FN); + } else { + layer_off(_FN); + } + return false; + break; + case ADJ: + if (record->event.pressed) { + layer_on(_ADJ); + } else { + layer_off(_ADJ); + } + return false; + break; + //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released + case RGBRST: + #ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + eeconfig_update_rgblight_default(); + rgblight_enable(); + RGB_current_mode = rgblight_config.mode; + } + #endif + break; + } + return true; +} + +void matrix_init_user(void) { + #ifdef RGBLIGHT_ENABLE + RGB_current_mode = rgblight_config.mode; + #endif + //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h + #ifdef SSD1306OLED + iota_gfx_init(!has_usb()); // turns on the display + #endif +} + +void matrix_scan_user(void) { + #ifdef SSD1306OLED + // led_test_init(); + iota_gfx_task(); // this is what updates the display continuously + #endif +} + + +//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h +#ifdef SSD1306OLED + +// hook point for 'led_test' keymap +// 'default' keymap's led_test_init() is empty function, do nothing +// 'led_test' keymap's led_test_init() force rgblight_mode_noeeprom(35); +__attribute__ ((weak)) +void led_test_init(void) {} + +void matrix_update(struct CharacterMatrix *dest, + const struct CharacterMatrix *source) { + if (memcmp(dest->display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +//assign the right code to your layers for OLED display +#define L_BASE 0 +#define L_FN (1<<_FN) +#define L_ADJ (1<<_ADJ) +#define L_ADJ_TRI (L_ADJ|L_FN) + +static void render_logo(struct CharacterMatrix *matrix) { + + static char logo[]={ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, + 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, + 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, + 0}; + matrix_write(matrix, logo); +} + + + +void render_status(struct CharacterMatrix *matrix) { + + // Render to mode icon + static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; + if(keymap_config.swap_lalt_lgui==false){ + matrix_write(matrix, logo[0][0]); + matrix_write_P(matrix, PSTR("\n")); + matrix_write(matrix, logo[0][1]); + }else{ + matrix_write(matrix, logo[1][0]); + matrix_write_P(matrix, PSTR("\n")); + matrix_write(matrix, logo[1][1]); + } + + // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below + char buf[40]; + snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); + matrix_write_P(matrix, PSTR("\nLayer: ")); + switch (layer_state) { + case L_BASE: + matrix_write_P(matrix, PSTR("Laser")); + break; + case L_FN: + matrix_write_P(matrix, PSTR("Function")); + break; + case L_ADJ: + case L_ADJ_TRI: + matrix_write_P(matrix, PSTR("Adjustment")); + break; + default: + matrix_write(matrix, buf); + } + + // Host Keyboard LED Status + char led[40]; + snprintf(led, sizeof(led), "\n%s %s %s", + (host_keyboard_leds() & (1< +Copyright 2015 Jack Humbert + +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 + + +// place overrides here + diff --git a/keyboards/sol/keymaps/danielhklein/keymap.c b/keyboards/sol/keymaps/danielhklein/keymap.c new file mode 100644 index 0000000000..883b418268 --- /dev/null +++ b/keyboards/sol/keymaps/danielhklein/keymap.c @@ -0,0 +1,354 @@ +#include QMK_KEYBOARD_H +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#include "split_util.h" +#endif +#ifdef SSD1306OLED + #include "common/ssd1306.h" +#endif + +extern keymap_config_t keymap_config; + +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +extern uint8_t is_master; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +enum layer_number { + _QWERTY = 0, + _COLEMAK, + _FN, + _ADJ +}; + +enum custom_keycodes { + QWERTY = SAFE_RANGE, + COLEMAK, + FN, + ADJ, + BACKLIT, + RGBRST +}; + +enum macro_keycodes { + KC_SAMPLEMACRO, +}; + +// Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns + /* Base Layout + * ,------------------------------------------------. ,------------------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | - | | = | 6 | 7 | 8 | 9 | 0 | Del | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | Tab | | | | | | [ | | ] | | | | | | Enter| + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | Caps | | | | | | { | | } | | | | | | ' | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * |Shift | | | | | | ` | | \ | | | | | |Shift | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | Left | Down | Ctrl | Alt | Gui | Bspc | FN | | ADJ | Space| Gui | Alt | Ctrl | Up |Right | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------' + * | Bspc | FN | | ADJ | Space| + * `-------------' `-------------' + */ +#define BASE_LAYOUT( \ + _00, _01, _02, _03, _04, _05, _06, _07, _08, _09, \ + _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \ + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29 \ +) \ +LAYOUT( \ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_MINS, KC_EQL, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ + KC_TAB, _00, _01, _02, _03, _04, KC_LBRC, KC_RBRC, _05, _06, _07, _08, _09, KC_ENT, \ + KC_CAPS, _10, _11, _12, _13, _14, KC_LCBR, KC_RCBR, _15, _16, _17, _18, _19, KC_QUOT, \ + KC_LSFT, _20, _21, _22, _23, _24, KC_GRV, KC_BSLS, _25, _26, _27, _28, _29, KC_RSFT, \ + KC_LEFT, KC_DOWN, KC_LCTRL, KC_LALT, KC_LGUI, KC_BSPC, FN, ADJ, KC_SPC, KC_RGUI, KC_RALT, KC_RCTRL, KC_UP, KC_RIGHT, \ + KC_VOLU, KC_VOLD, KC_BSPC, FN, ADJ, KC_SPC, KC_VOLU, KC_VOLD \ +) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Qwerty + * ,------------------------------------------------. ,------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | Q | W | E | R | T | | | | Y | U | I | O | P | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | A | S | D | F | G | | | | H | J | K | L | ; | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | Z | X | C | V | B | | | | N | M | , | . | / | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * `------+------+------+------+------+------+------| |------+------+------+------+------+------+------' + * | | | | | | + * `-------------' `-------------' + */ + [_QWERTY] = BASE_LAYOUT( \ + KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, \ + KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, \ + KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH \ + ), + + /* Colemak + * ,------------------------------------------------. ,------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | Q | W | F | P | G | | | | J | L | U | Y | ; | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | A | R | S | T | D | | | | H | N | E | I | O | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | Z | X | C | V | B | | | | K | M | , | . | / | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | | | | | | | | | | | | + * `------+------+------+------+------+------+------| |------+------+------+------+------+------+------' + * | | | | | | + * `-------------' `--------=----' + */ + [_COLEMAK] = BASE_LAYOUT( \ + KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, \ + KC_A, KC_R, KC_S, KC_T, KC_G, KC_K, KC_N, KC_E, KC_I, KC_O, \ + KC_Z, KC_X, KC_C, KC_D, KC_V, KC_M, KC_H, KC_COMM, KC_DOT, KC_SLSH \ + ), + + + /* FN + * ,------------------------------------------------. ,------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | | | | | | | | | | PGDN | UP | PGUP | PRINT| HOME | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | | | | | | | | | | LEFT | DOWN | RIGHT|INSERT| END | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * |Shift | | | | | | | | | PLAY | MUTE | VOL- | VOL+ | LAST | NEXT | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | | | | Gui | | | | | | | | | | | + * `------+------+------+------+------+------+------| |------+------+------+------+------+------+------' + * | | | | | | + * `-------------' `-------------' + */ + [_FN] = LAYOUT( \ + XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PGDN, KC_UP, KC_PGUP, KC_PSCR, KC_HOME, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS, KC_END, \ + _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MPLY, KC_MUTE, KC_VOLD, KC_VOLU, KC_MRWD, KC_MFFD, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \ + ), + + /* ADJ + * ,------------------------------------------------. ,------------------------------------------------. + * |RESET | F1 | F2 | F3 | F4 | F5 | F6 | | | = | / | * | - | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | 7 | 8 | 9 | + | | | + * |------+------+------+------+------+------|------| |------|------+------+------+------+------+------| + * | | HUI | VAI | SAI | | |COLEMK| | | 4 | 5 | 6 | Enter| | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | | HUD | VAD | SAD | | |QWERTY| | | 1 | 2 | 3 | Space| | | + * |------+------+------+------+------+------+------| |------+------+------+------+------+------+------| + * | |RGBRST|RGBTOG|RGBMOD|RGBSMD| | | | | | 0 | . | Bspc | | | + * `------+------+------+------+------+------+------| |------+------+------+------+------+------+------' + * | | | | | | + * `-------------' `-------------' + */ + + [_ADJ] = LAYOUT( \ + RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, KC_PEQL, KC_PSLS, KC_PAST, KC_PMNS, XXXXXXX, XXXXXXX, \ + XXXXXXX, KC_F7, KC_F8, KC_F9, KC_F1