# CALCULATOR — round-screen calculator for Xiaomi Watch S4 A calculator laid out for the circular display: tapered key rows that follow the chord of the round screen, large touch targets, high-contrast keys (#3a3a3e on #000). Supports chained operations, percent, sign toggle, decimals, and divide-by-zero error recovery. **Status: WORKING ON WATCH** (user-confirmed through v1.2; layout improved through 1.6). ## Usage - Tap keys to compute; `AC` clears all - `%` divides the display by 100 (plain semantics — 200+10% = 200.1) - Back button exits (no onBackPress interception — intercepted back made the button feel dead on a single-page app) - Crown does nothing (unsupported API on Vela); the original crown-selection scheme was abandoned for a directly-tappable list layout ## Round-screen layout (the interesting part) - Short viewport (~300px) so rows never exceed the circle chord - NO vertical margins on list-items (spacing baked into height — CSS/JS drift bug) - Top/bottom spacer items so first/last keys can center in the viewport - Focus = round((scrollY + KEYS_H/2 − ITEM_H/2 − PAD)/ITEM_H); re-centered after every press via scrollTo - Geometry + contrast assertions live in `tests/visual.cjs` (parses the .ux) ## Project layout ```text src/ ├── app.ux, manifest.json # com.example.hellovela identity (preserved for updates) ├── common/icon.png # 192×192 circular icon └── pages/index/index.ux # keys list + display + state machine tests/ ├── page.cjs # state machine: driven via press(key) sequences └── visual.cjs # parsed-from-source geometry/contrast contracts ``` ## Build & test ```bash npm ci npm run release node tests/page.cjs node tests/visual.cjs ``` ## Install Side-load via AstroBox. Releases: https://gitea.oimcloud.myaddr.tools/codex-bot/vela-calculator ## Bug history worth knowing (all caught by the stale-test TDD pass) - `fresh` never initialized → first digit appended to '0' ('01') - `=` with no pending op zeroed the display - Operators didn't auto-evaluate pending ops (2+3×4 gave 12, not 20) - Repeated `=` didn't re-apply the last op (2+3== gave 5, not 11)