Created
June 2, 2020 11:43
-
-
Save mrstebo/ee5bab6440441edd5d22e643c0a49f3a to your computer and use it in GitHub Desktop.
fez-panda-ii-with-matrix-keypad-2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public char[] GetKeys() | |
| { | |
| var s = ""; | |
| for (var i = 0; i < ColumnPins.Length; i++) | |
| { | |
| using (var output = new OutputPort(ColumnPins[i], false)) | |
| { | |
| for (var j = 0; j < RowPins.Length; j++) | |
| { | |
| using (var row = new InputPort(RowPins[j], false, Port.ResistorMode.PullUp)) | |
| { | |
| if (!row.Read()) | |
| s += Keymap[j][i]; | |
| } | |
| } | |
| output.Write(true); | |
| } | |
| using (var input = new InputPort(ColumnPins[i], false, Port.ResistorMode.Disabled)) | |
| { | |
| } | |
| } | |
| char[] result = new char[s.Length]; | |
| for (var i = 0; i < s.Length; i++) | |
| result[i] = s[i]; | |
| if (result.Length > 0) | |
| System.Threading.Thread.Sleep(HoldTime); | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment