Fork Let’s Split files
This commit is contained in:
parent
732a115b32
commit
aeade1b197
5
keyboards/nyquist/Makefile
Normal file
5
keyboards/nyquist/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
SUBPROJECT_DEFAULT = rev2
|
||||
|
||||
ifndef MAKEFILE_INCLUDED
|
||||
include ../../Makefile
|
||||
endif
|
276
keyboards/nyquist/common/glcdfont.c
Normal file
276
keyboards/nyquist/common/glcdfont.c
Normal file
@ -0,0 +1,276 @@
|
||||
// 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 <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266)
|
||||
#include <pgmspace.h>
|
||||
#else
|
||||
#define PROGMEM
|
||||
#endif
|
||||
|
||||
// Standard ASCII 5x7 font
|
||||
|
||||
static const unsigned char font[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
|
||||
0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
|
||||
};
|
||||
#endif // FONT5X7_H
|
32
keyboards/nyquist/config.h
Normal file
32
keyboards/nyquist/config.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#ifdef SUBPROJECT_rev1
|
||||
#include "rev1/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2
|
||||
#include "rev2/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2fliphalf
|
||||
#include "../../rev2fliphalf/config.h"
|
||||
#endif
|
||||
#endif
|
162
keyboards/nyquist/i2c.c
Normal file
162
keyboards/nyquist/i2c.c
Normal file
@ -0,0 +1,162 @@
|
||||
#include <util/twi.h>
|
||||
#include <avr/io.h>
|
||||
#include <stdlib.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/twi.h>
|
||||
#include <stdbool.h>
|
||||
#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<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
|
||||
lim++;
|
||||
|
||||
// easier way, but will wait slightly longer
|
||||
// _delay_us(100);
|
||||
}
|
||||
|
||||
// Setup twi to run at 100kHz
|
||||
void i2c_master_init(void) {
|
||||
// no prescaler
|
||||
TWSR = 0;
|
||||
// Set TWI clock frequency to SCL_CLOCK. Need TWBR>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<<TWINT) | (1<<TWEN) | (1<<TWSTA);
|
||||
|
||||
i2c_delay();
|
||||
|
||||
// check that we started successfully
|
||||
if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
|
||||
return 1;
|
||||
|
||||
TWDR = address;
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
|
||||
i2c_delay();
|
||||
|
||||
if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
|
||||
return 1; // slave did not acknowledge
|
||||
else
|
||||
return 0; // success
|
||||
}
|
||||
|
||||
|
||||
// Finish the i2c transaction.
|
||||
void i2c_master_stop(void) {
|
||||
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
|
||||
|
||||
uint16_t lim = 0;
|
||||
while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
|
||||
lim++;
|
||||
}
|
||||
|
||||
// Write one byte to the i2c slave.
|
||||
// returns 0 => slave ACK
|
||||
// 1 => slave NACK
|
||||
uint8_t i2c_master_write(uint8_t data) {
|
||||
TWDR = data;
|
||||
TWCR = (1<<TWINT) | (1<<TWEN);
|
||||
|
||||
i2c_delay();
|
||||
|
||||
// check if the slave acknowledged us
|
||||
return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
|
||||
}
|
||||
|
||||
// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
|
||||
// if ack=0 the acknowledge bit is not set.
|
||||
// returns: byte read from i2c device
|
||||
uint8_t i2c_master_read(int ack) {
|
||||
TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
|
||||
|
||||
i2c_delay();
|
||||
return TWDR;
|
||||
}
|
||||
|
||||
void i2c_reset_state(void) {
|
||||
TWCR = 0;
|
||||
}
|
||||
|
||||
void i2c_slave_init(uint8_t address) {
|
||||
TWAR = address << 0; // slave i2c address
|
||||
// TWEN - twi enable
|
||||
// TWEA - enable address acknowledgement
|
||||
// TWINT - twi interrupt flag
|
||||
// TWIE - enable the twi interrupt
|
||||
TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
|
||||
}
|
||||
|
||||
ISR(TWI_vect);
|
||||
|
||||
ISR(TWI_vect) {
|
||||
uint8_t ack = 1;
|
||||
switch(TW_STATUS) {
|
||||
case TW_SR_SLA_ACK:
|
||||
// this device has been addressed as a slave receiver
|
||||
slave_has_register_set = false;
|
||||
break;
|
||||
|
||||
case TW_SR_DATA_ACK:
|
||||
// this device has received data as a slave receiver
|
||||
// The first byte that we receive in this transaction sets the location
|
||||
// of the read/write location of the slaves memory that it exposes over
|
||||
// i2c. After that, bytes will be written at slave_buffer_pos, incrementing
|
||||
// slave_buffer_pos after each write.
|
||||
if(!slave_has_register_set) {
|
||||
slave_buffer_pos = TWDR;
|
||||
// don't acknowledge the master if this memory loctaion is out of bounds
|
||||
if ( slave_buffer_pos >= 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<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
|
||||
}
|
||||
#endif
|
49
keyboards/nyquist/i2c.h
Normal file
49
keyboards/nyquist/i2c.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
||||
#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
|
BIN
keyboards/nyquist/imgs/left.stl
Normal file
BIN
keyboards/nyquist/imgs/left.stl
Normal file
Binary file not shown.
17931
keyboards/nyquist/imgs/lets split rev2 case.iges
Normal file
17931
keyboards/nyquist/imgs/lets split rev2 case.iges
Normal file
File diff suppressed because it is too large
Load Diff
4077
keyboards/nyquist/imgs/letssplitv2.svg
Normal file
4077
keyboards/nyquist/imgs/letssplitv2.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 753 KiB |
BIN
keyboards/nyquist/imgs/plate.stl
Normal file
BIN
keyboards/nyquist/imgs/plate.stl
Normal file
Binary file not shown.
BIN
keyboards/nyquist/imgs/right.stl
Normal file
BIN
keyboards/nyquist/imgs/right.stl
Normal file
Binary file not shown.
BIN
keyboards/nyquist/imgs/split-keyboard-i2c-schematic.png
Normal file
BIN
keyboards/nyquist/imgs/split-keyboard-i2c-schematic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
keyboards/nyquist/imgs/split-keyboard-serial-schematic.png
Normal file
BIN
keyboards/nyquist/imgs/split-keyboard-serial-schematic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
5
keyboards/nyquist/keymaps/hexwire/Makefile
Normal file
5
keyboards/nyquist/keymaps/hexwire/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
RGBLIGHT_ENABLE = yes
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
108
keyboards/nyquist/keymaps/hexwire/README.md
Normal file
108
keyboards/nyquist/keymaps/hexwire/README.md
Normal file
@ -0,0 +1,108 @@
|
||||
Hexwire's Let's Split Layout
|
||||
============================
|
||||
|
||||
### Changes from default layout
|
||||
|
||||
- Main layer
|
||||
- The right space bar key has been changed to backspace, as I only hit space with my left thumb
|
||||
- Backtick is at the lower right and also serves goes to the 3rd function layer when held
|
||||
- Enter key acts as shift when held
|
||||
- Escape key acts as control when held
|
||||
- Minus key at upper right
|
||||
- Lower layer
|
||||
- Numbers are on the lower layer, to make it easier to use a numpad on the right hand
|
||||
- Arrow keys
|
||||
- Straight and curly brackets in the middle two columns
|
||||
- Screenshot keys for MacOS
|
||||
- Upper layer
|
||||
- Symbols are on the upper layer
|
||||
- Media keys
|
||||
- Page Up/Down, Home/End
|
||||
- 3rd function layer
|
||||
- Function keys
|
||||
|
||||
## Layouts
|
||||
|
||||
### Qwerty
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB , Q , W , E , R , T , Y , U , I , O , P ,MINS,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , S , D , F , G , H , J , K , L ,SCLN,QUOT,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, X4 ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
||||
|
||||
### Colemak
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,MINS,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , R , S , T , D , H , N , E , I , O ,QUOT,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT, Z , X , C , V , B , K , M ,COMM,DOT ,SLSH, X4 ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
||||
|
||||
### Dvorak
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,MINS,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , O , E , U , I , D , H , R , N , S ,SLSH,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT,SCLN, Q , J , K , X , B , M , W , V , Z , X4 ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
||||
|
||||
### Lower
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
DEL ,CAPP,LEFT,RGHT, UP ,LBRC, RBRC, P4 , P5 , P6 ,PLUS,PIPE,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , DEL , , P0 ,PDOT, ,
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
||||
|
||||
### Raise
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN, ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
DEL ,MPRV,MNXT,VOLU,PGUP,UNDS, EQL ,HOME, , , ,BSLS,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
MUTE,MSTP,MPLY,VOLD,PGDN,MINS, PLUS,END , , , , ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , ,
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
||||
|
||||
### 3rd function layer
|
||||
|
||||
```
|
||||
,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
F12 , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 ,F11 ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , , ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , , ,
|
||||
|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , ,
|
||||
`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
```
|
20
keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md
Normal file
20
keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Let's Split RGB Underglow
|
||||
|
||||
## Master
|
||||
|
||||
### Pro Micro
|
||||
- Red: LED +5V -> Pro Micro VCC
|
||||
- Green: LED Din -> Pro Micro TX0
|
||||
- Black: LED GND -> Pro Micro GND
|
||||
|
||||
### TRRS
|
||||
- Red: LED +5V -> PCB VCC
|
||||
- Green: LED Do -> PCB Extra Data
|
||||
- Black: LED GND -> PCB GND
|
||||
|
||||
## Slave
|
||||
|
||||
### TRRS
|
||||
- Red: LED +5V -> PCB VCC
|
||||
- Green: LED Din -> PCB Extra Data
|
||||
- Black: LED GND -> PCB GND
|
35
keyboards/nyquist/keymaps/hexwire/config.h
Normal file
35
keyboards/nyquist/keymaps/hexwire/config.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define USE_SERIAL
|
||||
|
||||
#define TAPPING_TERM 150
|
||||
|
||||
#ifdef SUBPROJECT_rev1
|
||||
#include "../../rev1/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2
|
||||
#include "../../rev2/config.h"
|
||||
#endif
|
||||
|
||||
#undef RGBLED_NUM
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
#define RGBLIGHT_VAL_STEP 8
|
205
keyboards/nyquist/keymaps/hexwire/keymap.c
Normal file
205
keyboards/nyquist/keymaps/hexwire/keymap.c
Normal file
@ -0,0 +1,205 @@
|
||||
#include "lets_split.h"
|
||||
#include "action_layer.h"
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _FN3 5
|
||||
#define _FN4 6
|
||||
#define _ADJUST 16
|
||||
|
||||
enum custom_keycodes {
|
||||
QWERTY = SAFE_RANGE,
|
||||
COLEMAK,
|
||||
DVORAK,
|
||||
LOWER,
|
||||
RAISE,
|
||||
FN3,
|
||||
FN4,
|
||||
ADJUST,
|
||||
};
|
||||
|
||||
#define KC_ KC_TRNS
|
||||
#define _______ KC_TRNS
|
||||
|
||||
#define KC_CAPW LGUI(LSFT(KC_3)) // Capture whole screen
|
||||
#define KC_CPYW LGUI(LSFT(LCTL(KC_3))) // Copy whole screen
|
||||
#define KC_CAPP LGUI(LSFT(KC_4)) // Capture portion of screen
|
||||
#define KC_CPYP LGUI(LSFT(LCTL(KC_4))) // Copy portion of screen
|
||||
#define KC_X0 MT(MOD_LCTL, KC_ESC)
|
||||
#define KC_X1 LOWER
|
||||
#define KC_X2 RAISE
|
||||
#define KC_X3 LT(_FN3, KC_GRV)
|
||||
#define KC_X4 MT(MOD_LSFT, KC_ENT)
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_QWERTY] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB , Q , W , E , R , T , Y , U , I , O , P ,MINS,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , S , D , F , G , H , J , K , L ,SCLN,QUOT,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, X4 ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
[_COLEMAK] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,MINS,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , R , S , T , D , H , N , E , I , O ,QUOT,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT, Z , X , C , V , B , K , M ,COMM,DOT ,SLSH, X4 ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
[_DVORAK] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,MINS,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X0 , A , O , E , U , I , D , H , R , N , S ,SLSH,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
LSFT,SCLN, Q , J , K , X , B , M , W , V , Z , X4 ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
[_LOWER] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
DEL ,CAPP,LEFT,RGHT, UP ,LBRC, RBRC, P4 , P5 , P6 ,PLUS,PIPE,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , DEL , , P0 ,PDOT, ,
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
[_RAISE] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN, ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
DEL ,MPRV,MNXT,VOLU,PGUP,UNDS, EQL ,HOME, , , ,BSLS,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
MUTE,MSTP,MPLY,VOLD,PGDN,MINS, PLUS,END , , , , ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , ,
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
[_FN3] = KC_KEYMAP(
|
||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||
F12 , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 ,F11 ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , , ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , , ,
|
||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||
, , , , , , , , , , ,
|
||||
//`----+----+----+----+----+----' `----+----+----+----+----+----'
|
||||
),
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset|RGB Tg|RGB Md|Hue Up|Hue Dn|Sat Up|Sat Dn|Val Up|Val Dn| | |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = KEYMAP( \
|
||||
_______, RESET , RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, _______, _______, \
|
||||
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
|
||||
)
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
#endif
|
||||
|
||||
void persistent_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case ADJUST:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_ADJUST);
|
||||
} else {
|
||||
layer_off(_ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
40
keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
Executable file
40
keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
class KeymapConverter
|
||||
|
||||
def initialize(filename)
|
||||
@filename = filename
|
||||
@mode = :search
|
||||
end
|
||||
|
||||
def read_keymaps
|
||||
lines = IO.readlines(@filename)
|
||||
lines.each { |line| parse_line line[0..-2] }
|
||||
end
|
||||
|
||||
def parse_line(line)
|
||||
case @mode
|
||||
when :search
|
||||
if line =~ /COMPACT_KEYMAP/
|
||||
puts "### #{line}"
|
||||
puts "```"
|
||||
@mode = :parse
|
||||
end
|
||||
when :parse
|
||||
if line =~ /\)/
|
||||
@mode = :search
|
||||
puts "```\n\n"
|
||||
else
|
||||
line = line[4..-1]
|
||||
line.sub!(/(,)^-/m, "|")
|
||||
line.sub!(/( {4})/, " |")
|
||||
|
||||
puts line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
converter = KeymapConverter.new('keymap.c')
|
||||
converter.read_keymaps
|
31
keyboards/nyquist/keymaps/i2c/config.h
Normal file
31
keyboards/nyquist/keymaps/i2c/config.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#define USE_I2C
|
||||
|
||||
#define MASTER_LEFT
|
||||
// #define _MASTER_RIGHT
|
||||
// #define EE_HANDS
|
||||
|
||||
#ifdef SUBPROJECT_rev1
|
||||
#include "../../rev1/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2
|
||||
#include "../../rev2/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2fliphalf
|
||||
#include "../../rev2fliphalf/config.h"
|
||||
#endif
|
214
keyboards/nyquist/keymaps/i2c/keymap.c
Normal file
214
keyboards/nyquist/keymaps/i2c/keymap.c
Normal file
@ -0,0 +1,214 @@
|
||||
#include "lets_split.h"
|
||||
#include "action_layer.h"
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
// 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.
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _ADJUST 16
|
||||
|
||||
enum custom_keycodes {
|
||||
QWERTY = SAFE_RANGE,
|
||||
COLEMAK,
|
||||
DVORAK,
|
||||
LOWER,
|
||||
RAISE,
|
||||
ADJUST,
|
||||
};
|
||||
|
||||
// Fillers to make layering more clear
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = KEYMAP( \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Colemak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_COLEMAK] = KEYMAP( \
|
||||
KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Dvorak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DVORAK] = KEYMAP( \
|
||||
KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
|
||||
KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = KEYMAP( \
|
||||
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP( \
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset| | | | | | | | | | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = KEYMAP( \
|
||||
_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
|
||||
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
|
||||
)
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
#endif
|
||||
|
||||
void persistent_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case ADJUST:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_ADJUST);
|
||||
} else {
|
||||
layer_off(_ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
34
keyboards/nyquist/keymaps/serial/config.h
Normal file
34
keyboards/nyquist/keymaps/serial/config.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define USE_SERIAL
|
||||
|
||||
#define MASTER_LEFT
|
||||
// #define _MASTER_RIGHT
|
||||
// #define EE_HANDS
|
||||
|
||||
|
||||
#ifdef SUBPROJECT_rev1
|
||||
#include "../../rev1/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2
|
||||
#include "../../rev2/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2fliphalf
|
||||
#include "../../rev2fliphalf/config.h"
|
||||
#endif
|
214
keyboards/nyquist/keymaps/serial/keymap.c
Normal file
214
keyboards/nyquist/keymaps/serial/keymap.c
Normal file
@ -0,0 +1,214 @@
|
||||
#include "lets_split.h"
|
||||
#include "action_layer.h"
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
// 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.
|
||||
#define _QWERTY 0
|
||||
#define _COLEMAK 1
|
||||
#define _DVORAK 2
|
||||
#define _LOWER 3
|
||||
#define _RAISE 4
|
||||
#define _ADJUST 16
|
||||
|
||||
enum custom_keycodes {
|
||||
QWERTY = SAFE_RANGE,
|
||||
COLEMAK,
|
||||
DVORAK,
|
||||
LOWER,
|
||||
RAISE,
|
||||
ADJUST,
|
||||
};
|
||||
|
||||
// Fillers to make layering more clear
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = KEYMAP( \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Colemak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_COLEMAK] = KEYMAP( \
|
||||
KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Dvorak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DVORAK] = KEYMAP( \
|
||||
KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
|
||||
KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
|
||||
KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
|
||||
ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
|
||||
),
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = KEYMAP( \
|
||||
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP( \
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset| | | | | | | | | | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = KEYMAP( \
|
||||
_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
|
||||
_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
|
||||
)
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
|
||||
float tone_dvorak[][2] = SONG(DVORAK_SOUND);
|
||||
float tone_colemak[][2] = SONG(COLEMAK_SOUND);
|
||||
#endif
|
||||
|
||||
void persistent_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_colemak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_COLEMAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DVORAK:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
|
||||
#endif
|
||||
persistent_default_layer_set(1UL<<_DVORAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case ADJUST:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_ADJUST);
|
||||
} else {
|
||||
layer_off(_ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
1
keyboards/nyquist/lets_split.c
Normal file
1
keyboards/nyquist/lets_split.c
Normal file
@ -0,0 +1 @@
|
||||
#include "lets_split.h"
|
30
keyboards/nyquist/lets_split.h
Normal file
30
keyboards/nyquist/lets_split.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef LETS_SPLIT_H
|
||||
#define LETS_SPLIT_H
|
||||
|
||||
#ifdef SUBPROJECT_rev1
|
||||
#include "rev1.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2
|
||||
#include "rev2.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_rev2fliphalf
|
||||
#include "rev2fliphalf.h"
|
||||
#endif
|
||||
|
||||
// Used to create a keymap using only KC_ prefixed keys
|
||||
#define KC_KEYMAP( \
|
||||
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
|
||||
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
|
||||
L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
|
||||
L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \
|
||||
) \
|
||||
KEYMAP( \
|
||||
KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \
|
||||
KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \
|
||||
KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \
|
||||
KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35 \
|
||||
)
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#endif
|
316
keyboards/nyquist/matrix.c
Normal file
316
keyboards/nyquist/matrix.c
Normal file
@ -0,0 +1,316 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "split_util.h"
|
||||
#include "pro_micro.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_I2C
|
||||
# include "i2c.h"
|
||||
#else // USE_SERIAL
|
||||
# include "serial.h"
|
||||
#endif
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
#define ERROR_DISCONNECT_COUNT 5
|
||||
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
static const int ROWS_PER_HAND = MATRIX_ROWS/2;
|
||||
static uint8_t error_count = 0;
|
||||
|
||||
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||
static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static matrix_row_t read_cols(void);
|
||||
static void init_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_init_quantum(void) {
|
||||
matrix_init_kb();
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_quantum(void) {
|
||||
matrix_scan_kb();
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_kb(void) {
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_init_user(void) {
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_user(void) {
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
debug_enable = true;
|
||||
debug_matrix = true;
|
||||
debug_mouse = true;
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
TX_RX_LED_INIT;
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
|
||||
matrix_init_quantum();
|
||||
}
|
||||
|
||||
uint8_t _matrix_scan(void)
|
||||
{
|
||||
// Right hand is stored after the left in the matirx so, we need to offset it
|
||||
int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
|
||||
|
||||
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i+offset] != cols) {
|
||||
matrix_debouncing[i+offset] = cols;
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
|
||||
matrix[i+offset] = matrix_debouncing[i+offset];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef USE_I2C
|
||||
|
||||
// Get rows from other half over i2c
|
||||
int i2c_transaction(void) {
|
||||
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
|
||||
|
||||
int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
|
||||
if (err) goto i2c_error;
|
||||
|
||||
// start of matrix stored at 0x00
|
||||
err = i2c_master_write(0x00);
|
||||
if (err) goto i2c_error;
|
||||
|
||||
// Start read
|
||||
err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
|
||||
if (err) goto i2c_error;
|
||||
|
||||
if (!err) {
|
||||
int i;
|
||||
for (i = 0; i < ROWS_PER_HAND-1; ++i) {
|
||||
matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
|
||||
}
|
||||
matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
|
||||
i2c_master_stop();
|
||||
} else {
|
||||
i2c_error: // the cable is disconnceted, or something else went wrong
|
||||
i2c_reset_state();
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // USE_SERIAL
|
||||
|
||||
int serial_transaction(void) {
|
||||
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
|
||||
|
||||
if (serial_update_buffers()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
matrix[slaveOffset+i] = serial_slave_buffer[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
int ret = _matrix_scan();
|
||||
|
||||
|
||||
|
||||
#ifdef USE_I2C
|
||||
if( i2c_transaction() ) {
|
||||
#else // USE_SERIAL
|
||||
if( serial_transaction() ) {
|
||||
#endif
|
||||
// turn on the indicator led when halves are disconnected
|
||||
TXLED1;
|
||||
|
||||
error_count++;
|
||||
|
||||
if (error_count > ERROR_DISCONNECT_COUNT) {
|
||||
// reset other half if disconnected
|
||||
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
matrix[slaveOffset+i] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// turn off the indicator led on no error
|
||||
TXLED0;
|
||||
error_count = 0;
|
||||
}
|
||||
matrix_scan_quantum();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void matrix_slave_scan(void) {
|
||||
_matrix_scan();
|
||||
|
||||
int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
|
||||
|
||||
#ifdef USE_I2C
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
/* i2c_slave_buffer[i] = matrix[offset+i]; */
|
||||
i2c_slave_buffer[i] = matrix[offset+i];
|
||||
}
|
||||
#else // USE_SERIAL
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
serial_slave_buffer[i] = matrix[offset+i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse16(matrix_get_row(row));
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop16(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void init_cols(void)
|
||||
{
|
||||
for(int x = 0; x < MATRIX_COLS; x++) {
|
||||
_SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
|
||||
_SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
matrix_row_t result = 0;
|
||||
for(int x = 0; x < MATRIX_COLS; x++) {
|
||||
result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
for(int x = 0; x < ROWS_PER_HAND; x++) {
|
||||
_SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
|
||||
_SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
_SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
|
||||
_SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
|
||||
}
|
362
keyboards/nyquist/pro_micro.h
Normal file
362
keyboards/nyquist/pro_micro.h
Normal file
@ -0,0 +1,362 @@
|
||||
/*
|
||||
pins_arduino.h - Pin definition functions for Arduino
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
// Workaround for wrong definitions in "iom32u4.h".
|
||||
// This should be fixed in the AVR toolchain.
|
||||
#undef UHCON
|
||||
#undef UHINT
|
||||
#undef UHIEN
|
||||
#undef UHADDR
|
||||
#undef UHFNUM
|
||||
#undef UHFNUML
|
||||
#undef UHFNUMH
|
||||
#undef UHFLEN
|
||||
#undef UPINRQX
|
||||
#undef UPINTX
|
||||
#undef UPNUM
|
||||
#undef UPRST
|
||||
#undef UPCONX
|
||||
#undef UPCFG0X
|
||||
#undef UPCFG1X
|
||||
#undef UPSTAX
|
||||
#undef UPCFG2X
|
||||
#undef UPIENX
|
||||
#undef UPDATX
|
||||
#undef TCCR2A
|
||||
#undef WGM20
|
||||
#undef WGM21
|
||||
#undef COM2B0
|
||||
#undef COM2B1
|
||||
#undef COM2A0
|
||||
#undef COM2A1
|
||||
#undef TCCR2B
|
||||
#undef CS20
|
||||
#undef CS21
|
||||
#undef CS22
|
||||
#undef WGM22
|
||||
#undef FOC2B
|
||||
#undef FOC2A
|
||||
#undef TCNT2
|
||||
#undef TCNT2_0
|
||||
#undef TCNT2_1
|
||||
#undef TCNT2_2
|
||||
#undef TCNT2_3
|
||||
#undef TCNT2_4
|
||||
#undef TCNT2_5
|
||||
#undef TCNT2_6
|
||||
#undef TCNT2_7
|
||||
#undef OCR2A
|
||||
#undef OCR2_0
|
||||
#undef OCR2_1
|
||||
#undef OCR2_2
|
||||
#undef OCR2_3
|
||||
#undef OCR2_4
|
||||
#undef OCR2_5
|
||||
#undef OCR2_6
|
||||
#undef OCR2_7
|
||||
#undef OCR2B
|
||||
#undef OCR2_0
|
||||
#undef OCR2_1
|
||||
#undef OCR2_2
|
||||
#undef OCR2_3
|
||||
#undef OCR2_4
|
||||
#undef OCR2_5
|
||||
#undef OCR2_6
|
||||
#undef OCR2_7
|
||||
|
||||
#define NUM_DIGITAL_PINS 30
|
||||
#define NUM_ANALOG_INPUTS 12
|
||||
|
||||
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
|
||||
#define TXLED0 PORTD |= (1<<5)
|
||||
#define TXLED1 PORTD &= ~(1<<5)
|
||||
#define RXLED0 PORTB |= (1<<0)
|
||||
#define RXLED1 PORTB &= ~(1<<0)
|
||||
|
||||
static const uint8_t SDA = 2;
|
||||
static const uint8_t SCL = 3;
|
||||
#define LED_BUILTIN 13
|
||||
|
||||
// Map SPI port to 'new' pins D14..D17
|
||||
static const uint8_t SS = 17;
|
||||
static const uint8_t MOSI = 16;
|
||||
static const uint8_t MISO = 14;
|
||||
static const uint8_t SCK = 15;
|
||||
|
||||
// Mapping of analog pins as digital I/O
|
||||
// A6-A11 share with digital pins
|
||||
static const uint8_t ADC0 = 18;
|
||||
static const uint8_t ADC1 = 19;
|
||||
static const uint8_t ADC2 = 20;
|
||||
static const uint8_t ADC3 = 21;
|
||||
static const uint8_t ADC4 = 22;
|
||||
static const uint8_t ADC5 = 23;
|
||||
static const uint8_t ADC6 = 24; // D4
|
||||
static const uint8_t ADC7 = 25; // D6
|
||||
static const uint8_t ADC8 = 26; // D8
|
||||
static const uint8_t ADC9 = 27; // D9
|
||||
static const uint8_t ADC10 = 28; // D10
|
||||
static const uint8_t ADC11 = 29; // D12
|
||||
|
||||
#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
|
||||
#define digitalPinToPCICRbit(p) 0
|
||||
#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
|
||||
#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
|
||||
|
||||
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
|
||||
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
|
||||
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
|
||||
|
||||
#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
|
||||
|
||||
#ifdef ARDUINO_MAIN
|
||||
|
||||
// On the Arduino board, digital pins are also used
|
||||
// for the analog output (software PWM). Analog input
|
||||
// pins are a separate set.
|
||||
|
||||
// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
|
||||
//
|
||||
// D0 PD2 RXD1/INT2
|
||||
// D1 PD3 TXD1/INT3
|
||||
// D2 PD1 SDA SDA/INT1
|
||||
// D3# PD0 PWM8/SCL OC0B/SCL/INT0
|
||||
// D4 A6 PD4 ADC8
|
||||
// D5# PC6 ??? OC3A/#OC4A
|
||||
// D6# A7 PD7 FastPWM #OC4D/ADC10
|
||||
// D7 PE6 INT6/AIN0
|
||||
//
|
||||
// D8 A8 PB4 ADC11/PCINT4
|
||||
// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
|
||||
// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
|
||||
// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
|
||||
// D12 A11 PD6 T1/#OC4D/ADC9
|
||||
// D13# PC7 PWM10 CLK0/OC4A
|
||||
//
|
||||
// A0 D18 PF7 ADC7
|
||||
// A1 D19 PF6 ADC6
|
||||
// A2 D20 PF5 ADC5
|
||||
// A3 D21 PF4 ADC4
|
||||
// A4 D22 PF1 ADC1
|
||||
// A5 D23 PF0 ADC0
|
||||
//
|
||||
// New pins D14..D17 to map SPI port to digital pins
|
||||
//
|
||||
// MISO D14 PB3 MISO,PCINT3
|
||||
// SCK D15 PB1 SCK,PCINT1
|
||||
// MOSI D16 PB2 MOSI,PCINT2
|
||||
// SS D17 PB0 RXLED,SS/PCINT0
|
||||
//
|
||||
// Connected LEDs on board for TX and RX
|
||||
// TXLED D24 PD5 XCK1
|
||||
// RXLED D17 PB0
|
||||
// HWB PE2 HWB
|
||||
|
||||
// these arrays map port names (e.g. port B) to the
|
||||
// appropriate addresses for various functions (e.g. reading
|
||||
// and writing)
|
||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRB,
|
||||
(uint16_t) &DDRC,
|
||||
(uint16_t) &DDRD,
|
||||
(uint16_t) &DDRE,
|
||||
(uint16_t) &DDRF,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTB,
|
||||
(uint16_t) &PORTC,
|
||||
(uint16_t) &PORTD,
|
||||
(uint16_t) &PORTE,
|
||||
(uint16_t) &PORTF,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PINB,
|
||||
(uint16_t) &PINC,
|
||||
(uint16_t) &PIND,
|
||||
(uint16_t) &PINE,
|
||||
(uint16_t) &PINF,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||
PD, // D0 - PD2
|
||||
PD, // D1 - PD3
|
||||
PD, // D2 - PD1
|
||||
PD, // D3 - PD0
|
||||
PD, // D4 - PD4
|
||||
PC, // D5 - PC6
|
||||
PD, // D6 - PD7
|
||||
PE, // D7 - PE6
|
||||
|
||||
PB, // D8 - PB4
|
||||
PB, // D9 - PB5
|
||||
PB, // D10 - PB6
|
||||
PB, // D11 - PB7
|
||||
PD, // D12 - PD6
|
||||
PC, // D13 - PC7
|
||||
|
||||
PB, // D14 - MISO - PB3
|
||||
PB, // D15 - SCK - PB1
|
||||
PB, // D16 - MOSI - PB2
|
||||
PB, // D17 - SS - PB0
|
||||
|
||||
PF, // D18 - A0 - PF7
|
||||
PF, // D19 - A1 - PF6
|
||||
PF, // D20 - A2 - PF5
|
||||
PF, // D21 - A3 - PF4
|
||||
PF, // D22 - A4 - PF1
|
||||
PF, // D23 - A5 - PF0
|
||||
|
||||
PD, // D24 - PD5
|
||||
PD, // D25 / D6 - A7 - PD7
|
||||
PB, // D26 / D8 - A8 - PB4
|
||||
PB, // D27 / D9 - A9 - PB5
|
||||
PB, // D28 / D10 - A10 - PB6
|
||||
PD, // D29 / D12 - A11 - PD6
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||
_BV(2), // D0 - PD2
|
||||
_BV(3), // D1 - PD3
|
||||
_BV(1), // D2 - PD1
|
||||
_BV(0), // D3 - PD0
|
||||
_BV(4), // D4 - PD4
|
||||
_BV(6), // D5 - PC6
|
||||
_BV(7), // D6 - PD7
|
||||
_BV(6), // D7 - PE6
|
||||
|
||||
_BV(4), // D8 - PB4
|
||||
_BV(5), // D9 - PB5
|
||||
_BV(6), // D10 - PB6
|
||||
_BV(7), // D11 - PB7
|
||||
_BV(6), // D12 - PD6
|
||||
_BV(7), // D13 - PC7
|
||||
|
||||
_BV(3), // D14 - MISO - PB3
|
||||
_BV(1), // D15 - SCK - PB1
|
||||
_BV(2), // D16 - MOSI - PB2
|
||||
_BV(0), // D17 - SS - PB0
|
||||
|
||||
_BV(7), // D18 - A0 - PF7
|
||||
_BV(6), // D19 - A1 - PF6
|
||||
_BV(5), // D20 - A2 - PF5
|
||||
_BV(4), // D21 - A3 - PF4
|
||||
_BV(1), // D22 - A4 - PF1
|
||||
_BV(0), // D23 - A5 - PF0
|
||||
|
||||
_BV(5), // D24 - PD5
|
||||
_BV(7), // D25 / D6 - A7 - PD7
|
||||
_BV(4), // D26 / D8 - A8 - PB4
|
||||
_BV(5), // D27 / D9 - A9 - PB5
|
||||
_BV(6), // D28 / D10 - A10 - PB6
|
||||
_BV(6), // D29 / D12 - A11 - PD6
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
TIMER0B, /* 3 */
|
||||
NOT_ON_TIMER,
|
||||
TIMER3A, /* 5 */
|
||||
TIMER4D, /* 6 */
|
||||
NOT_ON_TIMER,
|
||||
|
||||
NOT_ON_TIMER,
|
||||
TIMER1A, /* 9 */
|
||||
TIMER1B, /* 10 */
|
||||
TIMER0A, /* 11 */
|
||||
|
||||
NOT_ON_TIMER,
|
||||
TIMER4A, /* 13 */
|
||||
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
|
||||
7, // A0 PF7 ADC7
|
||||
6, // A1 PF6 ADC6
|
||||
5, // A2 PF5 ADC5
|
||||
4, // A3 PF4 ADC4
|
||||
1, // A4 PF1 ADC1
|
||||
0, // A5 PF0 ADC0
|
||||
8, // A6 D4 PD4 ADC8
|
||||
10, // A7 D6 PD7 ADC10
|
||||
11, // A8 D8 PB4 ADC11
|
||||
12, // A9 D9 PB5 ADC12
|
||||
13, // A10 D10 PB6 ADC13
|
||||
9 // A11 D12 PD6 ADC9
|
||||
};
|
||||
|
||||
#endif /* ARDUINO_MAIN */
|
||||
|
||||
// These serial port names are intended to allow libraries and architecture-neutral
|
||||
// sketches to automatically default to the correct port name for a particular type
|
||||
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
||||
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
||||
//
|
||||
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
||||
//
|
||||
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
||||
//
|
||||
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
||||
//
|
||||
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||
// pins are NOT connected to anything by default.
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_USBVIRTUAL Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial1
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial1
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
182
keyboards/nyquist/readme.md
Normal file
182
keyboards/nyquist/readme.md
Normal file
@ -0,0 +1,182 @@
|
||||
Let's Split
|
||||
======
|
||||
|
||||
This readme and most of the code are from https://github.com/ahtn/tmk_keyboard/
|
||||
|
||||
Split keyboard firmware for Arduino Pro Micro or other ATmega32u4
|
||||
based boards.
|
||||
|
||||
|
||||
## Build Guide
|
||||
|
||||
A build guide for putting together the Let's Split v2 can be found here: [An Overly Verbose Guide to Building a Let's Split Keyboard](https://github.com/nicinabox/lets-split-guide)
|
||||
|
||||
There is additional information there about flashing and adding RGB underglow.
|
||||
|
||||
## First Time Setup
|
||||
|
||||
Download or clone the whole firmware and navigate to the keyboards/lets_split directory. Once your dev env is setup, you'll be able to generate the default .hex using:
|
||||
|
||||
```
|
||||
$ make rev2
|
||||
```
|
||||
|
||||
You will see a lot of output and if everything worked correctly you will see the built hex files:
|
||||
|
||||
```
|
||||
lets_split_rev2_serial.hex
|
||||
lets_split_rev2_i2c.hex
|
||||
```
|
||||
|
||||
If you would like to use one of the alternative keymaps, or create your own, copy one of the existing [keymaps](keymaps/) and run make like so:
|
||||
|
||||
|
||||
```
|
||||
$ make rev2-YOUR_KEYMAP_NAME
|
||||
```
|
||||
|
||||
If everything worked correctly you will see a file:
|
||||
|
||||
```
|
||||
lets_split_rev2_YOUR_KEYMAP_NAME.hex
|
||||
```
|
||||
|
||||
For more information on customizing keymaps, take a look at the primary documentation for [Customizing Your Keymap](/readme.md##customizing-your-keymap) in the main readme.md.
|
||||
|
||||
### Let's split 1.0
|
||||
If you have a first generation Let's Split you will need to use the revision 1 code. To do so, use `rev1` in all your commands instead.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
For the full Quantum Mechanical Keyboard feature list, see [the parent readme.md](/readme.md).
|
||||
|
||||
Some features supported by the firmware:
|
||||
|
||||
* Either half can connect to the computer via USB, or both halves can be used
|
||||
independently.
|
||||
* You only need 3 wires to connect the two halves. Two for VCC and GND and one
|
||||
for serial communication.
|
||||
* Optional support for I2C connection between the two halves if for some
|
||||
reason you require a faster connection between the two halves. Note this
|
||||
requires an extra wire between halves and pull-up resistors on the data lines.
|
||||
|
||||
Required Hardware
|
||||
-----------------
|
||||
|
||||
Apart from diodes and key switches for the keyboard matrix in each half, you
|
||||
will need:
|
||||
|
||||
* 2 Arduino Pro Micro's. You can find theses on aliexpress for ≈3.50USD each.
|
||||
* 2 TRRS sockets and 1 TRRS cable, or 2 TRS sockets and 1 TRS cable
|
||||
|
||||
Alternatively, you can use any sort of cable and socket that has at least 3
|
||||
wires. If you want to use I2C to communicate between halves, you will need a
|
||||
cable with at least 4 wires and 2x 4.7kΩ pull-up resistors
|
||||
|
||||
Optional Hardware
|
||||
-----------------
|
||||
|
||||
A speaker can be hooked-up to either side to the `5` (`C6`) pin and `GND`, and turned on via `AUDIO_ENABLE`.
|
||||
|
||||
Wiring
|
||||
------
|
||||
|
||||
The 3 wires of the TRS/TRRS cable need to connect GND, VCC, and digital pin 3 (i.e.
|
||||
PD0 on the ATmega32u4) between the two Pro Micros.
|
||||
|
||||
Then wire your key matrix to any of the remaining 17 IO pins of the pro micro
|
||||
and modify the `matrix.c` accordingly.
|
||||
|
||||
The wiring for serial:
|
||||
|
||||
![serial wiring](imgs/split-keyboard-serial-schematic.png)
|
||||
|
||||
The wiring for i2c:
|
||||
|
||||
![i2c wiring](imgs/split-keyboard-i2c-schematic.png)
|
||||
|
||||
The pull-up resistors may be placed on either half. It is also possible
|
||||
to use 4 resistors and have the pull-ups in both halves, but this is
|
||||
unnecessary in simple use cases.
|
||||
|
||||
Notes on Software Configuration
|
||||
-------------------------------
|
||||
|
||||
Configuring the firmware is similar to any other QMK project. One thing
|
||||
to note is that `MATIX_ROWS` in `config.h` is the total number of rows between
|
||||
the two halves, i.e. if your split keyboard has 4 rows in each half, then
|
||||
`MATRIX_ROWS=8`.
|
||||
|
||||
Also the current implementation assumes a maximum of 8 columns, but it would
|
||||
not be very difficult to adapt it to support more if required.
|
||||
|
||||
Flashing
|
||||
-------
|
||||
From the keymap directory run `make SUBPROJECT-KEYMAP-avrdude` for automatic serial port resolution and flashing.
|
||||
Example: `make rev2-serial-avrdude`
|
||||
|
||||
|
||||
Choosing which board to plug the USB cable into (choosing Master)
|
||||
--------
|
||||
Because the two boards are identical, the firmware has logic to differentiate the left and right board.
|
||||
|
||||
It uses two strategies to figure things out: look at the EEPROM (memory on the chip) or looks if the current board has the usb cable.
|
||||
|
||||
The EEPROM approach requires additional setup (flashing the eeeprom) but allows you to swap the usb cable to either side.
|
||||
|
||||
The USB cable approach is easier to setup and if you just want the usb cable on the left board, you do not need to do anything extra.
|
||||
|
||||
### Setting the left hand as master
|
||||
If you always plug the usb cable into the left board, nothing extra is needed as this is the default. Comment out `EE_HANDS` and comment out `I2C_MASTER_RIGHT` or `MASTER_RIGHT` if for some reason it was set.
|
||||
|
||||
### Setting the right hand as master
|
||||
If you always plug the usb cable into the right board, add an extra flag to your `config.h`
|
||||
```
|
||||
#define MASTER_RIGHT
|
||||
```
|
||||
|
||||
### Setting EE_hands to use either hands as master
|
||||
If you define `EE_HANDS` in your `config.h`, you will need to set the
|
||||
EEPROM for the left and right halves.
|
||||
|
||||
The EEPROM is used to store whether the
|
||||
half is left handed or right handed. This makes it so that the same firmware
|
||||
file will run on both hands instead of having to flash left and right handed
|
||||
versions of the firmware to each half. To flash the EEPROM file for the left
|
||||
half run:
|
||||
```
|
||||
avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-lefthand.eep
|
||||
// or the equivalent in dfu-programmer
|
||||
|
||||
```
|
||||
and similarly for right half
|
||||
```
|
||||
avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-righhand.eep
|
||||
// or the equivalent in dfu-programmer
|
||||
```
|
||||
|
||||
NOTE: replace `$(COM_PORT)` with the port of your device (e.g. `/dev/ttyACM0`)
|
||||
|
||||
After you have flashed the EEPROM, you then need to set `EE_HANDS` in your config.h, rebuild the hex files and reflash.
|
||||
|
||||
Note that you need to program both halves, but you have the option of using
|
||||
different keymaps for each half. You could program the left half with a QWERTY
|
||||
layout and the right half with a Colemak layout using bootmagic's default layout option.
|
||||
Then if you connect the left half to a computer by USB the keyboard will use QWERTY and Colemak when the
|
||||
right half is connected.
|
||||
|
||||
|
||||
Notes on Using Pro Micro 3.3V
|
||||
-----------------------------
|
||||
|
||||
Do update the `F_CPU` parameter in `rules.mk` to `8000000` which reflects
|
||||
the frequency on the 3.3V board.
|
||||
|
||||
Also, if the slave board is producing weird characters in certain columns,
|
||||
update the following line in `matrix.c` to the following:
|
||||
|
||||
```
|
||||
// _delay_us(30); // without this wait read unstable value.
|
||||
_delay_us(300); // without this wait read unstable value.
|
||||
```
|
3
keyboards/nyquist/rev1/Makefile
Normal file
3
keyboards/nyquist/rev1/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
ifndef MAKEFILE_INCLUDED
|
||||
include ../../Makefile
|
||||
endif
|
91
keyboards/nyquist/rev1/config.h
Normal file
91
keyboards/nyquist/rev1/config.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x3060
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER Wootpatoot
|
||||
#define PRODUCT Lets Split v1
|
||||
#define DESCRIPTION A split keyboard for the cheap makers
|
||||
|
||||
/* key matrix size */
|
||||
// Rows are doubled-up
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 6
|
||||
|
||||
// wiring of each half
|
||||
#define MATRIX_ROW_PINS { B5, B4, E6, D7 }
|
||||
#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
|
||||
// #define MATRIX_COL_PINS { B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order
|
||||
|
||||
|
||||
#define CATERINA_BOOTLOADER
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* number of backlight levels */
|
||||
// #define BACKLIGHT_LEVELS 3
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCING_DELAY 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D3
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLED_NUM 16 // Number of LEDs
|
||||
#define ws2812_PORTREG PORTD
|
||||
#define ws2812_DDRREG DDRD
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
// #define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
// #define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
#endif
|
32
keyboards/nyquist/rev1/rev1.c
Normal file
32
keyboards/nyquist/rev1/rev1.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include "lets_split.h"
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_startup[][2] = SONG(STARTUP_SOUND);
|
||||
float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
_delay_ms(20); // gets rid of tick
|
||||
PLAY_NOTE_ARRAY(tone_startup, false, 0);
|
||||
#endif
|
||||
|
||||
// // green led on
|
||||
// DDRD |= (1<<5);
|
||||
// PORTD &= ~(1<<5);
|
||||
|
||||
// // orange led on
|
||||
// DDRB |= (1<<0);
|
||||
// PORTB &= ~(1<<0);
|
||||
|
||||
matrix_init_user();
|
||||
};
|
||||
|
||||
void shutdown_user(void) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
|
||||
_delay_ms(150);
|
||||
stop_all_notes();
|
||||
#endif
|
||||
}
|
28
keyboards/nyquist/rev1/rev1.h
Normal file
28
keyboards/nyquist/rev1/rev1.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef REV1_H
|
||||
#define REV1_H
|
||||
|
||||
#include "../lets_split.h"
|
||||
|
||||
//void promicro_bootloader_jmp(bool program);
|
||||
#include "quantum.h"
|
||||
|
||||
//void promicro_bootloader_jmp(bool program);
|
||||
|
||||
#define KEYMAP( \
|
||||
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
|
||||
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
|
||||
L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
|
||||
L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \
|
||||
) \
|
||||
{ \
|
||||
{ L00, L01, L02, L03, L04, L05 }, \
|
||||
{ L10, L11, L12, L13, L14, L15 }, \
|
||||
{ L20, L21, L22, L23, L24, L25 }, \
|
||||
{ L30, L31, L32, L33, L34, L35 }, \
|
||||
{ R00, R01, R02, R03, R04, R05 }, \
|
||||
{ R10, R11, R12, R13, R14, R15 }, \
|
||||
{ R20, R21, R22, R23, R24, R25 }, \
|
||||
{ R30, R31, R32, R33, R34, R35 } \
|
||||
}
|
||||
|
||||
#endif
|
5
keyboards/nyquist/rev1/rules.mk
Normal file
5
keyboards/nyquist/rev1/rules.mk
Normal file
@ -0,0 +1,5 @@
|
||||
BACKLIGHT_ENABLE = no
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../Makefile
|
||||
endif
|
3
keyboards/nyquist/rev2/Makefile
Normal file
3
keyboards/nyquist/rev2/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
ifndef MAKEFILE_INCLUDED
|
||||
include ../../Makefile
|
||||
endif
|
91
keyboards/nyquist/rev2/config.h
Normal file
91
keyboards/nyquist/rev2/config.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x3060
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER Wootpatoot
|
||||
#define PRODUCT Lets Split v2
|
||||
#define DESCRIPTION A split keyboard for the cheap makers
|
||||
|
||||
/* key matrix size */
|
||||
// Rows are doubled-up
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 6
|
||||
|
||||
// wiring of each half
|
||||
#define MATRIX_ROW_PINS { D7, E6, B4, B5 }
|
||||
#define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 }
|
||||
// #define MATRIX_COL_PINS { B6, B2, B3, B1, F7, F6 } //uncomment this line and comment line above if you need to reverse left-to-right key order
|
||||
|
||||
#define CATERINA_BOOTLOADER
|
||||
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* number of backlight levels */
|
||||
// #define BACKLIGHT_LEVELS 3
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCING_DELAY 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D3
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLED_NUM 12 // Number of LEDs
|
||||
#define ws2812_PORTREG PORTD
|
||||
#define ws2812_DDRREG DDRD
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
// #define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
// #define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
|
||||
#endif
|
39
keyboards/nyquist/rev2/rev2.c
Normal file
39
keyboards/nyquist/rev2/rev2.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include "lets_split.h"
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float tone_startup[][2] = SONG(STARTUP_SOUND);
|
||||
float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
#ifdef SSD1306OLED
|
||||
void led_set_kb(uint8_t usb_led) {
|
||||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
|
||||
led_set_user(usb_led);
|
||||
}
|
||||
#endif
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
_delay_ms(20); // gets rid of tick
|
||||
PLAY_NOTE_ARRAY(tone_startup, false, 0);
|
||||
#endif
|
||||
|
||||
// // green led on
|
||||
// DDRD |= (1<<5);
|
||||
// PORTD &= ~(1<<5);
|
||||
|
||||
// // orange led on
|
||||
// DDRB |= (1<<0);
|
||||
// PORTB &= ~(1<<0);
|
||||
|
||||
matrix_init_user();
|
||||
};
|
||||
|
||||
void shutdown_user(void) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
|
||||
_delay_ms(150);
|
||||
stop_all_notes();
|
||||
#endif
|
||||
}
|
60
keyboards/nyquist/rev2/rev2.h
Normal file
60
keyboards/nyquist/rev2/rev2.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef REV2_H
|
||||
#define REV2_H
|
||||
|
||||
#include "../lets_split.h"
|
||||
|
||||
//void promicro_bootloader_jmp(bool program);
|
||||
#include "quantum.h"
|
||||
|
||||
|
||||
#ifdef USE_I2C
|
||||
#include <stddef.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//void promicro_bootloader_jmp(bool program);
|
||||
|
||||
#ifndef FLIP_HALF
|
||||
// Standard Keymap
|
||||
// (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left)
|
||||
#define KEYMAP( \
|
||||
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
|
||||
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
|
||||
L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
|
||||
L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \
|
||||
) \
|
||||
{ \
|
||||
{ L00, L01, L02, L03, L04, L05 }, \
|
||||
{ L10, L11, L12, L13, L14, L15 }, \
|
||||
{ L20, L21, L22, L23, L24, L25 }, \
|
||||
{ L30, L31, L32, L33, L34, L35 }, \
|
||||
{ R05, R04, R03, R02, R01, R00 }, \
|
||||
{ R15, R14, R13, R12, R11, R10 }, \
|
||||
{ R25, R24, R23, R22, R21, R20 }, \
|
||||
{ R35, R34, R33, R32, R31, R30 } \
|
||||
}
|
||||
#else
|
||||
// Keymap with right side flipped
|
||||
// (TRRS jack on both halves are to the right)
|
||||
#define KEYMAP( \
|
||||
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
|
||||
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
|
||||
L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
|
||||
L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \
|
||||
) \
|
||||
{ \
|
||||
{ L00, L01, L02, L03, L04, L05 }, \
|
||||
{ L10, L11, L12, L13, L14, L15 }, \
|
||||
{ L20, L21, L22, L23, L24, L25 }, \
|
||||
{ L30, L31, L32, L33, L34, L35 }, \
|
||||
{ R00, R01, R02, R03, R04, R05 }, \
|
||||
{ R10, R11, R12, R13, R14, R15 }, \
|
||||
{ R20, R21, R22, R23, R24, R25 }, \
|
||||
{ R30, R31, R32, R33, R34, R35 } \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
5
keyboards/nyquist/rev2/rules.mk
Normal file
5
keyboards/nyquist/rev2/rules.mk
Normal file
@ -0,0 +1,5 @@
|
||||
BACKLIGHT_ENABLE = no
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../Makefile
|
||||
endif
|
88
keyboards/nyquist/rules.mk
Normal file
88
keyboards/nyquist/rules.mk
Normal file
@ -0,0 +1,88 @@
|
||||
SRC += matrix.c \
|
||||
i2c.c \
|
||||
split_util.c \
|
||||
serial.c \
|
||||
ssd1306.c
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Build Options
|
||||
# change to "no" to disable the options, or define them in the Makefile in
|
||||
# the appropriate keymap folder that will get included automatically
|
||||
#
|
||||
BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE ?= no # Console for debug(+400)
|
||||
COMMAND_ENABLE ?= yes # Commands for debug and configuration
|
||||
NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE ?= no # MIDI controls
|
||||
AUDIO_ENABLE ?= no # Audio output on port C6
|
||||
UNICODE_ENABLE ?= no # Unicode
|
||||
BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
|
||||
SUBPROJECT_rev1 ?= yes
|
||||
USE_I2C ?= yes
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
|
||||
|
||||
CUSTOM_MATRIX = yes
|
||||
|
||||
avrdude: build
|
||||
ls /dev/tty* > /tmp/1; \
|
||||
echo "Reset your Pro Micro now"; \
|
||||
while [[ -z $$USB ]]; do \
|
||||
sleep 1; \
|
||||
ls /dev/tty* > /tmp/2; \
|
||||
USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
|
||||
done; \
|
||||
avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex
|
||||
|
||||
.PHONY: avrdude
|
228
keyboards/nyquist/serial.c
Normal file
228
keyboards/nyquist/serial.c
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* WARNING: be careful changing this code, it is very timing dependent
|
||||
*/
|
||||
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 16000000
|
||||
#endif
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdbool.h>
|
||||
#include "serial.h"
|
||||
|
||||
#ifdef USE_SERIAL
|
||||
|
||||
// Serial pulse period in microseconds. Its probably a bad idea to lower this
|
||||
// value.
|
||||
#define SERIAL_DELAY 24
|
||||
|
||||
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
|
||||
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
|
||||
|
||||
#define SLAVE_DATA_CORRUPT (1<<0)
|
||||
volatile uint8_t status = 0;
|
||||
|
||||
inline static
|
||||
void serial_delay(void) {
|
||||
_delay_us(SERIAL_DELAY);
|
||||
}
|
||||
|
||||
inline static
|
||||
void serial_output(void) {
|
||||
SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
// make the serial pin an input with pull-up resistor
|
||||
inline static
|
||||
void serial_input(void) {
|
||||
SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
|
||||
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
inline static
|
||||
uint8_t serial_read_pin(void) {
|
||||
return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
|
||||
}
|
||||
|
||||
inline static
|
||||
void serial_low(void) {
|
||||
SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
inline static
|
||||
void serial_high(void) {
|
||||
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
void serial_master_init(void) {
|
||||
serial_output();
|
||||
serial_high();
|
||||
}
|
||||
|
||||
void serial_slave_init(void) {
|
||||
serial_input();
|
||||
|
||||
// Enable INT0
|
||||
EIMSK |= _BV(INT0);
|
||||
// Trigger on falling edge of INT0
|
||||
EICRA &= ~(_BV(ISC00) | _BV(ISC01));
|
||||
}
|
||||
|
||||
// Used by the master to synchronize timing with the slave.
|
||||
static
|
||||
void sync_recv(void) {
|
||||
serial_input();
|
||||
// This shouldn't hang if the slave disconnects because the
|
||||
// serial line will float to high if the slave does disconnect.
|
||||
while (!serial_read_pin());
|
||||
serial_delay();
|
||||
}
|
||||
|
||||
// Used by the slave to send a synchronization signal to the master.
|
||||
static
|
||||
void sync_send(void) {
|
||||
serial_output();
|
||||
|
||||
serial_low();
|
||||
serial_delay();
|
||||
|
||||
serial_high();
|
||||
}
|
||||
|
||||
// Reads a byte from the serial line
|
||||
static
|
||||
uint8_t serial_read_byte(void) {
|
||||
uint8_t byte = 0;
|
||||
serial_input();
|
||||
for ( uint8_t i = 0; i < 8; ++i) {
|
||||
byte = (byte << 1) | serial_read_pin();
|
||||
serial_delay();
|
||||
_delay_us(1);
|
||||
}
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
// Sends a byte with MSB ordering
|
||||
static
|
||||
void serial_write_byte(uint8_t data) {
|
||||
uint8_t b = 8;
|
||||
serial_output();
|
||||
while( b-- ) {
|
||||
if(data & (1 << b)) {
|
||||
serial_high();
|
||||
} else {
|
||||
serial_low();
|
||||
}
|
||||
serial_delay();
|
||||
}
|
||||
}
|
||||
|
||||
// interrupt handle to be used by the slave device
|
||||
ISR(SERIAL_PIN_INTERRUPT) {
|
||||
sync_send();
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||
serial_write_byte(serial_slave_buffer[i]);
|
||||
sync_send();
|
||||
checksum += serial_slave_buffer[i];
|
||||
}
|
||||
serial_write_byte(checksum);
|
||||
sync_send();
|
||||
|
||||
// wait for the sync to finish sending
|
||||
serial_delay();
|
||||
|
||||
// read the middle of pulses
|
||||
_delay_us(SERIAL_DELAY/2);
|
||||
|
||||
uint8_t checksum_computed = 0;
|
||||
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||
serial_master_buffer[i] = serial_read_byte();
|
||||
sync_send();
|
||||
checksum_computed += serial_master_buffer[i];
|
||||
}
|
||||
uint8_t checksum_received = serial_read_byte();
|
||||
sync_send();
|
||||
|
||||
serial_input(); // end transaction
|
||||
|
||||
if ( checksum_computed != checksum_received ) {
|
||||
status |= SLAVE_DATA_CORRUPT;
|
||||
} else {
|
||||
status &= ~SLAVE_DATA_CORRUPT;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
bool serial_slave_DATA_CORRUPT(void) {
|
||||
return status & SLAVE_DATA_CORRUPT;
|
||||
}
|
||||
|
||||
// Copies the serial_slave_buffer to the master and sends the
|
||||
// serial_master_buffer to the slave.
|
||||
//
|
||||
// Returns:
|
||||
// 0 => no error
|
||||
// 1 => slave did not respond
|
||||
int serial_update_buffers(void) {
|
||||
// this code is very time dependent, so we need to disable interrupts
|
||||
cli();
|
||||
|
||||
// signal to the slave that we want to start a transaction
|
||||
serial_output();
|
||||
serial_low();
|
||||
_delay_us(1);
|
||||
|
||||
// wait for the slaves response
|
||||
serial_input();
|
||||
serial_high();
|
||||
_delay_us(SERIAL_DELAY);
|
||||
|
||||
// check if the slave is present
|
||||
if (serial_read_pin()) {
|
||||
// slave failed to pull the line low, assume not present
|
||||
sei();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// if the slave is present syncronize with it
|
||||
sync_recv();
|
||||
|
||||
uint8_t checksum_computed = 0;
|
||||
// receive data from the slave
|
||||
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||
serial_slave_buffer[i] = serial_read_byte();
|
||||
sync_recv();
|
||||
checksum_computed += serial_slave_buffer[i];
|
||||
}
|
||||
uint8_t checksum_received = serial_read_byte();
|
||||
sync_recv();
|
||||
|
||||
if (checksum_computed != checksum_received) {
|
||||
sei();
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t checksum = 0;
|
||||
// send data to the slave
|
||||
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||
serial_write_byte(serial_master_buffer[i]);
|
||||
sync_recv();
|
||||
checksum += serial_master_buffer[i];
|
||||
}
|
||||
serial_write_byte(checksum);
|
||||
sync_recv();
|
||||
|
||||
// always, release the line when not in use
|
||||
serial_output();
|
||||
serial_high();
|
||||
|
||||
sei();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
26
keyboards/nyquist/serial.h
Normal file
26
keyboards/nyquist/serial.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef MY_SERIAL_H
|
||||
#define MY_SERIAL_H
|
||||
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* TODO: some defines for interrupt setup */
|
||||
#define SERIAL_PIN_DDR DDRD
|
||||
#define SERIAL_PIN_PORT PORTD
|
||||
#define SERIAL_PIN_INPUT PIND
|
||||
#define SERIAL_PIN_MASK _BV(PD0)
|
||||
#define SERIAL_PIN_INTERRUPT INT0_vect
|
||||
|
||||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||
#define SERIAL_MASTER_BUFFER_LENGTH 1
|
||||
|
||||
// Buffers for master - slave communication
|
||||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
|
||||
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
|
||||
|
||||
void serial_master_init(void);
|
||||
void serial_slave_init(void);
|
||||
int serial_update_buffers(void);
|
||||
bool serial_slave_data_corrupt(void);
|
||||
|
||||
#endif
|
84
keyboards/nyquist/split_util.c
Normal file
84
keyboards/nyquist/split_util.c
Normal file
@ -0,0 +1,84 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include "split_util.h"
|
||||
#include "matrix.h"
|
||||
#include "keyboard.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_I2C
|
||||
# include "i2c.h"
|
||||
#else
|
||||
# include "serial.h"
|
||||
#endif
|
||||
|
||||
volatile bool isLeftHand = true;
|
||||
|
||||
static void setup_handedness(void) {
|
||||
#ifdef EE_HANDS
|
||||
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
|
||||
#else
|
||||
// I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
|
||||
#if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
|
||||
isLeftHand = !has_usb();
|
||||
#else
|
||||
isLeftHand = has_usb();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void keyboard_master_setup(void) {
|
||||
#ifdef USE_I2C
|
||||
i2c_master_init();
|
||||
#ifdef SSD1306OLED
|
||||
matrix_master_OLED_init ();
|
||||
#endif
|
||||
#else
|
||||
serial_master_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void keyboard_slave_setup(void) {
|
||||
#ifdef USE_I2C
|
||||
i2c_slave_init(SLAVE_I2C_ADDRESS);
|
||||
#else
|
||||
serial_slave_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool has_usb(void) {
|
||||
USBCON |= (1 << OTGPADE); //enables VBUS pad
|
||||
_delay_us(5);
|
||||
return (USBSTA & (1<<VBUS)); //checks state of VBUS
|
||||
}
|
||||
|
||||
void split_keyboard_setup(void) {
|
||||
setup_handedness();
|
||||
|
||||
if (has_usb()) {
|
||||
keyboard_master_setup();
|
||||
} else {
|
||||
keyboard_slave_setup();
|
||||
}
|
||||
sei();
|
||||
}
|
||||
|
||||
void keyboard_slave_loop(void) {
|
||||
matrix_init();
|
||||
|
||||
while (1) {
|
||||
matrix_slave_scan();
|
||||
}
|
||||
}
|
||||
|
||||
// this code runs before the usb and keyboard is initialized
|
||||
void matrix_setup(void) {
|
||||
split_keyboard_setup();
|
||||
|
||||
if (!has_usb()) {
|
||||
keyboard_slave_loop();
|
||||
}
|
||||
}
|
24
keyboards/nyquist/split_util.h
Normal file
24
keyboards/nyquist/split_util.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef SPLIT_KEYBOARD_UTIL_H
|
||||
#define SPLIT_KEYBOARD_UTIL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef EE_HANDS
|
||||
#define EECONFIG_BOOTMAGIC_END (uint8_t *)10
|
||||
#define EECONFIG_HANDEDNESS EECONFIG_BOOTMAGIC_END
|
||||
#endif
|
||||
|
||||
#define SLAVE_I2C_ADDRESS 0x32
|
||||
|
||||
extern volatile bool isLeftHand;
|
||||
|
||||
// slave version of matix scan, defined in matrix.c
|
||||
void matrix_slave_scan(void);
|
||||
|
||||
void split_keyboard_setup(void);
|
||||
bool has_usb(void);
|
||||
void keyboard_slave_loop(void);
|
||||
|
||||
void matrix_master_OLED_init (void);
|
||||
|
||||
#endif
|
470
keyboards/nyquist/ssd1306.c
Normal file
470
keyboards/nyquist/ssd1306.c
Normal file
@ -0,0 +1,470 @@
|
||||
#ifdef SSD1306OLED
|
||||
|
||||
#include "ssd1306.h"
|
||||
#include "config.h"
|
||||
#include "i2c.h"
|
||||
#include <string.h>
|
||||
#include "print.h"
|
||||
#include "lets_split.h"
|
||||
#include "common/glcdfont.c"
|
||||
#ifdef ADAFRUIT_BLE_ENABLE
|
||||
#include "adafruit_ble.h"
|
||||
#endif
|
||||
#ifdef PROTOCOL_LUFA
|
||||
#include "lufa.h"
|
||||
#endif
|
||||
#include "sendchar.h"
|
||||
#include "pincontrol.h"
|
||||
|
||||
//assign the right code to your layers
|
||||
#define _BASE 0
|
||||
#define _LOWER 8
|
||||
#define _RAISE 16
|
||||
#define _FNLAYER 64
|
||||
#define _NUMLAY 128
|
||||
#define _NLOWER 136
|
||||
#define _NFNLAYER 192
|
||||
#define _MOUSECURSOR 256
|
||||
#define _ADJUST 65560
|
||||
|
||||
// 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
|
||||
|
||||
// Controls the SSD1306 128x32 OLED display via i2c
|
||||
|
||||
#define i2cAddress 0x3C
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
static struct CharacterMatrix display;
|
||||
//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;
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
// Write command sequence.
|
||||
// Returns true on success.
|
||||
static inline bool _send_cmd1(uint8_t cmd) {
|
||||
bool res = false;
|
||||
|
||||
if (i2c_start_write(i2cAddress)) {
|
||||
xprintf("failed to start write to %d\n", i2cAddress);
|
||||
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 matrix_clear(struct CharacterMatrix *matrix);
|
||||
|
||||
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(i2cAddress)) {
|
||||
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(void) {
|
||||
bool success = false;
|
||||
|
||||
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 */);
|
||||
|
||||
/// Flips the display orientation 0 degrees
|
||||
send_cmd1(SegRemap | 0x1);
|
||||
send_cmd1(ComScanDec);
|
||||
/*
|
||||
// the following Flip the display orientation 180 degrees
|
||||
send_cmd1(SegRemap);
|
||||
send_cmd1(ComScanInc);
|
||||
// end flip */
|
||||
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;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
static 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(i2cAddress)) {
|
||||
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 - 1));
|
||||
|
||||
for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++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);
|
||||
}
|
||||
|
||||
static 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;
|
||||
}
|
||||
}
|
||||
|
||||
static void render_status_info(void) {
|
||||
#if DEBUG_TO_SCREEN
|
||||
if (debug_enable) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct CharacterMatrix matrix;
|
||||
|
||||
matrix_clear(&matrix);
|
||||
matrix_write_P(&matrix, PSTR("USB: "));
|
||||
#ifdef PROTOCOL_LUFA
|
||||
switch (USB_DeviceState) {
|
||||
case DEVICE_STATE_Unattached:
|
||||
matrix_write_P(&matrix, PSTR("Unattached"));
|
||||
break;
|
||||
case DEVICE_STATE_Suspended:
|
||||
matrix_write_P(&matrix, PSTR("Suspended"));
|
||||
break;
|
||||
case DEVICE_STATE_Configured:
|
||||
matrix_write_P(&matrix, PSTR("Connected"));
|
||||
break;
|
||||
case DEVICE_STATE_Powered:
|
||||
matrix_write_P(&matrix, PSTR("Powered"));
|
||||
break;
|
||||
case DEVICE_STATE_Default:
|
||||
matrix_write_P(&matrix, PSTR("Default"));
|
||||
break;
|
||||
case DEVICE_STATE_Addressed:
|
||||
matrix_write_P(&matrix, PSTR("Addressed"));
|
||||
break;
|
||||
default:
|
||||
matrix_write_P(&matrix, PSTR("Invalid"));
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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("\n\nLayer: "));
|
||||
switch (layer_state) {
|
||||
case _BASE:
|
||||
matrix_write_P(&matrix, PSTR("Default"));
|
||||
break;
|
||||
case _RAISE:
|
||||
matrix_write_P(&matrix, PSTR("Raise"));
|
||||
break;
|
||||
case _LOWER:
|
||||
matrix_write_P(&matrix, PSTR("Lower"));
|
||||
break;
|
||||
case _ADJUST:
|
||||
matrix_write_P(&matrix, PSTR("ADJUST"));
|
||||
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<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
|
||||
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
|
||||
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
|
||||
matrix_write(&matrix, led);
|
||||
matrix_update(&display, &matrix);
|
||||
}
|
||||
|
||||
void iota_gfx_task(void) {
|
||||
render_status_info();
|
||||
|
||||
if (display.dirty) {
|
||||
iota_gfx_flush();
|
||||
}
|
||||
|
||||
if (timer_elapsed(last_flush) > ScreenOffInterval) {
|
||||
iota_gfx_off();
|
||||
}
|
||||
}
|
||||
#endif
|
17
keyboards/nyquist/ssd1306.h
Normal file
17
keyboards/nyquist/ssd1306.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SSD1306_H
|
||||
#define SSD1306_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
bool iota_gfx_init(void);
|
||||
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);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user