Add functions to generate shades from a single (usually theme provided)
basic palette colour.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
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>
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>
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>
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>
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>
Currently the empty string cannot be drawn into a fixed width box.
Fix this by adding a special case for empty strings.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently the line drawing code does not draw the final pixel of
straight lines. Thus a line from (0, 0) to (10, 10) finishes on a
different pixel to (10, 0) to (10, 10).
Fix this by removing the spurious subtract one from the end point
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
The 2-bit RLE encoding, in addition to supporting colour is also fully
ROMable meaning we can save 32 bytes of RAM per image by switching to
2-bit encoding.
Switch everything in icons and font.clock over to 2-bit encoding.
Note: this requires all the clock PNG files to be reencoded (because
they were originally in 1-bit grayscale format and this is no
longer supported by the encoder).
This reduces RAM overhead by 480 bytes and has only a negligable effect
on FLASH usage (+4 bytes).
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently the battery icon is overlarge compared to other status bar
icons such as the BT and notification icons (both of which are 32px
high). Fix this by redrawing the battery artwork and updating
the widgets in the status bar.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Update the icon so it more closely resembles the in-game visual style
(and also so it compresses better) and update the screenshot since the
old one is the wrong size (FullHD instead of 358x406) and doesn't render
correctly in the documentation.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Make the ticks and hands larger and shorten the hands slightly to avoid
visual glitches during "undraw".
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Polar coordinates are very convenient for implementing anything with
radial lines (such as a traditional watch face).
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently all lines are a single pixel wide. To draw wider lines we
must draw two parallel lines with a single pixel offset and this is
a *very* inefficient approach, espeically on ST7789 where we spend
longer setting the clipping window than we do drawing each pixel.
Fix this by constructing a line using a variable sized square rather than
a single pixel. This will "overdraw" (some pixels will be drawn more than
once) but since square blocks can be efficiently transferred to the
display the overdraw is acceptable.
Note: It is a difficult decision whether to maintain the convention that
color is the last argument or to keep compatibility with existing
line drawing tests. This patch opts for the former and fixes up
all uses within the existing codebase.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently there are default argument values for the start and end
coordinates but the defaults don't really make any sense since there
is no reason to prefer the value 0 over any other. Remove them.
Similarly color currently defaults to 0xffff which isn't right. It
should default to the foreground colour.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently `make check` doesn't test any not-default applications.
Fix this by automatically discovering constructors and ensure that the
application can be started and stopped without generating an exception.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Add the battery frame to the theme so it matches the frame used for
charging and rename accordingly.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This theming engine uses a bytestring (but supports anything indexable,
as long as the index results are a byte long),
stored as `wasp.system._theme`.
It has a default value, which should not change anything about the way this looks currently.
The theme can be set via `wasp.system.set_theme`,
but this should *ONLY* be used in `main.py`.
`wasp.system.set_theme` will return True if it was successful,
or False if the theme is of an old format.
Using an old format theme will *not* crash the watch,
but will use the default theme instead.
To theme this, one has to use tools/themer.py (use flag -h for complete explanation)
to generate a bytestring that's added in main.py (see diff).
The bytestring is then loaded into 'wasp.system._theme'.
Theme values can be looked up by apps by using `wasp.system.theme("theme-key")`.
Theme keys appear in the function body of `wasp.system.theme()`.
I've took the liberty of converting existing apps to use this method,
and it seems to work well.
A test theme is provided in `tools/test_theme.py`
Signed-off-by: kozova1 <mug66kk@gmail.com>
This is the API:
drawable.line(x1, y1, x2, y2, color)
The function has optimizations for the case of vertical or horizontal lines.
Signed-off-by: Kozova1 <mug66kk@gmail.com>
[daniel@redfelineninja.org.uk: Minor update to commit message]
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This makes the simulator look nicer when it starts up... but it
doesn't help the simulator.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently we can act on the controls but we cannot "see" the display
in the test suite. That leads us to a slightly odd form of "grey box"
testing. It's functionally black box testing but some of the asserts
have to reach inside the components instead of looking at the display.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently the tests do little more than fire up the simulator and
switch into (and out of) the built in applications. However this is
useful and allows us to fully integrate as a CI job.
Unfortunately the numpy warning from pysdl2 mean we have been forced
to disable all warnings to prevent pytest from collecting and reporting
them.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Signed-off-by: Carlos Gil Gonzalez <carlosgilglez@gmail.com>
[daniel@redfelineninja.org.uk: Fixed board support for simulator and
sphinx (a.k.a. doc builder)]
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Signed-off-by: Johannes Wache <jbwa@posteo.de>
[daniel@redfelineninja.org.uk: Removed some couple of unwanted merge artifacts]
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Like the other library applications this is enabled in the simulator and
included in the flash image but is disabled by default to conserve RAM
(and to give time to new apps to mature and receive improvements).
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently the widgets react to touch when the alarm is ringing (and they
are invisible. For now we fix this by disabling the alarm on a touch
event. Maybe the app should reject touch events since they could acidentally
dismiss the alarm... but we already disable the alarm if we get a swipe
event so this doesn't make things much worse than they already are!
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
The long term plan is to retire and remove the 1-bit RLE code from wasp-os
so we don't want new icons using that encoding.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Currently the swipe handling added for the confirmation view has a number
of prolems: it does not work at all for multi-screen notifications, it
interferes with the haptic feedback if we keep swiping down and an up
swipe incorrectly dismisses whole notification app.
Fix these.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>