1
0
Fork 0
Commit graph

8 commits

Author SHA1 Message Date
Daniel Thompson
0318640f62 apps: calc: Remember the results between invocations
Currently if you spend more then 15 seconds looking up figures or
transcribing the answer then the system will switch back to the
clock and the answer will be lost.

Fix this by remembering the output between invocations.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29 08:59:53 +00:00
Daniel Thompson
21210c5c07 apps: calc: Rewrite the display and calculation engine
Currently calculations such as 22/7 do not work correctly on the
simulator (which uses double precision floating point). Fix this
by explicitly truncating the strings when needed.

Additionally the current calculate() method has some problems when
the calculation cannot be evaluated since it will needlessly clear out
the calculation. Push calculate (and the exception handling) into the
caller and report errors using the vibration motor instead.

Finally we rename display_output() to the more idiomatic _update().

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29 08:59:53 +00:00
Daniel Thompson
e570bf4f26 apps: calc: Optimize the fields lookup structure
Currently the fields is a list of lists of strings. This will needlessly
consume RAM so lets switch it over to a simple string (which is immutable
and can be stored in flash).

We also replace indices with simple x and y variables. In addition to
avoiding a (temporary) memory allocation this is also easier to use
when looking up in fields.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29 08:59:53 +00:00
Daniel Thompson
60fecc9469 apps: calc: Draw a closed grid
Currently the calculator uses an open grid. It's a matter of taste but
I prefer a closed grid.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29 08:59:53 +00:00
Daniel Thompson
0884d22799 apps: calc: Correct after draw565 bug fix
Currently the coordindates used for line drawing are "tuned" for a bug in
the line drawing code (and now draw off the edge of the screen). Fix this.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-29 08:59:53 +00:00
Daniel Thompson
6d74d4f585 apps: calc: Adopt the system theme for accent colors
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-28 14:24:00 +00:00
Daniel Thompson
77b693414e apps: calc: Move the copyright header to the top of the file.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-12-28 14:20:17 +00:00
Johannes Wache
a1ee40016d apps: calc: Created memory-saving calculator app
Signed-off-by: Johannes Wache <jbwa@posteo.de>
2020-12-28 12:06:51 +00:00