Commit graph

2235 commits

Author SHA1 Message Date
Christophe de Dinechin
fe25a5d32c font: Record saved font with v update
This was apparently not dont in the fix for #1117

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-03 16:14:39 +02:00
Christophe de Dinechin
1fd19a423b equations: Remove need to define SINC
The `SINC` function is quite trivial, and the only special case is 0.
Use `IFTE` to special case 0 out and return 1 in that case.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-03 15:58:05 +02:00
Wiljea
d4e3e1070b Update equations.cc
Fix the units for `I` in several equations.

Signed-off-by: Wiljea <143950411+Wiljea@users.noreply.github.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-03 15:54:56 +02:00
Christophe de Dinechin
ba092c2d25 Release 0.7.16 "Clean" - New commands
The focus of this release is on new commands, notably for matrix and vector
operations. This release also ships with a DM48X-specific keymap, which fixes a
problem with teh file selector on the DM32. The equation library has been extended with numerous equations, but they are not fully validated yet.

**Features**

* `con`, `idn` and `ranm` matrix generation commands
* `Array→` and `→Array` commands to convert array to/from stack
* `dot` product and `cross` product commands for vectors
* `DispXY` styled text rendering command
* `DupDup` command duplicating top item twice
* Add a large number of equations to equation library

**Bug fixes**

* Fix `decimal::to_bignum` for small magnitudes
* Return angle unit for `atan2` and `arg` commands
* The `for` loop on lists no longer ends leaving the debugger active
* Interactive stack `DropN` command returns to level 1
* Fix file selector's "New file" on DM32 so that ENTER terminates it
* A few fixes in equations in the equation library

**Improvements**

* Improve graphical rendering of expressions such as multiplication operators
* doc: Update status
* font: Fix `v` glyph vertical placement, add dot and cross glyphs
* ttf2font: Add additional verbose info about source data
* Add `CONSTANTS` as an alias for `ConstantsMenu`
* Replace documentation references to `EEX` with `×10ⁿ`
* Optimize parsing of real numbers in parentheses

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 03:22:28 +02:00
Christophe de Dinechin
cf89de6e72 decimal: Fix decimal::to_bignum for small magnitudes
When the decimal value has a negative expoonent, we should not loop
forever building a very large multiplier, and we should not generate a
negative 0 either.

Fixes: #1156
Fixes: #1157

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 03:01:10 +02:00
Christophe de Dinechin
b2694b4dcf array: Implement ranm (RandomMatrix) command
The `ranm` command generates a random matrix.

Compared to the HP50G, the DB48X can also generate a random vector
in a way similar to `CON` for constant values.

Fixes: #1155

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 02:35:51 +02:00
Christophe de Dinechin
5aff1dc8db array: Implement idn command (IdentityMatrix)
This returns a diagonal matrix with 1 on the diagonal and 0 elsewhere.

Fixes: #1154

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 01:58:19 +02:00
Christophe de Dinechin
9d3346e683 array: Implement con (ConstantArray) command
The `con` command (`ConstantArray`) creates a constant array from
dimensions, another array or vector.

Fixes: #1153

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-02 01:53:32 +02:00
Christophe de Dinechin
5e4b661bdd arithmetic: Return angle unit for atan2
Like for `arg`, `atan2` returns an angle.

Fixes: #1151

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-01 15:11:32 +02:00
Christophe de Dinechin
3bb852224b array: Add Array→ and →Array commands
Add commands to expand and construct an array from stack elements.

Fixes: #1150

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-01 15:11:32 +02:00
Christophe de Dinechin
985b8a4619 complex: Return an angle from arg function
The `arg` function now returns an angle in current angle mode.

Fixes: #1149

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-09-01 15:10:18 +02:00
Christophe de Dinechin
c6068d1c37 grob: Render expressions in expression mode
This ensures that we get the right multiplication operators.

Fixes: #1148

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 23:16:38 +02:00
Christophe de Dinechin
83d85d91aa doc: Update status
Update the status information in the documentation:
- List of unimplemented features
- STATUS page

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 23:14:50 +02:00
Christophe de Dinechin
4d0350b0cd loops: Properly exit for loops on lists
When running a `for` loop on a list, make sure we cleanup properly on
exit.

Fixes: #1147

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 23:14:50 +02:00
Christophe de Dinechin
2a38b88600 arrays: Implement dot and cross
Implement dot and cross products.

Fixes: #1145

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 23:14:50 +02:00
Christophe de Dinechin
60236d8fc5 font: Fix v glyph vertical placement, add dot and cross glyphs
Fix the vertical bearing of the `v` glyph so that it does not appear
to be one pixel above the others.

Also add glyphs for

* dot-product (`⋅`, U8901)
* cross-product (`⨯`, 10799)

These can be used to refer to the `CROSS` and `DOT` commands.

Fixes: #1117

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 17:19:56 +02:00
Christophe de Dinechin
ce05231377 ttf2font: Add additional verbose info about source data
Emit the source information from the font, not just the computed one.

Used while investigating #1117

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 12:47:12 +02:00
Christophe de Dinechin
f511df292e graphics: Implement DispXY command
The `DispXY` command on the HP50G takes a font ID that takes 2 values,
1 for small font and 2 for regular font.

In order to implement this in a more easy way, reorder the font IDs so
that they "match", except that 0 gives the even smaller help font and
3 gives the larger editor font.

Fixes: #1146

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-31 01:41:18 +02:00
Christophe de Dinechin
9433f046b5 stack: Implement DupDup command
Implement the `DupDup`, duplicate the top of stack twice.

Fixes: #1144

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-30 22:43:00 +02:00
Christophe de Dinechin
acdb672f3b menus: Add CONSTANTS as an alias for ConstantsMenu
This is for compatibility with the HP50G

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-30 16:26:45 +02:00
Christophe de Dinechin
6af117e8b5 ui: Update interactive pointer on DropN
When dropping stack items, we need to put the interactive pointer at
the bottom since the stack items have been removed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-30 16:19:49 +02:00
Christophe de Dinechin
709436d095 dm32: Add DB48-specific keymap
Add a DM48 keymap that restores correct keybindings in the file
selector dialog.

Fixes: #1002

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-30 15:51:19 +02:00
Christophe de Dinechin
3385ea4b3b doc: Replace references to EEX with ×10ⁿ
The actual label on the keyboard overlays is now `×10ⁿ`.
For completeness, mention in the original description that we have `E`
on the DM42, `EEX` on old overlays.

Also a minor fix regarding bitmap pictures of the stack and command
line.

Fixes: #1123

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-29 22:33:40 +02:00
Christophe de Dinechin
0c7cef7bc7 library: Equation fixes
Various fixes in equations to avoid errors while parsing them.

Fixes: #1129

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-28 01:38:27 +02:00
Christophe de Dinechin
20c127d064 library: Add larger set of equations
Add a number of new equations to the equation library, contributed by
Jean Wilson.

Fixes: #1129

Co-authored-by: Jean Wilson <srmjwilson@gmail.com>
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-28 01:38:27 +02:00
Christophe de Dinechin
993f84efb8 complex: Fix parsing error when parsing units
When parsing units or expressions with parentheses, turn ERROR into
SKIP to make sure the higher-level selected expression parsing.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-28 01:38:27 +02:00
Christophe de Dinechin
fcbb81dcff Release 0.7.15 "Teaching" - Bug fixes notably on iOS
This release mostly focuses on issues exposed by the iOS releases.
It's a bug-fixes only release.

***Bug fixes***

* ios: Fix a screen refresh bug delaying the display of computation results
* ios: Increase user-accesssible memory for DB50X to match the DM32
* files: Avoid opening two files when a loaded file contains units/constants
* units: Restrict unit expressions further, e.g. forbid `1_km^s`
* build: Do not add unwanted macOS-specific files in release tar files
* build: Remove irrelevant help file from releae tar file
* constants: Fix numerical value for G constant
* tests: Rename `M` demo helper to `D`, since we use `M` in symbolic tests
* makefile: Add `mv` echo to targets doing image comparison
* units: Use pi constant in definition of radians unit
* parser: Detect syntax error on `(inv(x))` in non-expression mode
* units: Avoid infinite loop for bad unit exponents
* files: Avoid crash in `file_closer` if file does not exist
* tests: Add DMS/HMS operations to math demo
* tests: Add keyboard shortcuts to launch the demos

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-25 22:03:42 +02:00
Christophe de Dinechin
97a3252c91 units: Restrict unit expressions further
Only allow exponents with real values, and restrict allowed commands.

Fixes: #1135

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 14:38:42 +02:00
Christophe de Dinechin
75ac41bbd6 Makefile: Remove unwanted attributes from geneated tar file
The tar file we build should not include macos crap such as

```
help/img/._SimpleShear.bmp
tar: Ignoring unknown extended header keyword
     'LIBARCHIVE.xattr.com.apple.provenance'
```

Fixes: #1125

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 14:00:27 +02:00
Christophe de Dinechin
8a4559e3ac Makefile: Only include help[ file for target
When distributing a release, only include the relevant help file,
i.e. DB48X.md for DB48X and DB50X.md for DB50x.

Fixes: #1124

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 13:46:20 +02:00
Christophe de Dinechin
1ee54c9662 constants: Fix numerical value for G constant
The G constant had a bad definition with `2•kg` instead of `2*kg`.

Fixes; #1128

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:32 +02:00
Christophe de Dinechin
2157a99937 tests: Rename 'M' demo helper to 'D'
The 'M' name is actually used in a number of other tests, where we
expect a symbolic result and get a bug instead.

Renaming to 'D' ensures we don't disrupt those tests if we run them
after a demo.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:22 +02:00
Christophe de Dinechin
b3af5db1e1 makefile: Add mv echo for image comparisons
This is simply for convenience while updating tests.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:22 +02:00
Christophe de Dinechin
ce3faed861 files: Close source files before evaluating them
Since source file evaluation can involve units, constants, etc, we
need to make sure that the file is closed before evaluating it.

Fixes: #1137

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:22 +02:00
Christophe de Dinechin
9fb4489922 units: Use pi constant in definition of radians unit
The `r` unit is now defined as a function of `pi`.

As a side effect, fix parsing of expressions in units, allowing `inv`
to parse correctly in the definition of radians.

Fixes: #1136

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-23 11:55:21 +02:00
Christophe de Dinechin
5686c4c7ef parser: Detect syntax error on (inv(x)) in non-expression mode
When we parse `(...` in non-expression mode, this is supposed to be a
complex number. If what we parse is not a complex number, then this
should be a syntax error.

Fixes: #1134

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-22 23:10:39 +02:00
Christophe de Dinechin
96a98b6e04 units: Avoid infinite loop for bad unit exponents
If we have a unit expression with a non-numeric exponent, as seen in
bug #1128 where the unit expression parsed as `s^(2*kg)`, we may end
up with an infinite loop trying to factor out the term.

Add two independent fixes to address the problem:

1/ Check if we are making forward progress. If the resulting
   expression is the same as before, just stop evaluating the
   expression.

2/ In case the heuristic would not work, check if the EXIT key was
   pressed by calling `program::interrupted()`.

Fixes: #1133

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-22 16:10:51 +02:00
Christophe de Dinechin
116e425f3a files: Avoid crash in file_closer if file does not exist
On simulator, `ftell` crashes if the file was not opened correctly,
so we get a crash in the constructor.

Fixes: #1130

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-22 16:10:51 +02:00
Christophe de Dinechin
2ae5372fb1 tests: Add DMS/HMS operations to math demo
Add a simple demo of basic HMS, date and time operations.

Fixes: #1122

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-19 15:15:41 +02:00
Christophe de Dinechin
dee4501d7e tests: Add keyboard shortcuts to launch the demos
F7, F8 and F9 directly invoke the appropriate demos.

Fixes: #1121

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-19 14:19:15 +02:00
Christophe de Dinechin
104e4b976c Release 0.7.14 "Kids" - Equation-related bug fixes
This release fixes a number of issues that were discovered primarily
through the Columns and Beams equations.

**Features**

* trigonometrics: Add conversion from non-standard angles, so that
  `cos(1_turn)` gives the correct result.
* debug: Debug on error with `DebugOnError` and `KillOnError`
  settings. This makes it easier to debug an RPL program, by making it
  possible to single-step around the instruction that generated the
  error.
* tests: Add three 30 second demo of DB48X features. These are to
  generate marketing videos for the iPhone version on the Apple
  store (to be done).

**Bug fixes**

* ui: Keep a GC pointer in `draw_object` to avoid a memory crash
* equations: Add missing units in some equations, e.g. `I` and `A` in
  second equation of Coilumns and Beams
* equations: Add explicit `radian` unit in Eccentric Columns `cos`,
  which ensures we get the correct result from the HP50G manual even
  when in Degrees mode.
* units: Correctly factor out non-integral powers, so that we can
  compute `1/sqrt(epsilon_0*mu_0)` and get the correct result.
* catalog: Display commands that begin with selection first, so that
  `FORE` shows `Foreground` before `AlphaForeground`.
* stats: When computing a sum, evaluate the expression on all
  terms. The result for `Variance` with single variables was wrong
  because the first term was computed incorrectly due to a misguided
  optimization.
* graphics: Error out in `RGBPattern` for negative input. The negative
  values were generating an error, but it was not reported, so the next
  command was likely to report it.
* help: Render shift keys correctly in the color version. The bitmap
  was interpreted as containing color data. Colorize it instead.

**Improvements**

* ui: Select orange as background color during search. The previous
  setting of showing seardch using white foreground on a white
  background was probably pushing the notion of "blind search" a bit
  too far.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-18 12:14:07 +02:00
Christophe de Dinechin
28ff1800bc ui: Keep a GC pointer in draw_object
The `obj` pointer in `user_interface::draw_object` was not a GC pointer, but
there is a `do...while` loop calling `obj->graph` that may cause a garbage
collection, causing the input `obj` to be bogus.

Fixes: #1115

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-17 12:19:51 +02:00
Christophe de Dinechin
45241752e6 trigonometrics: Add conversion from non-standard angles
Accept `cos(1/4_turn)` without emiting an `Inconsistent Unit` error.

Fixes: #1114

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 22:35:57 +02:00
Christophe de Dinechin
cbd165d0f3 equations: Add missing units in some equations
There is no unit for some of the equations in the Columns and Beams
category. Notably, some equations are missing the units for `A` and
`I. Adding them back to avoid `Inconsistent units` error when the
variables are not already give a value with a unit (which was the case
from the easlier tests in the test suite).

Fixes: #1113

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 22:35:57 +02:00
Christophe de Dinechin
3ce815c12e equations: Add explicit radian unit in Eccentric Columns cos
The `cos` expression in the Eccentric Columns equation should explicitly have an
argument in radians so that it gives the correct result even when in Degrees
mode.

Fixes: #1112

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 22:30:56 +02:00
Christophe de Dinechin
aca1c1743f units: Correctly factor out non-integral powers
When we evaluate an expression like `1/√(ε₀·µ₀)`, we compute the
square root of unit `F*H`. Unit `F*H` evaluates as `s^2`, so this
ends up with `s`.

This requires evaluating `F^(1/2)*H^(1/2)`, which needs unit mode
flags (`unit::mode` and `unit::factoring`) to be correctly set along
the way, notably while computing powers.

With this, evaluating `'1/√(ε₀·µ₀)' →Num` gives the correct, albeit
unsimplified result `299792458_m/(F^(1/2)*H^(1/2))`. This seems
consistent with the way the HP50G does it. Using `UBase` gives the
correct simplified result `299792458_m/s`.

Fixes: #1110

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 22:15:45 +02:00
Christophe de Dinechin
de78d5f572 catalog: Display commands that begin with selection first
When selecting `FORE` in the catalog, show `Foreground` first, before
all other commands that contain `Foreground` (there are many settings
with that name).

Fixes: #1106

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 15:29:27 +02:00
Christophe de Dinechin
d7547676d8 debug: Debug on error
When we reach an error during program execution, automatically enter
debugging mode and enable the debug menu.

This is controlled by the `DebugOnError` setting, which is set by
default (the opposite is `KillOnError`)

Fixes: #1109

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-16 15:29:27 +02:00
Christophe de Dinechin
fe295d03f3 stats: When computing a sum, evaluate the expression on all terms.
The `total` internal function performs a sum of terms.
The code was optimizing away the sum to zero for the first term, but
as a result ended up not evaluating the term. So the first term in the
sum for the variance was evaluated as `d` instread if `(d-avg)^2`.

Fixes: #1103

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-14 12:00:06 +02:00
Christophe de Dinechin
a742e28af5 graphics: Error out in RGBPattern for negative input
Both `RGBPattern` and `GrayPattern` would emit a `Bad argument value`
for negative input, but not error out, so the next command could
report it incorrectly.

Fixes: #1108

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-08-14 12:00:06 +02:00