7
7
*/
8
8
9
9
import Toybox .Application ;
10
+ import Toybox .Application .Storage ;
10
11
import Toybox .BluetoothLowEnergy ;
11
12
import Toybox .Lang ;
12
13
import Toybox .WatchUi ;
13
14
import Toybox .System ;
14
15
15
- (:debug) function debug ( val as String or Char or Number ) as Void {
16
- switch ( val ) {
17
- case instanceof Lang . Number :
18
- System . println ( val as Number );
19
- break ;
20
- case instanceof Lang . Char :
21
- System . print ( val as Char );
22
- break ;
23
- case instanceof Lang . String :
24
- System . println ( val as String );
25
- break ;
16
+ var UserSettings as Array = [ 10 , 3 , 6 , 7 , false , false , false ];
17
+
18
+ // settings adjustable by user in garmin mobile app / garmin express
19
+ enum {
20
+ DisplayField1 ,
21
+ DisplayField2 ,
22
+ DisplayField3 ,
23
+ DisplayField4 ,
24
+ BattCalcMethod ,
25
+ FitLogging ,
26
+ DeviceLock
26
27
}
27
- }
28
28
29
29
// ! This data field app uses the BLE data interface of a forumslader.
30
30
// ! The field will pair with the first Forumslader it encounters and will
31
31
// ! show up to 4 user selectable values every 1 second in a simpledatafield.
32
32
class ForumsladerApp extends Application .AppBase {
33
33
34
34
private var
35
- _profileManager as ProfileManager ? ,
36
35
_bleDelegate as ForumsladerDelegate ? ,
37
36
_deviceManager as DeviceManager ? ,
38
37
_dataManager as DataManager ? ;
@@ -47,12 +46,10 @@ private var
47
46
public function onStart (state as Dictionary ?) as Void {
48
47
// debug("--- started ---");
49
48
getUserSettings ();
50
- _profileManager = new $ .ProfileManager ();
51
49
_dataManager = new $ .DataManager ();
52
50
_bleDelegate = new $ .ForumsladerDelegate ();
53
- _deviceManager = new $ .DeviceManager (_bleDelegate , _profileManager , _dataManager );
51
+ _deviceManager = new $ .DeviceManager (_bleDelegate , _dataManager );
54
52
BluetoothLowEnergy .setDelegate (_bleDelegate as ForumsladerDelegate );
55
- (_profileManager as ProfileManager ).registerProfiles ();
56
53
(_deviceManager as DeviceManager ).startScan ();
57
54
}
58
55
@@ -61,7 +58,6 @@ private var
61
58
public function onStop (state as Dictionary ?) as Void {
62
59
_deviceManager = null ;
63
60
_bleDelegate = null ;
64
- _profileManager = null ;
65
61
_dataManager = null ;
66
62
// debug("--- stopped ---");
67
63
}
@@ -80,4 +76,34 @@ private var
80
76
getUserSettings ();
81
77
WatchUi .requestUpdate ();
82
78
}
79
+
80
+ // ! read user settings from GCM properties in UserSettings array
81
+ function getUserSettings () as Void {
82
+ $ .UserSettings [$ .DisplayField1 ] = Application .Properties .getValue (" UserSetting1" ) as Number ;
83
+ $ .UserSettings [$ .DisplayField2 ] = Application .Properties .getValue (" UserSetting2" ) as Number ;
84
+ $ .UserSettings [$ .DisplayField3 ] = Application .Properties .getValue (" UserSetting3" ) as Number ;
85
+ $ .UserSettings [$ .DisplayField4 ] = Application .Properties .getValue (" UserSetting4" ) as Number ;
86
+ $ .UserSettings [$ .BattCalcMethod ] = Application .Properties .getValue (" BatteryCalcMethod" ) as Boolean ;
87
+ $ .UserSettings [$ .FitLogging ] = Application .Properties .getValue (" FitLogging" ) as Boolean ;
88
+ $ .UserSettings [$ .DeviceLock ] = Application .Properties .getValue (" DeviceLock" ) as Boolean ;
89
+ if ($ .UserSettings [$ .DeviceLock ] == false ) {
90
+ Storage .deleteValue (" MyDevice" );
91
+ }
92
+ // debug("User Settings: " + $.UserSettings.toString());
93
+ }
94
+
95
+ (:debug ) function debug (val as String or Char or Number ) as Void {
96
+ switch (val ) {
97
+ case instanceof Lang .Number :
98
+ System .println (val as Number );
99
+ break ;
100
+ case instanceof Lang .Char :
101
+ System .print (val as Char );
102
+ break ;
103
+ case instanceof Lang .String :
104
+ System .println (val as String );
105
+ break ;
106
+ }
107
+ }
108
+
83
109
}
0 commit comments