File tree Expand file tree Collapse file tree 1 file changed +56
-26
lines changed
Expand file tree Collapse file tree 1 file changed +56
-26
lines changed Original file line number Diff line number Diff line change 1111 var S_1 = require ( "Storage" ) ;
1212 var drawTimeout_1 ;
1313 var menuShown_1 = false ;
14- var splits_1 = [ ] ;
14+ var latestGps_1 ;
15+ var splits_1 = S_1 . readJSON ( "pace.json" , 1 ) || [ ] ;
1516 var splitOffset_1 = 0 , splitOffsetPx_1 = 0 ;
1617 var GPS_TIMEOUT_MS_1 = 30000 ;
18+ var drawGpsLvl = function ( l ) {
19+ var _a ;
20+ var gps = latestGps_1 ;
21+ var nsats = ( _a = gps === null || gps === void 0 ? void 0 : gps . satellites ) !== null && _a !== void 0 ? _a : 0 ;
22+ if ( ! gps || ! gps . fix )
23+ g . setColor ( "#FF0000" ) ;
24+ else if ( gps . satellites < 4 )
25+ g . setColor ( "#FF5500" ) ;
26+ else if ( gps . satellites < 6 )
27+ g . setColor ( "#FF8800" ) ;
28+ else if ( gps . satellites < 8 )
29+ g . setColor ( "#FFCC00" ) ;
30+ else
31+ g . setColor ( "#00FF00" ) ;
32+ g . fillRect ( l . x , l . y + l . h - 10 - ( l . h - 10 ) * ( ( nsats > 12 ? 12 : nsats ) / 12 ) , l . x + l . w , l . y + l . h ) ;
33+ } ;
1734 var layout_1 = new Layout_1 ( {
18- type : "v " ,
35+ type : "h " ,
1936 c : [
2037 {
21- type : "txt" ,
22- font : "6x8:2" ,
23- label : "Pace" ,
24- id : "paceLabel" ,
25- pad : 4
26- } ,
27- {
28- type : "txt" ,
29- font : "Vector:40" ,
30- label : "" ,
31- id : "pace" ,
32- halign : 0
33- } ,
34- {
35- type : "txt" ,
36- font : "6x8:2" ,
37- label : "Time" ,
38- id : "timeLabel" ,
39- pad : 4
38+ type : "custom" ,
39+ render : drawGpsLvl ,
40+ filly : 1 ,
41+ width : 10 ,
42+ bgCol : g . theme . bg ,
4043 } ,
4144 {
42- type : "txt" ,
43- font : "Vector:40" ,
44- label : "" ,
45- id : "time" ,
46- halign : 0
45+ type : "v" ,
46+ c : [
47+ {
48+ type : "txt" ,
49+ font : "6x8:2" ,
50+ label : "Pace" ,
51+ id : "paceLabel" ,
52+ pad : 4
53+ } ,
54+ {
55+ type : "txt" ,
56+ font : "Vector:40" ,
57+ label : "" ,
58+ id : "pace" ,
59+ halign : 0
60+ } ,
61+ {
62+ type : "txt" ,
63+ font : "6x8:2" ,
64+ label : "Time" ,
65+ id : "timeLabel" ,
66+ pad : 4
67+ } ,
68+ {
69+ type : "txt" ,
70+ font : "Vector:40" ,
71+ label : "" ,
72+ id : "time" ,
73+ halign : 0
74+ } ,
75+ ]
4776 } ,
4877 ]
4978 } , {
207236 Bangle . loadWidgets ( ) ;
208237 Bangle . drawWidgets ( ) ;
209238 Bangle . setGPSPower ( 1 , "pace" ) ;
239+ Bangle . on ( "GPS" , function ( gps ) { return latestGps_1 = gps ; } ) ;
210240 g . clearRect ( Bangle . appRect ) ;
211241 draw_1 ( ) ;
212242}
You can’t perform that action at this time.
0 commit comments