目录

VelaFit Edge

Native openvela smart-band with an AI Health Coach.

C11 + LVGL v9.1 on the goldfish emulator: the band builds a health snapshot, crosses the /share 9pfs bridge to a host companion, calls DeepSeek / MiniMax, and renders short coaching advice back on-device — with an on-device HTTPS path ready for real hardware.

AI Health Coach round-trip on the goldfish emulator

Watchface → AI Coach → DeepSeek → grounded advice back on-device, captured live on the goldfish emulator.

   band (C11 + LVGL)                 host companion (stdlib)
  ┌──────────────────┐  ai_request.json  ┌──────────────┐
  │ build snapshot   │ ───────────────▶  │ velafit_ai   │ ──▶ DeepSeek / MiniMax
  │ steps·HR·sport·7d│    /share (9pfs)  │              │ ◀── advice
  │ render advice    │ ◀───────────────  │ write reply  │
  └──────────────────┘  ai_advice.txt    └──────────────┘

VelaFit Edge is a native openvela app built in C11 with LVGL. It uses the /share transport on the emulator, keeps a board HAL split for hardware ports, and can be checked locally with the host tests or the headless emulator script.

VelaFit Edge is layered with a synchronous event bus, an HAL abstraction, and a power state machine, so the data source (simulator vs. hardware) can change without touching the UI.

Feature highlights

  • AI Health Coach: the band turns the day’s steps / heart rate / workout and 7-day history into short, personalised advice from a real LLM (DeepSeek or MiniMax). The request/advice round-trip rides the /share channel through the host companion by default, with an optional on-device HTTPS path (CONFIG_VELAFIT_ONDEVICE_AI) for networked hardware. See docs/07_ai_health_coach.md.
  • Two watchfaces: a hero digital clock and a real analog watchface whose hour/minute/second hands are drawn with lv_line + trigonometry and sweep every second. The choice persists in settings.kv.
  • Reproducible health data: heart-rate and steps come from a fixed-seed, scenario-driven generator (rest / walk / run / abnormal), shown on arc gauges.
  • Tileview navigation: swipe between watch, heart and steps; modal pages for sport, history, power, notifications and settings with animated transitions.
  • Sport sessions: run/walk with live time, steps, kcal and pace; results are written into the persistent daily history.
  • Notifications: call / SMS / app alerts pop as a floating banner on the LVGL top layer over any screen, with haptic and Do-Not-Disturb (calls bypass DND).
  • Persistence + history: a 7-slot ring buffer in /share/velafit (9pfs, survives reboot) with a highlighted 7-day bar chart and a one-tap “Seed Demo Data” button.
  • Low power: a 3-state machine (Active/Eco/Sleep) that actually retunes LVGL’s display refresh timer (~30 / ~8 / ~1 fps) plus backlight, visualised live in the Power HUD.
  • Sync: the watch writes /share/velafit/sync_out.json; the host companion renders it and writes an ack the watch consumes once. A CONFIG_VELAFIT_REAL_BLE GATT path is kept for boards with a BT controller.
  • Board port: HAL board placeholders + boards/adaptation_notes.md.

Screens

Captured from the running goldfish emulator (docs/media/).

Watchface + Coach card AI Coach + receipt 7-day history
watchface ai coach history
Power HUD Sport + Coach Run Analog watchface
power sport analog

The AI Coach screen shows provider, model, latency, and the exact band data used for the reply (grounded in: today 12 steps, 77 bpm, 7d avg 7721).

Display note

The goldfish “vela” emulator presents a 1280×800 RGB565 framebuffer (the AP / smart-display profile; goldfish has no 194×368 band skin). The UI is therefore responsive: on a wide panel it renders a centered ~460 px watch column; on narrow band hardware it uses the full width. Resolution is logged at boot.

Quick start

cd velafit_edge
./scripts/setup_ubuntu22.sh     # fetches repo + adb into tools/ (no sudo by default)
./scripts/fetch_source.sh       # repo-syncs openvela into .openvela/
./scripts/build_sim.sh          # installs app, patches defconfig, builds goldfish
./scripts/run_sim.sh            # boots the emulator (maps /share to .runtime/share)

In the emulator NSH shell:

velafit &

Headless one-command verification (no display required)

./scripts/run_headless_check.sh        # boots emulator -no-window, runs velafit,
                                       # asserts "VelaFit boot ok" + /share persistence

Push optional assets

./scripts/push_assets.sh                # finds adb automatically; no-op if empty

The UI uses LVGL built-in Montserrat fonts and vector drawing, so no external assets are required (a missing-asset black screen is impossible by design).

AI Health Coach

cp companion/velafit_ai.config.example.json companion/velafit_ai.config.json
$EDITOR companion/velafit_ai.config.json     # paste a DeepSeek / MiniMax key
python3 companion/velafit_companion.py --share .runtime/share/velafit --watch
# on the band: open "AI Coach" and tap "Ask DeepSeek" / "Ask MiniMax"

The real config is git-ignored so no key is committed. Full design and the file contract are in docs/07_ai_health_coach.md.

Host verification (no openvela tree needed)

./test/run_host_tests.sh

This runs C unit tests (event bus subscribe/publish/unsubscribe, store persistence + corruption recovery + demo seed, sensor/sport session with day rollover, notify queue + DND, AI request build / advice parse, device-side sync serializer), the device→companion sync contract, the AI coach companion round-trip (offline; VELAFIT_AI_LIVE=1 adds a real LLM call), and syntax-compiles every UI file against a fake LVGL header. Tests write only under test/tmp/.

Project layout

apps/velafit/       openvela builtin app (core / hal / services / data / ui)
boards/             board adaptation notes
companion/          host-side "phone" sync receiver
docs/               quick start, architecture, features, compliance, AI coach
scripts/            setup / fetch / install / build / run / push / headless-check
test/               host unit tests, fake LVGL, scenario notes
tools/              fetched dev tools (repo, adb) - not linked into firmware

Persistence rule

Mutable runtime data uses CONFIG_VELAFIT_DATA_PATH (default /share/velafit). This is intentional: openvela goldfish persistence must use the 9pfs-backed /share mount to survive a restart. Read-only assets may live under /data.

setup_ubuntu22.sh makes no system package changes by default; it places repo and adb under tools/. Set VELAFIT_ALLOW_SUDO=1 only on a machine you own. fetch_source.sh syncs with 1 job by default; build_sim.sh uses 2. Override with VELAFIT_REPO_JOBS / VELAFIT_BUILD_JOBS when the host can spare cores.

License

Apache-2.0 (see LICENSE, NOTICE, THIRD_PARTY.md). Every source file carries an SPDX header.

关于
3.1 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号