From 3766f902a02da7e9355685c733f70bcff9fe5a12 Mon Sep 17 00:00:00 2001 From: Gabriel Young Date: Sat, 18 Mar 2017 15:38:03 -0700 Subject: boilerplate project created with new_project.sh --- keyboards/frosty_flake/config.h | 162 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 keyboards/frosty_flake/config.h (limited to 'keyboards/frosty_flake/config.h') diff --git a/keyboards/frosty_flake/config.h b/keyboards/frosty_flake/config.h new file mode 100644 index 000000000..9390feb94 --- /dev/null +++ b/keyboards/frosty_flake/config.h @@ -0,0 +1,162 @@ +/* +Copyright 2012 Jun Wako + +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 CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER You +#define PRODUCT frosty_flake +#define DESCRIPTION A custom keyboard + +/* key matrix size */ +#define MATRIX_ROWS 2 +#define MATRIX_COLS 3 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * +*/ +#define MATRIX_ROW_PINS { D0, D5 } +#define MATRIX_COL_PINS { F1, F0, B0 } +#define UNUSED_PINS + +/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ +#define DIODE_DIRECTION COL2ROW + +// #define BACKLIGHT_PIN B7 +// #define BACKLIGHT_BREATHING +// #define BACKLIGHT_LEVELS 3 + + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCING_DELAY 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ +//#define MATRIX_HAS_GHOST + +/* number of backlight levels */ + +/* 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 + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER PAUSE +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif -- cgit v1.2.3 From 19fd20261b895a6848c8b15fd7365d5b87b7fd72 Mon Sep 17 00:00:00 2001 From: Gabriel Young Date: Sat, 18 Mar 2017 16:19:10 -0700 Subject: sketch out frosty flake matrix using custom matrix.c based on kitten paw --- keyboards/frosty_flake/config.h | 24 +++--- keyboards/frosty_flake/matrix.c | 167 ++++++++++++++++++++++++++++++++++++++++ keyboards/frosty_flake/rules.mk | 7 +- 3 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 keyboards/frosty_flake/matrix.c (limited to 'keyboards/frosty_flake/config.h') diff --git a/keyboards/frosty_flake/config.h b/keyboards/frosty_flake/config.h index 9390feb94..2575a52b1 100644 --- a/keyboards/frosty_flake/config.h +++ b/keyboards/frosty_flake/config.h @@ -24,13 +24,19 @@ along with this program. If not, see . #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x6060 #define DEVICE_VER 0x0001 -#define MANUFACTURER You +#define MANUFACTURER Bathroom Epiphanies #define PRODUCT frosty_flake -#define DESCRIPTION A custom keyboard +#define DESCRIPTION Frosty Flake controller for the CM Storm Quick Fire Rapid + +/* + * Frosty Flake Rev. 20140521 made by Bathroom Ephiphanies + * Schematic is available at https://deskthority.net/w/images/a/a4/Frosty_Flake_Schematics.pdf + * + */ /* key matrix size */ -#define MATRIX_ROWS 2 -#define MATRIX_COLS 3 +#define MATRIX_ROWS 8 // Row0 to Row7 in the schematic +#define MATRIX_COLS 18 // ColA to ColR in the schematic /* * Keyboard Matrix Assignments @@ -42,13 +48,13 @@ along with this program. If not, see . * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * */ -#define MATRIX_ROW_PINS { D0, D5 } -#define MATRIX_COL_PINS { F1, F0, B0 } -#define UNUSED_PINS +//#define MATRIX_ROW_PINS { D5, D4, D6, D2, D1, D0 } +//#define MATRIX_COL_PINS << n/a >> +//#define UNUSED_PINS { B0, C4, D3 } /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ -#define DIODE_DIRECTION COL2ROW - +//#define DIODE_DIRECTION << n/a >> + // #define BACKLIGHT_PIN B7 // #define BACKLIGHT_BREATHING // #define BACKLIGHT_LEVELS 3 diff --git a/keyboards/frosty_flake/matrix.c b/keyboards/frosty_flake/matrix.c new file mode 100644 index 000000000..21b0d9088 --- /dev/null +++ b/keyboards/frosty_flake/matrix.c @@ -0,0 +1,167 @@ +//TODO(gabe): customize for frosty flake + +/* + Copyright 2014 Ralf Schmitt + + 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 . +*/ + +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +#ifndef DEBOUNCING_DELAY +# define DEBOUNCING_DELAY 5 +#endif +static uint8_t debouncing = DEBOUNCING_DELAY; + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(void); +static void select_col(uint8_t col); + +inline uint8_t matrix_rows(void) { + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) { + return MATRIX_COLS; +} + +/* Column pin configuration + * + * col: 0 1 2 3 4 5 6 7 + * pin: PC7 PD5 PD3 PD1 PC2 PD6 PD4 PD2 + * + * Rrr pin configuration + * + * These rrrs uses one 74HC154 4 to 16 bit demultiplexer (low + * active), together with 2 rrrs driven directly from the micro + * controller, to control the 18 rrrs. The rrrs are driven from + * pins B6,5,4,3,2,1,0. + */ +void matrix_init(void) { + DDRC &= ~0b10000100; // Row input pins + DDRD &= ~0b01111110; + PORTC |= 0b10000100; + PORTD |= 0b01111110; + + DDRB |= 0b01111111; // Column output pins + + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + uint8_t rows = read_rows(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<. /* * Frosty Flake Rev. 20140521 made by Bathroom Ephiphanies - * Schematic is available at https://deskthority.net/w/images/a/a4/Frosty_Flake_Schematics.pdf + * Ported from the Bathroom Epiphanies TMK Firmware: + * https://github.com/BathroomEpiphanies/epiphanies_tmk_keyboard/tree/master/be_controllers * */ /* key matrix size */ -#define MATRIX_ROWS 8 // Row0 to Row7 in the schematic -#define MATRIX_COLS 18 // ColA to ColR in the schematic +#define MATRIX_ROWS 18 +#define MATRIX_COLS 8 /* * Keyboard Matrix Assignments diff --git a/keyboards/frosty_flake/keymaps/default/Makefile b/keyboards/frosty_flake/keymaps/default/Makefile index 9d3df5964..088766680 100644 --- a/keyboards/frosty_flake/keymaps/default/Makefile +++ b/keyboards/frosty_flake/keymaps/default/Makefile @@ -3,9 +3,9 @@ # the appropriate keymap folder that will get included automatically # BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) +CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality diff --git a/keyboards/frosty_flake/keymaps/default/keymap.c b/keyboards/frosty_flake/keymaps/default/keymap.c index 1c9e33b64..e55355566 100644 --- a/keyboards/frosty_flake/keymaps/default/keymap.c +++ b/keyboards/frosty_flake/keymaps/default/keymap.c @@ -28,11 +28,12 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) void matrix_init_user(void) { - + debug_enable = true; } void matrix_scan_user(void) { - + if (matrix_is_modified()) + matrix_print(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { @@ -41,4 +42,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { void led_set_user(uint8_t usb_led) { -} +} \ No newline at end of file diff --git a/keyboards/frosty_flake/matrix.c b/keyboards/frosty_flake/matrix.c index 21b0d9088..70456ada3 100644 --- a/keyboards/frosty_flake/matrix.c +++ b/keyboards/frosty_flake/matrix.c @@ -1,5 +1,3 @@ -//TODO(gabe): customize for frosty flake - /* Copyright 2014 Ralf Schmitt @@ -26,16 +24,71 @@ #include "util.h" #include "matrix.h" +#ifndef CONFIG_SPECIFIC_H +#define CONFIG_SPECIFIC_H + +#define CONFIG_LED_IO \ + DDRB |= (1<<7); \ + DDRC |= (1<<5) | (1<<6); + +#define USB_LED_CAPS_LOCK_ON PORTC &= ~(1<<5) +#define USB_LED_CAPS_LOCK_OFF PORTC |= (1<<5) +#define USB_LED_NUM_LOCK_ON PORTB &= ~(1<<7) +#define USB_LED_NUM_LOCK_OFF PORTB |= (1<<7) +#define USB_LED_SCROLL_LOCK_ON PORTC &= ~(1<<6) +#define USB_LED_SCROLL_LOCK_OFF PORTC |= (1<<6) + +#define CONFIG_MATRIX_IO \ + /* Column output pins */ \ + DDRD |= 0b01111011; \ + /* Row input pins */ \ + DDRC &= ~0b10000000; \ + DDRB &= ~0b01111111; \ + PORTC |= 0b10000000; \ + PORTB |= 0b01111111; + +#define MATRIX_ROW_SCAN \ + (PINC&(1<<7) ? 0 : ((matrix_row_t)1<<0)) | \ + (PINB&(1<<5) ? 0 : ((matrix_row_t)1<<1)) | \ + (PINB&(1<<4) ? 0 : ((matrix_row_t)1<<2)) | \ + (PINB&(1<<6) ? 0 : ((matrix_row_t)1<<3)) | \ + (PINB&(1<<1) ? 0 : ((matrix_row_t)1<<4)) | \ + (PINB&(1<<2) ? 0 : ((matrix_row_t)1<<5)) | \ + (PINB&(1<<3) ? 0 : ((matrix_row_t)1<<6)) | \ + (PINB&(1<<0) ? 0 : ((matrix_row_t)1<<7)) + +#define MATRIX_ROW_SELECT \ + case 0: PORTD = (PORTD & ~0b01111011) | 0b00011011; break; \ + case 1: PORTD = (PORTD & ~0b01111011) | 0b01000011; break; \ + case 2: PORTD = (PORTD & ~0b01111011) | 0b01101010; break; \ + case 3: PORTD = (PORTD & ~0b01111011) | 0b01111001; break; \ + case 4: PORTD = (PORTD & ~0b01111011) | 0b01100010; break; \ + case 5: PORTD = (PORTD & ~0b01111011) | 0b01110001; break; \ + case 6: PORTD = (PORTD & ~0b01111011) | 0b01100001; break; \ + case 7: PORTD = (PORTD & ~0b01111011) | 0b01110000; break; \ + case 8: PORTD = (PORTD & ~0b01111011) | 0b01100000; break; \ + case 9: PORTD = (PORTD & ~0b01111011) | 0b01101000; break; \ + case 10: PORTD = (PORTD & ~0b01111011) | 0b00101011; break; \ + case 11: PORTD = (PORTD & ~0b01111011) | 0b00110011; break; \ + case 12: PORTD = (PORTD & ~0b01111011) | 0b00100011; break; \ + case 13: PORTD = (PORTD & ~0b01111011) | 0b01111000; break; \ + case 14: PORTD = (PORTD & ~0b01111011) | 0b00010011; break; \ + case 15: PORTD = (PORTD & ~0b01111011) | 0b01101001; break; \ + case 16: PORTD = (PORTD & ~0b01111011) | 0b00001011; break; \ + case 17: PORTD = (PORTD & ~0b01111011) | 0b00111011; break; + +#endif + #ifndef DEBOUNCING_DELAY -# define DEBOUNCING_DELAY 5 +# define DEBOUNCING_DELAY 0 #endif static uint8_t debouncing = DEBOUNCING_DELAY; static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[MATRIX_ROWS]; -static uint8_t read_rows(void); -static void select_col(uint8_t col); +static matrix_row_t scan_row(void); +static void select_row(uint8_t row); inline uint8_t matrix_rows(void) { return MATRIX_ROWS; @@ -45,58 +98,40 @@ inline uint8_t matrix_cols(void) { return MATRIX_COLS; } -/* Column pin configuration - * - * col: 0 1 2 3 4 5 6 7 - * pin: PC7 PD5 PD3 PD1 PC2 PD6 PD4 PD2 - * - * Rrr pin configuration - * - * These rrrs uses one 74HC154 4 to 16 bit demultiplexer (low - * active), together with 2 rrrs driven directly from the micro - * controller, to control the 18 rrrs. The rrrs are driven from - * pins B6,5,4,3,2,1,0. - */ void matrix_init(void) { - DDRC &= ~0b10000100; // Row input pins - DDRD &= ~0b01111110; - PORTC |= 0b10000100; - PORTD |= 0b01111110; - - DDRB |= 0b01111111; // Column output pins + CONFIG_MATRIX_IO; for (uint8_t i=0; i < MATRIX_ROWS; i++) { matrix[i] = 0; matrix_debouncing[i] = 0; } + matrix_init_quantum(); } uint8_t matrix_scan(void) { - for (uint8_t col = 0; col < MATRIX_COLS; col++) { - select_col(col); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + select_row(row); _delay_us(3); - uint8_t rows = read_rows(); - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + matrix_row_t row_scan = scan_row(); + for (uint8_t col = 0; col < MATRIX_COLS; col++) { bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<. */ /* key matrix size */ -#define MATRIX_ROWS 18 -#define MATRIX_COLS 8 +#define MATRIX_ROWS 8 +#define MATRIX_COLS 18 /* * Keyboard Matrix Assignments diff --git a/keyboards/frosty_flake/frosty_flake.h b/keyboards/frosty_flake/frosty_flake.h index 767efcbd8..3b52df6ba 100644 --- a/keyboards/frosty_flake/frosty_flake.h +++ b/keyboards/frosty_flake/frosty_flake.h @@ -7,16 +7,6 @@ // The following is an example using the Planck MIT layout // The first section contains all of the arguements // The second converts the arguments into a two-dimensional array -#if 0 -#define KEYMAP( \ - k00, k01, k02, \ - k10, k11 \ -) \ -{ \ - { k00, k01, k02 }, \ - { k10, KC_NO, k11 }, \ -} -#endif /* Matrix col/row mapping @@ -36,38 +26,6 @@ | A4 | P2 | C6 | K6 | C0 | M3 | D0 | A1 | | O0 | K0 | L0 | | L6 | Q6 | | `-------------------------------------------------------------------------' `--------------' `-------------------' */ - -#define KEYMAP( \ - KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \ - KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, KK1, KL1, KQ1, KQ0, \ - KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, KK5, KL5, KQ5, KO5, \ - KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, KK2, KL2, KQ2, \ - KN2, KI6, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KO6, KK3, KL3, KQ3, KO3, \ - KA4, KP2, KC6, KK6, KC0, KM3, KD0, KA1, KO0, KK0, KL0, KL6, KQ6 \ -) \ -{ \ -/* 0 1 2 3 4 5 6 7 */ \ -/* A */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* B */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* C */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* D */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* E */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* F */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* G */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* H */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* I */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* J */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KJ6, KC_NO }, \ -/* K */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* L */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* M */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* N */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* O */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* P */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* Q */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ -/* R */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ -} - -#if 0 #define KEYMAP( \ KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, KK1, KL1, KQ1, KQ0, \ @@ -88,6 +46,5 @@ /* 6 */ { KC_NO, KB6, KC6, KC_NO, KE6, KF6, KG6, KH6, KI6, KJ6, KK6, KL6, KC_NO, KC_NO, KO6, KC_NO, KQ6, KR6 }, \ /* 7 */ { KA7, KB7, KC7, KD7, KE7, KF7, KG7, KH7, KI7, KJ7, KC_NO, KC_NO, KC_NO, KC_NO, KO7, KC_NO, KQ7, KR7 } \ } -#endif #endif diff --git a/keyboards/frosty_flake/keymaps/default/keymap.c b/keyboards/frosty_flake/keymaps/default/keymap.c index 90711732f..4383f7a8d 100644 --- a/keyboards/frosty_flake/keymaps/default/keymap.c +++ b/keyboards/frosty_flake/keymaps/default/keymap.c @@ -35,8 +35,7 @@ void matrix_init_user(void) { } void matrix_scan_user(void) { - if (matrix_is_modified()) - matrix_print(); + matrix_print(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { diff --git a/keyboards/frosty_flake/matrix.c b/keyboards/frosty_flake/matrix.c index 07b9f6dd6..f289f506a 100644 --- a/keyboards/frosty_flake/matrix.c +++ b/keyboards/frosty_flake/matrix.c @@ -1,5 +1,5 @@ /* - Copyright 2014 Ralf Schmitt + Copyright 2017 Gabriel Young 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 @@ -24,9 +24,6 @@ #include "util.h" #include "matrix.h" -#ifndef CONFIG_SPECIFIC_H -#define CONFIG_SPECIFIC_H - #define CONFIG_LED_IO \ DDRB |= (1<<7); \ DDRC |= (1<<5) | (1<<6); @@ -38,85 +35,40 @@ #define USB_LED_SCROLL_LOCK_ON PORTC &= ~(1<<6) #define USB_LED_SCROLL_LOCK_OFF PORTC |= (1<<6) -#define CONFIG_MATRIX_IO \ - /* Column output pins */ \ - DDRD |= 0b01111011; \ - /* Row input pins */ \ - DDRC &= ~0b10000000; \ - DDRB &= ~0b01111111; \ - PORTC |= 0b10000000; \ - PORTB |= 0b01111111; - -#define MATRIX_ROW_SCAN \ - (PINC&(1<<7) ? 0 : ((matrix_row_t)1<<0)) | \ - (PINB&(1<<5) ? 0 : ((matrix_row_t)1<<1)) | \ - (PINB&(1<<4) ? 0 : ((matrix_row_t)1<<2)) | \ - (PINB&(1<<6) ? 0 : ((matrix_row_t)1<<3)) | \ - (PINB&(1<<1) ? 0 : ((matrix_row_t)1<<4)) | \ - (PINB&(1<<2) ? 0 : ((matrix_row_t)1<<5)) | \ - (PINB&(1<<3) ? 0 : ((matrix_row_t)1<<6)) | \ - (PINB&(1<<0) ? 0 : ((matrix_row_t)1<<7)) - -#define MATRIX_ROW_SELECT \ - case 0: PORTD = (PORTD & ~0b01111011) | 0b00011011; break; \ - case 1: PORTD = (PORTD & ~0b01111011) | 0b01000011; break; \ - case 2: PORTD = (PORTD & ~0b01111011) | 0b01101010; break; \ - case 3: PORTD = (PORTD & ~0b01111011) | 0b01111001; break; \ - case 4: PORTD = (PORTD & ~0b01111011) | 0b01100010; break; \ - case 5: PORTD = (PORTD & ~0b01111011) | 0b01110001; break; \ - case 6: PORTD = (PORTD & ~0b01111011) | 0b01100001; break; \ - case 7: PORTD = (PORTD & ~0b01111011) | 0b01110000; break; \ - case 8: PORTD = (PORTD & ~0b01111011) | 0b01100000; break; \ - case 9: PORTD = (PORTD & ~0b01111011) | 0b01101000; break; \ - case 10: PORTD = (PORTD & ~0b01111011) | 0b00101011; break; \ - case 11: PORTD = (PORTD & ~0b01111011) | 0b00110011; break; \ - case 12: PORTD = (PORTD & ~0b01111011) | 0b00100011; break; \ - case 13: PORTD = (PORTD & ~0b01111011) | 0b01111000; break; \ - case 14: PORTD = (PORTD & ~0b01111011) | 0b00010011; break; \ - case 15: PORTD = (PORTD & ~0b01111011) | 0b01101001; break; \ - case 16: PORTD = (PORTD & ~0b01111011) | 0b00001011; break; \ - case 17: PORTD = (PORTD & ~0b01111011) | 0b00111011; break; - -#endif - #ifndef DEBOUNCING_DELAY -# define DEBOUNCING_DELAY 0 +# define DEBOUNCING_DELAY 5 #endif static uint8_t debouncing = DEBOUNCING_DELAY; static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[MATRIX_ROWS]; -static matrix_row_t scan_row(void); -static void select_row(uint8_t row); - -inline uint8_t matrix_rows(void) { - return MATRIX_ROWS; -} - -inline uint8_t matrix_cols(void) { - return MATRIX_COLS; -} +static matrix_row_t scan_col(void); +static void select_col(uint8_t row); void matrix_init(void) { - CONFIG_MATRIX_IO; - - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - matrix_debouncing[i] = 0; - } - - matrix_init_quantum(); + /* Row output pins */ + DDRD |= 0b01111011; + /* Column input pins */ + DDRC &= ~0b10000000; + DDRB &= ~0b01111111; + PORTC |= 0b10000000; + PORTB |= 0b01111111; + + for (uint8_t i=0; i < MATRIX_ROWS; i++) + matrix[i] = matrix_debouncing[i] = 0; + + matrix_init_quantum(); } uint8_t matrix_scan(void) { - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - select_row(row); + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); _delay_us(3); - matrix_row_t row_scan = scan_row(); - for (uint8_t col = 0; col < MATRIX_COLS; col++) { + matrix_row_t col_scan = scan_col(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<. */ /* key matrix size */ -#define MATRIX_ROWS 8 -#define MATRIX_COLS 18 +#define MATRIX_ROWS 8 // Row0 - Row7 in the schematic +#define MATRIX_COLS 18 // ColA - ColR in the schematic /* * Keyboard Matrix Assignments - * - * Change this to how you wired your keyboard - * COLS: AVR pins used for columns, left to right - * ROWS: AVR pins used for rows, top to bottom - * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) - * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) - * -*/ -//#define MATRIX_ROW_PINS { D5, D4, D6, D2, D1, D0 } -//#define MATRIX_COL_PINS << n/a >> -//#define UNUSED_PINS { B0, C4, D3 } - -/* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ -//#define DIODE_DIRECTION << n/a >> - -// #define BACKLIGHT_PIN B7 -// #define BACKLIGHT_BREATHING -// #define BACKLIGHT_LEVELS 3 - + */ +#define UNUSED_PINS { B0, C4, D3 } /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCING_DELAY 5 -/* define if matrix has ghost (lacks anti-ghosting diodes) */ -//#define MATRIX_HAS_GHOST - -/* number of backlight levels */ - /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ -- cgit v1.2.3