- HTML 30.4%
- C 29.3%
- JavaScript 27.6%
- CSS 4.5%
- Shell 4.1%
- Other 4.1%
| .github/workflows | ||
| config | ||
| npins | ||
| resources | ||
| src | ||
| store | ||
| test | ||
| tools | ||
| .envrc | ||
| .gitignore | ||
| appinfo.json | ||
| package.json | ||
| package.json.full | ||
| README.md | ||
| shell.nix | ||
| wscript | ||
Binary Time
A Pebble binary (BCD) watchface, rebuilt from scratch from a closed-source watchface that has no published source.
Build
nix-shell # pebble.nix pinned with npins (see shell.nix)
pebble sdk install 4.9.169 # once; newer SDKs need pebble-tool >= 5.1
pebble build # -> build/<directory-name>.pbw (aplite basalt chalk diorite emery)
pebble install --emulator basalt
Icon
The icon is the watchface's dot grid reading 12:34, drawn by node tools/make-icons.js: the 25×25 menu icon
(resources/icon.png, plus icon~bw.png for aplite and diorite) and the store icons in store/ (48 and 144 px).
Edit the script and rerun it rather than editing the PNGs.
Sleep screen
While Pebble Health reports the wearer asleep, the watchface is replaced by a terminal-style panel for the
people around them (src/c/sleep_screen.c; not on aplite, which has no Health API). It shows the sleep phase,
when the night started, time slept against the typical night, deep sleep time and number of deep periods,
wake-ups, recent movement, heart rate with the night's range (only on watches with a sensor), the next alarm
with a countdown, and Quiet Time. Health reports sleep with a delay, so the panel appears some minutes after
the wearer falls asleep.
While it is shown the hourly vibration is skipped, unless "Hourly vibration while asleep" is turned on in the
settings (that option is hidden on aplite).
Pebble firmware only distinguishes light and restful (deep) sleep. The phases are a table in
sleep_screen.c; when a firmware reports REM sleep, set HEALTH_ACTIVITY_REM_SLEEP to its activity bit and
the REM phase, its row (time and number of REM periods) and detection follow.
A watchface cannot read the system Alarms app, so alarms are pushed to it by AppMessage, e.g. from a phone
automation through PebbleKit (app UUID 3ddc5ba8-09d8-4f37-bc40-5930ba1fced1):
| key | id | value |
|---|---|---|
ALARM_TIME |
10034 | UTC seconds of the next alarm; 0 clears it; a time already passed means "ringing now" |
ALARM_SNOOZED |
10035 | 1 when that alarm is a snooze (optional) |
When the alarm time is reached the watchface comes back. A snooze (ALARM_SNOOZED=1 with the snooze end)
brings the sleep screen back; any other new alarm does not, so pushing tomorrow's alarm right after
dismissing today's keeps the watchface up. The new keys are appended to messageKeys so the ids of the
existing ones do not change.
For screenshots, SLEEP_SCREEN_TEST=1 pebble build compiles in a test mode: an AppMessage SLEEP_TEST
(id 10037) with a phase (1 light, 2 deep, 0 off) fakes that sleep phase with fixed readings, instead of
Pebble Health, and clears the alarm state. Normal builds ignore the key.
tools/screenshots.sh builds that way; its sleep scenes (19-23) cover both phases, an alarm, a snooze, an alarm
that went off (the watchface is back) and test mode off.
Charging screen
While the watch is on its charger the watchface is replaced by a charging screen (src/c/charging_screen.c, all
platforms): a ring that fills with the charge, a bolt and the percentage inside it, and below it the time until full
(the two largest units: 1h 15m, 12m 30s, 45s) and the charging power. While it is shown the sleep screen is
switched off: the Health event subscription is dropped, so neither sleep state nor heart rate is read.
The battery service only reports the charge in 10 % steps, with no current or voltage, so both readings are
estimates from when the percentage steps up (over the last three steps; they show -- until two steps were seen,
typically 15-25 minutes after plugging in). The power is that rate times the battery's nominal capacity and 3.8 V;
the capacities are approximate per platform (BATTERY_MAH). The estimate survives leaving the watchface for up to
5 minutes.
In test builds (SLEEP_SCREEN_TEST=1) an AppMessage CHARGE_TEST (id 10038) sets a fixed rate in % per hour
(0 = measure it); screenshot scenes 24-26 use it, scene 15 shows the screen before any rate is known.
Visual regression tests
Screenshots are compared pixel by pixel with committed baselines (tools/lib/png-diff.js, no npm deps).
A run writes current/, plus red-on-grey diff images in diff/ for anything that changed. It exits non-zero
when an image differs by more than --threshold (fraction of pixels, default 0.001) or is missing.
After an intended change, rerun with --update and commit the new baselines.
| what | command (inside nix-shell) | baselines |
|---|---|---|
| watchface in the emulator (26 scenes, 5 of them the sleep screen, 4 the charging screen; 20 on aplite) | tools/screenshots.sh [--update] [--only REGEX] [platform...] |
test/screenshots/baseline/ |
| settings page in headless Chromium (8 scenes × 5 platforms) | node tools/settings-screenshots.js [--update] [--only REGEX] [platform...] |
test/settings-screenshots/baseline/ |
| PNG diff library | node --test test/png-diff.test.js |
The watchface scenes send their settings through the real phone path: pebble emu-app-config runs with
tools/lib/fake-config-browser.js as the browser, which returns the scene's settings JSON. The scenes also set the
emulated battery, quick view and tap state, and pin the clock (UTC) right before each shot. Each scene's
settings are merged over test/screenshots/base-config.json. The emulator runs from a private
test/screenshots/.state and is shut down at the end. The settings page runs with Date frozen at the same moment.