kwark 1.0
This commit is contained in:
parent
6c9ad11f12
commit
2853e56106
Binary file not shown.
@ -51,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define ws2812_PORTREG PORTD
|
||||
#define ws2812_DDRREG DDRD
|
||||
#define ws2812_pin PD2
|
||||
#define RGBLED_NUM 10 // Number of LEDs
|
||||
#define RGBLED_NUM 4 // Number of LEDs
|
||||
#ifndef RGBLIGHT_HUE_STEP
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#endif
|
||||
|
BIN
keyboard/flanck/flanck.bin
Normal file
BIN
keyboard/flanck/flanck.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
keyboard/gnap/gnap.bin
Normal file
BIN
keyboard/gnap/gnap.bin
Normal file
Binary file not shown.
BIN
keyboard/kwark/FLASH.bin
Normal file
BIN
keyboard/kwark/FLASH.bin
Normal file
Binary file not shown.
426
keyboard/kwark/LED_FastGPIO.ino
Normal file
426
keyboard/kwark/LED_FastGPIO.ino
Normal file
@ -0,0 +1,426 @@
|
||||
#include <FastGPIO.h>
|
||||
#include <TimerOne.h>
|
||||
|
||||
int iByte;
|
||||
byte col = 0;
|
||||
byte leds[12][4];
|
||||
byte pass = 1;
|
||||
int fadecount = 1;
|
||||
const int fadelimit = 3000;
|
||||
const int fadelimitshort = 1000;
|
||||
byte mode = 4;
|
||||
byte brightness = 2;
|
||||
boolean changemode = 0;
|
||||
int rain = 0;
|
||||
const int rainlimit = 5000;
|
||||
const int rainfade = 5000;
|
||||
byte rx = 0;
|
||||
byte ry = 0;
|
||||
|
||||
// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
|
||||
int pins[17] = {
|
||||
-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 14, 15, 18, 19, 20, 21
|
||||
};
|
||||
|
||||
// col[xx] of leds = pin yy on led matrix
|
||||
int cols[12] = {
|
||||
pins[8], pins[7], pins[6], pins[5], pins[9], pins[10], pins[11], pins[12], pins[13], pins[14], pins[15], pins[16]
|
||||
};
|
||||
|
||||
// row[xx] of leds = pin yy on led matrix
|
||||
int rows[4] = {
|
||||
pins[1], pins[2], pins[3], pins[4]
|
||||
};
|
||||
|
||||
|
||||
#define DELAY 0
|
||||
extern byte leds[12][4];
|
||||
|
||||
void setup() {
|
||||
Serial1.begin(9600);
|
||||
setupLeds();
|
||||
for (int s = 0; s < 5; s++) {
|
||||
for ( int r = 1; r < 9; r++) {
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
leds[i][j] = 1;
|
||||
for (int p = 0; p < 25; p++) {
|
||||
}
|
||||
leds[i][j] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( int r = 9; r > 0; r--) {
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
leds[i][j] = 1;
|
||||
for (int p = 0; p < 25; p++) {
|
||||
}
|
||||
leds[i][j] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
//Blacklight
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
leds[i][j] = brightness;
|
||||
}
|
||||
}
|
||||
checkserial();
|
||||
break;
|
||||
case 1:
|
||||
//Breathing
|
||||
for ( int r = 1; r < 9; r++) {
|
||||
checkserial();
|
||||
if (changemode == 0) {
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
leds[i][j] = 1;
|
||||
for (int p = 0; p < 25; p++) {
|
||||
}
|
||||
leds[i][j] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( int r = 9; r > 0; r--) {
|
||||
checkserial();
|
||||
if (changemode == 0) {
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
leds[i][j] = 1;
|
||||
for (int p = 0; p < 25; p++) {
|
||||
}
|
||||
leds[i][j] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( int r = 1; r < 30; r++) {
|
||||
checkserial();
|
||||
if (changemode == 0) {
|
||||
delayMicroseconds(65000);
|
||||
delayMicroseconds(65000);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
//Random
|
||||
leds[random(12)][random(4)] = random(8);
|
||||
delayMicroseconds(10000);
|
||||
checkserial();
|
||||
break;
|
||||
case 3:
|
||||
//Rain
|
||||
rain++;
|
||||
if (rain > rainlimit) {
|
||||
rain = 0;
|
||||
rx = random(12);
|
||||
ry = random(4);
|
||||
if (leds[rx][ry] == 0) {
|
||||
leds[rx][ry] = 18;
|
||||
}
|
||||
}
|
||||
fadecount++;
|
||||
if (fadecount > rainfade) {
|
||||
fadecount = 1;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (leds[i][j] > 0) {
|
||||
leds[i][j] = leds[i][j] - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checkserial();
|
||||
break;
|
||||
case 4:
|
||||
//Reactive
|
||||
fadecount++;
|
||||
if (fadecount > fadelimit) {
|
||||
fadecount = 1;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (leds[i][j] > 0) {
|
||||
leds[i][j] = leds[i][j] - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checkserial();
|
||||
break;
|
||||
case 5:
|
||||
//Reactive Target
|
||||
fadecount++;
|
||||
if (fadecount > fadelimitshort) {
|
||||
fadecount = 1;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (leds[i][j] > 0) {
|
||||
leds[i][j] = leds[i][j] - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checkserial();
|
||||
break;
|
||||
default:
|
||||
mode = 0;
|
||||
break;
|
||||
}
|
||||
changemode = 0;
|
||||
}
|
||||
|
||||
void checkserial() {
|
||||
if (Serial1.available() > 0) {
|
||||
iByte = Serial1.read();
|
||||
if (iByte == 100) {
|
||||
brightness++;
|
||||
if (brightness > 9) {
|
||||
brightness = 1;
|
||||
}
|
||||
}
|
||||
if (iByte == 101) {
|
||||
mode++;
|
||||
}
|
||||
if (iByte < 100) {
|
||||
if (mode == 4) {
|
||||
byte row = iByte / 16;
|
||||
byte col = iByte % 16;
|
||||
leds[col][row] = 18;
|
||||
}
|
||||
if (mode == 5) {
|
||||
byte row = iByte / 16;
|
||||
byte col = iByte % 16;
|
||||
for (byte i = 0; i < 12; i++) {
|
||||
leds[i][row] = 18;
|
||||
}
|
||||
for (byte p = 0; p < 4; p++) {
|
||||
leds[col][p] = 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setupLeds() {
|
||||
// sets the pins as output
|
||||
FastGPIO::Pin<2>::setOutputLow();
|
||||
FastGPIO::Pin<3>::setOutputLow();
|
||||
FastGPIO::Pin<4>::setOutputLow();
|
||||
FastGPIO::Pin<5>::setOutputLow();
|
||||
FastGPIO::Pin<6>::setOutputLow();
|
||||
FastGPIO::Pin<7>::setOutputLow();
|
||||
FastGPIO::Pin<8>::setOutputLow();
|
||||
FastGPIO::Pin<9>::setOutputLow();
|
||||
FastGPIO::Pin<10>::setOutputLow();
|
||||
FastGPIO::Pin<16>::setOutputLow();
|
||||
FastGPIO::Pin<14>::setOutputLow();
|
||||
FastGPIO::Pin<15>::setOutputLow();
|
||||
FastGPIO::Pin<18>::setOutputLow();
|
||||
FastGPIO::Pin<19>::setOutputLow();
|
||||
FastGPIO::Pin<20>::setOutputLow();
|
||||
FastGPIO::Pin<21>::setOutputLow();
|
||||
|
||||
// set up Cols
|
||||
FastGPIO::Pin<6>::setOutputValueLow();
|
||||
FastGPIO::Pin<7>::setOutputValueLow();
|
||||
FastGPIO::Pin<8>::setOutputValueLow();
|
||||
FastGPIO::Pin<9>::setOutputValueLow();
|
||||
FastGPIO::Pin<10>::setOutputValueLow();
|
||||
FastGPIO::Pin<16>::setOutputValueLow();
|
||||
FastGPIO::Pin<14>::setOutputValueLow();
|
||||
FastGPIO::Pin<15>::setOutputValueLow();
|
||||
FastGPIO::Pin<18>::setOutputValueLow();
|
||||
FastGPIO::Pin<19>::setOutputValueLow();
|
||||
FastGPIO::Pin<20>::setOutputValueLow();
|
||||
FastGPIO::Pin<21>::setOutputValueLow();
|
||||
|
||||
// set up Rows
|
||||
FastGPIO::Pin<2>::setOutputValueLow();
|
||||
FastGPIO::Pin<3>::setOutputValueLow();
|
||||
FastGPIO::Pin<4>::setOutputValueLow();
|
||||
FastGPIO::Pin<5>::setOutputValueLow();
|
||||
|
||||
clearLeds();
|
||||
Timer1.initialize(25);
|
||||
Timer1.attachInterrupt(display);
|
||||
|
||||
}
|
||||
|
||||
void clearLeds() {
|
||||
// Clear display array
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
leds[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onLeds() {
|
||||
// Clear display array
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
leds[i][j] = 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Interrupt routine
|
||||
void display() {
|
||||
|
||||
switch (col) { // Turn whole previous column off
|
||||
case 0:
|
||||
FastGPIO::Pin<6>::setOutputValueLow();
|
||||
break;
|
||||
case 1:
|
||||
FastGPIO::Pin<7>::setOutputValueLow();
|
||||
break;
|
||||
case 2:
|
||||
FastGPIO::Pin<8>::setOutputValueLow();
|
||||
break;
|
||||
case 3:
|
||||
FastGPIO::Pin<9>::setOutputValueLow();
|
||||
break;
|
||||
case 4:
|
||||
FastGPIO::Pin<10>::setOutputValueLow();
|
||||
break;
|
||||
case 5:
|
||||
FastGPIO::Pin<16>::setOutputValueLow();
|
||||
break;
|
||||
case 6:
|
||||
FastGPIO::Pin<14>::setOutputValueLow();
|
||||
break;
|
||||
case 7:
|
||||
FastGPIO::Pin<15>::setOutputValueLow();
|
||||
break;
|
||||
case 8:
|
||||
FastGPIO::Pin<18>::setOutputValueLow();
|
||||
break;
|
||||
case 9:
|
||||
FastGPIO::Pin<19>::setOutputValueLow();
|
||||
break;
|
||||
case 10:
|
||||
FastGPIO::Pin<20>::setOutputValueLow();
|
||||
break;
|
||||
case 11:
|
||||
FastGPIO::Pin<21>::setOutputValueLow();
|
||||
break;
|
||||
}
|
||||
|
||||
col++;
|
||||
if (col == 12) {
|
||||
col = 0;
|
||||
pass++;
|
||||
if (pass > 8) {
|
||||
pass = 1;
|
||||
}
|
||||
}
|
||||
for (int row = 0; row < 4; row++) {
|
||||
if (leds[col][row] > pass) {
|
||||
switch (row) { // Turn on this led
|
||||
case 0:
|
||||
FastGPIO::Pin<2>::setOutputValueLow();
|
||||
break;
|
||||
case 1:
|
||||
FastGPIO::Pin<3>::setOutputValueLow();
|
||||
break;
|
||||
case 2:
|
||||
FastGPIO::Pin<4>::setOutputValueLow();
|
||||
break;
|
||||
case 3:
|
||||
FastGPIO::Pin<5>::setOutputValueLow();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (row) { // Turn off this led
|
||||
case 0:
|
||||
FastGPIO::Pin<2>::setOutputValueHigh();
|
||||
break;
|
||||
case 1:
|
||||
FastGPIO::Pin<3>::setOutputValueHigh();
|
||||
break;
|
||||
case 2:
|
||||
FastGPIO::Pin<4>::setOutputValueHigh();
|
||||
break;
|
||||
case 3:
|
||||
FastGPIO::Pin<5>::setOutputValueHigh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (col) { // Turn column on
|
||||
case 0:
|
||||
FastGPIO::Pin<6>::setOutputValueHigh();
|
||||
break;
|
||||
case 1:
|
||||
FastGPIO::Pin<7>::setOutputValueHigh();
|
||||
break;
|
||||
case 2:
|
||||
FastGPIO::Pin<8>::setOutputValueHigh();
|
||||
break;
|
||||
case 3:
|
||||
FastGPIO::Pin<9>::setOutputValueHigh();
|
||||
break;
|
||||
case 4:
|
||||
FastGPIO::Pin<10>::setOutputValueHigh();
|
||||
break;
|
||||
case 5:
|
||||
FastGPIO::Pin<16>::setOutputValueHigh();
|
||||
break;
|
||||
case 6:
|
||||
FastGPIO::Pin<14>::setOutputValueHigh();
|
||||
break;
|
||||
case 7:
|
||||
FastGPIO::Pin<15>::setOutputValueHigh();
|
||||
break;
|
||||
case 8:
|
||||
FastGPIO::Pin<18>::setOutputValueHigh();
|
||||
break;
|
||||
case 9:
|
||||
FastGPIO::Pin<19>::setOutputValueHigh();
|
||||
break;
|
||||
case 10:
|
||||
FastGPIO::Pin<20>::setOutputValueHigh();
|
||||
break;
|
||||
case 11:
|
||||
FastGPIO::Pin<21>::setOutputValueHigh();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
135
keyboard/kwark/Makefile
Normal file
135
keyboard/kwark/Makefile
Normal file
@ -0,0 +1,135 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = kwark
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = matrix.c \
|
||||
led.c \
|
||||
protocol/serial_uart.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_kwark.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# 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
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
#EXTRALDFLAGS = -Wl,--relax
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
93
keyboard/kwark/config.h
Normal file
93
keyboard/kwark/config.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x0A0C
|
||||
#define DEVICE_VER 0x000A
|
||||
#define MANUFACTURER di0ib
|
||||
#define PRODUCT The KWARK Keyboard
|
||||
#define DESCRIPTION A compact keyboard
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 4
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 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)) \
|
||||
)
|
||||
|
||||
/* Enable GNAP matrix serial output */
|
||||
#define GNAP_ENABLE
|
||||
|
||||
/* USART configuration */
|
||||
#ifdef __AVR_ATmega32U4__
|
||||
# define SERIAL_UART_BAUD 9600
|
||||
# define SERIAL_UART_DATA UDR1
|
||||
# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
|
||||
# define SERIAL_UART_RXD_VECT USART1_RX_vect
|
||||
# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
|
||||
# define SERIAL_UART_INIT() do { \
|
||||
/* baud rate */ \
|
||||
UBRR1L = SERIAL_UART_UBRR; \
|
||||
/* baud rate */ \
|
||||
UBRR1H = SERIAL_UART_UBRR >> 8; \
|
||||
/* enable TX */ \
|
||||
UCSR1B = _BV(TXEN1); \
|
||||
/* 8-bit data */ \
|
||||
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
|
||||
sei(); \
|
||||
} while(0)
|
||||
# else
|
||||
# error "USART configuration is needed."
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
49
keyboard/kwark/keymap_common.h
Normal file
49
keyboard/kwark/keymap_common.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright 2012,2013 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 KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
void gnaplight_toggle(void);
|
||||
void gnaplight_step(void);
|
||||
|
||||
#define KEYMAP( \
|
||||
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0a, K0b, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1b, \
|
||||
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2a, K2b, \
|
||||
K30, K31, K32, K33, K35, K38, K39, K3a, K3b \
|
||||
) \
|
||||
{ \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0a, KC_##K0b }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_NO, KC_##K1b }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2a, KC_##K2b }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_NO, KC_##K35, KC_NO, KC_NO, KC_##K38, KC_##K39, KC_##K3a, KC_##K3b } \
|
||||
}
|
||||
|
||||
#endif
|
87
keyboard/kwark/keymap_kwark.c
Normal file
87
keyboard/kwark/keymap_kwark.c
Normal file
@ -0,0 +1,87 @@
|
||||
#include "keymap_common.h"
|
||||
#include "protocol/serial.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
KEYMAP(
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
FN2, A, S, D, F, G, H, J, K, L, FN3,
|
||||
CAPS, LSFT, Z, X, C, V, B, N, M, COMM, DOT, FN3,
|
||||
LCTL, LGUI, LALT, FN1, SPC, FN0, SCLN, QUOT, SLSH
|
||||
),
|
||||
|
||||
KEYMAP(
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, DELETE,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL, LBRC, TRNS,
|
||||
TRNS, TRNS, F9, F10, F11, F12, F13, F14, F15, F16, PGUP, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, END
|
||||
),
|
||||
|
||||
KEYMAP(
|
||||
FN6, FN7, FN8, FN9, FN10, FN11, FN12, FN13, FN14, FN15, FN16, DELETE,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN17, FN18, FN19, TRNS,
|
||||
TRNS, TRNS, F1, F2, F3, F4, F5, F6, F7, F8, PGUP,TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, END
|
||||
),
|
||||
|
||||
KEYMAP( /* Tab */
|
||||
ESC, CALC, WHOM, MAIL, MYCM, TRNS, TRNS, TRNS, TRNS, TRNS, PSCR, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, FN4, FN5, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, UP, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, LEFT, DOWN, RGHT
|
||||
),
|
||||
};
|
||||
|
||||
enum function_id {
|
||||
GNAPLED_TOGGLE,
|
||||
GNAPLED_STEP_MODE,
|
||||
};
|
||||
|
||||
const action_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_LAYER_MOMENTARY(2),
|
||||
[2] = ACTION_LAYER_TAP_KEY(3, KC_TAB),
|
||||
[3] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
|
||||
[4] = ACTION_FUNCTION(GNAPLED_TOGGLE),
|
||||
[5] = ACTION_FUNCTION(GNAPLED_STEP_MODE),
|
||||
[6] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[7] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[8] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[9] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
};
|
||||
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
switch (id) {
|
||||
case GNAPLED_TOGGLE:
|
||||
if (record->event.pressed) {
|
||||
gnaplight_toggle();
|
||||
}
|
||||
break;
|
||||
case GNAPLED_STEP_MODE:
|
||||
if (record->event.pressed) {
|
||||
gnaplight_step();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//GNAP keymap functions
|
||||
void gnaplight_step(void) {
|
||||
serial_send(101);
|
||||
}
|
||||
|
||||
void gnaplight_toggle(void) {
|
||||
serial_send(100);
|
||||
}
|
BIN
keyboard/kwark/kwark.bin
Normal file
BIN
keyboard/kwark/kwark.bin
Normal file
Binary file not shown.
BIN
keyboard/kwark/kwark.jpg
Normal file
BIN
keyboard/kwark/kwark.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 245 KiB |
26
keyboard/kwark/led.c
Normal file
26
keyboard/kwark/led.c
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
|
||||
}
|
209
keyboard/kwark/matrix.c
Normal file
209
keyboard/kwark/matrix.c
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
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 <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "protocol/serial.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
|
||||
serial_init();
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i] != cols) {
|
||||
matrix_debouncing[i] = cols;
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* Column pin configuration
|
||||
* col: 0 1 2 3 4 5 6 7 8 9 10 11
|
||||
* pin: D7 E6 B4 B5 B6 B2 B3 B1 F7 F6 F5 F4
|
||||
*/
|
||||
|
||||
static void init_cols(void)
|
||||
{
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
DDRF &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||
PORTF |= (1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||
DDRE &= ~(1<<6);
|
||||
PORTE |= (1<<6);
|
||||
DDRD &= ~(1<<7);
|
||||
PORTD |= (1<<7);
|
||||
DDRB &= ~(1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6);
|
||||
PORTB |= (1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6);
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return (PIND&(1<<7) ? 0 : (1<<0)) |
|
||||
(PINE&(1<<6) ? 0 : (1<<1)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<5) ? 0 : (1<<3)) |
|
||||
(PINB&(1<<6) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<2) ? 0 : (1<<5)) |
|
||||
(PINB&(1<<3) ? 0 : (1<<6)) |
|
||||
(PINB&(1<<1) ? 0 : (1<<7)) |
|
||||
(PINF&(1<<7) ? 0 : (1<<8)) |
|
||||
(PINF&(1<<6) ? 0 : (1<<9)) |
|
||||
(PINF&(1<<5) ? 0 : (1<<10)) |
|
||||
(PINF&(1<<4) ? 0 : (1<<11));
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: 0 1 2 3
|
||||
* pin: D1 D0 D4 C6
|
||||
*/
|
||||
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRD &= ~0b00010011;
|
||||
PORTD &= ~0b00010011;
|
||||
DDRC &= ~0b01000000;
|
||||
PORTC &= ~0b01000000;
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
switch (row) {
|
||||
case 0:
|
||||
DDRD |= (1<<1);
|
||||
PORTD &= ~(1<<1);
|
||||
break;
|
||||
case 1:
|
||||
DDRD |= (1<<0);
|
||||
PORTD &= ~(1<<0);
|
||||
break;
|
||||
case 2:
|
||||
DDRD |= (1<<4);
|
||||
PORTD &= ~(1<<4);
|
||||
break;
|
||||
case 3:
|
||||
DDRC |= (1<<6);
|
||||
PORTC &= ~(1<<6);
|
||||
break;
|
||||
}
|
||||
}
|
38
keyboard/kwark/readme.md
Normal file
38
keyboard/kwark/readme.md
Normal file
@ -0,0 +1,38 @@
|
||||
## KWARK keyboard firmware
|
||||
![KWARK 1.0 Assembled](kwark.jpg)
|
||||
======================
|
||||
KWARK dual matrix, dual controller. Per key LED control, reactive lighting.
|
||||
|
||||
Based on the GNAP!
|
||||
|
||||
Dual Pro Micro's. One running TMK, the other running an Arduino sketch driving the LEDs. Pro Micro's are connected to each other via hardware serial UART.
|
||||
|
||||
Pinout
|
||||
|
||||
Rows D1, D0, D4, C6
|
||||
Cols D7, E6, B4, B5, B6, B2, B3, B1, F7, F6, F5, F4
|
||||
|
||||
keymap_gnap.c contains functions to send bytes to the LED controller. The Arduino code interprets these to change modes or brightness.
|
||||
|
||||
//GNAP keymap functions
|
||||
void gnaplight_step(void) {
|
||||
serial_send(101);
|
||||
}
|
||||
|
||||
void gnaplight_toggle(void) {
|
||||
serial_send(100);
|
||||
}
|
||||
|
||||
\tmk_core\common\keyboard.c was modified to send the row/column of the key being pressed encoded as as single byte over the serial link to the LED controller.
|
||||
|
||||
#ifdef GNAP_ENABLE
|
||||
//send single byte with value of row column
|
||||
serial_send((r*16)+c);
|
||||
#endif
|
||||
|
||||
The example Arduino sketch [LED_FastGPIO.ino](LED_FastGPIO.ino) uses the fastGPIO and TimerOne libraries. These can be installed with the Library manager.
|
||||
|
||||
[FastGPIO](https://github.com/pololu/fastgpio-arduino)
|
||||
[TimerOne](https://www.pjrc.com/teensy/td_libs_TimerOne.html)
|
||||
|
||||
[Original Quark Keyboard](https://deskthority.net/workshop-f7/quark-keyboard-40-staggered-layout-that-fits-all-planck-cases-t10474.html)
|
Loading…
Reference in New Issue
Block a user