File tree Expand file tree Collapse file tree 1 file changed +63
-25
lines changed
Expand file tree Collapse file tree 1 file changed +63
-25
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const S = require("Storage");
1515
1616let drawTimeout : TimeoutId | undefined ;
1717let menuShown = false ;
18+ let latestGps : GPSFix | undefined ;
1819
1920type Dist = number & { brand : 'dist' } ;
2021type Time = number & { brand : 'time' } ;
@@ -29,36 +30,72 @@ let splitOffset = 0, splitOffsetPx = 0;
2930
3031const GPS_TIMEOUT_MS = 30000 ;
3132
33+ const drawGpsLvl = ( l : Layout . RenderedHierarchy ) => {
34+ const gps = latestGps ;
35+ const nsats = gps ?. satellites ?? 0 ;
36+
37+ if ( ! gps || ! gps . fix )
38+ g . setColor ( "#FF0000" ) ;
39+ else if ( gps . satellites < 4 )
40+ g . setColor ( "#FF5500" ) ;
41+ else if ( gps . satellites < 6 )
42+ g . setColor ( "#FF8800" ) ;
43+ else if ( gps . satellites < 8 )
44+ g . setColor ( "#FFCC00" ) ;
45+ else
46+ g . setColor ( "#00FF00" ) ;
47+
48+ g . clearRect ( l . x , l . y , l . x + l . w , l . y + l . h ) ;
49+
50+ g . fillRect (
51+ l . x ,
52+ l . y + l . h - 10 - ( l . h - 10 ) * ( ( nsats > 12 ? 12 : nsats ) / 12 ) ,
53+ l . x + l . w ,
54+ l . y + l . h
55+ ) ;
56+ } ;
57+
3258const layout = new Layout ( {
33- type : "v " ,
59+ type : "h " ,
3460 c : [
3561 {
36- type : "txt" ,
37- font : "6x8:2" ,
38- label : "Pace" ,
39- id : "paceLabel" ,
40- pad : 4
41- } ,
42- {
43- type : "txt" ,
44- font : "Vector:40" ,
45- label : "" ,
46- id : "pace" ,
47- halign : 0
48- } ,
49- {
50- type : "txt" ,
51- font : "6x8:2" ,
52- label : "Time" ,
53- id : "timeLabel" ,
54- pad : 4
62+ type : "custom" ,
63+ render : drawGpsLvl ,
64+ filly : 1 ,
65+ width : 10 ,
5566 } ,
5667 {
57- type : "txt" ,
58- font : "Vector:40" ,
59- label : "" ,
60- id : "time" ,
61- halign : 0
68+ type : "v" ,
69+ c : [
70+ {
71+ type : "txt" ,
72+ font : "6x8:2" ,
73+ label : "Pace" ,
74+ id : "paceLabel" ,
75+ pad : 4
76+ } ,
77+ {
78+ type : "txt" ,
79+ font : "Vector:40" ,
80+ label : "" ,
81+ id : "pace" ,
82+ halign : 0
83+ } ,
84+ {
85+ type : "txt" ,
86+ font : "6x8:2" ,
87+ label : "Time" ,
88+ id : "timeLabel" ,
89+ pad : 4
90+ } ,
91+ {
92+ type : "txt" ,
93+ font : "Vector:40" ,
94+ label : "" ,
95+ id : "time" ,
96+ halign : 0
97+ } ,
98+ ]
6299 } ,
63100 ]
64101} , {
@@ -262,6 +299,7 @@ Bangle.on('tap', e => {
262299Bangle . loadWidgets ( ) ;
263300Bangle . drawWidgets ( ) ;
264301Bangle . setGPSPower ( 1 , "pace" ) ;
302+ Bangle . on ( "GPS" , gps => latestGps = gps ) ;
265303
266304g . clearRect ( Bangle . appRect ) ;
267305draw ( ) ;
You can’t perform that action at this time.
0 commit comments