Skip to content

Instantly share code, notes, and snippets.

@mrstebo
Created June 2, 2020 11:43
Show Gist options
  • Select an option

  • Save mrstebo/ee5bab6440441edd5d22e643c0a49f3a to your computer and use it in GitHub Desktop.

Select an option

Save mrstebo/ee5bab6440441edd5d22e643c0a49f3a to your computer and use it in GitHub Desktop.
fez-panda-ii-with-matrix-keypad-2
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