Introduces watch/, a real Pebble watchapp (built via pebble build) that
build / build (push) Successful in 30s
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:
@@ -0,0 +1,50 @@
|
||||
#include <pebble.h>
|
||||
|
||||
#include "../../../engine/src/i18n.h"
|
||||
#include "app_message.h"
|
||||
#include "config.h"
|
||||
#include "i18n_tables.h"
|
||||
#include "reading_state.h"
|
||||
#include "ui_menu_window.h"
|
||||
#include "ui_text_window.h"
|
||||
|
||||
static WatchConfig s_config;
|
||||
|
||||
static void show_setup_required(void) {
|
||||
text_window_push(i18n_get("ui.setup_required_title", "Setup Required"),
|
||||
i18n_get("ui.setup_required_body",
|
||||
"Open this app's settings from the Pebble mobile app to add your "
|
||||
"birth details, then reopen Deck in a Dash."));
|
||||
}
|
||||
|
||||
static void on_config_updated(const WatchConfig *cfg) {
|
||||
bool was_configured = s_config.configured;
|
||||
s_config = *cfg;
|
||||
watch_i18n_load(s_config.lang);
|
||||
|
||||
if (!s_config.configured) return;
|
||||
|
||||
reading_state_recompute(&s_config.birth);
|
||||
if (was_configured) {
|
||||
menu_window_reload();
|
||||
} else {
|
||||
menu_window_push();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
config_load(&s_config);
|
||||
watch_i18n_load(s_config.lang);
|
||||
app_message_init(on_config_updated);
|
||||
|
||||
if (s_config.configured) {
|
||||
reading_state_recompute(&s_config.birth);
|
||||
menu_window_push();
|
||||
} else {
|
||||
show_setup_required();
|
||||
}
|
||||
|
||||
app_event_loop();
|
||||
|
||||
menu_window_deinit();
|
||||
}
|
||||
Reference in New Issue
Block a user