Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ Every watchface install ends in `flashFx` (`ble.model`): `fitForWatch`, `assertF
`assertWatchCompat` (`core/format/compat.ts`) on the bytes that go out. The last one reads the raw
file as the firmware's parser does, because a wrong verdict is a boot loop: never move it onto
`parseBin`'s tree, and don't add a way to send a face around it. `PRO2_FACES_STUB` stays null
until a stub release that draws types 4..7 has its number reserved in cmf-watch-sdk and is tried
on a real watch, and a Watch Pro 2 gets no cf 14 until that is seen working on one. A procedural
layer's rules (fixed image count, type 4 doesn't move, no rescale) live in `edits.ts` `procPatch`
and `overlay.ts` `resizable`.
until the stub release that draws types 4..7 (planned as 11) is out and tried on a real watch, and a Watch Pro 2 gets no cf 14 as it is until that is seen working on one
(`fitForWatch` converts it, with ETC2, to cf 5 on the way). A procedural layer's rules (fixed image
count, type 4 doesn't move, no rescale) live in `edits.ts` `procPatch` and `overlay.ts` `resizable`.

`Face`/`FaceNode` are the file's own shape, not the editor's: `parseBin` produces them,
`fromLegacy` turns them into a `Doc`, `toLegacy` turns one back, and the importers build them
Expand Down
10 changes: 7 additions & 3 deletions docs/cmf-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,13 @@ The layout is in `core/render/proc-scene.ts`. Where each type may be installed i
struct (18 bytes, no 2 bytes of padding) followed by a condition does have one as far as the
firmware is concerned, and boot-loops it: keep the `0000` tail.

A Watch Pro 2 is also refused any cf 14 (A8) resource, the thumbnail included, until A8 has been
seen on a real one: the emulator stops on faces that use it. Export for Watch Pro 2 re-encodes it as
cf 5.
A Watch Pro 2 never gets a cf 14 (A8) resource as it is, the thumbnail included, until A8 has been
seen on a real one: the emulator stops on faces that use it. `fitForWatch` re-encodes A8 and ETC2 as
cf 5 on the way to a Pro 2 (and Export for Watch Pro 2 in a file), as long as every screen then stays
within the 1.955 MB tested there; the gate refuses the rest.

A Watch Pro 2 draws types 4..7 with the stub release planned as 11 (cmf-watch-sdk); until it is out
and tried on a real watch, `PRO2_FACES_STUB` keeps them off every Pro 2.

Sources only a Watch 3 Pro has run 0x8e..0x9d. Known: `0x93` the minutes of last night's sleep,
`0x99` the number of the face's colour theme. A themed layer (meta[7] = 4) takes the theme the
Expand Down
10 changes: 10 additions & 0 deletions src/lib/modules/device/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export const t = dict(
help: helpEn,
backToFaces: "Back to the watchfaces",
// after a flash that had to compress images (bleModel.$fitNote)
convertNote: (n: number) =>
`${n} ${n === 1 ? "image was" : "images were"} converted to a format the Watch Pro 2 draws — Watch 3 Pro images it can't show as they are.`,
fitNote: (n: number) =>
`${n} ${n === 1 ? "image was" : "images were"} compressed to fit the watch's memory — they can look slightly softer than in the editor.`,
},
Expand Down Expand Up @@ -252,6 +254,8 @@ export const t = dict(
helpTitle: "Перед подключением — FMC",
helpDescription:
"Что FMC делает с вашими часами CMF, чего он не умеет и как решить конфликт Bluetooth с приложением Nothing X.",
convertNote: (n) =>
`${n} ${plural("ru", n, { one: "изображение переведено", few: "изображения переведены", many: "изображений переведено" })} в формат, который рисует Watch Pro 2: в исходном формате Watch 3 Pro эти часы их не показывают.`,
fitNote: (n: number) =>
`${n} ${plural("ru", n, { one: "изображение сжато", few: "изображения сжаты", many: "изображений сжато" })}, чтобы циферблат поместился в память часов — на часах они могут выглядеть чуть мягче, чем в редакторе.`,
help: helpRu,
Expand Down Expand Up @@ -375,6 +379,8 @@ export const t = dict(
helpTitle: "Перед підключенням — FMC",
helpDescription:
"Що FMC робить з вашим годинником CMF, чого він не вміє і як усунути конфлікт Bluetooth із застосунком Nothing X.",
convertNote: (n) =>
`${n} ${plural("uk", n, { one: "зображення переведено", few: "зображення переведено", many: "зображень переведено" })} у формат, який малює Watch Pro 2: у вихідному форматі Watch 3 Pro цей годинник їх не показує.`,
fitNote: (n: number) =>
`${n} ${plural("uk", n, { one: "зображення стиснуто", few: "зображення стиснуто", many: "зображень стиснуто" })}, щоб циферблат помістився в пам'ять годинника — на годиннику вони можуть виглядати трохи м'якше, ніж у редакторі.`,
help: helpUk,
Expand Down Expand Up @@ -499,6 +505,8 @@ export const t = dict(
helpTitle: "Antes de conectar — FMC",
helpDescription:
"Qué le hace FMC a tu reloj CMF, qué no puede hacer y cómo resolver el conflicto de Bluetooth con la app Nothing X.",
convertNote: (n) =>
`${n} ${plural("es", n, { one: "imagen se convirtió", other: "imágenes se convirtieron" })} a un formato que el Watch Pro 2 dibuja: en el formato original del Watch 3 Pro no las muestra.`,
fitNote: (n: number) =>
`${n} ${plural("es", n, { one: "imagen se comprimió", other: "imágenes se comprimieron" })} para que la esfera quepa en la memoria del reloj — pueden verse algo más suaves que en el editor.`,
help: helpEs,
Expand Down Expand Up @@ -618,6 +626,8 @@ export const t = dict(
helpTitle: "कनेक्ट करने से पहले — FMC",
helpDescription:
"FMC आपकी CMF घड़ी के साथ क्या करता है, क्या नहीं कर सकता, और Nothing X ऐप के साथ Bluetooth की टक्कर कैसे ठीक करें।",
convertNote: (n) =>
`${n} इमेज ऐसे फ़ॉर्मेट में बदली गईं जिसे Watch Pro 2 दिखाता है: Watch 3 Pro के मूल फ़ॉर्मेट में यह घड़ी उन्हें नहीं दिखाती।`,
fitNote: (n: number) =>
`घड़ी की मेमोरी में फ़ेस फ़िट करने के लिए ${n} इमेज कंप्रेस की गईं — घड़ी पर वे एडिटर से थोड़ी धुंधली दिख सकती हैं।`,
help: helpHi,
Expand Down
14 changes: 14 additions & 0 deletions src/lib/modules/device/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const en = {
`this face has a widget of type ${type}, which no supported watch knows — it can restart a watch in a loop. Nothing was sent to the watch.`,
widgetUnsupported: (type: string) =>
`this face has a Watch 3 Pro widget (type ${type}) that this watch's firmware can't draw — the watch would restart in a loop. Nothing was sent to the watch.`,
a8TooHeavy: (need: string, max: string) =>
`this face has A8 images (cf 14), and converted for a Watch Pro 2 a screen needs ${need} MB, over the ${max} MB tested there — the watch could restart in a loop. Nothing was sent to the watch.`,
a8Untested:
"this face has A8 images (cf 14), which haven't been tested on a Watch Pro 2. Open it in the editor, use Export for Watch Pro 2 and install the exported file. Nothing was sent to the watch.",
etc2OverTested: (need: string, max: string) =>
Expand Down Expand Up @@ -187,6 +189,8 @@ export const bt = dict(en, {
`в этом циферблате виджет типа ${type}, его не знают ни одни поддерживаемые часы — от него часы могут зациклиться на перезагрузке. На часы ничего не отправлено.`,
widgetUnsupported: (type) =>
`в этом циферблате виджет Watch 3 Pro (тип ${type}), который прошивка этих часов не умеет рисовать — часы зациклятся на перезагрузке. На часы ничего не отправлено.`,
a8TooHeavy: (need, max) =>
`в этом циферблате изображения A8 (cf 14), и после перевода для Watch Pro 2 экрану нужно ${need} МБ, а проверено только до ${max} МБ — часы могут зациклиться на перезагрузке. На часы ничего не отправлено.`,
a8Untested:
"в этом циферблате изображения A8 (cf 14), их работа на Watch Pro 2 не проверена. Откройте его в редакторе, выберите «Экспорт для Watch Pro 2» и установите полученный файл. На часы ничего не отправлено.",
etc2OverTested: (need, max) =>
Expand Down Expand Up @@ -296,6 +300,8 @@ export const bt = dict(en, {
`у цьому циферблаті віджет типу ${type}, його не знає жоден підтримуваний годинник — через нього годинник може циклічно перезавантажуватися. На годинник нічого не надіслано.`,
widgetUnsupported: (type) =>
`у цьому циферблаті віджет Watch 3 Pro (тип ${type}), який прошивка цього годинника не вміє малювати — годинник циклічно перезавантажуватиметься. На годинник нічого не надіслано.`,
a8TooHeavy: (need, max) =>
`у цьому циферблаті зображення A8 (cf 14), і після переведення для Watch Pro 2 екрану потрібно ${need} МБ, а перевірено лише до ${max} МБ — годинник може циклічно перезавантажуватися. На годинник нічого не надіслано.`,
a8Untested:
"у цьому циферблаті зображення A8 (cf 14), їхню роботу на Watch Pro 2 не перевірено. Відкрийте його в редакторі, виберіть «Експорт для Watch Pro 2» і встановіть отриманий файл. На годинник нічого не надіслано.",
etc2OverTested: (need, max) =>
Expand Down Expand Up @@ -405,6 +411,8 @@ export const bt = dict(en, {
`esta esfera tiene un widget de tipo ${type} que ningún reloj compatible conoce — puede dejar el reloj reiniciándose en bucle. No se envió nada al reloj.`,
widgetUnsupported: (type) =>
`esta esfera tiene un widget del Watch 3 Pro (tipo ${type}) que el firmware de este reloj no sabe dibujar — el reloj se reiniciaría en bucle. No se envió nada al reloj.`,
a8TooHeavy: (need, max) =>
`esta esfera tiene imágenes A8 (cf 14) y, convertidas para un Watch Pro 2, una pantalla necesita ${need} MB, más de los ${max} MB probados allí — el reloj podría reiniciarse en bucle. No se envió nada al reloj.`,
a8Untested:
"esta esfera tiene imágenes A8 (cf 14), que no se han probado en un Watch Pro 2. Ábrela en el editor, usa «Exportar para Watch Pro 2» e instala el archivo exportado. No se envió nada al reloj.",
etc2OverTested: (need, max) =>
Expand Down Expand Up @@ -516,6 +524,8 @@ export const bt = dict(en, {
`इस फ़ेस में टाइप ${type} का विजेट है, जिसे कोई समर्थित घड़ी नहीं पहचानती — इससे घड़ी बार-बार रीस्टार्ट हो सकती है। घड़ी पर कुछ नहीं भेजा गया।`,
widgetUnsupported: (type) =>
`इस फ़ेस में Watch 3 Pro का विजेट (टाइप ${type}) है, जिसे इस घड़ी का फ़र्मवेयर नहीं दिखा सकता — घड़ी बार-बार रीस्टार्ट होती रहेगी। घड़ी पर कुछ नहीं भेजा गया।`,
a8TooHeavy: (need, max) =>
`इस फ़ेस में A8 इमेज (cf 14) हैं, और Watch Pro 2 के लिए बदलने पर स्क्रीन को ${need} MB चाहिए, जो वहाँ जाँची गई ${max} MB सीमा से ज़्यादा है — घड़ी बार-बार रीस्टार्ट हो सकती है। घड़ी पर कुछ नहीं भेजा गया।`,
a8Untested:
"इस फ़ेस में A8 इमेज (cf 14) हैं, जिन्हें Watch Pro 2 पर जाँचा नहीं गया है। इसे एडिटर में खोलें, “Watch Pro 2 के लिए एक्सपोर्ट” चुनें और एक्सपोर्ट की गई फ़ाइल इंस्टॉल करें। घड़ी पर कुछ नहीं भेजा गया।",
etc2OverTested: (need, max) =>
Expand Down Expand Up @@ -631,6 +641,10 @@ const RULES: Rule[] = [
],
[/^this face has a widget of type (\d+), /, (w, m) => w.widgetUnknown(m[1])],
[/^this face has a Watch 3 Pro widget \(type (\d+)\)/, (w, m) => w.widgetUnsupported(m[1])],
[
/^this face has A8 images \(cf 14\), and converted for a Watch Pro 2 a screen needs ([\d.]+) MB, over the ([\d.]+) MB/,
(w, m) => w.a8TooHeavy(m[1], m[2]),
],
lit("a8Untested"),
[
/^this face's ETC2 images need ([\d.]+) MB unpacked on a Watch Pro 2, over the ([\d.]+) MB/,
Expand Down
13 changes: 10 additions & 3 deletions src/lib/modules/device/model/ble.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export const $sizeWarning = createStore<string | null>(null);
// how many images a flash re-encoded to fit the watch (fitForWatch) — null when none; the UI
// words it (device/i18n fitNote)
export const $fitNote = createStore<number | null>(null);
// how many A8/ETC2 images a flash re-encoded for a Watch Pro 2 (fitForWatch) — null when none
export const $convertNote = createStore<number | null>(null);
// the watch a flash went to: $bleInfo resets the moment the link drops, which is before a flash
// cut off by that drop fails — so the outcome reads who it was from here, not from $bleInfo
const $flashWatch = createStore<WatchInfo | null>(null);
Expand Down Expand Up @@ -125,7 +127,7 @@ export const $connecting = connectFx.pending;
const flashFx = createEffect(async ({ bin: file, preview, key, slot, confirmed }: Pending) => {
// every install — editor and marketplace — comes through here, so this is the one gate
const device = watchDevice(watch!.name);
const { bin, compressed } = await fitForWatchOffThread(file, device);
const { bin, compressed, converted } = await fitForWatchOffThread(file, device);

assertFlashable(bin, device);
await assertWatchCompat(bin, device, async () => (await watch!.readWp2())?.stub.version ?? null);
Expand All @@ -140,7 +142,7 @@ const flashFx = createEffect(async ({ bin: file, preview, key, slot, confirmed }
rememberDial(id, name, preview, watch!.serial);
// …and only now does the merged dial list know about it, so refresh it
watch!.mergeDials();
return { id, compressed };
return { id, compressed, converted };
});
export const $flashing = flashFx.pending;
const removeDialFx = createEffect((id: number) => {
Expand Down Expand Up @@ -346,7 +348,12 @@ sample({
fn: ({ compressed }) => compressed || null,
target: $fitNote,
});
reset({ clock: [flashRequested, disconnected], target: $fitNote });
sample({
clock: flashFx.doneData,
fn: ({ converted }) => converted || null,
target: $convertNote,
});
reset({ clock: [flashRequested, disconnected], target: [$fitNote, $convertNote] });

sample({
clock: flashFx.failData,
Expand Down
3 changes: 1 addition & 2 deletions src/lib/modules/editor/core/document/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
// note can't promise what the gate then refuses.
import { buildBin } from "../format";
import { drawnFormats, isUnknownWidget, procWidgets, stockSafe } from "../format/compat";
export { PRO2_CONVERTS } from "../format/compat";
import { toLegacy, type Doc, type Layer } from "./doc";

/** The colour theme's number: a source only a Watch 3 Pro answers. */
export const THEME_SOURCE = 0x99;
/** What the export re-encodes: A8 (not sent to a Watch Pro 2) and ETC2 (stock doesn't show it). */
export const PRO2_CONVERTS = [14, 28];

/**
* `none`: a widget no watch knows. `pro3Only`: one a Watch Pro 2 would boot-loop on.
Expand Down
28 changes: 19 additions & 9 deletions src/lib/modules/editor/core/format/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import type { FaceNode, Resource } from "./raw";
import { TAG, u16 } from "./raw";

/** The stub release that draws types 4..7 on a Watch Pro 2, or null while none has shipped: then
* no Pro 2 gets them and nobody asks for its stub. Set it only once the number is reserved in
* cmf-watch-sdk and tried on a real watch — two branches there have both called themselves 9. */
* no Pro 2 gets them and nobody asks for its stub. Planned as stub 11 (9 is the boot guard, 10 the
* widget templates); set it to 11 only once that release is out and tried on a real watch. */
export const PRO2_FACES_STUB: number | null = null;

/** Decoded bytes a screen is known to load on a Watch Pro 2.
Expand Down Expand Up @@ -119,12 +119,16 @@ export function drawnFormats(screen: FaceNode, resources: Resource[]): Set<numbe
return formats;
}

/** Bytes a screen takes with its ETC2 images unpacked to cf 5, which is how a Watch Pro 2 holds
* them (stub 10 does it on load, FMC's export does it in the file). */
/** The Watch 3 Pro's formats a Watch Pro 2 gets as cf 5: A8 (never sent as it is) and ETC2 (stock
* doesn't draw it). fitForWatch converts them on the way, Export for Watch Pro 2 in a file. */
export const PRO2_CONVERTS = [14, 28];

/** Bytes a screen takes with those formats as cf 5, which is how a Watch Pro 2 holds them (stub
* 10 unpacks ETC2 on load, FMC converts both before they go). */
export const unpackedBytes = (screen: FaceNode, resources: Resource[]) =>
screenBytes(
screen,
resources.map((r) => (r.cf === 28 ? { ...r, cf: 5 } : r)),
resources.map((r) => (PRO2_CONVERTS.includes(r.cf) ? { ...r, cf: 5 } : r)),
);

/**
Expand Down Expand Up @@ -162,13 +166,19 @@ export async function assertWatchCompat(
// stock those images don't show at all
const { screens, resources } = parseBin(bin);

// unknown on a real watch, and no stub converts it. Every resource counts, the thumbnail (the
// face picker draws it there too) and whatever the tree walk can't place: unknown means refused.
// unknown on a real watch, so it never goes as it is: fitForWatch converts it, and what reaches
// this is a face too heavy to convert. Every resource counts, the thumbnail (the face picker
// draws it there too) and whatever the tree walk can't place: unknown means refused.
// ponytail: lift it, or narrow it to the thumbnail, once cf 14 has been seen on a Watch Pro 2.
if (resources.some((r) => r.cf === 14))
if (resources.some((r) => r.cf === 14)) {
const need = Math.max(...screens.map((s) => unpackedBytes(s, resources)));

throw new Error(
"this face has A8 images (cf 14), which haven't been tested on a Watch Pro 2. Open it in the editor, use Export for Watch Pro 2 and install the exported file. Nothing was sent to the watch.",
need > PRO2_TESTED_BYTES
? `this face has A8 images (cf 14), and converted for a Watch Pro 2 a screen needs ${(need / 1e6).toFixed(1)} MB, over the ${(PRO2_TESTED_BYTES / 1e6).toFixed(2)} MB tested there — the watch could restart in a loop. Nothing was sent to the watch.`
: "this face has A8 images (cf 14), which haven't been tested on a Watch Pro 2. Open it in the editor, use Export for Watch Pro 2 and install the exported file. Nothing was sent to the watch.",
);
}

for (const screen of screens) {
const etc2 = drawnFormats(screen, resources).has(28);
Expand Down
Loading
Loading