Skip to content

Add an Animation tab for the Watch Pro 2's animated image (0x82, type 2) - #122

Merged
freethinkel merged 5 commits into
fmctools:mainfrom
hassan-software-dev:feat/pro2-anim-widget
Nov 29, 2026
Merged

freethinkel merged 5 commits into
fmctools:mainfrom
hassan-software-dev:feat/pro2-anim-widget

Conversation

@hassan-software-dev

@hassan-software-dev hassan-software-dev commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What

The Watch Pro 2 (stock 1.0.0.73) already plays the animated image widget
(tag 0x82, type 2), but the editor treated types 0..3 as plain images and
only kept their bytes. This adds editing and preview for it.

  • Decode/encode the 25-byte 0x5c body (proc.ts): duration, start/end angle,
    and the other fields, named by offset (raw4..raw18, flags, tail)
    and labelled "raw" in the UI. encodeAnim reproduces the stock bytes.
  • New Animation tab: the list of animated images, a timeline that plays or
    scrubs on its own clock, and the effect fields. Selecting a layer no longer
    leaves this tab.
  • Preview (render/anim.ts): the position math is a port of the firmware's
    function, and the wake sweep follows its timer. The simulator can wake the
    screen; changing the time, sunrise or sunset replays it.
  • "Animated layer" in the add menu, seeded with Sun Circle's exact body.
  • The panel points out values the firmware is known to handle badly. It only
    warns; nothing is blocked.
  • Sun Circle AOD is added as a Doc round-trip fixture.

compat.ts and assertWatchCompat are untouched: types 0..3 are already
allowed on a Pro 2.

What is known, and how

The position math was read from the stock app firmware (app_073.bin,
function at 0x1004BAE0) and checked against the firmware's own code run in an
emulator. orbitAt is tested against every row of that output (1800 angles at
R = 3817, 181 at R = 1900) with no tolerance. Its details: a float32
angle, two branches with their own base angle (180 and 270), the constant
3.14, truncation toward zero and 16-bit wrap. The sweep follows the firmware's
timer callback (0x100DF2EC): the step angle is a fractional float32, and both
of its emulated outputs (value 50 and 100, 125 callbacks each) are compared
step by step, also with no tolerance.

Confirmed on a watch (Sun Circle): the sun and moon sweep in on wake over
about 2 s and stop where daylight % / night % put them, bottom to top.

Still inferred, so please read the labels accordingly:

  • The callback period of the sweep. The firmware asks its timer for 10 ms, but
    the sweep is one step per callback and a watch showed about 2 s for a
    duration of 2000, so the preview assumes one step per 18 ms. The display
    service that drives the timer was not traced.
  • What body offsets 8, 10 and 18 do (the firmware reads them; no visible effect
    was traced in orbit mode).

Tests that change one field each on a real watch are planned.

Testing

  • tests/doc-anim.test.ts: the stock body round-trips, edits change only the
    field named, the factory layer equals the stock layer, orbitAt matches the
    firmware's CSV output exactly, and the sweep and warnings behave as described.
  • Doc round trip over the corpus, including the new fixture: unchanged.
  • pnpm check, pnpm lint and pnpm format:check clean; unit tests pass apart
    from tests/typography.test.ts, which fails on Windows because its
    allowlist uses / paths (unrelated to this change).
  • Browser tests were not run locally (Playwright's Chromium wasn't installed);
    CI will run them.
  • Exercised by hand in the editor (load, scrub, play, edit, undo, night time,
    add layer); nothing was flashed to a watch.

🤖 Generated with Claude Code

hassan-software-dev and others added 3 commits November 29, 2026 15:25
The editor kept these layers byte for byte but treated them as plain images.
Decode the 0x5c body into a typed view (duration, start/end angle; the fields
whose meaning isn't known stay raw, named by offset) with an encoder that
reproduces the stock bytes, and edit it through a pure withAnim edit.

- Animation tab in the right panel: the layer list, a timeline that plays or
  scrubs on its own clock, and the effect fields.
- Preview: one geometry function (render/anim.ts) places the image by value
  and replays the wake sweep; the simulator can wake the screen, and a time,
  sunrise or sunset change replays it too.
- "Animated layer" in the add menu, seeded with Sun Circle's exact body.
- Selecting a layer no longer leaves the Animation tab.

compat.ts and assertWatchCompat are untouched; types 0..3 were already
allowed on a Pro 2. The geometry is a model that fits Sun Circle, to be
checked on a watch. Sun Circle AOD is added as a round-trip fixture.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The preview now computes the position the firmware does (app_073.bin,
0x1004BAE0): a float32 angle, two branches with their own base angle (180 and
270), the constant 3.14, truncation toward zero and 16-bit wrap. An angle the
watch ignores leaves the image where it was. The wake sweep starts at the start
angle and walks linearly to the value-scaled end, as the firmware's timer does.

orbitAt is tested against every row of the firmware's own output (1800 angles
at R = 3817 and 181 at R = 1900), with no tolerance.

Also: off 16 and 18 are signed; the Animation panel points out values the
firmware is known to handle badly (duration under 18 ms, flags other than
0x88/0x89, angles outside 180..360 degrees, a radius outside 0..8000 px).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The timer callback does not round the step angle to whole tenths: it computes
((float)((end - start) * k) / (float)N + (float)start) / 10 in float32 and
hands that fractional degree to the position function. Doing the same makes
the preview's sweep agree with the firmware on every step; truncating to
tenths was off on about 100 of Sun Circle's 110.

orbitAt is split into orbitAtDeg (a float angle) and orbitAt (tenths). Both
sweep outputs of the firmware's timer callback (value 50 and 100, 125
callbacks each) are fixtures and are compared exactly.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@hassan-software-dev

Copy link
Copy Markdown
Contributor Author

I am still working on the capability of animated watch faces like sun circle, I will let you once my research and working is done

hassan-software-dev and others added 2 commits November 29, 2026 16:53
The Animation tab now offers ten ready-made effects for the Watch Pro 2's
animated image (type 2), grouped as Slide and Arc, each with a thumbnail
and a motion-path preview. Sun Circle's rise and set are the proven bytes;
the others change only values the firmware reads (angles, radius, offset,
duration) and are labelled as not yet tried on a watch.

The simple controls (direction, speed, angles, repeat, reset) write only
inside ANIM_LIMITS, and the raw fields are folded under "advanced". The
widget type word is always 2, so no edit can reach the types the Pro 2
boot-loops on; compat.ts and assertWatchCompat are untouched. Tests cover
the preset bytes, the firmware positions of the arcs, and 200 fuzzed
bodies through assertWatchCompat.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- A new animated layer's blank frame is cf 5: cf 4 has no alpha, so it was
  an opaque black disc over the whole screen.
- The timeline runs to animEndMs (start delay + every step), not to the
  duration, so its end is where the motion rests.
- The phone's sheet lets go of the scrub when the tab unmounts.
- Animation edits go through withAnim + committed: a no-op keeps its undo
  step, and a locked layer is refused (and shown disabled, as in Props).
- Source 0 ignores the timeline's value, as the watch does; the value
  slider shows the source's value and hides for source 0.
- The path preview's stroke is a fixed 2px.
- The tab's layer list and current layer live in sim.model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@freethinkel
freethinkel merged commit 523cee0 into fmctools:main Nov 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants