Commit graph

129 commits

Author SHA1 Message Date
Christophe de Dinechin
8b48fa64d9 menu: Replace abs with |z| in complex menu
This is more readable.

Also changed the glyph for `|` to have a deeper descender.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-25 10:41:13 +02:00
Christophe de Dinechin
5326fc0a4e polynomial: Add rendering and editing
Add rendering and editing of polynomials.

On the command line, a polynommial is identified by a prefix `Ⓟ`
(which displays as `[poly]` inverted).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-02 17:39:57 +02:00
Christophe de Dinechin
2e246e34cb polynomial: Add polynomial division
Implement polynomial euclidean division, which gives a meaning to
divide and remainder for polynomials.

Polynomial division is only well-defined with a single variable.
On HP calculators, this is configured by the `VX` variable in the
`CASDIR` directory. A similar mechanism is provided allowing the
creation of an algebraic configuration directory.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-02 01:30:16 +02:00
Christophe de Dinechin
6df12cd583 characters: Add music characters menu
The `Boxes` menu is a replication of the `Blocks` menu.
Replace it with a `Music` menu.

Add four missing music glyphs to the font.

Also add the reference file for `chars-menu.png`, which was missing.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
a1f3cf8392 constants: Add prefix to identify constants, equations and xlib
There was a prefix in the editor in the first iteration of the
implementation for constants. This was actually a good idea, since it
lets us distinguish if you really want a constant or a normal symbol.

One of the main benefits is that there is no namespace clash. For
example, you can again use the `g` name, since the g constant will
actually be (cst) g. This was breaking the part in the Demo that used
`g` as a value for the level of green.

Visually, added three characters that show as (cst), (eq) and (lib) in
the text editor, in order to know what kind of name we are dealing
with.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 11:20:42 +01:00
Christophe de Dinechin
535072fc87 constants: Represent constants with an index
Instead of identifying a constant using a name, use an index in the
constants list, which takes less space and is more efficient at
runtime.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
f81745fa97 characters: Add character catalog
Add character catalog when inside text.
Define character menus with various languages and shapes.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
000bd35ce7 characters: Organize Greek character set
Organize the Greek characters menu so that uppercase letters are
shifted and diacritical show up above in the same menu page.

Also add some missing glyphs in Greek font.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
c6a94c02bb Add reduced font 2024-03-08 12:13:21 +01:00
Christophe de Dinechin
e6845b1743 font: Make the white circle a bit thicker
This is to make the unselected flags look a bit better

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
beaaee23e4 constants: Evaluate constants from config/constants.csv
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
465c34443e font: Add radian glyph
Add an superscript `r` for radians, and superscript `π` for
pi-radians. This commit only adds the glyphs, but changes in parsing
of units is also necessary, see next commits.

Fixes: #809

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-11 23:51:43 +01:00
Christophe de Dinechin
9388f60064 font: Add missing glyphs for angles
The glyphs added in 1444a8adb6 were lost
along the way (probably by keeping the font editor open during a
bisect). Restore them.

Fixes: #712

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-14 23:35:45 +01:00
Christophe de Dinechin
8c900786cc font: Add the Angstrom character
This is used in the Units menu, but not defined in the font.

Fixes: #477

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-01 17:46:51 +01:00
Christophe de Dinechin
5fb3fcd74f font: Add tool glyph
Created glyph for "tool", adapted from DejaVu Sans.
Added the glyph for `⇆`. It turns out that DM-32 and DM-42 have
the two arrows in different directions.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 12:40:07 +02:00
Christophe de Dinechin
a5ae7bcbe9 dm32: Generate config-independent font file
The generated font files contained an ID that could depend on the
configuration settings for the build. That caused the font file on
DM32 to be incorrect, which caused a crash when editing text.

Fixes: #458

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:18:47 +02:00
Christophe de Dinechin
90518b6083 units: Add units menus
Add the various units menus that are present on the HP50G.
The units themselves are not fully implemented yet.

Fixes: #16

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00
Christophe de Dinechin
b4eeaa6bb8 unit: Implementation of unit objects
This is a very basic implementation of unit objects.
Unit objects are treated as equations where the outermost object
is an ID_mkunit operator.

Fixes: #16

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00
Christophe de Dinechin
0934c76423 cursor: Add CursorBlinkRate setting
Fixes the bug where the cursor was not blinking correctly unless some other
animation was happening (bug #407).

Add a setting to adjust the cursor blink rate, `CursorBlinkRate`.

Fixes: #407

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
a891aea89e decimal128: Add MinimumSignificantDigits
Select the minimum number of significant digits before switching to
scientific notation in `FIX` mode.

The default value is 0, which is similar to how HP calculators
perform. For example, with `2 FIX`, the value `0.055` will display as
`0.06`, and `0.0055` will display as `0.01`.

A higher value will switch to scienfic mode to show at least the given
number of digits. For instance, with `2 FIX`, if the value is `1`,
then `0.055` will still display as `0.06` but `0.0055` will display as
`5.50E-3`. If the value is `2`, then `0.055` will display as `5.5E-2`.

In other words, setting the value to `0` emulates the behaviour of HP
calculators. Seting the value to `34` will switch to scientific
notation if not all digits can be displayed

Fixes: #412

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
6f3c07e759 integrate: Initial implementation of numerical integration
Implement a really basic algorithm for integration evaluation.
This divides the integration surface by two every time.
This appears much less efficient than the integration done by HP calculators.

Fixes: #42

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
6cce8f9a45 Add root command
Add the `root` command, which implements a numerical solver

Fixes: #36

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
b42ebda223 Implement the Cycle function
The `Cycle` function is mostly intended for interactive use, mapped
on the `EEX` key.

Currently implemented cycles:

* Polar <-> Rectangular for complex numbers
* Decimal <-> Fraction
* Integer <-> Based (cycles through the bases)
* Array <-> List <-> Program
* Text <-> Symbol

Fixes: #273

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-08 18:13:57 +02:00
Christophe de Dinechin
8358338090 ui: Connect editor menu
Implement stubs for cut, copy, paste and other editor menu commands.
That makes the editor functionally complete, but not functional.

Fixes: #381

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-06 12:18:29 +02:00
Christophe de Dinechin
93e8e1aec4 ui: Replace LAST menu with LASTARG command
All the 'last' things are directly accessible, so there is no real
need for a dedicated menu. Having the command directly accessible
makes more sense from a usability point of view.

Fixes: #396

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-05 19:20:41 +02:00
Christophe de Dinechin
3b4adcff5a keyboard: Add connection for EditMenu
Add an `EditMenu` which is mapped to xshift-Down.
Also update the stack menu to put `LastX` there.

Fixes: #394
Fixes: #396

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-05 18:51:39 +02:00
Christophe de Dinechin
f8ac4d2ecc menus: Complete reorganization of menus and connexion to keyboard
With this commit, we probably have an almost complete layout of menus
and their mapping to keyboard commands.

Several of the menus are not complete yet, but the general layout is
probably quite close to the "final product".

Fixes: #389

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-03 23:05:44 +02:00
Christophe de Dinechin
0acc65301f menus: Reorganize menus and keyboard layout
Reorganize the menus and keyboard according to the following logic:

1. Match the documented keyboard layout
2. No more than 18 entries per menu

The highest impact is on the `ModesMenu`, which is now split into more
logical units.

Fixes: #389

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-03 19:50:43 +02:00
Christophe de Dinechin
257773267f Add LastX command
The `LastX` implementation is not part of any RPL implementation that
I am aware of, but it is a staple of RPN. Implementing it in RPL might
make it easier to backport a few RPN programs.

Fixes: #384

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 19:23:10 +02:00
Christophe de Dinechin
a0bff89b06 undo: Connect Undo and LastArg
Implement the `Undo` and `LastArg` commands

Fixes: #379
Fixes: #380

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 19:23:10 +02:00
Christophe de Dinechin
8015398f92 stack: Render graph using graphics instead of text
Use graphic-based rendering of stack levels (depends on setting)
This will enable more advanced rendering in the future e.g. for
equations or matrices.

Fixes: #382

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 18:53:39 +02:00
Christophe de Dinechin
9901539ecd graphics: Implement GOr, GXor, GAnd
Implement three graphic primitives `GXor` and `GOr` (same as HP48)
and `GAnd` (specific to DB48X)

Fixes: #383

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 18:53:39 +02:00
Christophe de Dinechin
012ddf2548 grob: Add support for bitmap graphic objects
Graphic objects (GROB in RPL parlance) represent bitsmaps of arbitrary
size. They can be used to represent the screen or any other graphic
surface.

Fixes: #30

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 10:41:42 +02:00
Christophe de Dinechin
5645c4f8c3 Implement Tag type
The tag type is used to add a label to any arbitrary object.
It is parsed as `:Label:object`, and renders the same, except on the
stack where it renders as `Label:object`.

Note that the HP48 renders a label with an extra space. The space is
apparently gone on the HP50.

Fixes: #21

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-13 16:45:49 +02:00
Christophe de Dinechin
8d2e3d9305 plot: Add parametric and polar plot types
Remove the `PlotFunction`, use `FunctionPlot` for that feature (there
is no point in having two IDs, one of which was useless).

Parameterize the rendering code with the function plot type.

Implement polar by rewriting result as `y * exp(i*x)`.

Fixes: #364

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 17:37:50 +02:00
Christophe de Dinechin
209d202ea7 Implement source-code comments
This commit implements comments that are preserved in the source code.

A comment begins with `@` and ends with the end of line.
It acts as a no-operation during execution.
It is rendered beginning with a new-line.

This commit also adjusts various issues related to rendering of
newlines and indentation in loops or blocks.

Fixes: #94

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:23:03 +02:00
Christophe de Dinechin
24162aaf9e Add CAS numeric flag, allow numerical evaluation of equations
Add a numeric settting for evaluation, forcing evaluation to a decimal
value (much like the HP48 does, and like the numeric flag on HP50).

Set this flag transitorily while evaluating equations to implement
`->NUM` for equations.

Evaluate fractions and function arguments numerically when the flag is
set.

Fixes: #345
Fixes: #346

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:23:03 +02:00
Christophe de Dinechin
a4e06ea956 Add clip and currentclip commands
The `Clip` command sets the clipping rectangle. It takes a list with 4 pixel
coordinates. If the list is empty, it resets the clipping rectangle to the whole
screen.

The `CurrentClip` command returns the current clipping rectangle on the stack.

Fixes: #313

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:17:40 +02:00
Christophe de Dinechin
2f44f52977 Add separate PlotFunction
Adding a separate command that plots a function taken from the stack.

Moving forward, I am considering maintaining two parallel set of
commands for plotting:

1/ `Draw` (aka `DrawPlot`) would be the higher-level one, obeying the
   semantics of RPL on HP48, i.e. fetching a function from `EQ` with
   `PPAR` specifying the type of function to plot and the independent
   variable.

2/ `PlotFunction` would be the lower-level one, taking its function
   from the stack, and assuming the function itself takes its input
   from the stack.

Fixes: #339

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:17:40 +02:00
Christophe de Dinechin
228d68f484 Add ResetModes command
This command is necessary to be able to use `Modes`

Fixes: #315

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-16 23:27:16 +02:00
Christophe de Dinechin
0b2586a8c8 Implement the wait command.
Wait for a key press or a time lapse.

When the argument is greater than 0, interrupt the program for the given number
of seconds, which can be fractional.

When the argument is 0 or negative, wait indefinitely until a key is
pressed. The key code for the key that was pressed will be pushed in the
stack. If the argument is negative, the current menu will be displayed on the
screen during the wait.

Fixes: #324

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-14 00:59:33 +02:00
Christophe de Dinechin
f0ab9da283 Implement the drax command
The `drax` command (also spelled `DrawAxes`) is used to draw the axes
for the plot according to the values in `ppar` (or `PlotParameters`).

Fixes: #321

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-14 00:59:33 +02:00
Christophe de Dinechin
eb68728c77 Add support for PPAR / PlotParameters special variable
The PPARM variable defines the plotting / drawing range

Fixes: #319

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-13 19:23:30 +02:00
Christophe de Dinechin
a698bd8fb9 Implement DrawRectangle and DrawRoundedRectangle
Implement the two routines, currently with fake coordinates.

Fixes: #318

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-12 14:40:54 +02:00
Christophe de Dinechin
c7ba20c660 Implement ellipse and circle
Implement a simplified (no PPAR) version of `ellipse` and `circle`.

Fixes: #316

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-12 14:40:54 +02:00
Christophe de Dinechin
7dce12544a Add line drawing command, along with line attributes
Add `line` command to draw a line
Add `foreground` and `bacground` commands to set patterns
Add `LineWidth` command to set line width

Fixes: #311
Fixes: #312

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-12 14:40:54 +02:00
Christophe de Dinechin
ab33b7d663 menus: More options for menu rendering
Add options for:
* Single-row, Flattened or three-row menus
* Square or rounded menus

Fixes: #309

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-12 14:40:54 +02:00
Christophe de Dinechin
4331d7a623 Implement xroot operation
The `xroot` operation is equivalent to raising to the inverse power.

Fixes: #276

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
486f425dde Implement directories
Implement `crdir`, `updir`, `pgdir`, as well as per-directory lookup

Fixes: #298

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
59c4ef6057 Implement the disp command
Implement the `disp` command, with variants for font changes, etc.

Fixes: #296

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00