Commit graph

58 commits

Author SHA1 Message Date
Christophe de Dinechin
51c254b298 linux: Address warnings about missing initializers
It looks like gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4) thinks it's a good
idea to complain about every single zero-initialized C structure.

This is widely acknowledged as a (rather annoying)
[GCC bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119)

Add a constructor to silence the warning where possible.
For DMCP C structures where this is not possible, well, add ugly code.
2024-03-13 23:25:15 +01:00
Christophe de Dinechin
745b7227aa simulator: Do not try to create directory if it exists
This is just to avoid setting `errno` when we are just trying to
make sure that the directory exists.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-12 09:49:54 +01:00
Christophe de Dinechin
97cc7f90bd simulator: Add sound support
Add basic sound simulation in Qt

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
a5493f1e1c simulator: Lazy screen refresh
Perform screen refresh on demand instead of timer-based.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
75478a90e3 dmcp: Add UI refresh callback
Add a callback to explicitly refresh the screen instead of relying on
a volatile counter indicating that the screen is dirty.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
84764d71b1 simulator: Move QT-dependent code out of dmcp.cpp
Split the user-interface portion and the execution portion

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-08 12:13:35 +01:00
Christophe de Dinechin
4fc7e9c5b3 runtime: Various changes to isolate QT build from the rest
Being able to isolate parts that actually use QT is important
to build other platforms.
2024-03-05 12:36:42 +01:00
Christophe de Dinechin
3c48208759 dmcp: Day of week convention adjustment
By convention, 0 is Monday for DMCP, but Sunday for Unix.
I managed to not notice until now...

Fixes: #838

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 22:04:09 +01:00
Christophe de Dinechin
b0efb0ab44 simulator: Add screenshot keys
When hitting the F9 key, take a partial screen snapshot directly
(partial meaning no header).

When hitting the F8 key, take a screen snapshot using the `Screenshot`
command, which is now implemented on the simulator.

Also reduce the size of the window a little so that we can take video
snapshots that are 720 x 400 pixels and capture the keyboard.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
418b5e2919 simulator: Adjust DMCP month off-by-one error
The DMCP convention is for the month field to start at 1.
Integrate that in our emulation.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
9b451d7887 time: Add ChronoTime command
The `ChronoTime` command returns time with centisecond precision.

Fixes: #827

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
13958d1ac1 time: Add commands to set the system date and time
Add the `→Date` command to set the system date,
and the `→Time` command to set the system time.

Fixes: #823

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
71a4798534 dmcp: Make sure the tests don't block on wait_for_key
A call to `wait_for_key()` would prevent the key sync counters from
being updated, and as a result, the test suite would stop.

Fixes: #731

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-18 22:47:52 +01:00
Christophe de Dinechin
699ce554c9 simulator: Fix day of week shortcut
On simulator, Sunday is day 0.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-01 16:50:23 +01:00
Christophe de Dinechin
76150c6289 files: Allow STO and RCL to write to filesystem
When the argument describing the variable is a text, interpret that as
a file path on the disk. By default, data is stored in in a directory
named `data`, which will be created if necessary. For example, you can
use `3 "foo.48s" STO` to store the value `3` in a file named
`data/foo.48s` on disk.

How the file is stored depends on the extension given to the file:

* For `.txt` files, the object is stored as text
* For `.48s` files, the object is stored as DB48X source code
* For `.48b` files, the object is stored in binary format
* For `.csv` files, the object is stored in comma-separated format.

The binary format used for `.48b` includes a 4-byte magic number
identifying a DB48X format, and a 4-byte checksum used to ensure
binary compatibility between the firmware and the disk format.

At least during early days of development (prior to 1.0), it is quite
unlikely that the binary format for one version of the firmware would
be readable or writable by another version. If you need to recover
data from another version, you need to install that version and save
the object again in `.48s` (text) format.

Fixes: #375

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-15 01:59:04 +01:00
Christophe de Dinechin
465725cb55 battery: Automatically switch off with message if vbat < 2.5V
Detect a low-batter situation and, when it happens, automatically
switch the calculator with a message on top of the off-image.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-01 19:54:49 +01:00
Christophe de Dinechin
d9686133b8 simulator: Read the tail as the last written element
The `key_tail()` function should return the last key written, not the
first one.

Fixes: #356

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 18:53:39 +02:00
Christophe de Dinechin
b1a1706623 dmcp: Better recorder logging for key_empty
Only show `key_empty()` for changes in empty status

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-28 02:43:03 +02:00
Christophe de Dinechin
3eed95ddf9 Fix indentation
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:23:03 +02:00
Christophe de Dinechin
f762b305f6 header: Draw time in the header depending on options
Draw the time in the header when the corresponding option is activated

Fixes: #123

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-28 21:57:16 +02:00
Christophe de Dinechin
6be0afceb7 simulator: Simulate transient alpha mode
When the shift key is held, send UP key to the RPL thread.
When the alt key is held. send DOWN key to the RPL thread.

Fixes: #215

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-27 13:27:14 +02:00
Christophe de Dinechin
ae73146878 Add transient alpha mode
After a lot of experimentation, it turns out that it's not really
possible to use the shift key as originally planned, because it is not
reliably visible when two keys are simultaneously visible. It can only
be combined with key N and O (and maybe a few others), and these
combinations are clearly treated specially (they give some magic
keycode, e.g. screen snapshot with Shift-DISP on the DM42).

It turns out only three keys seem somewhat reliable in combination
with alphabetic keys: ON, UP and DOWN. On works with _almost_ all
keys, but apparently B or C is missing (forgot which one). Up and Down
work with all alphabetic keys. This turns out to be a good thing,
because it gives us an additional option that was not originally
planned: quick access to lowercases.

The behavior implemented in this commit is therefore the following:
- "Up" held with any key gives an uppercase letter
- "Down" held with any key gives a lowercase letter.

A minor side effect is that up and down are now active on release and
not on key press. In practice, this is barely noticeable.

Fixes: #204

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-27 09:52:32 +02:00
Christophe de Dinechin
2514dc2111 tests: Do not pollute test output wihe messages about saved state
Now that we display the name of the saved state in the header,
we get tons of messages from a debug message in `get_reset_state_file`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-21 12:08:08 +02:00
Christophe de Dinechin
92420bb993 Optimize redrawing of components in the user interface
Only draw elements of the user interface that are individually dirty.
This notably disables the slow and expensive redrawing of menus
while editing, which improves the user experience on battery
(and probably battery life too).

Fixes: #153

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-19 19:03:09 +02:00
Christophe de Dinechin
f73290d0be Avoid the beep on Shift-ENTER
The new shift-Enter behaviour works, but on real hardware, it causes
a beep!

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-17 16:02:48 +02:00
Christophe de Dinechin
17160f891b test: Yet another pass at synchronization logic
With the new alpha-shifting logic, the test suite runs much faster
than before, and as a result, ran into many more synchronization issues.

Ensure that we wait for the stack to actually update before we
proceed with evaluating its content. This required a change in logic
where we expect the stack to actually change value, so some tests
have to be changed accordingly.

The net result is that the tests can now pass reliably at full speed.

Fixes: #77

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-17 02:58:57 +02:00
Christophe de Dinechin
1c21767890 Refresh the main loop to match DM42 PGM structure
There are some slight differences between the structure of the DM42
program and the structure implemented here. Not sure whether the
differences matter, but better follow a known-good model.

Also add missing DMCP critical section functions that appear used
in the DM42 code: `sys_critical_start()` and `sys_critical_end()`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-30 20:46:01 +02:00
Christophe de Dinechin
042461e98c Rate limiting of the warning messages about pixels out of range
It really slows down the rendering when they are being output in Emacs

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-24 00:35:50 +02:00
Christophe de Dinechin
bdefd10f38 Force exit of DMCP menus when application exits
The application dialog is in a loop processing keys, so send a special "exit"
keycopde (-1) to force it out.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 23:58:38 +02:00
Christophe de Dinechin
ca9fcbe3a6 Switch to using QT File dialog and settings to save state
The `QSettings` class is only used to store the path to the actual state.
The use of the file dialog seems to cause some trouble with the current working
directory, and this impacts the display of the help file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 22:53:37 +02:00
Christophe de Dinechin
a6110717be Implement a basic DMCP file selector
This makes it possible to test and debug the state load/save code on the
simulator.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 20:26:34 +02:00
Christophe de Dinechin
f13cd0c6dc Some hare-brained simulation of the DMCP menu system
This makes it possible to handle DMCP menus, including load/save state.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 19:50:21 +02:00
Christophe de Dinechin
c187d3f6a8 Add some stubs for missing DMCP commands
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 18:31:57 +02:00
Christophe de Dinechin
6e39474f3b Infrastructure and DMCP menus to load/save programs and state
This is heavily lifted from the DMCP code examples

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-23 10:18:16 +02:00
Christophe de Dinechin
08638f7ef8 Remove debug menu, allocate more memory
Experimentally, we need to leave about 4K free for "other stuff"

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
7eb144db2a Avoid having a noisy warning on the simulator
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:33 +02:00
Christophe de Dinechin
0280891dfb Parsing and evaluation of programs
A simple program now evaluates, but a bit too early

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
390a79a870 Batter voltage reading
Not sure I got this right, but better to see some voltage reading on the actual machine.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:32 +02:00
Christophe de Dinechin
ad439196e3 Add lcd_toggleFontT emulation
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
18c1fb3d84 Highlight key positions when a key is pressed
This makes it plain which key is being pressed in the simulator

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
c3b6cebb32 Increment screen update to make it easier to detect changes
If multiple consumers need to check if the screen has changed, a simple flag
does not do it. Instead, increment a counter that each client will be able to
check indepdendently.

This will be useful for an upcoming test framework

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
82e30ecf7b The simulator has no "OFF mode
Clear the corresponding bits, otherwise the RPL thread goes into infinite loop

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
ea710d247d Indicate location of bad character
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
f29743061f Record menu content in lcd_draw_menu_keys
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
db47cd69ca Put the primary makefile rules at the top
If not, then recorder/config.h gets picked by default for 'make'

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
9840da59d3 Fix bad error message
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:31 +02:00
Christophe de Dinechin
62baa7d25e Super-dumb implementation of timers
I wanted to do something smart with QTimer, but it fails because they interact
with QT's event loop, making timers across threads annoyingly difficult.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:30 +02:00
Christophe de Dinechin
3accd9d15d Revert the display to match what the calculator displays
Had one and zeroes backwards.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:30 +02:00
Christophe de Dinechin
be3591b822 Add an display class, finish some cleanup on editor
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:30 +02:00
Christophe de Dinechin
884b3d164e Some progress towards having a real editor
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-06-19 21:56:30 +02:00