-
Notifications
You must be signed in to change notification settings - Fork 2
/
functionInput.pde
139 lines (128 loc) · 2.84 KB
/
functionInput.pde
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
void fnINDEG() { inDegrees = true; }
void fnINRAD() { inDegrees = false; }
void fnFIX()
{
if ((digitNUM >= -2.0) && (digitNUM < 10.0) && ((int)digitNUM == digitNUM))
{
int num = (int) digitNUM;
numFloating = num;
digitRESET = "0." + nf(0, numFloating);
fnDROP();
}
else { outputSTR = "FIX: integer number required [-2, 9]"; }
}
void enterPressed()
{
pila.push(digitNUM);
isBlocked = true;
isResult = true;
digitSTR="";
outputSTR = String.valueOf(digitNUM);
}
void fn0() { numberButtonPressed("0"); }
void fn1() { numberButtonPressed("1"); }
void fn2() { numberButtonPressed("2"); }
void fn3() { numberButtonPressed("3"); }
void fn4() { numberButtonPressed("4"); }
void fn5() { numberButtonPressed("5"); }
void fn6() { numberButtonPressed("6"); }
void fn7() { numberButtonPressed("7"); }
void fn8() { numberButtonPressed("8"); }
void fn9() { numberButtonPressed("9"); }
void numberButtonPressed (String num)
{
if (isResult)
{
if (!isBlocked) { pila.push(digitNUM); }
digitSTR = "";
}
isResult = false;
if (digitSTR.length() < maxDigits)
{
digitSTR = digitSTR + num;
digitNUM = Double.valueOf(digitSTR);
}
outputSTR = String.valueOf(digitNUM);
}
void numberPressed()
{
if (isResult)
{
if (!isBlocked) { pila.push(digitNUM); }
digitSTR = "";
}
isResult = false;
if (digitSTR.length() < maxDigits)
{
int num = key - 48;
digitSTR = digitSTR + str(num);
digitNUM = Double.valueOf(digitSTR);
}
outputSTR = String.valueOf(digitNUM);
}
void changeSignPressed()
{
if ((!isResult) && (digitSTR.length() != 0) && (digitNUM != 0.0))
{
if (digitSTR.charAt(0) == '-')
{ digitSTR = digitSTR.substring(1, digitSTR.length()); }
else { digitSTR = '-' + digitSTR; }
digitNUM = Double.valueOf(digitSTR);
}
else if ((isResult) && (digitNUM != 0.0))
{
digitNUM = - digitNUM;
}
outputSTR = String.valueOf(digitNUM);
}
void dotPressed()
{
if (isResult)
{
digitSTR = "0.";
if (!isBlocked) pila.push(digitNUM);
digitNUM = 0.0;
isResult = false;
isBlocked = false;
}
else if (digitSTR.indexOf('.') < 0)
{
digitSTR = digitSTR + ".";
}
}
void backspacePressed()
{
if (isResult)
{
digitSTR = digitRESET;
digitNUM = 0.0;
isBlocked = true;
}
else
{
if (digitSTR.length() > 1)
{
digitSTR = digitSTR.substring(0, digitSTR.length() - 1);
if (digitSTR.equals("-"))
{ digitNUM = 0.0; digitSTR = digitRESET; isResult = true;}
else { digitNUM = Double.valueOf(digitSTR); }
}
else
{
digitSTR = digitRESET;
digitNUM = 0.0;
isResult = true;
isBlocked = true;
}
}
outputSTR = String.valueOf(digitNUM);
}
void deletePressed()
{
lastX = digitNUM;
digitNUM = 0.0;
digitSTR = digitRESET;
isResult = true;
isBlocked = true;
outputSTR = String.valueOf(digitNUM);
}