for c := range colPins {
colPins[c].Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
}
for r := range rowPins {
rowPins[r].Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
}
func (d *MatrixKeyboard) Get() []State {
for c := range d.Col {
for r := range d.Row {
//d.State[r*len(d.Col)+c] = d.Row[r].Get()
current := false
if !d.options.InvertDiode {
d.Col[c].Configure(machine.PinConfig{Mode: machine.PinOutput})
d.Col[c].High()
current = d.Row[r].Get()
} else {
d.Row[r].Configure(machine.PinConfig{Mode: machine.PinOutput})
d.Row[r].High()
current = d.Col[c].Get()
}
if !d.options.InvertDiode { // COL2ROW
for c := range colPins {
colPins[c].Configure(machine.PinConfig{Mode: machine.PinOutput})
}
for r := range rowPins {
rowPins[r].Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
}
} else { // ROW2COL
for c := range colPins {
colPins[c].Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
}
for r := range rowPins {
rowPins[r].Configure(machine.PinConfig{Mode: machine.PinOutput})
}
}
AddMatrixKeyboardで https://github.com/sago35/tinygo-keyboard/blob/066aa2b85a5328ec588497ea14d9894261f43cf4/kbmatrix.go#L27-L32
で設定しているのに https://github.com/sago35/tinygo-keyboard/blob/066aa2b85a5328ec588497ea14d9894261f43cf4/kbmatrix.go#L74-L86
のようにキースキャン1回ごとに出力ピンを設定している
入出力を切り替える必要があるDuplexや改良二乗マトリクスでは必要だと思われるが、 一方方向にしかスキャンしない一般のキーマトリクスでは不要に思われる。
AddMatrixKeyboardで
のように設定してはダメだろうか。