diff options
author | Joel Challis <[email protected]> | 2024-05-30 10:00:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-30 10:00:28 +0100 |
commit | b39285807e1d21300e8a5dbbf6f2c43a8aab3494 (patch) | |
tree | 311895a73c967f5d322885c1a9f1073a7b9f1b91 /docs/how_a_matrix_works.md | |
parent | 6ef97172889ccd5db376b2a9f8825489e24fdac4 (diff) | |
download | qmk_firmware-b39285807e1d21300e8a5dbbf6f2c43a8aab3494.tar.gz qmk_firmware-b39285807e1d21300e8a5dbbf6f2c43a8aab3494.zip |
[docs] Fix code blocks overflowing page width (#23829)
Fix code blocks overflowing page width
Diffstat (limited to 'docs/how_a_matrix_works.md')
-rw-r--r-- | docs/how_a_matrix_works.md | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/docs/how_a_matrix_works.md b/docs/how_a_matrix_works.md index ebe90eb3de..fdd8c2d76f 100644 --- a/docs/how_a_matrix_works.md +++ b/docs/how_a_matrix_works.md @@ -6,6 +6,7 @@ When the circuit is arranged in rows and columns, if a key is pressed, a column The microcontroller will be set up via the firmware to send a logical 1 to the columns, one at a time, and read from the rows, all at once - this process is called matrix scanning. The matrix is a bunch of open switches that, by default, don't allow any current to pass through - the firmware will read this as no keys being pressed. As soon as you press one key down, the logical 1 that was coming from the column the keyswitch is attached to gets passed through the switch and to the corresponding row - check out the following 2x2 example: +``` Column 0 being scanned Column 1 being scanned x x col0 col1 col0 col1 @@ -13,11 +14,13 @@ The microcontroller will be set up via the firmware to send a logical 1 to the c row0 ---(key0)---(key1) row0 ---(key0)---(key1) | | | | row1 ---(key2)---(key3) row1 ---(key2)---(key3) +``` The `x` represents that the column/row associated has a value of 1, or is HIGH. Here, we see that no keys are being pressed, so no rows get an `x`. For one keyswitch, keep in mind that one side of the contacts is connected to its row, and the other, its column. When we press `key0`, `col0` gets connected to `row0`, so the values that the firmware receives for that row is `0b01` (the `0b` here means that this is a bit value, meaning all of the following digits are bits - 0 or 1 - and represent the keys in that column). We'll use this notation to show when a keyswitch has been pressed, to show that the column and row are being connected: +``` Column 0 being scanned Column 1 being scanned x x col0 col1 col0 col1 @@ -25,16 +28,20 @@ When we press `key0`, `col0` gets connected to `row0`, so the values that the fi x row0 ---(-+-0)---(key1) row0 ---(-+-0)---(key1) | | | | row1 ---(key2)---(key3) row1 ---(key2)---(key3) +``` We can now see that `row0` has an `x`, so has the value of 1. As a whole, the data the firmware receives when `key0` is pressed is: - col0: 0b01 - col1: 0b00 - │└row0 - └row1 +``` +col0: 0b01 +col1: 0b00 + │└row0 + └row1 +``` A problem arises when you start pressing more than one key at a time. Looking at our matrix again, it should become pretty obvious: +``` Column 0 being scanned Column 1 being scanned x x col0 col1 col0 col1 @@ -44,16 +51,20 @@ A problem arises when you start pressing more than one key at a time. Looking at x row1 ---(key2)---(-+-3) x row1 ---(key2)---(-+-3) Remember that this ^ is still connected to row1 +``` The data we get from that is: - col0: 0b11 - col1: 0b11 - │└row0 - └row1 +``` +col0: 0b11 +col1: 0b11 + │└row0 + └row1 +``` Which isn't accurate, since we only have 3 keys pressed down, not all 4. This behavior is called ghosting, and only happens in odd scenarios like this, but can be much more common on a bigger keyboard. The way we can get around this is by placing a diode after the keyswitch, but before it connects to its row. A diode only allows current to pass through one way, which will protect our other columns/rows from being activated in the previous example. We'll represent a dioded matrix like this; +``` Column 0 being scanned Column 1 being scanned x x col0 col1 col0 col1 @@ -65,11 +76,13 @@ Which isn't accurate, since we only have 3 keys pressed down, not all 4. This be (key2) (key3) (key2) (key3) ! ! ! ! row1 ─────┴────────┘ row1 ─────┴────────┘ +``` In practical applications, the black line of the diode will be placed facing the row, and away from the keyswitch - the `!` in this case is the diode, where the gap represents the black line. A good way to remember this is to think of this symbol: `>|` Now when we press the three keys, invoking what would be a ghosting scenario: +``` Column 0 being scanned Column 1 being scanned x x col0 col1 col0 col1 @@ -81,13 +94,16 @@ Now when we press the three keys, invoking what would be a ghosting scenario: (key2) (┌─┘3) (key2) (┌─┘3) ! ! ! ! row1 ─────┴────────┘ x row1 ─────┴────────┘ +``` Things act as they should! Which will get us the following data: - col0: 0b01 - col1: 0b11 - │└row0 - └row1 +``` +col0: 0b01 +col1: 0b11 + │└row0 + └row1 +``` The firmware can then use this correct data to detect what it should do, and eventually, what signals it needs to send to the OS. |