summaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authorGabriel Young <gabeplaysdrums@live.com>2017-03-19 20:33:41 -0700
committerGabriel Young <gabeplaysdrums@live.com>2017-03-19 20:34:53 -0700
commita43ae7c92fd2c41b283d03a8543677638a7c61f1 (patch)
treeed5385861a179747218d695e76746ae51052ec28 /keyboards
parent4a97ef6c48ce7fee2b58c6a175c1c8003267a428 (diff)
Swap rows and columns to match the schematic
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/frosty_flake/config.h4
-rw-r--r--keyboards/frosty_flake/frosty_flake.h43
-rw-r--r--keyboards/frosty_flake/keymaps/default/keymap.c3
-rw-r--r--keyboards/frosty_flake/matrix.c154
4 files changed, 62 insertions, 142 deletions
diff --git a/keyboards/frosty_flake/config.h b/keyboards/frosty_flake/config.h
index 507e6a6b69..f03cecb3e6 100644
--- a/keyboards/frosty_flake/config.h
+++ b/keyboards/frosty_flake/config.h
@@ -36,8 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* 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 767efcbd81..3b52df6baa 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 90711732fa..4383f7a8d7 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 07b9f6dd68..f289f506ad 100644
--- a/keyboards/frosty_flake/matrix.c
+++ b/keyboards/frosty_flake/matrix.c
@@ -1,5 +1,5 @@
/*
- Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+ Copyright 2017 Gabriel Young <gabeplaysdrums@live.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
@@ -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<<col);
- bool curr_bit = row_scan & (1<<col);
+ bool curr_bit = col_scan & (1<<row);
if (prev_bit != curr_bit) {
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
debouncing = DEBOUNCING_DELAY;
@@ -136,30 +88,17 @@ uint8_t matrix_scan(void) {
return 1;
}
-bool matrix_is_modified(void) {
- if (debouncing)
- return false;
- else
- 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];
}
-static const char ROW_NAMES[] = "ABCDEFGHIJKLMNOPQR";
-
void matrix_print(void) {
- print("\nr/c 01234567\n");
+ print("\nr\\c ABCDEFGHIJKLMNOPQR\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
- matrix_row_t row_scan = matrix_get_row(row);
- xprintf("%c: ", ROW_NAMES[row]);
+ matrix_row_t matrix_row = matrix_get_row(row);
+ xprintf("%02X: ", row);
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
- bool curr_bit = row_scan & (1<<col);
+ bool curr_bit = matrix_row & (1<<col);
xprintf("%c", curr_bit ? '*' : '.');
}
print("\n");
@@ -168,18 +107,43 @@ void matrix_print(void) {
uint8_t matrix_key_count(void) {
uint8_t count = 0;
- for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- count += bitpop32(matrix[i]);
- }
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++)
+ count += bitpop32(matrix[row]);
return count;
}
-static matrix_row_t scan_row(void) {
- return MATRIX_ROW_SCAN;
+static matrix_row_t scan_col(void) {
+ return (
+ (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))
+ );
}
-static void select_row(uint8_t row) {
- switch (row) {
- MATRIX_ROW_SELECT;
- }
+static void select_col(uint8_t col) {
+ switch (col) {
+ 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;
+ }
} \ No newline at end of file