No description
  • HTML 30.4%
  • C 29.3%
  • JavaScript 27.6%
  • CSS 4.5%
  • Shell 4.1%
  • Other 4.1%
Find a file
2026-11-20 01:28:44 +00:00
.github/workflows Move release workflow off Node 20 actions and pin the runner 2026-11-13 16:31:32 -06:00
config Add sleep screen shown while the wearer is asleep 2026-11-13 11:51:14 -06:00
npins Initial commit 2026-11-11 17:29:20 -06:00
resources feat: added icon 2026-11-14 01:18:23 -06:00
src Add charging screen shown while the watch is on its charger 2026-11-19 19:19:15 -06:00
store feat: added icon 2026-11-14 01:18:23 -06:00
test Add charging screen shown while the watch is on its charger 2026-11-19 19:19:15 -06:00
tools Add charging screen shown while the watch is on its charger 2026-11-19 19:19:15 -06:00
.envrc Initial commit 2026-11-11 17:29:20 -06:00
.gitignore Add visual regression snapshot tests for the watchface and settings page 2026-11-13 13:05:40 -06:00
appinfo.json Initial commit 2026-11-11 17:29:20 -06:00
package.json Bump version to 2.9.0 after releasing 2.8.0 2026-11-20 01:28:44 +00:00
package.json.full Initial commit 2026-11-11 17:29:20 -06:00
README.md Add charging screen shown while the watch is on its charger 2026-11-19 19:19:15 -06:00
shell.nix Add visual regression snapshot tests for the watchface and settings page 2026-11-13 13:05:40 -06:00
wscript Add a build-time test mode for sleep screen screenshots 2026-11-13 12:15:16 -06:00

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.