summaryrefslogtreecommitdiff
path: root/spike/settings/source/SpikeView.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-18 23:44:18 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-18 23:44:18 +0200
commitac60fb060414261935ac5e158b26b34e211e1e06 (patch)
treea8f97e1c4b0bf8f1b433d3e8f33a5d30994e7c58 /spike/settings/source/SpikeView.mc
parent93aa7e3aa291f3328cf34a5a2f86172f41d0affd (diff)
feat(spike): add the M1 settings spike app and make targets
A separate throwaway app (own app ID, no permissions) that shows what the Garmin Connect app delivers per settings field and writes values back, to measure the undocumented settings limits on the real phone and watch. Includes length-marked test strings, `make spike` / `make spike-sim`, `make vectors`, and step-by-step instructions in docs/SETTINGS_SPIKE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'spike/settings/source/SpikeView.mc')
-rw-r--r--spike/settings/source/SpikeView.mc53
1 files changed, 53 insertions, 0 deletions
diff --git a/spike/settings/source/SpikeView.mc b/spike/settings/source/SpikeView.mc
new file mode 100644
index 0000000..68bacc7
--- /dev/null
+++ b/spike/settings/source/SpikeView.mc
@@ -0,0 +1,53 @@
+// Author: cirakg & claude ai
+// Summary: Scrollable text screen showing the spike's measurements.
+//
+// Lines come from SpikeReport. The first visible line moves with
+// SpikeDelegate (UP/DOWN buttons or swipes); text stays in the middle band of
+// round screens so nothing is cut off at the top or bottom.
+
+import Toybox.Graphics;
+import Toybox.Lang;
+import Toybox.WatchUi;
+
+class SpikeView extends WatchUi.View {
+
+ // Share of the screen height left free at the top and at the bottom.
+ private const MARGIN_FRACTION = 0.14;
+
+ private var _report as SpikeReport;
+ private var _firstLine as Number = 0;
+
+ function initialize(report as SpikeReport) {
+ View.initialize();
+ _report = report;
+ }
+
+ // Move the first visible line by delta lines, staying within the text.
+ function scroll(delta as Number) as Void {
+ var last = _report.lines.size() - 1;
+ _firstLine += delta;
+ if (_firstLine > last) {
+ _firstLine = last;
+ }
+ if (_firstLine < 0) {
+ _firstLine = 0;
+ }
+ WatchUi.requestUpdate();
+ }
+
+ function onUpdate(dc as Graphics.Dc) as Void {
+ dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
+ dc.clear();
+ var font = Graphics.FONT_XTINY;
+ var lineHeight = dc.getFontHeight(font);
+ var top = (dc.getHeight() * MARGIN_FRACTION).toNumber();
+ var bottom = dc.getHeight() - top;
+ var x = dc.getWidth() / 2;
+ var y = top;
+ var lines = _report.lines;
+ for (var i = _firstLine; i < lines.size() && y + lineHeight <= bottom; i++) {
+ dc.drawText(x, y, font, lines[i], Graphics.TEXT_JUSTIFY_CENTER);
+ y += lineHeight;
+ }
+ }
+}