Fix handling of mouse click position.
The coordinates were computed relative to the wrong dimensions, so the
buttons were all the more unreliable the more they were at the bottom
and to the right.
Fixes: #1096
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the missing equations from "Columns and Beams" section of the
HP50G advanced reference manual.
Notice that some of the descriptions are incorrect in the manual, and
that the correct equations had to be fetched from the HP50G itself.
Foe example, the `Simple Moment` example defines `c`, which is not set
in the documented equation. The actual equation contains `IFTE`
expressions, which require the fix for #1093 to work.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
We were treating negation in a special way in the expression parser.
As a result, `-a²` was parsed as `(-a)²` instead of `-(a²)`.
Treat negation like a normal prefix, generating an object, which makes
it possible to deal with precedence the right way.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we multiply or divide unit objects, or raise a unit object to
some power, we don't want to evaluate variables in the unit.
For example, if we have `1_N*m 2_m *`, the result should not depend on
the value of variable `m`.
Fixes: #1095
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
If the called function errors out, report that error instead of hiding
it behind `Invalid function` error.
Fixes: #1094
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `IFTE` is special in that it does not evaluate its arguments ahead
of time. For example `'IFTE(1;0;ln(0))'` should not result in an error
because of the `ln(0)` evaluation.
Fixes: #1093
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the equation for Simple Slope from page 5-5/5-6 of the HP50G
advanced reference manual.
Refs: #1040
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The date differences evaluation is expensive, so we should avoid doing
it in `EvalEq`.
Fixes: #1092
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we have an expression, it is useful to be able to convert all
values in it to their unit base.
Fixes: #1091
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When storing in a solver variable, we need to check that units are
compatible, but we should not change the unit selected by the user.
For example, the Simple Deflection equations example in the HP50G
advanced reference manual are given in obsolete units. We want the
units to remain as is, since it's the user's preference.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Now that we render units in variables correctly, do not remove units
and equations before solving. Instead, evaluate with units and
equations. This is a bit slower, but more precise.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we are given a value like `1_cm/in`, it is OK to pass it as input
to the `sin` function or similar.
Fixes: #1089
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we have an actual equation in the solver, e.g. `L=R`, then we can
make the epsilon of the solver relative to `L` or `R`.
This allows equations with large values for `L` and `R`, like the
Elastic Buckling examples given, to solve correctly (i.e. without a
`Sign reversal` error message) with the default settings.
Fixes: #1088
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we compute powers for units with numerical results on, we may end
up with decimal powers in units for no reason.
Spotted by displaying the result of an `EvalEq` with `FIX 2`.
Fixes: #1086
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When parsing an expression that contains parenthese, which could be
interpreted as a complex number, check if this is indeed a complex
number or if this is just a real number.
Fixes: #1084
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Fix an off-by-one in the check for end of stack in the interactive
stack editor, so that we can swap the last two levels.
Fixes: #1067
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
We need to make sure that we have a chance to evaluate correctly
before actually evaluating each side.
Fixes: #1078
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add support for a "transient object" to be shown for context.
This object will be hidden the next time the stack is redrawn.
That way, we only see the equation when it's useful.
Fixes: #1077
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The solver and other operations return tagged objects.
It's practical that conversion functions accept to operate on them.
Fixes: #1076
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When we are given inputs that have units, make sure that we convert
them to the proper units before solving.
Fixes: #1075
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Now, For an expression like `Expr1=Expr2`, the result is given as
another equation `Left=Right+Delta`, which is a much more readable way
to present the result.
Fixes: #1074
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
If an expression contains something like `P_m`, it indicates that `P`
is a variable with a default unit of `m`. It does not mean that we
should evaluate `P` and apply `m` as a unit afterwards.
So when we have a variable name like that:
- Skip unit application during evaluation
- Skip unit rendering in text and graph mode, unless editing
Fixes: #1075
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
It is legitimate for the `file_closer` to be used on a file that could
not open (e.g. the file does not exist).
The `file_closer` must avoid trying to get the position or reopening
the file in that case.
Fixes: #1071
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
In practice, it's more useful to have vectors of values show
vertically by default. This is notably true for the results of
`EvalEq` when there is a left, right and diff result.
Fixes: #1069
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Select the solver menu when we have a library equation, as it's the
most appropriate tool for that type of object.
Fixes: #1068
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release focuses on the equation solver, notably in interaction
with the equation library. The goal is to get one step closer to the
equation library in the HP50G, including the ability to have graphical
illustration and multiple equations.
**Features**
* doc: Add documentation for the equation library
* doc: Add images from HP50G equation library (to be used later)
* doc: Some help for the elastic buckling equations.
* equations: Accept lists of equations in library
* help: Add documentation for the various constants
* help: Do not exit help when opening URLs or missing topics
* lists: Add a setting to evaluate list as programs
* menu: Add menu entries for solver imprecision and iterations
* solver: Add support for multiple equation solving
* ui: Add settings to hide/show empty menus and clear menu on EXIT
* units: Add flow units (per user request) in Fluid section of units
**Bug fixes**
* blitter: Adjust the right margin
* blitter: Base horizontal adjust on scanline, not width
* characters: Display correct content for built-in menus
* constants: Close current file while parsing values
* constants: Update some outdated values
* doc: Show help for equations and constants
* help: Do not try to load PNG images
* rewrites: Avoid contradictory rules when reordering constants
* solver: Work correctly with units (when in variables but not equation)
**Improvements**
* build: Shorten the size of the version abbrev
* config: Use config files only for user configuration
* doc: Record performance data about unit conversion
* help: Avoid slowing down when scrolling through pages of help
* help: Record position for history even without a `\n`
* simulator: Add tweak to show RPL object details
* tests: Increase wait time for tests with blinking cursor
* units: Do not simplify while in unit mode
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
In order to save space, moved all fluid-related units to the `Fluids`
menu.
Fixes: #1060
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
For constant and equations menus, match the index in the help file.
Fixes: #1039Fixes: #1048
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Grabbed images from the HP50G advanced reference manual and converted
them to BMP format so that we can show them on DB48X in the help file.
Fixes: #1034
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The HP50G equation library contains equations list, e.g. the
Elastic Buckling set of 4 equations.
Make sure that NextEq and the solver behave correctly with those.
Fixes: #1063
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Parsing the values may require opening another file (units/ constants)
Close it before trying to parse anything.
Fixes: #1062
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the possibility for the solver to contain a list of equations.
The `NextEq` command rotates the equation list.
Add the `EvalEq` command to evaluate the equation.
Add `EvalEq` and `NextEq` to the solving menu.
Fixes: #1050
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Showing the address, type and size of RPL objects is not often useful.
It is generally sufficient to just show the object rendering.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Deal with units correctly in the solver when they are not supplied in
the equation itself. For example, for equation `'A^2+B^2=C^2'`,
process units correctly if `A=10_m`, `B=85_ft` and `C=1_cm`.
When solving for `C` in the above case, this gives a result in `cm`.
Fixes: #1049Fixes: #1056
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add menu labels and entries for `SolverImprecision` and
`SolverIterations` settings.
Fixes: #1058
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
In order to accelerate conversions, do not run expression
simplifications while in unit mode. There is a dedicated factoring
step for units, so simplifications do not help much.
Fixes: #1055
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Switch to using the built-in data files by default, and extending them
with teh configuration file.
The `ShowBuiltinConstants`, `ShowBuiltinCharacters` and
`ShowBuiltinUnits` are not on by default. The size of the
corresponding `config/*.csv` files are reduced to a really simple
example.
Fixes: #1052
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>