Compare commits

...

28 Commits

Author SHA1 Message Date
Jurij Podgoršek 7384b83935 Keymap improvement 2020-02-01 02:05:38 +01:00
Jurij Podgoršek 8cdd16b5b7 Balthazar readme 2020-02-01 01:25:13 +01:00
Jurij Podgorsek 8d4b300d30 Popravki, dinamicni makroji 2019-04-15 00:47:52 +02:00
Jurij Podgorsek eeeb5e7049 Popravki, izboljsave keybindov 2019-04-14 00:32:08 +02:00
Jurij Podgoršek 56d8efc061 Properly popravljen thumb cluster 2019-04-01 22:34:02 +02:00
Jurij Podgoršek ba0d7dd2d5 Še več popravkov 2019-03-05 00:35:14 +01:00
Jurij Podgoršek db2895c8d2 Nekaj popravkov, bootloader fix za reset key 2019-03-04 00:20:22 +01:00
Jurij Podgoršek f349dad3bc Ekesperimentalni popravek thumb clusterja 2019-02-24 15:06:46 +01:00
Jurij Podgorsek c2eb7b5487 Popravki - miska, symb layer -, symb layer toggle 2019-01-19 22:08:43 +01:00
Jurij Podgorsek 0b795298bf Fix poskus 2 2019-01-04 23:22:25 +01:00
Jurij Podgorsek 7e64767812 Fix poskus 1 2019-01-04 23:17:12 +01:00
Jurij Podgorsek d9f719304b Umirjeno skrolanje 2018-11-05 02:27:53 +01:00
Jurij Podgorsek c56b23619b Debounce dodan nazaj, manjsi popravek 2018-11-05 00:13:11 +01:00
Gismoe c193a84dd1 Layout update, no debounce 2018-09-15 10:16:29 -05:00
Jure Podgoršek 0bb84e01d5 Spejs kadet in spimpan super/esc 2018-08-30 22:42:05 +02:00
Gismoe 99b32944cd Popravljen daktil manuform keymap 2018-08-29 01:51:52 +02:00
ivangrozni 94fbfb11f6 Enable mouse support for daktil. 2018-08-29 01:51:52 +02:00
Gismoe 3fb7c5d820 Popravljen keymap (zaradi ozicenja) 2018-08-29 01:51:52 +02:00
Gismoe a97b70d4e9 WIP popravek 2018-08-29 01:51:52 +02:00
Jure Podgoršek 23cf521698 Fix build in newer gcc 2018-08-29 01:51:52 +02:00
ivangrozni b1da87a7a4 Obrnjen vrstni red stolpcev in vrstic 2018-08-29 01:51:52 +02:00
Jure Podgoršek 6e20495b6d Popravki nekih pinov in podobno ter preimenovanje 2018-08-29 01:51:52 +02:00
Jure Podgoršek 3e948d8b86 dajmo to ven malo 2018-08-29 01:51:52 +02:00
Jure Podgoršek 9203a74be5 Opis! 2018-08-29 01:51:51 +02:00
Mojca Miklavec 82ffa0662d Rename dactyl -> daktil 2018-08-29 01:51:51 +02:00
Jure Podgoršek d2c5a3dad0 Pod-zabljena pičja 2018-08-29 01:51:51 +02:00
Jure Podgoršek df8eab83e9 Poskus pravilnejšega mapiranja:
Rows: PB6-PF6
Cols: PB5-PD4

(Od desne proti leve gledano oboje)
2018-08-29 01:51:51 +02:00
Jure Podgoršek b8fdf46f77 Nov entry za naš štukar 2018-08-29 01:51:51 +02:00
20 changed files with 1774 additions and 18 deletions

View File

@ -39,10 +39,9 @@ void init_expander(void);
k10,k11,k12,k13,k14,k15, \
k20,k21,k22,k23,k24,k25, \
k30,k31,k32,k33,k34,k35, \
k40,k41,k42,k43,k44, \
k55,k50, \
k54, \
k53,k52,k51, \
k42,k43,k44,k45, \
k52,k53, \
k54,k55, \
\
k06,k07,k08,k09,k0A,k0B, \
k16,k17,k18,k19,k1A,k1B, \
@ -59,8 +58,8 @@ void init_expander(void);
{ k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1A, k1B }, \
{ k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2A, k2B }, \
{ k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3A, k3B }, \
{ k40, k41, k42, k43, k44, KC_NO, KC_NO, k47, k48, k49, k4A, k4B }, \
{ k50, k51, k52, k53, k54, k55, k56, k57, k58, k59, k5A, k5B }, \
{KC_NO,KC_NO,k42, k43, k44, k45, KC_NO, k47, k48, k49, k4A, k4B }, \
{KC_NO,KC_NO,k52, k53, k54, k55, k56, k57, k58, k59, k5A, k5B }, \
}

View File

@ -0,0 +1,68 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
Copyright 2017 Erin Call <hello@erincall.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 DACTYL_CONFIG_H
#define DACTYL_CONFIG_H
#include "config_common.h"
/* USB Device descriptor parameter */
#define VENDOR_ID 0x6660
#define PRODUCT_ID 0xD571
#define DEVICE_VER 0x0002
#define MANUFACTURER Ludamila
#define PRODUCT Daktil
#define DESCRIPTION Dober stukar. Vec: wiki.ljudmila.org
/* key matrix size
* At this time, "row" in the dactyl's code actually means "column" on the
* physical keyboard. It's confusing. I'm sorry. Blame Jack Humbert :P
*/
#define MATRIX_ROWS 12
#define MATRIX_COLS 6
#define MOUSEKEY_INTERVAL 15
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60
#define MOUSEKEY_MAX_SPEED 7
#define MOUSEKEY_WHEEL_MAX_SPEED 3
#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
#define TAPPING_TOGGLE 1
#define TAPPING_TERM 200
#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \
keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \
)
/* fix space cadet rollover issue */
#define DISABLE_SPACE_CADET_ROLLOVER
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 15
#define PREVENT_STUCK_MODIFIERS
#define USB_MAX_POWER_CONSUMPTION 500
#endif

View File

@ -0,0 +1,84 @@
#include "daktil.h"
#include "i2cmaster.h"
bool i2c_initialized = 0;
uint8_t mcp23018_status = 0x20;
void matrix_init_kb(void) {
/*
DDRB &= ~(1<<4); // set B(4) as input <- wtf to sploh ne gre z naso tipkovnico
PORTB &= ~(1<<4); // set B(4) internal pull-up disabled
*/
DDRF &= ~(1<<4); // <- tak pa ze ja!
PORTF &= ~(1<<4);
// unused pins - C7, D4, D5, D7, E6
// set as input with internal pull-up enabled
DDRC &= ~(1<<7);
DDRD &= ~(1<<5);
DDRE &= ~(1<<6);
PORTC |= (1<<7);
PORTD |= (1<<5);
PORTE |= (1<<6);
matrix_init_user();
}
uint8_t init_mcp23018(void) {
mcp23018_status = 0x20;
// I2C subsystem
if (i2c_initialized == 0) {
i2c_init(); // on pins D(1,0)
i2c_initialized = true;
_delay_ms(1000);
}
// set pin direction
// - unused : input : 1
// - input : input : 1
// - driving : output : 0
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
i2c_stop();
// set pull-up
// - unused : on : 1
// - input : on : 1
// - driving : off : 0
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out;
out:
i2c_stop();
return mcp23018_status;
}
#ifdef SWAP_HANDS_ENABLE
__attribute__ ((weak))
// swap-hands action needs a matrix to define the swap
const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
/* Left hand, matrix positions */
{{0,11}, {1,11}, {2,11}, {3,11}, {4,11}, {5,11}},
{{0,10}, {1,10}, {2,10}, {3,10}, {4,10}, {5,10}},
{{0,9}, {1,9}, {2,9}, {3,9}, {4,9}, {5,9}},
{{0,8}, {1,8}, {2,8}, {3,8}, {4,8}, {5,8}},
{{0,7}, {1,7}, {2,7}, {3,7}, {4,7}, {5,7}},
{{0,6}, {1,6}, {2,6}, {3,6}, {4,6}, {5,6}},
/* Right hand, matrix positions */
{{0,5}, {1,5}, {2,5}, {3,5}, {4,5}, {5,5}},
{{0,4}, {1,4}, {2,4}, {3,4}, {4,4}, {5,4}},
{{0,3}, {1,3}, {2,3}, {3,3}, {4,3}, {5,3}},
{{0,2}, {1,2}, {2,2}, {3,2}, {4,2}, {5,2}},
{{0,1}, {1,1}, {2,1}, {3,1}, {4,1}, {5,1}},
{{0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}},
};
#endif

View File

@ -0,0 +1,72 @@
#ifndef DAKTIL_H
#define DAKTIL_H
#include "quantum.h"
#include <stdint.h>
#include <stdbool.h>
#include "i2cmaster.h"
#include <util/delay.h>
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define CPU_16MHz 0x00
// I2C aliases and register addresses (see "mcp23018.md")
#define I2C_ADDR 0b0100000
#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
#define IODIRA 0x00 // i/o direction register
#define IODIRB 0x01
#define GPPUA 0x0C // GPIO pull-up resistor register
#define GPPUB 0x0D
#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT)
#define GPIOB 0x13
#define OLATA 0x14 // output latch register
#define OLATB 0x15
extern uint8_t mcp23018_status;
void init_dactyl(void);
uint8_t init_mcp23018(void);
#define KEYMAP( \
\
/* left hand, spatial positions */ \
k00,k01,k02,k03,k04,k05, \
k10,k11,k12,k13,k14,k15, \
k20,k21,k22,k23,k24,k25, \
k30,k31,k32,k33,k34,k35, \
k42,k43,k44,k45, \
k52,k53, \
k54,k55, \
\
/* right hand, spatial positions */ \
k06,k07,k08,k09,k0A,k0B, \
k16,k17,k18,k19,k1A,k1B, \
k26,k27,k28,k29,k2A,k2B, \
k36,k37,k38,k39,k3A,k3B, \
k46,k47,k48,k49, \
k56,k57, \
k58,k59 ) \
\
/* matrix positions */ \
{ \
{ k00, k10, k20, k30, KC_NO, KC_NO }, \
{ k01, k11, k21, k31, KC_NO, KC_NO }, \
{ k02, k12, k22, k32, k42, k52 }, \
{ k03, k13, k23, k33, k43, k53 }, \
{ k04, k14, k24, k34, k44, k54 }, \
{ k05, k15, k25, k35, k45, k55 }, \
\
{ k06, k16, k26, k36, k46, k56 }, \
{ k07, k17, k27, k37, k47, k57 }, \
{ k08, k18, k28, k38, k48, k58 }, \
{ k09, k19, k29, k39, k49, k59 }, \
{ k0A, k1A, k2A, k3A, KC_NO, KC_NO }, \
{ k0B, k1B, k2B, k3B, KC_NO, KC_NO } \
}
#define LAYOUT_dactyl KEYMAP
#endif

View File

@ -0,0 +1,178 @@
#ifndef _I2CMASTER_H
#define _I2CMASTER_H 1
/*************************************************************************
* Title: C include file for the I2C master interface
* (i2cmaster.S or twimaster.c)
* Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
* File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $
* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
* Target: any AVR device
* Usage: see Doxygen manual
**************************************************************************/
#ifdef DOXYGEN
/**
@defgroup pfleury_ic2master I2C Master library
@code #include <i2cmaster.h> @endcode
@brief I2C (TWI) Master Software Library
Basic routines for communicating with I2C slave devices. This single master
implementation is limited to one bus master on the I2C bus.
This I2c library is implemented as a compact assembler software implementation of the I2C protocol
which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c).
Since the API for these two implementations is exactly the same, an application can be linked either against the
software I2C implementation or the hardware I2C implementation.
Use 4.7k pull-up resistor on the SDA and SCL pin.
Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module
i2cmaster.S to your target when using the software I2C implementation !
Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.
@note
The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted
to GNU assembler and AVR-GCC C call interface.
Replaced the incorrect quarter period delays found in AVR300 with
half period delays.
@author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
@par API Usage Example
The following code shows typical usage of this library, see example test_i2cmaster.c
@code
#include <i2cmaster.h>
#define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet
int main(void)
{
unsigned char ret;
i2c_init(); // initialize I2C library
// write 0x75 to EEPROM address 5 (Byte Write)
i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
i2c_write(0x05); // write address = 5
i2c_write(0x75); // write value 0x75 to EEPROM
i2c_stop(); // set stop conditon = release bus
// read previously written value back from EEPROM address 5
i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
i2c_write(0x05); // write address = 5
i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode
ret = i2c_readNak(); // read one byte from EEPROM
i2c_stop();
for(;;);
}
@endcode
*/
#endif /* DOXYGEN */
/**@{*/
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
#endif
#include <avr/io.h>
/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_READ 1
/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_WRITE 0
/**
@brief initialize the I2C master interace. Need to be called only once
@param void
@return none
*/
extern void i2c_init(void);
/**
@brief Terminates the data transfer and releases the I2C bus
@param void
@return none
*/
extern void i2c_stop(void);
/**
@brief Issues a start condition and sends address and transfer direction
@param addr address and transfer direction of I2C device
@retval 0 device accessible
@retval 1 failed to access device
*/
extern unsigned char i2c_start(unsigned char addr);
/**
@brief Issues a repeated start condition and sends address and transfer direction
@param addr address and transfer direction of I2C device
@retval 0 device accessible
@retval 1 failed to access device
*/
extern unsigned char i2c_rep_start(unsigned char addr);
/**
@brief Issues a start condition and sends address and transfer direction
If device is busy, use ack polling to wait until device ready
@param addr address and transfer direction of I2C device
@return none
*/
extern void i2c_start_wait(unsigned char addr);
/**
@brief Send one byte to I2C device
@param data byte to be transfered
@retval 0 write successful
@retval 1 write failed
*/
extern unsigned char i2c_write(unsigned char data);
/**
@brief read one byte from the I2C device, request more data from device
@return byte read from I2C device
*/
extern unsigned char i2c_readAck(void);
/**
@brief read one byte from the I2C device, read is followed by a stop condition
@return byte read from I2C device
*/
extern unsigned char i2c_readNak(void);
/**
@brief read one byte from the I2C device
Implemented as a macro, which calls either i2c_readAck or i2c_readNak
@param ack 1 send ack, request more data from device<br>
0 send nak, read is followed by a stop condition
@return byte read from I2C device
*/
extern unsigned char i2c_read(unsigned char ack);
#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
/**@}*/
#endif

View File

@ -0,0 +1,203 @@
#include "daktil.h"
#include "debug.h"
#include "action_layer.h"
#include "version.h"
#define BASE 0 // default layer
#define SYMB 1 // symbols
#define MDIA 2 // media keys
#define TKTK 3 // Tehnoklistir layer
enum custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum
VRSN,
DYNAMIC_MACRO_RANGE
};
#include "dynamic_macro.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
* ,-----------------------------------------. ,-----------------------------------------.
* | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | Del | Q | W | E | R | T | | Y | U | I | O | P | \ |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | BkSp | A | S | D | F | G | | H | J | K | L |; / L2|'/Cmd |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* |LSft/(|Z/Ctrl| X | C | V | B | | N | M | , | . |//Ctrl|RSft/)|
* `------+------+------+------+------+------' `------+------+------+------+------+------'
* | LAlt |Insert| | [ | ] |
* `-------------' `-------------'
* ,------,------. ,------------.
* | | | | | |
* | Spc | Bksp |-----. ,-----+ Tab |Enter|
* | | |Esc/m| |Esc/m| | |
* |------+------+-----| |-----+------+-----|
* | Lalt | End |Home | | PgUp| PgDn | Ralt|
* `------+------+-----' `-----+------+-----'
*/
[BASE] = LAYOUT_dactyl( // layer 0 : default
// left hand
LALT(KC_LSFT), KC_1, KC_2, KC_3, KC_4, KC_5,
LT(TKTK,KC_EQL), KC_Q, KC_W, KC_E, KC_R, KC_T,
KC_LSPO, KC_A, KC_S, KC_D, KC_F, KC_G,
LT(SYMB,KC_GRV), CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B,
KC_DELT, KC_INS, KC_SPC,KC_BSPC,
ALT_T(KC_APP), LGUI_T(KC_ESC),
KC_END, KC_HOME,
// right hand
KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
KC_Y, KC_U, KC_I, KC_O, KC_P,LT(TKTK,KC_BSLS),
KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), KC_RSPC,
KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH),LT(SYMB,KC_QUOT),
KC_TAB, KC_ENT, KC_LBRC, KC_RBRC,
LGUI_T(KC_ESC), KC_RALT,
KC_PGUP, KC_PGDN
),
/* Keymap 1: Symbol Layer
*
* ,-----------------------------------------. ,-----------------------------------------.
* |Versn | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | ! | @ | { | } | | | | & | 7 | 8 | 9 | * | F12 |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | # | $ | ( | ) | ` | | ^ | 4 | 5 | 6 | + | = |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | % | ^ | [ | ] | ~ | | _ | 1 | 2 | 3 | - | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* |RESET | | | | | | | . | 0 |
* `----------------------------------' `--------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
// SYMBOLS
[SYMB] = LAYOUT_dactyl(
// left hand
KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5,
VRSN, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC,
KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV,
KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
// right hand
KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_AMPR, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
KC_CIRC, KC_4, KC_5, KC_6, KC_PLUS, KC_EQL,
KC_UNDS, KC_1, KC_2, KC_3, KC_MINS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_DOT, KC_0,
KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS
),
/* Keymap 2: Media and mouse keys
* ,-----------------------------------------. ,-----------------------------------------.
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | MsUp | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | |MsLeft|MsDown|MsRght| | | | | | | | Play |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | | | | | | | Prev | Next | | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* | | | | Lclk | Rclk | | VolUp| VolDn| Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | |Brwser|
* | | |------| |------| |Back |
* | | | | | | | |
* `--------------------' `--------------------'
*
*/
// MEDIA AND MOUSE
[MDIA] = LAYOUT_dactyl(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RESET, KC_TRNS, KC_WH_U, KC_MS_U, KC_WH_D, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
KC_MPLY, KC_BTN3,
KC_MPRV, KC_MNXT,
// right hand
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_VOLD, KC_VOLU,
KC_TRNS, KC_MUTE,
KC_TRNS, KC_TRNS
),
// TK LAYER
[TKTK] = LAYOUT_dactyl(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RESET, KC_TRNS, KC_WH_U, KC_MS_U, KC_WH_D, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, DYN_MACRO_PLAY1, DYN_REC_START1,
KC_MPLY, DYN_REC_STOP,
KC_MPRV, KC_MNXT,
// right hand
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
DYN_REC_START2, DYN_MACRO_PLAY2, KC_VOLD, KC_VOLU,
DYN_REC_STOP, KC_MUTE,
KC_TRNS, KC_TRNS
),
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case 0:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
break;
case 1:
if (record->event.pressed) { // For resetting EEPROM
eeconfig_init();
}
break;
}
return MACRO_NONE;
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_record_dynamic_macro(keycode, record)) {
return false;
}
switch (keycode) {
case VRSN:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
return false;
break;
}
return true;
}
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
};
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {};

View File

@ -0,0 +1,10 @@
# Dactyl Default Configuration
## Changelog
* Nov 2017:
* Copied and adapted from the Ergodox EZ equivalent
* Notable differences:
- Don't try to have the columns that don't exist, naturally
- Removed RGB keys, since there are no RGB LEDs in the Dactyl (as designed, at least)

View File

@ -0,0 +1,183 @@
#include "daktil.h"
#include "debug.h"
#include "action_layer.h"
#include "version.h"
#define BASE 0 // default layer
#define SYMB 1 // symbols
#define MDIA 2 // media keys
enum custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum
VRSN,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
* ,-----------------------------------------. ,-----------------------------------------.
* | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | Del | '" | , | . | P | Y | | F | G | C | R | L | \ |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | BkSp | A | O | E | U | I | | D | H | T | N | S/L2 |//Cmd |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* |LShift|;/Ctrl| Q | J | K | X | | B | M | W | V |Z/Ctrl|RShift|
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* |Grv/L1| = |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | App | LGui | | Alt | ^/Esc|
* ,------|------|------| |------+------+------.
* | | | Home | | PgUp | | |
* | Space|Backsp|------| |------| Tab |Enter |
* | |ace | End | | PgDn | | |
* `--------------------' `--------------------'
*/
[BASE] = LAYOUT_dactyl( // layer 0 : default
// left hand
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5,
KC_DELT, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y,
KC_BSPC, KC_A, KC_O, KC_E, KC_U, KC_I,
KC_LSFT, CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X,
LT(SYMB,KC_GRV), KC_EQL, LALT(KC_LSFT), KC_LEFT, KC_RGHT,
ALT_T(KC_APP), KC_LGUI,
KC_HOME,
KC_SPC, KC_BSPC, KC_END,
// right hand
KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSLS,
KC_D, KC_H, KC_T, KC_N, LT(MDIA, KC_S), GUI_T(KC_SLSH),
KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_RSFT,
KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_FN1,
KC_RALT, CTL_T(KC_ESC),
KC_PGUP,
KC_PGDN, KC_TAB, KC_ENT
),
/* Keymap 1: Symbol Layer
*
* ,-----------------------------------------. ,-----------------------------------------.
* |Versn | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | ! | @ | { | } | | | | Up | 7 | 8 | 9 | * | F12 |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | # | $ | ( | ) | ` | | Down | 4 | 5 | 6 | + | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | % | ^ | [ | ] | ~ | | & | 1 | 2 | 3 | \ | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* |RESET | | | | | | | . | 0 | = | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
// SYMBOLS
[SYMB] = LAYOUT_dactyl(
// left hand
VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5,
KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE,
KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV,
KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD,
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS
),
/* Keymap 2: Media and mouse keys
* ,-----------------------------------------. ,-----------------------------------------.
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | MsUp | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | |MsLeft|MsDown|MsRght| | | | | | | | Play |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | | | | | | | Prev | Next | | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* | | | | Lclk | Rclk | | VolUp| VolDn| Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | |Brwser|
* | | |------| |------| |Back |
* | | | | | | | |
* `--------------------' `--------------------'
*
*/
// MEDIA AND MOUSE
[MDIA] = LAYOUT_dactyl(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_WBAK
),
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
switch(id) {
case 0:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
break;
case 1:
if (record->event.pressed) { // For resetting EEPROM
eeconfig_init();
}
break;
}
return MACRO_NONE;
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case VRSN:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
return false;
break;
}
return true;
}
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
};
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {};

View File

@ -0,0 +1,9 @@
# Dactyl Dvorak keymap
Modifiers and layers 1+ are the same as in the default layout.
Only the layer-0 dvorak-relevant keys are different.
## Changelog
* Nov 2017:
* Copied and adapted from the default keymap.

View File

@ -0,0 +1,162 @@
#include "daktil.h"
#include "debug.h"
#include "action_layer.h"
#include "version.h"
#define BASE 0 // default layer
#define CONT 1 // control layer
#define QWER 2 // qwerty layer
enum custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum
COLON_EQ,
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
* ,-----------------------------------------. ,-----------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | \ |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | Tab | '" | , | . | P | Y | | F | G | C | R | L | / |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | := | A | O | E | U | I | | D | H | T | N | S | - |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* |LShift| ; | Q | J | K | X | | B | M | W | V | Z |RShift|
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* | Home | ` | = | Left | Right| | Up | Down | [ | ] | End |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | LCtl | LAlt | | RCtl | Ralt |
* ,------|------|------| |------+------+------.
* | | | L1 | | L1 | | |
* | Back |Delete|------| |------|Enter |Space |
* |Space | | LGui | | RGui | | |
* `--------------------' `--------------------'
*/
[BASE] = LAYOUT_dactyl( // layer 0 : default
// left hand
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5,
KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y,
COLON_EQ, KC_A, KC_O, KC_E, KC_U, KC_I,
KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X,
KC_HOME, KC_GRV, KC_EQL, KC_LEFT, KC_RGHT,
KC_LCTRL, KC_LALT,
MO(CONT),
KC_BSPC, KC_DEL, KC_LGUI,
// right hand
KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,
KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH,
KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS,
KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT,
KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_END,
KC_RALT, KC_RCTL,
MO(CONT),
KC_RGUI, KC_ENT, KC_SPACE
),
/* Keymap 1: Control layer (media keys, Fkeys, numpad)
*
* ,-----------------------------------------. ,-----------------------------------------.
* | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | RESET|
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | Mute | VolD | VolU | | | | 7 | 8 | 9 | + | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | Prev |PPause| Next | | | | 4 | 5 | 6 | = | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | | | | | | 1 | 2 | 3 | , | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* |PageUp| | | | | | 0 | 0 | . | |PageDn|
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
// SYMBOLS
[CONT] = LAYOUT_dactyl(
// left hand
KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5,
KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS,
TG(QWER), KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_PGUP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, RESET,
KC_TRNS, KC_7, KC_8, KC_9, KC_KP_PLUS, KC_TRNS,
KC_TRNS, KC_4, KC_5, KC_6, KC_EQL, KC_TRNS,
KC_TRNS, KC_1, KC_2, KC_3, KC_COMM, KC_TRNS,
KC_0, KC_0, KC_DOT, KC_TRNS, KC_PGDN,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS
),
/* Keymap 2: QWERTY overlay
* ,-----------------------------------------. ,-----------------------------------------.
* | | | | | | | | | | | | | [ |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | Q | W | E | R | T | | Y | U | I | O | P | ] |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | A | S | D | F | G | | H | J | K | L | ; | '" |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | Z | X | C | V | B | | N | M | , | . | / | |
* |------+------+------+------+------+------' `------+------+------+------+------+------|
* | | | | | | | | | - | \ | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | | |
* | | |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*
*/
// QWERTY
[QWER] = LAYOUT_dactyl(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_Q, KC_W, KC_E, KC_R, KC_T,
KC_TRNS, KC_A, KC_S, KC_D, KC_F, KC_G,
KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC,
KC_Y, KC_U, KC_I, KC_O, KC_P, KC_RBRC,
KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MINS, KC_BSLS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS
),
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch(keycode) {
case COLON_EQ:
SEND_STRING(":=");
return false;
break;
}
}
return true;
}
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
};
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {};

View File

@ -0,0 +1,6 @@
# Erincalling Dactyl keymap
## Changelog
* Nov 2017:
* Ported and adapted from the ergodox-firmware layout I'd been using

View File

@ -0,0 +1,439 @@
/*
Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
Copyright 2017 Erin Call <hello@erincall.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 "wait.h"
#include "action_layer.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "daktil.h"
#include "i2cmaster.h"
#ifdef DEBUG_MATRIX_SCAN_RATE
#include "timer.h"
#endif
/*
* This constant define not debouncing time in msecs, but amount of matrix
* scan loops which should be made to get stable debounced results.
*
* On the Dactyl, the matrix scan rate is relatively low, because
* communicating with the left hand's I/O expander is slower than simply
* selecting local pins.
* Now it's only 317 scans/second, or about 3.15 msec/scan.
* According to Cherry specs, debouncing time is 5 msec.
*
* And so, there is no sense to have DEBOUNCE higher than 2.
*/
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
// Debouncing: store for each key the number of scans until it's eligible to
// change. When scanning the matrix, ignore any changes in keys that have
// already changed in the last DEBOUNCE scans.
static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS];
static matrix_row_t read_cols(uint8_t row);
static void init_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);
static uint8_t mcp23018_reset_loop;
#ifdef DEBUG_MATRIX_SCAN_RATE
uint32_t matrix_timer;
uint32_t matrix_scan_count;
#endif
__attribute__ ((weak))
void matrix_init_user(void) {}
__attribute__ ((weak))
void matrix_scan_user(void) {}
__attribute__ ((weak))
void matrix_init_kb(void) {
matrix_init_user();
}
__attribute__ ((weak))
void matrix_scan_kb(void) {
matrix_scan_user();
}
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
mcp23018_status = init_mcp23018();
unselect_rows();
init_cols();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
for (uint8_t j=0; j < MATRIX_COLS; ++j) {
debounce_matrix[i * MATRIX_COLS + j] = 0;
}
}
#ifdef DEBUG_MATRIX_SCAN_RATE
matrix_timer = timer_read32();
matrix_scan_count = 0;
#endif
matrix_init_quantum();
}
void matrix_power_up(void) {
mcp23018_status = init_mcp23018();
unselect_rows();
init_cols();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
}
#ifdef DEBUG_MATRIX_SCAN_RATE
matrix_timer = timer_read32();
matrix_scan_count = 0;
#endif
}
// Returns a matrix_row_t whose bits are set if the corresponding key should be
// eligible to change in this scan.
matrix_row_t debounce_mask(uint8_t row) {
matrix_row_t result = 0;
for (uint8_t j=0; j < MATRIX_COLS; ++j) {
if (debounce_matrix[row * MATRIX_COLS + j]) {
--debounce_matrix[row * MATRIX_COLS + j];
} else {
result |= (1 << j);
}
}
return result;
}
// Report changed keys in the given row. Resets the debounce countdowns
// corresponding to each set bit in 'change' to DEBOUNCE.
void debounce_report(matrix_row_t change, uint8_t row) {
for (uint8_t i = 0; i < MATRIX_COLS; ++i) {
if (change & (1 << i)) {
debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE;
}
}
}
uint8_t matrix_scan(void)
{
if (mcp23018_status) { // if there was an error
if (++mcp23018_reset_loop == 0) {
// since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
// this will be approx bit more frequent than once per second
print("trying to reset mcp23018\n");
mcp23018_status = init_mcp23018();
if (mcp23018_status) {
print("left side not responding\n");
} else {
print("left side attached\n");
}
}
}
#ifdef DEBUG_MATRIX_SCAN_RATE
matrix_scan_count++;
uint32_t timer_now = timer_read32();
if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
print("matrix scan frequency: ");
pdec(matrix_scan_count);
print("\n");
matrix_timer = timer_now;
matrix_scan_count = 0;
}
#endif
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
wait_us(30); // without this wait read unstable value.
matrix_row_t mask = debounce_mask(i);
matrix_row_t cols = (read_cols(i) & mask) | (matrix[i] & ~mask);
debounce_report(cols ^ matrix[i], i);
matrix[i] = cols;
unselect_rows();
}
matrix_scan_quantum();
return 1;
}
bool matrix_is_modified(void) // deprecated and evidently not called.
{
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
*
* Teensy
* col: 0 1 2 3 4 5
* pin: F0 F1 F4 F5 F6 F7
*
* MCP23018
* col: 0 1 2 3 4 5
* pin: B5 B4 B3 B2 B1 B0
*/
static void init_cols(void)
{
// init on mcp23018
// not needed, already done as part of init_mcp23018()
// init on teensy
// Input with pull-up(DDR:0, PORT:1)
// To je za stran vrec
//DDRF &= ~(1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
//PORTF |= (1<<7 | 1<<6 | 1<<5 | 1<<4 | 1<<1 | 1<<0);
// Cist mimo
DDRB &= ~(1<<6 | 1<<3 | 1<<2 | 1<<1 );
PORTB |= (1<<6 | 1<<3 | 1<<2 | 1<<1 );
// Evo to je ze boljse
DDRF &= ~(1<<6 | 1<<7);
PORTF |= (1<<6 | 1<<7);
}
static matrix_row_t read_cols(uint8_t row)
{
if (row < 6) {
if (mcp23018_status) { // if there was an error
return 0;
} else {
uint8_t data = 0;
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPIOB); if (mcp23018_status) goto out;
mcp23018_status = i2c_start(I2C_ADDR_READ); if (mcp23018_status) goto out;
data = i2c_readNak();
data = ~data;
out:
i2c_stop();
return data;
}
} else {
// read from teensy
return
/* OLOSH
(PINF&(1<<0) ? 0 : (1<<0)) |
(PINF&(1<<1) ? 0 : (1<<1)) |
(PINF&(1<<4) ? 0 : (1<<2)) |
(PINF&(1<<5) ? 0 : (1<<3)) |
(PINF&(1<<6) ? 0 : (1<<4)) |
(PINF&(1<<7) ? 0 : (1<<5)) ;
(PINB&(1<<6) ? 0 : (1<<0)) |
(PINB&(1<<2) ? 0 : (1<<1)) |
(PINB&(1<<3) ? 0 : (1<<2)) |
(PINB&(1<<1) ? 0 : (1<<3)) |
(PINF&(1<<7) ? 0 : (1<<4)) |
(PINF&(1<<6) ? 0 : (1<<5)) ;
*/
(PINB&(1<<6) ? 0 : (1<<5)) |
(PINB&(1<<2) ? 0 : (1<<4)) |
(PINB&(1<<3) ? 0 : (1<<3)) |
(PINB&(1<<1) ? 0 : (1<<2)) |
(PINF&(1<<7) ? 0 : (1<<1)) |
(PINF&(1<<6) ? 0 : (1<<0)) ;
}
}
/* Row pin configuration
*
* Micro Pro
* row: 6 7 8 9 10 11
* pin: B5 F4 E6 D7 C6 D4
*
* Teensy
* row: 6 7 8 9 10 11
* pin: B1 B2 B3 D2 D3 C6
*
* MCP23018
* row: 0 1 2 3 4 5
* pin: A0 A1 A2 A3 A4 A5
*/
static void unselect_rows(void)
{
// unselect on mcp23018
if (mcp23018_status) { // if there was an error
// do nothing
} else {
// set all rows hi-Z : 1
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0xFF); if (mcp23018_status) goto out;
out:
i2c_stop();
}
// unselect on teensy
// Hi-Z(DDR:0, PORT:0) to unselect
/* spet mimo jojoj
DDRB &= ~(1<<1 | 1<<2 | 1<<3);
PORTB &= ~(1<<1 | 1<<2 | 1<<3);
DDRD &= ~(1<<2 | 1<<3);
PORTD &= ~(1<<2 | 1<<3);
DDRC &= ~(1<<6);
PORTC &= ~(1<<6);
*/
DDRB &= ~(1<<5);
PORTB &= ~(1<<5);
DDRC &= ~(1<<6);
PORTC &= ~(1<<6);
DDRD &= ~(1<<4 | 1<<7);
PORTD &= ~(1<<4 | 1<<7);
DDRE &= ~(1<<6);
PORTE &= ~(1<<6);
DDRF &= ~(1<<4);
PORTF &= ~(1<<4);
}
/* Row pin configuration
*
* Teensy
* row: 6 7 8 9 10 11
* pin: B1 B2 B3 D2 D3 C6
*
* MCP23018
* row: 0 1 2 3 4 5
* pin: A0 A1 A2 A3 A4 A5
*/
static void select_row(uint8_t row)
{
if (row < 6) {
// select on mcp23018
if (mcp23018_status) { // if there was an error
// do nothing
} else {
// set active row low : 0
// set other rows hi-Z : 1
mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0xFF & ~(1<<row)); if (mcp23018_status) goto out;
out:
i2c_stop();
}
} else {
// select on teensy
// Output low(DDR:1, PORT:0) to select
switch (row) {
case 11:
DDRB |= (1<<5);
PORTB &= ~(1<<5);
break;
case 10:
DDRF |= (1<<4);
PORTF &= ~(1<<4);
break;
case 9:
DDRE |= (1<<6);
PORTE &= ~(1<<6);
break;
case 8:
DDRD |= (1<<7);
PORTD &= ~(1<<7);
break;
case 7:
DDRC |= (1<<6);
PORTC &= ~(1<<6);
break;
case 6:
DDRD |= (1<<4);
PORTD &= ~(1<<4);
break;
}
}
}

View File

@ -0,0 +1,39 @@
# Dactyl
See https://github.com/adereth/dactyl-keyboard
The Dactyl uses the [Teensy Loader](https://www.pjrc.com/teensy/loader.html).
Linux users need to modify udev rules as described on the [Teensy
Linux page]. Some distributions provide a binary, maybe called
`teensy-loader-cli`.
[Teensy Linux page]: https://www.pjrc.com/teensy/loader_linux.html
To flash the firmware:
- Build the firmware with `make handwired/dactyl:<keymapname>`, for example `make handwired/dactyl:default`
- This will result in a hex file called `handwired_dactyl_<keymapname>.hex`, e.g.
`handwired_dactyl_default.hex`
- Start the teensy loader.
- Load the .hex file into it.
- Put the Teensy in firmware-loading mode:
* If your current layout has a RESET key, press it.
* If you lack a RESET key, press the reset button on the Teensy board itself.
- Click the button in the Teensy app to download the firmware.
To flash with ´teensy-loader-cli´:
- Build the firmware as above
- Run `<path/to/>teensy_loader_cli -mmcu=atmega32u4 -w handwired_dactyl_<keymapname>.hex`
- If you like, you can do both at once: `make handwired/dactyl:<keymapname>:teensy`
- Put the Teensy in firmware-loading mode:
* If your current layout has a RESET key, press it.
* If you lack a RESET key, press the reset button on the Teensy board itself.

View File

@ -0,0 +1,89 @@
#----------------------------------------------------------------------------
# On command line:
#
# make = Make software.
#
# make clean = Clean out built project files.
#
# That's pretty much all you need. To compile, always go make clean,
# followed by make.
#
# For advanced users only:
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
#----------------------------------------------------------------------------
# # project specific files
SRC = twimaster.c \
matrix.c
# MCU name
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=512
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MIDI_ENABLE = no # MIDI support (+2400 to 4200)
POINTING_DEVICE_ENABLE = no
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+8000)
COMMAND_ENABLE = no # Commands for debug and configuration
CUSTOM_MATRIX = yes # Custom matrix file for the Dactyl
NKRO_ENABLE = yes # USB Nkey Rollover
UNICODE_ENABLE = yes # Unicode
SWAP_HANDS_ENABLE = yes # Allow swapping hands of keyboard
SLEEP_LED_ENABLE = no
API_SYSEX_ENABLE = no
RGBLIGHT_ENABLE = no
# Fix za soft reest
BOOTLOADER = caterina

View File

@ -0,0 +1,207 @@
/*************************************************************************
* Title: I2C master library using hardware TWI interface
* Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
* File: $Id: twimaster.c,v 1.3 2005/07/02 11:14:21 Peter Exp $
* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
* Target: any AVR device with hardware TWI
* Usage: API compatible with I2C Software Library i2cmaster.h
**************************************************************************/
#include <inttypes.h>
#include <compat/twi.h>
#include <i2cmaster.h>
/* define CPU frequency in Hz here if not defined in Makefile */
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
/* I2C clock in Hz */
#define SCL_CLOCK 400000L
/*************************************************************************
Initialization of the I2C bus interface. Need to be called only once
*************************************************************************/
void i2c_init(void)
{
/* initialize TWI clock
* minimal values in Bit Rate Register (TWBR) and minimal Prescaler
* bits in the TWI Status Register should give us maximal possible
* I2C bus speed - about 444 kHz
*
* for more details, see 20.5.2 in ATmega16/32 secification
*/
TWSR = 0; /* no prescaler */
TWBR = 10; /* must be >= 10 for stable operation */
}/* i2c_init */
/*************************************************************************
Issues a start condition and sends address and transfer direction.
return 0 = device accessible, 1= failed to access device
*************************************************************************/
unsigned char i2c_start(unsigned char address)
{
uint8_t twst;
// send START condition
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
// wait until transmission completed
while(!(TWCR & (1<<TWINT)));
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
if ( (twst != TW_START) && (twst != TW_REP_START)) return 1;
// send device address
TWDR = address;
TWCR = (1<<TWINT) | (1<<TWEN);
// wail until transmission completed and ACK/NACK has been received
while(!(TWCR & (1<<TWINT)));
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;
return 0;
}/* i2c_start */
/*************************************************************************
Issues a start condition and sends address and transfer direction.
If device is busy, use ack polling to wait until device is ready
Input: address and transfer direction of I2C device
*************************************************************************/
void i2c_start_wait(unsigned char address)
{
uint8_t twst;
while ( 1 )
{
// send START condition
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
// wait until transmission completed
while(!(TWCR & (1<<TWINT)));
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
if ( (twst != TW_START) && (twst != TW_REP_START)) continue;
// send device address
TWDR = address;
TWCR = (1<<TWINT) | (1<<TWEN);
// wail until transmission completed
while(!(TWCR & (1<<TWINT)));
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
if ( (twst == TW_MT_SLA_NACK )||(twst ==TW_MR_DATA_NACK) )
{
/* device busy, send stop condition to terminate write operation */
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
// wait until stop condition is executed and bus released
while(TWCR & (1<<TWSTO));
continue;
}
//if( twst != TW_MT_SLA_ACK) return 1;
break;
}
}/* i2c_start_wait */
/*************************************************************************
Issues a repeated start condition and sends address and transfer direction
Input: address and transfer direction of I2C device
Return: 0 device accessible
1 failed to access device
*************************************************************************/
unsigned char i2c_rep_start(unsigned char address)
{
return i2c_start( address );
}/* i2c_rep_start */
/*************************************************************************
Terminates the data transfer and releases the I2C bus
*************************************************************************/
void i2c_stop(void)
{
/* send stop condition */
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
// wait until stop condition is executed and bus released
while(TWCR & (1<<TWSTO));
}/* i2c_stop */
/*************************************************************************
Send one byte to I2C device
Input: byte to be transfered
Return: 0 write successful
1 write failed
*************************************************************************/
unsigned char i2c_write( unsigned char data )
{
uint8_t twst;
// send data to the previously addressed device
TWDR = data;
TWCR = (1<<TWINT) | (1<<TWEN);
// wait until transmission completed
while(!(TWCR & (1<<TWINT)));
// check value of TWI Status Register. Mask prescaler bits
twst = TW_STATUS & 0xF8;
if( twst != TW_MT_DATA_ACK) return 1;
return 0;
}/* i2c_write */
/*************************************************************************
Read one byte from the I2C device, request more data from device
Return: byte read from I2C device
*************************************************************************/
unsigned char i2c_readAck(void)
{
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA);
while(!(TWCR & (1<<TWINT)));
return TWDR;
}/* i2c_readAck */
/*************************************************************************
Read one byte from the I2C device, read is followed by a stop condition
Return: byte read from I2C device
*************************************************************************/
unsigned char i2c_readNak(void)
{
TWCR = (1<<TWINT) | (1<<TWEN);
while(!(TWCR & (1<<TWINT)));
return TWDR;
}/* i2c_readNak */

View File

@ -20,7 +20,8 @@ OPTIMIZATION = 1
TARGET = Test
SRC = $(TARGET).c
LUFA_PATH = ../../LUFA
CC_FLAGS = -Werror
#CC_FLAGS = -Werror
CC_FLAGS =
DEBUG_LEVEL = 0

View File

@ -31,7 +31,7 @@ endif
# Generic C/C++ compiler flags
CC_FLAGS = -Wextra
CC_FLAGS += -Werror
#CC_FLAGS += -Werror
CC_FLAGS += -Wformat=2
CC_FLAGS += -Winit-self
CC_FLAGS += -Wswitch-enum

View File

@ -32,7 +32,7 @@ LUFA_PATH = ../../LUFA
# Generic C/C++ compiler flags
CC_FLAGS = -Wextra
CC_FLAGS += -Werror
#CC_FLAGS += -Werror
CC_FLAGS += -Wformat=2
CC_FLAGS += -Winit-self
CC_FLAGS += -Wswitch-enum

View File

@ -1,3 +1,10 @@
# Balthazar keyboard firmware
Modification of [https://docs.qmk.fm/#/ QMK firmware] for the [https://balthazar.space/wiki/Balthazar Balthazar personal computing device].
We have based our keyboard development following the Open Sourced [https://github.com/adereth/dactyl-keyboard Parameterized ergonomic keyboard] done by Matt Adereth
and modified for our developement by Balthazar team. [https://github.com/g1smo/balthazar_dactyl Here] you can find our detailed documentation on a current modification.
# Quantum Mechanical Keyboard Firmware
[![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags)

View File

@ -92,9 +92,9 @@ endif
endif
CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CFLAGS += -Werror
endif
#ifneq ($(strip $(ALLOW_WARNINGS)), yes)
# CFLAGS += -Werror
#endif
#CFLAGS += -mshort-calls
#CFLAGS += -fno-unit-at-a-time
#CFLAGS += -Wundef
@ -118,9 +118,9 @@ CPPFLAGS += -O$(OPT)
CPPFLAGS += -w
CPPFLAGS += -Wall
CPPFLAGS += -Wundef
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CPPFLAGS += -Werror
endif
#ifneq ($(strip $(ALLOW_WARNINGS)), yes)
# CPPFLAGS += -Werror
#endif
#CPPFLAGS += -mshort-calls
#CPPFLAGS += -fno-unit-at-a-time
#CPPFLAGS += -Wstrict-prototypes
@ -138,7 +138,7 @@ CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
# files -- see avr-libc docs [FIXME: not yet described there]
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
# dump that will be displayed for a given single line of source input.
ASFLAGS += $(ADEFS)
ASFLAGS += $(ADEFS)
ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
#---------------- Library Options ----------------
@ -284,7 +284,7 @@ BEGIN = gccversion sizebefore
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
$(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS))
@$(BUILD_CMD)
define GEN_OBJRULE
$1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC))
@ -352,7 +352,7 @@ DEPS = $(patsubst %.o,%.d,$(OBJ))
.PRECIOUS: $(DEPS)
# Empty rule to force recompilation if the .d file is missing
$(DEPS):
$(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT))))