forked from tmk/tmk_keyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
onekey: Fix for V-USB of ATtiny85 and key scan
- Loading branch information
Showing
7 changed files
with
83 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Onekey | ||
====== | ||
Just one key keyboard for example. It sends 'a' key if pins PB0 and PB1 are short-circuited. | ||
Just one key keyboard for example. It sends 'a' key if pins PB0 and GND are short-circuited. | ||
|
||
https://github.com/tmk/tmk_keyboard/issues/56 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Copyright 2017 Jun Wako <[email protected]> | ||
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 "debug.h" | ||
#include "timer.h" | ||
#include "matrix.h" | ||
|
||
|
||
#ifndef DEBOUNCE | ||
# define DEBOUNCE 5 | ||
#endif | ||
/* matrix state(1:on, 0:off) */ | ||
static matrix_row_t row_debounced = 0; | ||
static matrix_row_t row_debouncing = 0; | ||
static bool debouncing = false; | ||
static uint16_t debouncing_time = 0; | ||
|
||
|
||
void matrix_init(void) | ||
{ | ||
debug_enable = true; | ||
debug_matrix = true; | ||
debug_mouse = true; | ||
|
||
// PB0: Input with pull-up(DDR:0, PORT:1) | ||
DDRB &= ~(1<<0); | ||
PORTB |= (1<<0); | ||
} | ||
|
||
uint8_t matrix_scan(void) | ||
{ | ||
matrix_row_t r = (PINB&(1<<0) ? 0 : 1); | ||
if (row_debouncing != r) { | ||
row_debouncing = r; | ||
debouncing = true; | ||
debouncing_time = timer_read(); | ||
} | ||
|
||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) { | ||
row_debounced = row_debouncing; | ||
debouncing = false; | ||
} | ||
return 1; | ||
} | ||
|
||
inline | ||
matrix_row_t matrix_get_row(uint8_t row) | ||
{ | ||
return row_debounced; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters