2 Copyright 2017 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 /* matrix state(1:on, 0:off) */
33 static matrix_row_t row_debounced = 0;
34 static matrix_row_t row_debouncing = 0;
35 static bool debouncing = false;
36 static uint16_t debouncing_time = 0;
39 void matrix_init(void)
45 // PB0: Input with pull-up(DDR:0, PORT:1)
50 uint8_t matrix_scan(void)
52 matrix_row_t r = (PINB&(1<<0) ? 0 : 1);
53 if (row_debouncing != r) {
56 debouncing_time = timer_read();
59 if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
60 row_debounced = row_debouncing;
67 matrix_row_t matrix_get_row(uint8_t row)