Fix key release change detection in polling mode

This commit is contained in:
Ondrej Jirman 2021-06-18 18:28:56 +02:00
parent 93687e1b04
commit c8d8eef090
1 changed files with 30 additions and 26 deletions

View File

@ -80,6 +80,8 @@ void timer1_interupt(void) __interrupt(IRQ_TIMER1)
TF1 = 0;
}
// {{{ Key scanning
// Keyboard has 12 columns and 6 rows directly connected to GPIOs.
//
// C1 P95
@ -262,6 +264,9 @@ void ext_int_deassert(void)
P1_P9M0 |= BIT(0);
}
// }}}
// {{{ I2C
#define I2C_N_REGS 16
static uint8_t i2c_transfer = 0x00;
@ -427,10 +432,10 @@ void main(void)
run_tasks = 0;
#if POLL_INPUT
// every 10ms we will scan the keyboard keys state and check for changes
// every 20ms we will scan the keyboard keys state and check for changes
uint8_t keys[12];
uint8_t active_rows = keyscan_scan(keys);
if (active_rows) {
// pressing FN+PINE+F switches to flashing mode (keys 1:2 3:5 5:2, electrically)
if (keys[0] & BIT(2) && keys[2] & BIT(5) && keys[4] & BIT(2)) {
EA = 0;
@ -448,9 +453,8 @@ void main(void)
ext_int_assert();
delay_us(100);
ext_int_deassert();
}
#else
//XXX: not figured out yet, not tested, not working
if (scan_active) {
uint8_t active_rows = keyscan_scan(i2c_regs + 4);
if (!active_rows) {