From 8ee49a2d30a7a9337a6872d1a88af7928f5d286b Mon Sep 17 00:00:00 2001 From: sago35 Date: Tue, 16 Jan 2024 23:32:06 +0900 Subject: [PATCH] Fix due to debounce not working (#27) --- kbduplexmatrix.go | 24 ++++-------------------- kbgpio.go | 12 ++---------- kbmatrix.go | 12 ++---------- kbsquaredmatrix.go | 12 ++---------- 4 files changed, 10 insertions(+), 50 deletions(-) diff --git a/kbduplexmatrix.go b/kbduplexmatrix.go index 11f1558..4ea1070 100644 --- a/kbduplexmatrix.go +++ b/kbduplexmatrix.go @@ -85,11 +85,7 @@ func (d *DuplexMatrixKeyboard) Get() []State { d.cycleCounter[idx] = 0 } case NoneToPress: - if current { - d.State[idx] = Press - } else { - d.State[idx] = PressToRelease - } + d.State[idx] = Press case Press: if current { d.cycleCounter[idx] = 0 @@ -102,11 +98,7 @@ func (d *DuplexMatrixKeyboard) Get() []State { } } case PressToRelease: - if current { - d.State[idx] = NoneToPress - } else { - d.State[idx] = None - } + d.State[idx] = None } } d.Col[c].High() @@ -132,11 +124,7 @@ func (d *DuplexMatrixKeyboard) Get() []State { d.cycleCounter[idx] = 0 } case NoneToPress: - if current { - d.State[idx] = Press - } else { - d.State[idx] = PressToRelease - } + d.State[idx] = Press case Press: if current { d.cycleCounter[idx] = 0 @@ -149,11 +137,7 @@ func (d *DuplexMatrixKeyboard) Get() []State { } } case PressToRelease: - if current { - d.State[idx] = NoneToPress - } else { - d.State[idx] = None - } + d.State[idx] = None } } d.Row[r].High() diff --git a/kbgpio.go b/kbgpio.go index a4bdbbb..ad9c1c3 100644 --- a/kbgpio.go +++ b/kbgpio.go @@ -84,11 +84,7 @@ func (d *GpioKeyboard) Get() []State { d.cycleCounter[c] = 0 } case NoneToPress: - if current { - d.State[c] = Press - } else { - d.State[c] = PressToRelease - } + d.State[c] = Press case Press: if current { d.cycleCounter[c] = 0 @@ -101,11 +97,7 @@ func (d *GpioKeyboard) Get() []State { } } case PressToRelease: - if current { - d.State[c] = NoneToPress - } else { - d.State[c] = None - } + d.State[c] = None } } diff --git a/kbmatrix.go b/kbmatrix.go index abbe536..2b1d07d 100644 --- a/kbmatrix.go +++ b/kbmatrix.go @@ -99,11 +99,7 @@ func (d *MatrixKeyboard) Get() []State { d.cycleCounter[idx] = 0 } case NoneToPress: - if current { - d.State[idx] = Press - } else { - d.State[idx] = PressToRelease - } + d.State[idx] = Press case Press: if current { d.cycleCounter[idx] = 0 @@ -116,11 +112,7 @@ func (d *MatrixKeyboard) Get() []State { } } case PressToRelease: - if current { - d.State[idx] = NoneToPress - } else { - d.State[idx] = None - } + d.State[idx] = None } if !d.options.InvertDiode { d.Col[c].Low() diff --git a/kbsquaredmatrix.go b/kbsquaredmatrix.go index d2ffcd9..cfe5fc0 100644 --- a/kbsquaredmatrix.go +++ b/kbsquaredmatrix.go @@ -89,11 +89,7 @@ func (d *SquaredMatrixKeyboard) Get() []State { d.cycleCounter[idx] = 0 } case NoneToPress: - if current { - d.State[idx] = Press - } else { - d.State[idx] = PressToRelease - } + d.State[idx] = Press case Press: if current { d.cycleCounter[idx] = 0 @@ -106,11 +102,7 @@ func (d *SquaredMatrixKeyboard) Get() []State { } } case PressToRelease: - if current { - d.State[idx] = NoneToPress - } else { - d.State[idx] = None - } + d.State[idx] = None } d.Pins[j].Configure(machine.PinConfig{Mode: machine.PinInputPullup}) }