From 8665ed3efc62e649d0eac5b88761d7b3f8f30cd7 Mon Sep 17 00:00:00 2001 From: Stick Date: Tue, 18 Apr 2017 09:46:07 -0500 Subject: small changes --- keyboards/ergodox/keymaps/familiar/README.md | 4 ++-- keyboards/ergodox/keymaps/familiar/keymap.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox/keymaps/familiar/README.md b/keyboards/ergodox/keymaps/familiar/README.md index e4336d9b55..8db9a77122 100644 --- a/keyboards/ergodox/keymaps/familiar/README.md +++ b/keyboards/ergodox/keymaps/familiar/README.md @@ -1,5 +1,5 @@ # ErgoDox Familiar Layout -Familiar layout for those who regularly switch back and forth from ErgoDox to regular QWERTY. +Familiar layout for those who regularly switch back and forth from ErgoDox to "normal" QWERTY. [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](../../../../license_GPLv3.md../../../../license_GPLv3.md) [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme) @@ -50,7 +50,7 @@ $ make ergodox-ez-familiar-teensy ### Layers 1. Base Layer: QWERTY, with arrow keys at bottom right. 1. UCIS Layer: US-International symbols layer, plus —. Accessed by toggling the `INTL` layer using the UCIS key (bottom of left thumb cluster). -1. UCIS-Shifted Layer: Making shift work for UCIS characters. An ugly workaround. Any ideas? Accessed through holding shift while the UCIS layer is active (toggles the `INSF` layer). +1. UCIS-Shifted Layer: Making shift work for UCIS characters. An ugly workaround. Any ideas? Accessed by holding shift while the UCIS layer is active (toggles the `INSF` layer). 1. Numpad Layer: Right hand number pad. Accessed by toggling the `NUMP` layer using the NPAD key (bottom of right thumb cluster). 1. Function Layer: F1-F12, arrows on ESDF and HJKL, media player controls. Accessed by holding either FN key (center key of each thumb cluster), which toggles the `ARRW` layer. I know, I need to work on my naming conventions. diff --git a/keyboards/ergodox/keymaps/familiar/keymap.c b/keyboards/ergodox/keymaps/familiar/keymap.c index c5f94afda8..0e3958de01 100644 --- a/keyboards/ergodox/keymaps/familiar/keymap.c +++ b/keyboards/ergodox/keymaps/familiar/keymap.c @@ -31,7 +31,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | LCTRL | LGUI | MENU | ' | " | | [ | ] | LEFT | DOWN | RIGHT | * `------------------------------------' `------------------------------------' * ,-------------. ,-------------. - * | VOL- | VOL+ | | | | + * | VOL- | VOL+ | |PRTSCR| | * ,------|------|------| |------+------+------. * | SPC/ |SLASH/| MUTE | |NUMLCK|WHACK/| SPC/ | * | ALT | MO(1)|------| |------|MO(1) | ALT | @@ -54,7 +54,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENTER, KC_PGDN, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSPC, KC_LBRC, KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT, - _______, _______, + KC_PSCR, _______, KC_NLCK, TG(NUMP), LT(ARRW,KC_BSLS), ALT_T(KC_SPC) ), @@ -202,7 +202,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | | | | | | | | | HOME | PGDN | END | * `------------------------------------' `------------------------------------' * ,-------------. ,-------------. - * | | PAUSE| | | | + * | | PAUSE| |SYSREQ| | * ,------|------|------| |------+------+------. * | | | | |SCRLK | | | * | | |------| |------| | | @@ -225,7 +225,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, KC_PGUP, _______, _______, _______, KC_HOME, KC_PGDN, KC_END, - _______, _______, + KC_SYSREQ, _______, KC_SLCK, _______, _______, _______ ), -- cgit v1.2.3 From 4cf17210b60eb7da77f66b8e5af1947a3d168f2f Mon Sep 17 00:00:00 2001 From: Stick Date: Fri, 2 Jun 2017 19:51:29 -0500 Subject: moved alt out from under space --- keyboards/ergodox/keymaps/familiar/keymap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox/keymaps/familiar/keymap.c b/keyboards/ergodox/keymaps/familiar/keymap.c index 0e3958de01..714118d93e 100644 --- a/keyboards/ergodox/keymaps/familiar/keymap.c +++ b/keyboards/ergodox/keymaps/familiar/keymap.c @@ -28,13 +28,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+------+------+------+------+------| END | | PGDN |------+------+------+------+------+--------| * | (/LSFT | Z | X | C | V | B | | | | N | M | , | . | UP | )/RSFT | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' - * | LCTRL | LGUI | MENU | ' | " | | [ | ] | LEFT | DOWN | RIGHT | + * | LCTRL | LGUI | MENU | ' | LALT | |[/RALT| ] | LEFT | DOWN | RIGHT | * `------------------------------------' `------------------------------------' * ,-------------. ,-------------. * | VOL- | VOL+ | |PRTSCR| | * ,------|------|------| |------+------+------. - * | SPC/ |SLASH/| MUTE | |NUMLCK|WHACK/| SPC/ | - * | ALT | MO(1)|------| |------|MO(1) | ALT | + * | |SLASH/| MUTE | |NUMLCK|WHACK/| | + * | SPC | MO(1)|------| |------|MO(1) | SPC | * | | | LAY3 | | LAY2 | | | * `--------------------' `--------------------' */ @@ -44,19 +44,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_HOME, KC_GRV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_END, - KC_LCTL, KC_LGUI, KC_MENU, KC_QUOT, S(KC_QUOT), + KC_LCTL, KC_LGUI, KC_MENU, KC_QUOT, KC_LALT, KC_VOLD, KC_VOLU, KC_MUTE, - ALT_T(KC_SPC), LT(ARRW,KC_SLSH), TG(INTL), + KC_SPC, LT(ARRW, KC_SLSH), TG(INTL), // right hand KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENTER, KC_PGDN, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_RSPC, - KC_LBRC, KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT, + MT(MOD_RALT, KC_LBRC), KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR, _______, KC_NLCK, - TG(NUMP), LT(ARRW,KC_BSLS), ALT_T(KC_SPC) + TG(NUMP), LT(ARRW, C_BSLS), KC_SPC ), /* layer 1: International symbols, etc -- cgit v1.2.3 From f397402e101774eedd1748b1e31c7386f927d4ed Mon Sep 17 00:00:00 2001 From: Stick Date: Fri, 2 Jun 2017 20:02:02 -0500 Subject: ugly workaround for ErgoDoxEZ LED bugs: turn 'em all off --- keyboards/ergodox/ez/ez.c | 42 +++++++++++++-------------- keyboards/ergodox/ez/matrix.c | 3 +- keyboards/ergodox/keymaps/familiar/keymap.c | 44 ++++++++++++++--------------- 3 files changed, 44 insertions(+), 45 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox/ez/ez.c b/keyboards/ergodox/ez/ez.c index 3e19f23028..55b51f6fa8 100644 --- a/keyboards/ergodox/ez/ez.c +++ b/keyboards/ergodox/ez/ez.c @@ -22,30 +22,30 @@ void matrix_init_kb(void) { PORTD |= (1<<5 | 1<<4); PORTE |= (1<<6); - ergodox_blink_all_leds(); + //ergodox_blink_all_leds(); matrix_init_user(); } -void ergodox_blink_all_leds(void) -{ - ergodox_led_all_off(); - ergodox_led_all_set(LED_BRIGHTNESS_HI); - ergodox_right_led_1_on(); - _delay_ms(50); - ergodox_right_led_2_on(); - _delay_ms(50); - ergodox_right_led_3_on(); - _delay_ms(50); - ergodox_right_led_1_off(); - _delay_ms(50); - ergodox_right_led_2_off(); - _delay_ms(50); - ergodox_right_led_3_off(); - //ergodox_led_all_on(); - //_delay_ms(333); - ergodox_led_all_off(); -} +// void ergodox_blink_all_leds(void) +// { +// ergodox_led_all_off(); +// ergodox_led_all_set(LED_BRIGHTNESS_HI); +// ergodox_right_led_1_on(); +// _delay_ms(50); +// ergodox_right_led_2_on(); +// _delay_ms(50); +// ergodox_right_led_3_on(); +// _delay_ms(50); +// ergodox_right_led_1_off(); +// _delay_ms(50); +// ergodox_right_led_2_off(); +// _delay_ms(50); +// ergodox_right_led_3_off(); +// //ergodox_led_all_on(); +// //_delay_ms(333); +// ergodox_led_all_off(); +// } uint8_t init_mcp23018(void) { mcp23018_status = 0x20; @@ -57,7 +57,7 @@ uint8_t init_mcp23018(void) { // cli(); if (i2c_initialized == 0) { i2c_init(); // on pins D(1,0) - i2c_initialized++; + i2c_initialized = 1; _delay_ms(1000); } diff --git a/keyboards/ergodox/ez/matrix.c b/keyboards/ergodox/ez/matrix.c index 21b60a542e..a489e5b5cc 100644 --- a/keyboards/ergodox/ez/matrix.c +++ b/keyboards/ergodox/ez/matrix.c @@ -183,7 +183,7 @@ uint8_t matrix_scan(void) print("left side not responding\n"); } else { print("left side attached\n"); - ergodox_blink_all_leds(); +// ergodox_blink_all_leds(); } } } @@ -391,4 +391,3 @@ static void select_row(uint8_t row) } } } - diff --git a/keyboards/ergodox/keymaps/familiar/keymap.c b/keyboards/ergodox/keymaps/familiar/keymap.c index 714118d93e..513bb5541c 100644 --- a/keyboards/ergodox/keymaps/familiar/keymap.c +++ b/keyboards/ergodox/keymaps/familiar/keymap.c @@ -56,7 +56,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { MT(MOD_RALT, KC_LBRC), KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR, _______, KC_NLCK, - TG(NUMP), LT(ARRW, C_BSLS), KC_SPC + TG(NUMP), LT(ARRW, KC_BSLS), KC_SPC ), /* layer 1: International symbols, etc @@ -242,26 +242,26 @@ void matrix_init_user(void) { // Runs constantly in the background, in a loop. void matrix_scan_user(void) { - uint8_t layer = biton32(layer_state); - - ergodox_board_led_off(); - ergodox_right_led_1_off(); - ergodox_right_led_2_off(); - ergodox_right_led_3_off(); - switch (layer) { - case INTL: - case INSF: - ergodox_right_led_1_on(); - break; - case NUMP: - ergodox_right_led_2_on(); - break; - case ARRW: - ergodox_right_led_3_on(); - break; - default: - // none - break; - } + // uint8_t layer = biton32(layer_state); + // + // ergodox_board_led_off(); + // ergodox_right_led_1_off(); + // ergodox_right_led_2_off(); + // ergodox_right_led_3_off(); + // switch (layer) { + // case INTL: + // case INSF: + // ergodox_right_led_1_on(); + // break; + // case NUMP: + // ergodox_right_led_2_on(); + // break; + // case ARRW: + // ergodox_right_led_3_on(); + // break; + // default: + // // none + // break; + // } }; -- cgit v1.2.3 From 5a70cb30eecc8b76410e4b21a225b10c344e12c7 Mon Sep 17 00:00:00 2001 From: Stick Date: Thu, 8 Jun 2017 08:59:30 -0500 Subject: trying to fix LEDs --- keyboards/ergodox/keymaps/familiar/keymap.c | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox/keymaps/familiar/keymap.c b/keyboards/ergodox/keymaps/familiar/keymap.c index 513bb5541c..1dd1d5cbc1 100644 --- a/keyboards/ergodox/keymaps/familiar/keymap.c +++ b/keyboards/ergodox/keymaps/familiar/keymap.c @@ -242,26 +242,26 @@ void matrix_init_user(void) { // Runs constantly in the background, in a loop. void matrix_scan_user(void) { - // uint8_t layer = biton32(layer_state); - // - // ergodox_board_led_off(); - // ergodox_right_led_1_off(); - // ergodox_right_led_2_off(); - // ergodox_right_led_3_off(); - // switch (layer) { - // case INTL: - // case INSF: - // ergodox_right_led_1_on(); - // break; - // case NUMP: - // ergodox_right_led_2_on(); - // break; - // case ARRW: - // ergodox_right_led_3_on(); - // break; - // default: - // // none - // break; - // } + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + case INTL: + case INSF: + ergodox_right_led_1_on(); + break; + case NUMP: + ergodox_right_led_2_on(); + break; + case ARRW: + ergodox_right_led_3_on(); + break; + default: + // none + break; + } }; -- cgit v1.2.3 From 4b50ab029d49830cf0efd0e5e0606cb39c8dabae Mon Sep 17 00:00:00 2001 From: Stick Date: Thu, 8 Jun 2017 08:59:33 -0500 Subject: Revert "ugly workaround for ErgoDoxEZ LED bugs: turn 'em all off" This reverts commit f397402e101774eedd1748b1e31c7386f927d4ed. --- keyboards/ergodox/ez/ez.c | 42 ++++++++++++++--------------- keyboards/ergodox/ez/matrix.c | 3 ++- keyboards/ergodox/keymaps/familiar/keymap.c | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox/ez/ez.c b/keyboards/ergodox/ez/ez.c index 55b51f6fa8..3e19f23028 100644 --- a/keyboards/ergodox/ez/ez.c +++ b/keyboards/ergodox/ez/ez.c @@ -22,30 +22,30 @@ void matrix_init_kb(void) { PORTD |= (1<<5 | 1<<4); PORTE |= (1<<6); - //ergodox_blink_all_leds(); + ergodox_blink_all_leds(); matrix_init_user(); } -// void ergodox_blink_all_leds(void) -// { -// ergodox_led_all_off(); -// ergodox_led_all_set(LED_BRIGHTNESS_HI); -// ergodox_right_led_1_on(); -// _delay_ms(50); -// ergodox_right_led_2_on(); -// _delay_ms(50); -// ergodox_right_led_3_on(); -// _delay_ms(50); -// ergodox_right_led_1_off(); -// _delay_ms(50); -// ergodox_right_led_2_off(); -// _delay_ms(50); -// ergodox_right_led_3_off(); -// //ergodox_led_all_on(); -// //_delay_ms(333); -// ergodox_led_all_off(); -// } +void ergodox_blink_all_leds(void) +{ + ergodox_led_all_off(); + ergodox_led_all_set(LED_BRIGHTNESS_HI); + ergodox_right_led_1_on(); + _delay_ms(50); + ergodox_right_led_2_on(); + _delay_ms(50); + ergodox_right_led_3_on(); + _delay_ms(50); + ergodox_right_led_1_off(); + _delay_ms(50); + ergodox_right_led_2_off(); + _delay_ms(50); + ergodox_right_led_3_off(); + //ergodox_led_all_on(); + //_delay_ms(333); + ergodox_led_all_off(); +} uint8_t init_mcp23018(void) { mcp23018_status = 0x20; @@ -57,7 +57,7 @@ uint8_t init_mcp23018(void) { // cli(); if (i2c_initialized == 0) { i2c_init(); // on pins D(1,0) - i2c_initialized = 1; + i2c_initialized++; _delay_ms(1000); } diff --git a/keyboards/ergodox/ez/matrix.c b/keyboards/ergodox/ez/matrix.c index a489e5b5cc..21b60a542e 100644 --- a/keyboards/ergodox/ez/matrix.c +++ b/keyboards/ergodox/ez/matrix.c @@ -183,7 +183,7 @@ uint8_t matrix_scan(void) print("left side not responding\n"); } else { print("left side attached\n"); -// ergodox_blink_all_leds(); + ergodox_blink_all_leds(); } } } @@ -391,3 +391,4 @@ static void select_row(uint8_t row) } } } + diff --git a/keyboards/ergodox/keymaps/familiar/keymap.c b/keyboards/ergodox/keymaps/familiar/keymap.c index 1dd1d5cbc1..714118d93e 100644 --- a/keyboards/ergodox/keymaps/familiar/keymap.c +++ b/keyboards/ergodox/keymaps/familiar/keymap.c @@ -56,7 +56,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { MT(MOD_RALT, KC_LBRC), KC_RBRC, KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR, _______, KC_NLCK, - TG(NUMP), LT(ARRW, KC_BSLS), KC_SPC + TG(NUMP), LT(ARRW, C_BSLS), KC_SPC ), /* layer 1: International symbols, etc -- cgit v1.2.3 From 23b0fc20e3c94972db7ff897854d2b0513937d71 Mon Sep 17 00:00:00 2001 From: npoirey Date: Fri, 7 Oct 2016 17:18:49 +0200 Subject: Frenchdev v1 --- keyboards/frenchdev/Makefile | 5 + keyboards/frenchdev/config.h | 34 ++ keyboards/frenchdev/frenchdev.c | 4 + keyboards/frenchdev/frenchdev.h | 7 + .../frenchdev/keymaps/default/keyboard-layout.png | Bin 0 -> 138511 bytes keyboards/frenchdev/keymaps/default/keymap.c | 409 +++++++++++++++++++++ keyboards/frenchdev/readme.md | 53 +++ keyboards/frenchdev/rules.mk | 79 ++++ keyboards/frenchdev/v1/Makefile | 8 + keyboards/frenchdev/v1/config.h | 68 ++++ keyboards/frenchdev/v1/i2cmaster.h | 178 +++++++++ keyboards/frenchdev/v1/matrix.c | 394 ++++++++++++++++++++ keyboards/frenchdev/v1/rules.mk | 80 ++++ keyboards/frenchdev/v1/twimaster.c | 208 +++++++++++ keyboards/frenchdev/v1/v1.c | 86 +++++ keyboards/frenchdev/v1/v1.h | 116 ++++++ 16 files changed, 1729 insertions(+) create mode 100644 keyboards/frenchdev/Makefile create mode 100644 keyboards/frenchdev/config.h create mode 100644 keyboards/frenchdev/frenchdev.c create mode 100644 keyboards/frenchdev/frenchdev.h create mode 100644 keyboards/frenchdev/keymaps/default/keyboard-layout.png create mode 100644 keyboards/frenchdev/keymaps/default/keymap.c create mode 100644 keyboards/frenchdev/readme.md create mode 100644 keyboards/frenchdev/rules.mk create mode 100644 keyboards/frenchdev/v1/Makefile create mode 100644 keyboards/frenchdev/v1/config.h create mode 100644 keyboards/frenchdev/v1/i2cmaster.h create mode 100644 keyboards/frenchdev/v1/matrix.c create mode 100644 keyboards/frenchdev/v1/rules.mk create mode 100644 keyboards/frenchdev/v1/twimaster.c create mode 100644 keyboards/frenchdev/v1/v1.c create mode 100644 keyboards/frenchdev/v1/v1.h (limited to 'keyboards') diff --git a/keyboards/frenchdev/Makefile b/keyboards/frenchdev/Makefile new file mode 100644 index 0000000000..73a289f1d4 --- /dev/null +++ b/keyboards/frenchdev/Makefile @@ -0,0 +1,5 @@ +SUBPROJECT_DEFAULT = v1 + +ifndef MAKEFILE_INCLUDED + include ../../Makefile +endif diff --git a/keyboards/frenchdev/config.h b/keyboards/frenchdev/config.h new file mode 100644 index 0000000000..f535010ef1 --- /dev/null +++ b/keyboards/frenchdev/config.h @@ -0,0 +1,34 @@ +#ifndef KEYBOARDS_ERGODOX_CONFIG_H_ +#define KEYBOARDS_ERGODOX_CONFIG_H_ + +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_DELAY 0 +#define MOUSEKEY_TIME_TO_MAX 5 +#define MOUSEKEY_MAX_SPEED 2 +#define MOUSEKEY_WHEEL_DELAY 0 + +#define TAPPING_TOGGLE 1 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +#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.) + +/* 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_LCTL) | MOD_BIT(KC_RCTL)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \ +) + +#ifdef SUBPROJECT_v1 + #include "v1/config.h" +#endif + + +#endif /* KEYBOARDS_ERGODOX_CONFIG_H_ */ diff --git a/keyboards/frenchdev/frenchdev.c b/keyboards/frenchdev/frenchdev.c new file mode 100644 index 0000000000..ecc1021696 --- /dev/null +++ b/keyboards/frenchdev/frenchdev.c @@ -0,0 +1,4 @@ +#include "frenchdev.h" +#include "debug.h" +#include "action_layer.h" + diff --git a/keyboards/frenchdev/frenchdev.h b/keyboards/frenchdev/frenchdev.h new file mode 100644 index 0000000000..60afda21d6 --- /dev/null +++ b/keyboards/frenchdev/frenchdev.h @@ -0,0 +1,7 @@ +#ifndef KEYBOARDS_ERGODOX_ERGODOX_H_ +#define KEYBOARDS_ERGODOX_ERGODOX_H_ +#ifdef SUBPROJECT_v1 + #include "v1.h" +#endif + +#endif /* KEYBOARDS_ERGODOX_ERGODOX_H_ */ diff --git a/keyboards/frenchdev/keymaps/default/keyboard-layout.png b/keyboards/frenchdev/keymaps/default/keyboard-layout.png new file mode 100644 index 0000000000..40f556f438 Binary files /dev/null and b/keyboards/frenchdev/keymaps/default/keyboard-layout.png differ diff --git a/keyboards/frenchdev/keymaps/default/keymap.c b/keyboards/frenchdev/keymaps/default/keymap.c new file mode 100644 index 0000000000..e0a05cb3c6 --- /dev/null +++ b/keyboards/frenchdev/keymaps/default/keymap.c @@ -0,0 +1,409 @@ +#include "frenchdev.h" +#include "mousekey.h" +#include "action.h" +#include "action_layer.h" +#include "keymap_extras/keymap_bepo.h" + + +// 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. +#define _BASE 0 +#define _SYMBOLS 1 +#define _MEDIA 2 +#define _TRNS 8 + +#define PEDAL_DELAY 250 +#define KEY_DELAY 130 + +enum macros { + M_LP, // left pedal + M_RP, // right pedal + M_SF, // shift + M_SFS, // shift and space + M_L1E, // L1 and space + L2INS, // L2 and insert + L2LOC, // Lock L2 + M_UN, // undo + M_CUT, // cut + M_CP, // copy + M_PS, // paste + M_SE, // search + M_SFU, // shift and underscore +}; + +static uint16_t key_timer_left_pedal; +static uint16_t key_timer_right_pedal; +static uint16_t key_timer_shift; +static uint16_t key_timer_1; +static uint16_t key_timer_2; + +static uint16_t shift_count = 0; //this is used to keep track of shift state and avoid inserting non breakable space +static uint16_t l2_locked = 0; //this indicate wether L2 is locked + +#define BP_CBSP CTL_T(KC_BSPC) +#define BP_CDEL CTL_T(KC_DEL) + +//layout : http://www.keyboard-layout-editor.com/#/gists/4480e3ab8026eb7c710a7e22203ef4aa +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* base + * left foot clicked is right click + * left foot pressed is layer 2 + * right foot clicked is left click + * right foot pressed is layer 1 + scroll lock (used with autohotkey for easier scrolling with trackballs) + * ,------. .. ,------. * + * ,------| F3 |-------------. .. ,-------------| F10 |------. * + * ,------| F2 |------| F4 | F5 |------. .. ,------| F8 | F9 |------| F11 |------. * + * | F1 |------| »/3 |------|------| F6 | .. | F7 |------|------| -/8 |------| F12 | * + * ,------+------| «/2 |------| (/4 | )/5 |------| .. |------| @/6 | +/7 |------| //9 |------+------. * + * | ESC | "/1 |------| O |------|------| ¨ | .. | ^ |------|------| D |------| * /0 |BCKSP | * + * |------+------| É |------| P | È |------| .. |------| K | V |------| L |------+------| * + * | TAB | B |------| E |------|------| _ | .. | =/° |------|------| S |------| J |ENTER | * + * |------+------| U |------| I | F |------| .. |------| C | T |------| R |------+------| * + * | ` | A |------| Y |------|------| ; | .. | ! |------|------| UP |------| N | '/? | * + * |------+------| À |------| X | W |------|-------------. .. .-------------|------| M | G |------| H |------+------| * + * | SHIFT| Z |------| . |------|------|sp/sh |bsp/ct|L2/ins| .. |L2lock|del/CT|sp/sh |------|------| DOWN |------| Q |SHIFT | * + * |------+------| / |------| , | space|------|------|------ .. ------|------|------| L1/sp| LEFT |------| UP |------+------| * + * | CTRL | win |------/ \-------------| L1 | alt | .. | CAPS | L1 |-------------/ \------| : | CTRL | * + * `-------------/ \-------------/ .. \-------------/ \-------------/ * + *M(M_LP) + */ +[_BASE] = KEYMAP( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ + KC_ESC, BP_DQOT, BP_LGIL, BP_RGIL, BP_LPRN, BP_RPRN, BP_DTRM, BP_DCRC, BP_AT, BP_PLUS, BP_MINS, BP_SLSH, BP_ASTR, KC_BSPC, \ + KC_TAB, BP_B, BP_ECUT, BP_O, BP_P, BP_EGRV, BP_UNDS, BP_EQL, BP_K, BP_V, BP_D, BP_L, BP_J, KC_ENT, \ + BP_GRV, BP_A, BP_U, BP_E, BP_I, BP_F, BP_SCLN, BP_EXLM, BP_C, BP_T, BP_S, BP_R, BP_N, BP_APOS, \ + M(M_SF), BP_Z, BP_AGRV, BP_Y, BP_X, BP_W, M(M_SFS), BP_CBSP, M(L2INS), M(L2LOC), BP_CDEL, M(M_SFS),BP_M, BP_G, KC_UP, BP_H, BP_Q, M(M_SF), \ + KC_LCTL, KC_LGUI, KC_PSLS, BP_DOT, BP_COMM, KC_SPACE,M(M_L1E), KC_LALT, KC_CAPS, M(M_L1E),KC_SPACE,KC_LEFT, KC_DOWN, KC_RIGHT,BP_COLN, KC_RCTL, \ + //left pedals + M(M_LP), M(M_RP), KC_TRNS, \ + //right pedals + M(M_LP), M(M_RP), KC_TRNS \ +), + + /* Larer 1 for symbols. + * left foot is middle click + * ,------. .. ,------. * + * ,------| |-------------. .. ,-------------| |------. * + * ,------| |------| | |------. .. ,------| | |------| |------. * + * | |------| § |------|------| | .. | |------|------| ± |------| | * + * ,------+------| ¶ |------| µ | |------| .. |------| ≤ | ≥ |------| ÷ |------+------. * + * | | ¤ |------| { |------|------| ~ | .. | ˇ |------|------| ] |------| × | | * + * |------+------| * |------| } | ` |------| .. |------| # | [ |------| % |------+------| * + * | | \ |------| ( |------|------| | .. | ≠ |------|------| > |------| ‰ | | * + * |------+------| Ù |------| ) | + |------| .. |------| Ç | < |------| & |------+------| * + * | | = |------| copy |------|------| : | .. | ? |------|------| PGUP |------| _ | | * + * |------+------| cut |------| paste|search|------|-------------. .. .-------------|------| $ | = |------| | |------+------| * + * | | undo |------| \ |------|------| | | | .. | | | |------|------| PGDN |------| / | | * + * |------+------| |------| | |------|------|------ .. ------|------|------| | HOME |------| PGDN |------+------| * + * | | |------/ \-------------| | | .. | | |-------------/ \------| | | * + * `-------------/ \-------------/ .. \-------------/ \-------------/ * + * + */ +[_SYMBOLS] = KEYMAP( + 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, BP_DCUR, BP_PARG, BP_SECT, BP_DGRK, KC_TRNS, BP_TILD, BP_DCAR, BP_LEQL, BP_GEQL, BP_PSMS, BP_OBEL, BP_TIMS, KC_TRNS, \ + KC_TRNS, BP_BSLS, BP_ASTR, BP_LCBR, BP_RCBR, BP_GRV, KC_TRNS, BP_DIFF, BP_HASH, BP_LBRC, BP_RBRC, BP_PERC, BP_PMIL, KC_TRNS, \ + KC_TRNS, BP_EQL, BP_UGRV, BP_LPRN, BP_RPRN, BP_PLUS, BP_COLN, BP_QEST, BP_CCED, BP_LESS, BP_GRTR, BP_AMPR, BP_UNDS, KC_TRNS, \ + KC_TRNS, M(M_UN), M(M_CUT),M(M_CP), M(M_PS), M(M_SE), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BP_DLR, BP_EQL, KC_PGUP, BP_PIPE, BP_SLSH, KC_TRNS, \ + KC_TRNS, KC_TRNS, BP_BSLS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_END, KC_TRNS, KC_TRNS, \ + //left pedals + KC_TRNS, KC_BTN1, KC_TRNS, \ + //right pedals + KC_TRNS, KC_BTN1, KC_TRNS \ +), + + /* MEDIA, mouse and numpad. + * right pedal is left clic + * ,------. .. ,------. * + * ,------|PAUSE |-------------. .. ,-------------| PRINT|------. * + * ,------|SCROLL|------|MUTE |VOLUD |------. .. ,------| pre | next |------| calc |------. * + * |RESET |------| stop |------|------|VOLDU | .. | play |------|------| stop |------| num | * + * ,------+------| |------| pre | next |------| .. |------| pre | next |------| |------+------. * + * | | |------|scrolu|------|------| play | .. | play |------|------| 8 |------| - | | * + * |------+------| |------| | bt4 |------| .. |------| next | 7 |------| 9 |------+------| * + * | | |------|scrold|------|------| bt5 | .. | pre |------|------| 5 |------| + | | * + * |------+------| |------|mclic | rclic|------| .. |------| rclic| 4 |------| 6 |------+------| * + * | | |------| |------|------| lclic| .. | lclic|------|------| 2 |------| * | | * + * |------+------| |------| | mclck|------|-------------. .. .-------------|------| mclic| 1 |------| 3 |------+------| * + * | | |------| |------|------| | | | .. | | | |------|------| num. |------| / | | * + * |------+------| |------| | |------|------|------ .. ------|------|------| | 0 |------| . |------+------| * + * | | |------/ \-------------| | | .. | | |-------------/ \------| , | | * + * `-------------/ \-------------/ .. \-------------/ \-------------/ * + * + */ +[_MEDIA] = KEYMAP( + RESET, KC_SLCK, KC_PAUS, KC_MUTE, KC_VOLD, KC_VOLU, KC_MUTE, KC_VOLD, KC_VOLU, KC_PSCR, KC_CALC, KC_NLCK, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_MSTP, KC_MPRV, KC_MNXT, KC_MPLY, KC_MPLY, KC_MPRV, KC_MNXT, KC_MSTP, KC_TRNS, KC_PMNS, KC_TRNS, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_WH_U, KC_TRNS, KC_BTN4, KC_BTN5, KC_BTN4, KC_BTN5, KC_KP_7, KC_KP_8, KC_KP_9, KC_PPLS, KC_TRNS, \ + KC_TRNS, KC_TRNS, KC_TRNS, KC_WH_D, KC_BTN3, KC_BTN2, KC_BTN1, KC_BTN1, KC_BTN2, KC_KP_4, KC_KP_5, KC_KP_6, KC_PAST, KC_TRNS, \ + KC_TRNS, M(M_UN), M(M_CUT),M(M_CP), M(M_PS), KC_BTN3, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN3, KC_KP_1, KC_KP_2, KC_KP_3, KC_PSLS, 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_KP_0, KC_PDOT, BP_DOT, BP_COMM, KC_TRNS, \ + //left pedals + KC_BTN3, M(M_RP), KC_TRNS, \ + //right pedals + KC_BTN3, M(M_RP), KC_TRNS \ +), + +/* TRNS - skeleton for laters + * ,------. .. ,------. * + * ,------| |-------------. .. ,-------------| |------. * + * ,------| |------| | |------. .. ,------| | |------| |------. * + * | |------| |------|------| | .. | |------|------| |------| | * + * ,------+------| |------| | |------| .. |------| | |------| |------+------. * + * | | |------| |------|------| | .. | |------|------| |------| | | * + * |------+------| |------| | |------| .. |------| | |------| |------+------| * + * | | |------| |------|------| | .. | |------|------| |------| | | * + * |------+------| |------| | |------| .. |------| | |------| |------+------| * + * | | |------| |------|------| | .. | |------|------| |------| | | * + * |------+------| |------| | |------|-------------. .. .-------------|------| | |------| |------+------| * + * | | |------| |------|------| | | | .. | | | |------|------| |------| | | * + * |------+------| |------| | |------|------|------ .. ------|------|------| | |------| |------+------| * + * | | |------/ \-------------| | | .. | | |-------------/ \------| | | * + * `-------------/ \-------------/ .. \-------------/ \-------------/ * + * + */ + +[_TRNS] = KEYMAP( + 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_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_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_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_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_TRNS, KC_TRNS, KC_TRNS, \ + //left pedals + KC_BTN3, M(M_RP), KC_TRNS, \ + //right pedals + KC_BTN3, M(M_RP), KC_TRNS \ +), + +}; + + +const uint16_t PROGMEM fn_actions[] = { + +}; + +void hold_shift(void) { + shift_count = shift_count + 1; + register_code(KC_LSHIFT); +} + +void release_shift(void) { + shift_count = shift_count - 1; + if(shift_count <= 0){ + unregister_code(KC_LSHIFT); + shift_count = 0; + } +} + +void press_space(void) { + if(shift_count > 0) unregister_code (KC_LSHIFT); + register_code (KC_SPACE); + unregister_code (KC_SPACE); + if(shift_count > 0) register_code (KC_LSHIFT); +} + +void press_enter(void) { + if(shift_count > 0) unregister_code (KC_LSHIFT); + register_code (KC_ENT); + unregister_code (KC_ENT); + if(shift_count > 0) register_code (KC_LSHIFT); +} + +void press_underscore(void) { + if(shift_count > 0) unregister_code (KC_LSHIFT); + register_code (BP_UNDS); + unregister_code (BP_UNDS); + if(shift_count > 0) register_code (KC_LSHIFT); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case M_LP: //left pedal + if (record->event.pressed) { + layer_on(1); + register_code (KC_SLCK); + key_timer_left_pedal = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_left_pedal) < KEY_DELAY) { + mousekey_on (KC_BTN2); + mousekey_send(); + mousekey_off (KC_BTN2); + mousekey_send(); + } + unregister_code (KC_SLCK); + layer_off(1); + } + break; + case M_RP: //right pedal + if (record->event.pressed) { + layer_on(2); + key_timer_right_pedal = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_right_pedal) < PEDAL_DELAY) { + mousekey_on (KC_BTN1); + mousekey_send(); + mousekey_off (KC_BTN1); + mousekey_send(); + } + layer_off(2); + } + break; + case M_SF: // shift, using macro to keep track of shift state and avoid inserting nbsp by mistake + if (record->event.pressed) { + hold_shift(); + } else { + release_shift(); + } + break; + case M_SFS: // shift when held, space when tapped + if (record->event.pressed) { + hold_shift(); + key_timer_shift = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_shift) < KEY_DELAY) { + press_space(); + } + release_shift(); + } + break; + case M_SFU: // shift when held, _ when tapped + if (record->event.pressed) { + hold_shift(); + key_timer_shift = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_shift) < KEY_DELAY) { + press_space(); + } + release_shift(); + } + break; + case M_L1E: // L1 when held, space when tapped + if (record->event.pressed) { + layer_on(1); + key_timer_1 = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_1) < KEY_DELAY) { + press_enter(); + } + layer_off(1); + } + break; + case L2INS: //activate layer 2, if released before 100ms trigger INS. basicaly equivalent to LT(2, KC_INS) but without delay for activation of layer 2 + if (record->event.pressed) { + layer_on(2); + key_timer_2 = timer_read(); // if the key is being pressed, we start the timer. + } else { + if (timer_elapsed(key_timer_2) < KEY_DELAY) { + register_code (KC_INS); + unregister_code (KC_INS); + } + l2_locked = 0; + layer_off(2); + } + break; + case L2LOC: //lock L2 + if (record->event.pressed) { + key_timer_2 = timer_read(); // if the key is being pressed, we start the timer. + layer_on(2); + } else { + if (timer_elapsed(key_timer_2) < KEY_DELAY && l2_locked == 0) { + l2_locked = 1; + layer_on(2); + } else { + l2_locked = 0; + layer_off(2); + } + } + break; + case M_UN: // undo + if (record->event.pressed) { + register_code(KC_LCTL); + register_code(BP_Z); + unregister_code(BP_Z); + unregister_code(KC_LCTL); + } + break; + case M_CUT: // cut + if (record->event.pressed) { + register_code(KC_LCTL); + register_code(BP_X); + unregister_code(BP_X); + unregister_code(KC_LCTL); + } + break; + case M_CP: // copy + if (record->event.pressed) { + register_code(KC_LCTL); + register_code(BP_C); + unregister_code(BP_C); + unregister_code(KC_LCTL); + } + break; + case M_PS: // paste + if (record->event.pressed) { + register_code(KC_LCTL); + register_code(BP_V); + unregister_code(BP_V); + unregister_code(KC_LCTL); + } + break; + case M_SE: // search + if (record->event.pressed) { + register_code(KC_LCTL); + register_code(BP_F); + unregister_code(BP_F); + unregister_code(KC_LCTL); + } + break; + } + return MACRO_NONE; +}; + +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { + +} + +void matrix_init_user(void) { +} + +// Bleah globals need to be initialized. +uint8_t old_layer=_BASE; + +void matrix_scan_user(void) { + uint8_t layer = biton32(layer_state); + + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + switch (layer) { + case _BASE: + ergodox_right_led_2_on(); + break; + case _SYMBOLS: + ergodox_right_led_1_on(); + break; + case _MEDIA: + ergodox_right_led_1_on(); + ergodox_right_led_2_on(); + default: + // none + break; + } +} + + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} + +void led_set_user(uint8_t usb_led) { + if (usb_led & (1< +Copyright 2013 Oleg Kostyuk + +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 . +*/ + +#ifndef FRENCHDEV_V1_CONFIG_H +#define FRENCHDEV_V1_CONFIG_H + +#include "../config.h" + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x1307 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Sacapuces +#define PRODUCT Frenchdev V1 +#define DESCRIPTION QMK keyboard firmware for Frenchdev + +/* key matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 6 + +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 3 + +#define LED_BRIGHTNESS_LO 15 +#define LED_BRIGHTNESS_HI 255 + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +#define USB_MAX_POWER_CONSUMPTION 500 + +/* + * 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 +//#define DEBUG_MATRIX_SCAN_RATE + +#endif diff --git a/keyboards/frenchdev/v1/i2cmaster.h b/keyboards/frenchdev/v1/i2cmaster.h new file mode 100644 index 0000000000..3917b9e6c0 --- /dev/null +++ b/keyboards/frenchdev/v1/i2cmaster.h @@ -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 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 @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 + + + #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 + +/** 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
+ 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 diff --git a/keyboards/frenchdev/v1/matrix.c b/keyboards/frenchdev/v1/matrix.c new file mode 100644 index 0000000000..70fa6a696d --- /dev/null +++ b/keyboards/frenchdev/v1/matrix.c @@ -0,0 +1,394 @@ +/* + +Note for ErgoDox EZ customizers: Here be dragons! +This is not a file you want to be messing with. +All of the interesting stuff for you is under keymaps/ :) +Love, Erez + +Note to self, the "column" and "row" in here actually refers to the opposite on the keyboard +see definition of KEYMAP in v1.h, the grid is transposed so that a "row" in here is actually a "column" on the physical keyboard +Nicolas + +Copyright 2013 Oleg Kostyuk + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include "wait.h" +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "v1.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 Ergodox matrix scan rate is relatively low, because of slow I2C. + * 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 +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(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 + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; + debug_mouse = true; + + 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; + matrix_debouncing[i] = 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; + matrix_debouncing[i] = 0; + } + +#ifdef DEBUG_MATRIX_SCAN_RATE + matrix_timer = timer_read32(); + matrix_scan_count = 0; +#endif + +} + +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"); + ergodox_blink_all_leds(); + } + } + } + +#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 cols = read_cols(i); + 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) { + wait_us(1); + // this should be wait_ms(1) but has been left as-is at EZ's request + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + matrix_scan_quantum(); + + 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<