-
Notifications
You must be signed in to change notification settings - Fork 2
/
keys.pde
142 lines (113 loc) · 4.2 KB
/
keys.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
140
141
142
//*********************************
void keyPressed()
{
loop();
start = true;
// discover keys....
// println((int)key, hex(key), keyCode);
// play sound
if (sound) { click.play(); }
// Sound keys (on/off)
if (key == '=') { sound = !sound; }
// Create number with exponent
if (key == 'l' || key == 'L') { fnEEX(); }
// open PDF manual (HELP)
if (key == '?') { fnHELP(); }
// clear stack
if (key == ESC) { key = 0; fnCLS(); }
// input a digit "0..9"
if ((key >= '0') && (key <= '9')) { numberPressed(); }
// change sign
if (key == '_' || key == '\\') { changeSignPressed(); }
// insert floating point "."
if (key == '.' || key == ',') { dotPressed(); }
// insert BACKSPACE --> delete a input digit
if (key == BACKSPACE) { backspacePressed(); }
// insert DELETE or ESC--> clear input number
if (key == DELETE) { deletePressed(); }
// insert RETURN | ENTER --> Push number on stack
if ((key == RETURN) || (key == ENTER) || (key == ' ')) { enterPressed(); }
// Press "+" --> sum top two number of the stack
if (key == '+') { fnPLUS(); }
// Press "-" --> subtract top two number of the stack
if (key == '-') { fnMINUS(); }
// Press "*" --> multiply top two number of the stack
if (key == '*') { fnMULT(); }
// Press "-" --> divide top two number of the stack
if (key == '/') { fnDIV(); }
// Common maths (two rows)
// first row
if (key == 'q' || key == 'Q') { fnX2(); }
if (key == 'w' || key == 'W') { fnEULER(); }
if (key == 'e' || key == 'E') { fnPOWTEN(); }
if (key == 'r' || key == 'R') { fnPOW(); }
if (key == 't' || key == 'T') { fnINVERSE(); }
if (key == 'y' || key == 'Y') { fnINT(); }
if (key == 'u' || key == 'U') { fnABS(); }
// second row
if (key == 'a' || key == 'A') { fnSQRT(); }
if (key == 's' || key == 'S') { fnLN(); }
if (key == 'd' || key == 'D') { fnLOG(); }
if (key == 'f' || key == 'F') { fnROOTS(); }
if (key == 'g' || key == 'G') { fnCBRT(); }
if (key == 'h' || key == 'H') { fnFRAC(); }
if (key == 'j' || key == 'J') { fnROUND(); }
if (key == '[') { fnSIN(); }
if (key == '{') { fnASIN(); }
if (key == ']') { fnCOS(); }
if (key == '}') { fnACOS(); }
if (key == ';') { fnTAN(); }
if (key == ':') { fnATAN(); }
// recover last X
if (key == 'x' || key == 'X') { fnLASTX(); }
// math constant
if (key == 'i' || key == 'I') { fnPHI(); }
if (key == 'o' || key == 'O') { fnE(); }
if (key == 'p' || key == 'P') { fnPI(); }
// Forth button
if (keyCode==112) { fnDUP(); } // F1
if (keyCode==113) { fnDROP(); } // F2
if (keyCode==114) { fnSWAP(); } // F3
if (keyCode==115) { fnOVER(); } // F4
if (keyCode==116) { fnROT(); } // F5
if (keyCode==117) { fnNIP(); } // F6
if (keyCode==118) { fnTUCK(); } // F7
// copy stack
//if (key == 0x03) { fnCOPYS(); } //(Ctrl+c)
if (key == 'c' || key == 'C' ) { fnCOPYS(); }
// paste stack
//if (key == 0x16) { fnPASTES(); } //(Ctrl+v)
if (key == 'v' || key == 'V') { fnPASTES(); }
if (keyCode==119) { fnChangeTrigUnit(); } // F8 (Degrees <-> Radians)
if (keyCode==120) { fnPICKS(); } // F9
if (keyCode==121) { fnROLLS(); } // F10
if (keyCode==122) { fnFLIPS(); } // F11 reverse stack
if (keyCode==123) { fnCLS(); } // F12 clear stack
if (keyCode == UP) { fnRUPS(); } // roll up the stack (+1)
if (keyCode == DOWN) { fnRDOWNS(); } // roll down the stack (-1)
// load stack from file (n)
if (key == 'n' || key == 'N') { fnloadFILE(); }
// save stack on file (m)
if (key == 'm' || key == 'M') { fnsaveFILE(); }
// Change number of floating digits (+/-)
if (keyCode == LEFT) // more digits
{
numFloating = numFloating + 1;
if (numFloating > 9 ) { numFloating = -1; }
digitRESET = "0." + nf(0, numFloating);
}
if (keyCode == RIGHT) // less digits
{
numFloating = numFloating - 1;
if (numFloating < -1 ) { numFloating = 9; }
digitRESET = "0." + nf(0, numFloating);
}
// show/hide shortcuts
if (key==TAB) { viewShortcuts = !viewShortcuts; }
// save image
if (key=='z'||key=='Z') { saveImage(); }
// print stack (console)
//if (key == '>') { println(digitNUM); pila.printStack(); }
// Edit stack with text editor
if (key == 'k' || key == 'K') { fnEDIT(); }
}