Calculator - portapack-mayhem/mayhem-firmware GitHub Wiki
The Calculator is a FORTH-programmable scientific RPN (Reverse Polish Notation) calculator based on the IVT (IVEE-TINY) engine by zooxo/deetee.
In RPN, operands are entered before the operator. Instead of 3 + 4, you enter 3, then 4, then +. Numbers are pushed onto a stack; operations consume values from the top of the stack and push the result.
- D (DUP) pushes/duplicates the current number onto the stack, or confirms number entry.
- C (DROP) removes the top of stack, or clears the current number entry.
The keypad has two modes. Press F to toggle the shifted layer.
| Col 1 | Col 2 | Col 3 | Col 4 |
|---|---|---|---|
| F (shift) | 7 | 8 | 9 |
| E (10^x) | 4 | 5 | 6 |
| N (negate) | 1 | 2 | 3 |
| C (DROP/clear) | 0 | . (decimal) | D (DUP/enter) |
| Col 1 | Col 2 | Col 3 | Col 4 |
|---|---|---|---|
| MENU | SUM+ | PRG | / |
| SWAP | DICT | USR | * |
| ROT | RCL | STO | - |
| CA | PI | INT | + |
| Key | Description |
|---|---|
| 0โ9, . | Enter digits and decimal point |
| E | Scientific notation exponent (Y ร 10^X) |
| N | Negate (change sign) |
| D | DUP โ duplicate top of stack / confirm number entry |
| C | DROP โ remove top of stack / clear current entry |
| F | Shift to function layer; double-press opens user MENU |
| + โ ร รท | Basic arithmetic |
| SWAP | Swap top two stack values (1 2 โ 2 1) |
| ROT | Rotate stack (1 2 3 โ 2 3 1) |
| STO / RCL | Store/recall a number to memory slot 0โ9 (enter slot number first) |
| CA | Clear all โ clears stack and statistics memories |
| PI | Push ฯ onto the stack |
| INT | Integer part of top value |
| SUM+ | Add X (or X,Y) data point for statistics / linear regression |
| DICT | Browse the full dictionary of all commands |
| USR | Assign a dictionary entry to the user menu |
| MENU | Open the user-defined menu |
| PRG | Edit a user program (enter program number 0โ15 first) |
Access all commands via DICT (F+4). Functions include:
Math: SQRT, POW (y^x), INV (1/x), EXP, LN, SIN, COS, TAN, ASIN, ACOS, ATAN, GAMMA (ln ฮ)
Stack: DUP, DROP, SWAP, ROT, OVER
Statistics: SUM+, SUMclr, MEAN/STDEV, LR (linear regression)
Other: PV (present value), ND (normal distribution PDF/CDF), P>R / R>P (polar/rectangular), nPr, nCr, SOLVE (root finder)
Control flow (for programs): IF, ELSE, THEN, BEGIN, UNTIL, <, =, <>, >
IVT supports up to 16 user programs (numbered 00โ15) with up to 440 total steps.
To edit a program:
- Enter the program number (e.g.
0,5) - Press F + PRG
- Navigate steps with E (up) and N (down)
- Insert steps by pressing a key or selecting from DICT
- Delete a step with .
- Save and exit with C
Note
User program 00 is reserved for the SOLVE (root finder) function.
| Item | Limit |
|---|---|
| Stack depth | 24 |
| Significant digits | 7 |
| Memory slots (STO/RCL) | 10 (0โ9) |
| User programs | 16 |
| Total program steps | 440 |
| User menu slots | 32 |
| Number precision | IEEE 754 32-bit float (~6โ7 decimal digits) |
ABS: DUP 0 > IF THEN NEG
SINH: EXP DUP INV NEG + 2 /
LOG: LN 1 0 LN /
%: OVER / 1 0 0 *
C<>F: DUP 1 . 8 * 3 2 + SWAP 3 2 - 1 . 8 /