Skip to content

Commit 7156423

Browse files
committed
Prevent short circuits in BM without diodes
1 parent 7ec746f commit 7156423

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

doc/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change log
22

3+
## 7.1.2
4+
5+
- Button matrices configured for negative logic,
6+
now use open drain mode for the selector pins.
7+
This prevents a short circuit when the diodes are removed
8+
which is unfortunately a common use case among users.
9+
Note that **short circuits cannot be avoided** in a button matrix
10+
without diodes configured for positive logic.
11+
312
## 7.1.1
413

514
- The code for active wait has been revised for even better accuracy.

doc/hardware/subsystems/Switches/Switches_en.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ You should be able to extrapolate those designs to your needs.
4343
Button matrices in this project work in *positive logic*
4444
(inputs are internally pulled down).
4545

46+
> [!CAUTION]
47+
> Do not remove the diodes from these designs.
48+
> Otherwise this firmware will cause a **short circuit**.
49+
4650
### Button Matrix (25 inputs)
4751

4852
Needed parts (not counting input hardware like push buttons nor a perfboard):
@@ -77,7 +81,7 @@ This [circuit design](./BtnMatrix16Inputs.diy) requires no wiring but takes more
7781

7882
The purpose of this circuit is to transform analog potentiometers
7983
into "on/off" switches that can be wired to a button matrix.
80-
**Usefull for clutch paddles if no ADC-capable pins are available**.
84+
**Useful for clutch paddles if no ADC-capable pins are available**.
8185
Another soldered potentiometer (called "trimmer")
8286
will calibrate the position where on/off switching happens.
8387
Please, **follow this calibration procedure in order to minimize battery drainage**:
@@ -407,6 +411,13 @@ Selector pins must be wired to valid output capable GPIO pins.
407411
Such a hardware design is not in this project,
408412
but this option allows you to use a recycled button matrix from another project.
409413

414+
> [!CAUTION]
415+
> If, despite my advice, your button matrix does not have diodes,
416+
> configure your custom firmware to work with negative logic
417+
> by setting the second parameter to `true`.
418+
> Otherwise, you will have a **short circuit**.
419+
> Either way, you will have ghost inputs.
420+
410421
For example:
411422

412423
```c++

src/common/InputHardware.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ ButtonMatrixInput::ButtonMatrixInput(
277277
// Compute mask and initialize GPIO pins
278278
for (auto row : this->matrix)
279279
{
280-
internals::hal::gpio::forOutput(row.first, negativeLogic, false);
280+
internals::hal::gpio::forOutput(row.first, negativeLogic, negativeLogic);
281281
for (auto col : row.second)
282282
{
283283
internals::hal::gpio::forInput(col.first, !negativeLogic, negativeLogic);

0 commit comments

Comments
 (0)