Introduces watch/, a real Pebble watchapp (built via pebble build) that
build / build (push) Successful in 30s

shows the daily tarot/astrology reading on-device: persistence, reading
computation, and UI screens, driven by the existing engine/interpreter
code linked in unchanged where possible.

Required engine-side changes to make that linking work:
- A compact low-precision ephemeris (lowprec_ephemeris.c) replacing the
  vendored ~127KB Astronomy Engine, which doesn't fit the watch's ~64KB
  app budget.
- Hand-rolled sqrt/atan2/sin/cos replacements for that ephemeris and
  astro.c's Ascendant calculation - Pebble's statically-linked libm
  hard-faults on real hardware under this app's -fPIE link for all four.
- narrative.c/guidance.c refactored from FILE*/fprintf onto snprintf-
  based buffers, since Pebble's SDK blocks fprintf at compile time.
This commit is contained in:
ml
2026-07-14 17:10:22 +02:00
parent d9b6e2889b
commit 1a654da3e9
44 changed files with 1920 additions and 182 deletions
+24 -6
View File
@@ -136,8 +136,11 @@ static const char *narrative_field(const char *slug, const char *field, const ch
return i18n_get(key, fallback);
}
void narrative_print(FILE *out, const char *indent, const Aspect *aspect,
void narrative_write(char *buf, size_t buf_size, const char *indent, const Aspect *aspect,
int transiting_house) {
if (buf_size == 0) return;
buf[0] = '\0';
const TransitNarrative *n = &k_narratives[aspect->transiting_planet];
const char *base = narrative_field(n->slug, "base", n->base);
@@ -147,7 +150,15 @@ void narrative_print(FILE *out, const char *indent, const Aspect *aspect,
if (base[0] == '\0' && extra[0] == '\0') return;
fprintf(out, "%s", indent);
/* Chained snprintf() calls, each bounds-checked against the running
* length before the next one runs - never fprintf/sprintf/vsnprintf,
* all of which Pebble's SDK blocks at compile time (see narrative.h's
* doc comment). Once `len` reaches buf_size (truncated), every
* subsequent call is skipped rather than computing buf_size - len,
* which would underflow. */
size_t len = (size_t)snprintf(buf, buf_size, "%s", indent);
if (len >= buf_size) return;
if (transiting_house >= 1 && transiting_house <= 12) {
char house_key[24];
snprintf(house_key, sizeof house_key, "narrative.house.%d", transiting_house);
@@ -156,9 +167,16 @@ void narrative_print(FILE *out, const char *indent, const Aspect *aspect,
char frame[256];
snprintf(frame, sizeof frame, i18n_get("narrative.house_frame", "In matters of %s (house %d)."),
area, transiting_house);
fprintf(out, "%s ", frame);
len += (size_t)snprintf(buf + len, buf_size - len, "%s ", frame);
if (len >= buf_size) return;
}
if (base[0] != '\0') fprintf(out, "%s", base);
if (extra[0] != '\0') fprintf(out, "%s%s", base[0] != '\0' ? " " : "", extra);
fprintf(out, "\n");
if (base[0] != '\0') {
len += (size_t)snprintf(buf + len, buf_size - len, "%s", base);
if (len >= buf_size) return;
}
if (extra[0] != '\0') {
len += (size_t)snprintf(buf + len, buf_size - len, "%s%s", base[0] != '\0' ? " " : "", extra);
if (len >= buf_size) return;
}
snprintf(buf + len, buf_size - len, "\n");
}