1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
// add reference to Microsoft.SPOT.TinyCore.dll
using UAM.InformatiX.SPOT.Input;
public enum KeyMaskedAsButton
// did you know you can use chars as enum values?
{
A =
'a', B =
'b', C =
'c', D =
'd',
E =
'e', F =
'f', G =
'g', H =
'h',
I =
'i', J =
'j', K =
'k', L =
'l',
M =
'm', N =
'n', O =
'o', P =
'p',
Q =
'q', R =
'r', S =
's', T =
't',
U =
'u', V =
'v', W =
'w', X =
'x',
Y =
'y', Z =
'z'
}
public class ValueButtonTranslator : IButtonTranslator
{
public bool GetLetter(Button button,
int pressedCount,
out string text)
{
text = ((
char)button).ToString();
return true;
}
public bool GetNumber(Button button,
out int number)
{
number = (
int)button;
return true;
}
}
public class Program
{
public static void Main()
{
ValueButtonTranslator translator =
new ValueButtonTranslator();
string text;
translator.GetLetter((Button)KeyMaskedAsButton.A, 0,
out text);
Debug.Print(
"Input: " + text);
}
}
namespace UAM.InformatiX.SPOT.Input
{
public interface IButtonTranslator
{
bool GetLetter(Button button,
int pressedCount,
out string text);
bool GetNumber(Button button,
out int number);
}
}