aboutsummaryrefslogtreecommitdiff
path: root/spike/settings/source/SpikeApp.mc
blob: c5adcb2dcb508e98a15f7ecc394720ee69a18d82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Author:  cirakg & claude ai
// Summary: Settings spike entry point: analyses every setting on start and on each change, and writes a status back.
//
// The spike measures what Garmin doesn't document (README section 16, M1):
// how long a text setting may be, which characters survive, whether values
// the watch writes back reach the phone, and when onSettingsChanged fires.
// It is a throwaway app with its own app id; nothing here is reused by OTP
// Wallet except the measured numbers.

import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;

class SpikeApp extends Application.AppBase {

    // The analysis shown on screen, refreshed on start and on every change.
    var report as SpikeReport;

    function initialize() {
        AppBase.initialize();
        report = new SpikeReport();
    }

    // Read the values the watch already has (from the last sync).
    function onStart(state as Dictionary?) as Void {
        report.analyseOnStart();
        DebugSelfTest.run(self);
    }

    function onStop(state as Dictionary?) as Void {
    }

    function getInitialView() as [Views] or [Views, InputDelegates] {
        var view = new SpikeView(report);
        return [view, new SpikeDelegate(view)];
    }

    // Called when you save the settings on the phone while the app runs.
    function onSettingsChanged() as Void {
        report.settingsChanged();
        WatchUi.requestUpdate();
    }
}