-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHP12c_Update.elm
354 lines (244 loc) · 8.78 KB
/
HP12c_Update.elm
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
module HP12c_Update exposing (..)
import HP12c_KeyTypes exposing (..)
import HP12c_Model exposing (..)
import HP12c_Update_utils exposing (..)
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
let
handler =
case msg of
KeyMsg code ->
handleKeyCode code
N_Key ->
defaultModelTransformer
I_Key ->
defaultModelTransformer
PV_Key ->
defaultModelTransformer
PMT_Key ->
defaultModelTransformer
FV_Key ->
defaultModelTransformer
Times_12_Key ->
defaultModelTransformer
DIVIDE_BY_12_Key ->
defaultModelTransformer
CF_0_Key ->
defaultModelTransformer
CF_j_Key ->
defaultModelTransformer
N_j_Key ->
defaultModelTransformer
AMORT_Key ->
defaultModelTransformer
INT_Key ->
defaultModelTransformer
NPV_Key ->
defaultModelTransformer
IRR_Key ->
defaultModelTransformer
DATE_Key ->
defaultModelTransformer
BEG_Key ->
defaultModelTransformer
END_Key ->
defaultModelTransformer
Delta_Days_Key ->
defaultModelTransformer
D_MY_Key ->
defaultModelTransformer
M_DY_Key ->
defaultModelTransformer
RunMode_Key ->
defaultModelTransformer
GTO_Key ->
defaultModelTransformer
PSE_Key ->
defaultModelTransformer
BST_Key ->
defaultModelTransformer
SST_Key ->
defaultModelTransformer
Program_Mode_Key ->
defaultModelTransformer
CL_x_Key ->
clearXRegister
CLEAR_Σ_Key ->
clearSigma
CLEAR_PRGM_Key ->
clearProgramMemory
CLEAR_FIN_Key ->
clearFinancialRegisters
CLEAR_REG_Key ->
clearAllRegisters
CLEAR_PREFIX_Key ->
clearPrefix
-- TODO: easing for display
STO_Key ->
defaultModelTransformer
RCL_Key ->
defaultModelTransformer
MEM_Key ->
defaultModelTransformer
Divide_Key ->
binaryOperator y_divided_by_x
Y_toThe_X_Key ->
binaryOperator y_to_the_x
Multiply_Key ->
binaryOperator y_times_x
Subtract_Key ->
binaryOperator y_minus_x
Sum_Key ->
binaryOperator y_plus_x
LN_Key ->
unaryOperator natural_log
Square_Root_Key ->
unaryOperator square_root
Reciprocal_Key ->
unaryOperator reciprocal
E_to_the_x_Key ->
unaryOperator e_to_the_x
FRAC_Key ->
unaryOperator fractional_part
INTG_Key ->
unaryOperator integral_part
X_Squared_Key ->
unaryOperator x_squared
N_Factorial_Key ->
unaryOperator n_factorial
RND_Key ->
unaryOperator (round_function model.displayPrecision)
PRICE_Key ->
defaultModelTransformer
YTM_Key ->
defaultModelTransformer
SL_Key ->
defaultModelTransformer
SOYD_Key ->
defaultModelTransformer
DB_Key ->
defaultModelTransformer
Weighted_Mean_Key ->
defaultModelTransformer
Mean_of_X_Key ->
defaultModelTransformer
Std_Dev_Key ->
defaultModelTransformer
Sigma_Plus_Key ->
defaultModelTransformer
Sigma_Minus_Key ->
defaultModelTransformer
X_lte_Y_Key ->
defaultModelTransformer
X_eq_0_Key ->
defaultModelTransformer
Linear_Estimate_X_Key ->
defaultModelTransformer
Linear_Estimate_Y_Key ->
defaultModelTransformer
RPN_Key ->
setComputationMode RPN_Mode
ALG_Key ->
setComputationMode ALG_Mode
Equals_Key ->
numericalInputTerminated
Enter_Key ->
numericalInputTerminated
BackSpace_Key ->
backSpaceReg_X
Roll_Down_Key ->
roll_Down_Stack
Exchange_X_Y_Key ->
exchange_X_Y_Regs
Last_X_Key ->
last_X
Left_Paren_Key ->
defaultModelTransformer
Right_Paren_Key ->
defaultModelTransformer
Number_1_Key ->
handleDigitInput 1
Number_2_Key ->
handleDigitInput 2
Number_3_Key ->
handleDigitInput 3
Number_4_Key ->
handleDigitInput 4
Number_5_Key ->
handleDigitInput 5
Number_6_Key ->
handleDigitInput 6
Number_7_Key ->
handleDigitInput 7
Number_8_Key ->
handleDigitInput 8
Number_9_Key ->
handleDigitInput 9
Number_0_Key ->
handleDigitInput 0
Decimal_Point_Key ->
handleDecimalPoint
EEX_Key ->
handleEEX_Key
CHS_Key ->
handle_CHS_Key
ON_Key ->
handlePOWERONKey
OFF_Key ->
handlePOWERONKey
Percentage_T_Key ->
binaryOperator_No_Down_Shift percentage_of_total
Delta_Percentage_Key ->
binaryOperator_No_Down_Shift delta_percentage
Percent_Key ->
binaryOperator_No_Down_Shift x_percent_of_y
SetPrecision_0_Key ->
update_Display_Precision 0
SetPrecision_1_Key ->
update_Display_Precision 1
SetPrecision_2_Key ->
update_Display_Precision 2
SetPrecision_3_Key ->
update_Display_Precision 3
SetPrecision_4_Key ->
update_Display_Precision 4
SetPrecision_5_Key ->
update_Display_Precision 5
SetPrecision_6_Key ->
update_Display_Precision 6
SetPrecision_7_Key ->
update_Display_Precision 7
SetPrecision_8_Key ->
update_Display_Precision 8
SetPrecision_9_Key ->
update_Display_Precision 9
SetDisplayScientific_Key ->
update_Display_Precision 10
Orange_F_Key ->
setPrefix Orange
Blue_G_Key ->
setPrefix Blue
Undo_Key ->
defaultModelTransformer
newModel =
handler model
defaultMessage u msg =
(if (u) then
"UNIMPLEMENTED!!!"
else
""
-- newModel.message
)
++ Basics.toString msg
in
( { newModel
| message = defaultMessage newModel.unimplemented msg
, unimplemented = False
, inputQueue =
if (newModel.addToInputQueue) then
msg :: newModel.inputQueue
else
newModel.inputQueue
}
, Cmd.none
)