forked from MrJordanRoth/NS2Win
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NS2Win.ini
649 lines (595 loc) · 69.8 KB
/
NS2Win.ini
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
[Rainmeter]
; The Update option in the [Rainmeter] section controls how often in milliseconds a skin should update the measures and meters.
; By default, Update=1000 (=1000 ms = 1 second)
Update=1000
; This enables diplay and removal of the "Settings Button" on mouseover
MouseOverAction=[!SetOption MeterSettingsButton ImageAlpha 255][!UpdateMeter "MeterSettingsButton"]#RawSet#[!Redraw]
MouseLeaveAction=[!SetOption MeterSettingsButton ImageAlpha 0][!UpdateMeter "MeterSettingsButton"]#RawUnset#[!Redraw]
MiddleMouseUpAction=!Refresh
; This shows "Change NS2Win Settings" in the skin's context menu
ContextAction=["#ROOTCONFIGPATH#\UserVariables.inc"]
ContextTitle=Change +NS2Win Settings+
; This gives a greyish transparent background: Deprecated since using "Solid background2" with rounded edges, adapted from SilverAzide Gadgets
;BackgroundMode=2
;SolidColor=5,5,5,220
DynamicWindowSize=1
; Using AccurateText=1 gives more blurry text and shifts text by a few pixels, doesn't look good!
AccurateText=0
; Added to ensure meter Refresh after wakeup from sleeping/locked system: probably a fix for the "5min synched polling" variant not needed for 1min standard code
OnWakeAction=[!SetOption meterTimeDifferenceMinutes Text "5s to Refresh"][!Delay 5000][!Refresh]
; This is limiting the total skin background height/width including scale factor, do not change here!
SkinHeight=(#BgHeight# * #Scale#)
SkinWidth=(#BgWidth# * #Scale#)
[Metadata]
Name=NS2Win
Author=Marco Krueger (based on Jordan Roth's initial release V1.0.0)
Information=Displays your current Nightscout glucose with delta, trend direction and IOB+COB via the PEBBLE api incl. optional authentification with token; api call firing "every 60s" and configuration settings in UserVariables.inc
License=Creative Commons Attribution-NonCommercial-ShareAlike 4.0
; Original V1.0.0 by Jordan Roth
; Update V1.1.0 to 1.1.2 @2022-10-05 to 10-09 MK
; Note: Original pebble API call only worked with --> AUTH_DEFAULT_ROLES="readable", thus was not usable with: export AUTH_DEFAULT_ROLES="denied"
; Added Nigtscout token functionality for enabling using secure AUTH_DEFAULT_ROLES="denied" nightscout configurations
; Modified [meterDeltaDirection] with additional code split in [measure]-section to display positive delta values with leading "+"
; Removed [cUpdate] section doing a !Refresh every minute (with logfile entry!); instead using UpdateRate=60 in the Webparser section, same effect but "clean solution"
; Removed [MeasureMinutes2Milliseconds] incorporated directly into StaleData formula and DynamicVariable / !Redraw improvements; preparation for 5 min event driven api call
; Update V1.2.0 @2022-10-12 MK
; Added X min ago display and various code simplifications/improvements incl. timezone/daylightsavings client vs UTC servertime delta
; Added X.X min "ticking" time difference last glucose on server vs. client time as preparation for 5 min polling
; Various improvements from first 5 min polling attempts (1.1.5a) but reverted to 1 min polling due stability issues, Revision set to 1.2.0
; Remaining improvement potential: Sync Webparser call via Trigger //IfTrueAction2=[!CommandMeasure MeasureSite "Update"]// if time delta >5.X <5.5 mins
; Update V1.2.5 @2022-10-15 MK
; Fixed IfCondition3=CalcGlucoseDelta = 0 to make sure "delta 0" is colored grey and NOT red or green, now all conditions are covered
; Fixed various color issues e.g. "lucky 100" rainbow color not going away and fixed display of ticking minutes with more than 2 digits
; Added "Solid background2" with rounded edges for the skin, adapted from SilverAzide Gadgets 7.4.0 suite and removed BackgroundMode=2 SolidColor
; Update V1.2.6 @2022-10-29 MK -- release uploaded to https://github.com/emp-00/NS2Win/
; Added calculation of "sum of last 3 deltas" to calculate own trend arrow and removed [MeasureDeltaDirection] displaying mostly "Flat" due to xDrip/NS-bug
; Update V1.3.0 @2022-11-26 MK -- release uploaded to https://github.com/emp-00/NS2Win/
; Added IOB and COB to RegExp and added display of these two values with two additional meters, total gadget width increased accordingly
; Fixed issue by adding [!SetVariable GlucoseDelta0+1+2 "0"] bang to IfCondition=MeasureTimeDifferenceMinutes>#StaleGlucoseAlertMinutes# deleting last deltas before signal loss
; Changed the ticking time display from decimal e.g. 3.8 min to "3:50" with modulus/floor calcs; can be easily adjusted to rounding to e.g 15 secs if liked better
; Improved WebParser RegExp robustness for pebble API: using look-ahead assertion sub-string functionality, now working with different NS configurations e.g. without COB/IOB
; Added user specific settings file "Uservariables.inc", nightscout server URL/token, alarm+arrow thresholds, colors and skin scale factor (right click -> Change NS2Win settings)
; Added "Settings button" only showing in left top corner when hovering over the skin, adapted from SilverAzide's Gadgets 7.4.0 suite
; Added option to configure color of the "Ticking Time" meter in user settings and thus if desired, this meter can be disabled by setting the color to the background color
; Added automatic error message display with separate meter and [ErrorCounter] measure, separately for Nightscout URL/token misconfiguration or network error/dropouts
; Added Tooltips for normal running mode and for error message meter showing Nightscout URL/Token and instructions how to change settings
; Compressed total skin width by changeover to Calibri font, changed font sizes and pixel-by-pixel optimized overall layout
; Added full skin scaling functionality e.g. for high dpi screens with scale factor e.g. 1.55 = 155% with TransformationMatrix styles (thanks to Xanxi)
Version=1.3.0
[Variables]
; This includes the main user settings variables such as the Nightscout URL, token information, color alarm thresholds and more
@Include=#ROOTCONFIGPATH#\UserVariables.inc
; Variables declared here are used later on between two # characters (e.g. #MyVariable#)
; Variables for total skin width/height and "Solid background2" with rounded edges, adapted from SilverAzide Gadgets 7.4.0 suite
BgWidth=128
BgHeight=55
; Variables for storing last 3 delta values, initialization only, do not change: 0=current, 1=latest, 2=2nd last
GlucoseDelta0=0
GlucoseDelta1=0
GlucoseDelta2=0
; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------
[ErrorCounter]
; Only if switched on, this increases with every Update rate, e.g. 1000ms = 1s --> used to delay network/nightscout error message
Measure=Calc
Formula=(ErrorCounter) + 1
; ** NETWORK Dropout Error
IfCondition=(ErrorCounter >1) && (MeasureCurrentTime > 0)
; ShowMeter bang displays error message, the ErrorMeter must be actively switched off when the Webparser finishes normally
IfTrueAction=[!ShowMeter MeterError][!SetOption MeterError Text "** NETWORK **#CRLF#Connection#CRLF#ERROR"][!Redraw][!HideMeter MeterTimeDifferenceMinutes][!HideMeter MeterClientToGlucoseTimeDeltaMinutes][!HideMeter MeterGlucose][!HideMeter MeterDeltaDirection][!HideMeter MeterGlucoseDelta][!HideMeter SeparatorV1][!HideMeter MeterIOB][!HideMeter MeterCOB]
IfFalseAction=[!HideMeter MeterError]
; ** Nightcout URL/Token Error: MeasureCurrentTime=0 means not one single successful server read was achieved yet, thus this must be first time skin start!
IfCondition2=(ErrorCounter >1) && (MeasureCurrentTime = 0)
; ShowMeter bang displays error message, the ErrorMeter must be actively switched off when the Webparser finishes normally
IfTrueAction2=[!ShowMeter MeterError][!SetOption MeterError Text "* Nightscout *#CRLF#URL or Token#CRLF#Settings ERROR"][!Redraw][!HideMeter MeterTimeDifferenceMinutes][!HideMeter MeterClientToGlucoseTimeDeltaMinutes][!HideMeter MeterGlucose][!HideMeter MeterDeltaDirection][!HideMeter MeterGlucoseDelta][!HideMeter SeparatorV1][!HideMeter MeterIOB][!HideMeter MeterCOB]
IfFalseAction2=[!HideMeter MeterError]
;[!ShowMeter MeterTimeDifferenceMinutes][!ShowMeter MeterClientToGlucoseTimeDeltaMinutes][!ShowMeter MeterGlucose][!ShowMeter MeterDeltaDirection][!ShowMeter MeterGlucoseDelta][!ShowMeter SeparatorV1][!ShowMeter MeterIOB][!ShowMeter MeterCOB]
Disabled=1
[MeasureSite]
; This is the WebParser pulling the data from Nightscout via the PEBBLE api
Measure=WebParser
; Documentation info: With skin update of 1000 ms (Update=1000 in above [Rainmeter] section) and a default UpdateRate of 600 on the measure,
; a WebParser parent measure will access the remote resource every 10 minutes: 1000ms equals 1s, times 600 equals 600s, which equals 10 minutes.
; "UpdateRate=60" <-- equals every 1 minute; thus this executes the api call every 1 minute
; "UpdateRate=-1" <-- That means it will fire one time only, the first time the skin loads, then never again. Needed for synched 5 min polling.
UpdateRate=60
URL=#NightScoutURL#pebble#NightScoutToken#
; Info MK: Changed this call to allow AUTH_DEFAULT-ROLES="denied" --> added NightScoutToken string set in Variables
; This exemplary call works with token (set up via Admin Tools): https://[YOUR-NIGHTSCOUT-URL]/pebble?token=[YOUR-NIGHTSCOUT-TOKEN]
;
; Documentation info: RexExp format taken from RainRegExp help tab:
; FORMAT:RegExp=(?siU)search1(.*)endsearch1.*search2(.*)endsearch2
;
; Example pebble api output1: {"status":[{"now":1667747473294}],"bgs":[
; {"sgv":"131","trend":4,"direction":"Flat","datetime":1667747202471,"bgdelta":5,"battery":"96","iob":"6.86","bwp":"-5.11","bwpo":-88,"cob":57.8}],"cals":[]}
; Example pebble api output2: {"status":[{"now":1668296148640}],"bgs":[{"sgv":"109","trend":4,"direction":"Flat","datetime":1668295949000,"bgdelta":-2}],"cals":[]}
; ***
; New with IOB/COB: Note that "cob" strangely ends with "}", therefore all RegExp "stop strings" were consistently changed to [}",] -> stopping on only of these 3 characters.
; Issue: in case iob/cob plugins are not available the old RexExp would fail with "Error = 1: Could not match all searches" !
; Solution: Look-ahead assertions, see below incl. sub-string carveout documentation --> Yeah! Now this RegExp should be working with "all" nightscout configurations!!
RegExp=(?siU)(?(?=.*now":).*now":(.*)[,"}])(?(?=.*sgv":").*sgv":"(.*)[,"}])(?(?=.*direction":").*direction":"(.*)[,"}])(?(?=.*datetime":).*datetime":(.*)[,"}])(?(?=.*bgdelta":).*bgdelta":(.*)[,"}])(?(?=.*iob":").*iob":"(.*)[,"}])(?(?=.*cob":).*cob":(.*)[,"}])
OnConnectErrorAction=[!EnableMeasure ErrorCounter]
; Output StringIndex
; 1 - Current Server Timestamp
; 2 - Glucose = BG value e.g. 104 mg/dl
; 3 - Direction (Text)
; 4 - Last Glucose Timestamp
; 5 - BG Delta (Number) e.g. -3 or 5; the "+" sign is not returned by the api
; 6 - IOB = Insulin on Board, e.g. 2.3 units
; 7 - COB = Carbs on Board, e.g. 54 grams
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Rainmeter documentation for look-ahead RegExp functionality:
; RegExp regular with fixed number of Strings, will fail if one or more are missing!
; RegExp="(?siU)<Item>.*<Name>(.*)</Name>.*<Item>.*<Name>(.*)</Name>.*<Item>.*<Name>(.*)</Name>.*"
; RegExp with look-ahead assertions
; RegExp="(?siU)(?(?=.*<Item>).*<Name>(.*)</Name>)(?(?=.*<Item>).*<Name>(.*)</Name>)(?(?=.*<Item>).*<Name>(.*)</Name>)"
; +++++++++++++++++++++++++IMPLEMENTATION START+++++++++++++++++++++++
; RegExp without look-ahead assertions:
;RegExp=(?siU)now":(.*)[,"}].*sgv":"(.*)[,"}].*trend":(.*)[,"}].*direction":"(.*)[,"}].*datetime":(.*)[,"}].*bgdelta":(.*)[,"}].*iob":"(.*)[,"}].*cob":(.*)[,"}]
; Substring documentation with converted look-head substrings:
;.*now":
;.*now":(.*)[,"}]
;(?(?=.*now":).*now":(.*)[,"}])
;.*sgv":"
;.*sgv":"(.*)[,"}]
;(?(?=.*sgv":").*sgv":"(.*)[,"}])
;.*direction":"
;.*direction":"(.*)[,"}]
;(?(?=.*direction":").*direction":"(.*)[,"}])
;.*datetime":
;.*datetime":(.*)[,"}]
;(?(?=.*datetime":).*datetime":(.*)[,"}])
;.*bgdelta":
;.*bgdelta":(.*)[,"}]
;(?(?=.*bgdelta":).*bgdelta":(.*)[,"}])
;.*iob":"
;.*iob":"(.*)[,"}]
;(?(?=.*iob":").*iob":"(.*)[,"}])
;.*cob":
;.*cob":(.*)[,"}]
;(?(?=.*cob":).*cob":(.*)[,"}])
; +++++++++++++++++++++++++IMPLEMENTATION END+++++++++++++++++++++++++
; *** Old RegExp only for history documentation purposes ***
;
;##Working with IOB/COB, but not for everybody:
;RegExp=(?siU)now":(.*)}],.*sgv":"(.*)",.*trend":(.*),.*direction":"(.*)",.*datetime":(.*),.*bgdelta":(.*),.*iob":"(.*)",.*cob":(.*)}
;##Old working RegExp without IOB/COB:
;RegExp=(?siU)now":(.*)}],.*sgv":"(.*)",.*trend":(.*),.*direction":"(.*)",.*datetime":(.*),.*bgdelta":(.*),
;
;##2022-10-14: This does not work: Error Text is displayed "on error" but this does not revert to normal after connection is back up!! Text remains!
;##OnConnectErrorAction=[!SetOption meterTimeDifferenceMinutes Text "!Network!"][!SetOption meterGlucose Text "-!-"][!SetOption meterGlucoseDelta Text "*"][!SetOption meterDeltaDirection Text "*"]
;##OnRegExpErrorAction=[!SetOption meterTimeDifferenceMinutes Text "!Nightscout!"][!SetOption meterGlucose Text "-!-"][!SetOption meterGlucoseDelta Text "*"][!SetOption meterDeltaDirection Text "*"]
;FinishAction=[!Log "WebParser API update call finished"]
[MeasureCurrentTime]
; Current nightscout server timestamp
Measure=WebParser
URL=[MeasureSite]
StringIndex=1
; If MeasureCurrentTime =0 ==> no nightscout data is received: switching on ErrorCounter to display error message after a delay of e.g. 2 seconds to avoid initialization error
IfCondition=(MeasureCurrentTime = 0)
IfTrueAction=[!EnableMeasure ErrorCounter]
OnChangeAction=[!ShowMeter MeterTimeDifferenceMinutes][!ShowMeter MeterClientToGlucoseTimeDeltaMinutes][!ShowMeter MeterGlucose][!ShowMeter MeterDeltaDirection][!ShowMeter MeterGlucoseDelta][!ShowMeter SeparatorV1][!ShowMeter MeterIOB][!ShowMeter MeterCOB][!HideMeter MeterError][!DisableMeasure ErrorCounter][!Redraw]
; DynamicVariables=1 required for OnChangeAction to work properly
DynamicVariables=1
[MeasureGlucoseTime]
; Last received nightscout glucose value timestamp
Measure=WebParser
URL=[MeasureSite]
StringIndex=4
; This stores the last 3 GlucoseDelta's in 3 variables and pushes one down **only when a new BG value is received** and avoiding loss due to unchanged MeasureGlucoseDelta when OnChangeAction there!
OnChangeAction=[!SetVariable GlucoseDelta2 "#GlucoseDelta1#"][!SetVariable GlucoseDelta1 "#GlucoseDelta0#"][!SetVariable GlucoseDelta0 "[MeasureGlucoseDelta]"]
; DynamicVariables=1 required for OnChangeAction to work properly
DynamicVariables=1
[MeasureGlucose]
; Last received nightscout glucose value in mg/dl
Measure=WebParser
URL=[MeasureSite]
StringIndex=2
; ***Change BG color to Red
IfCondition=MeasureGlucose < #LowGlucoseAlert#
IfTrueAction=[!SetOption meterGlucose FontColor #ColorRed#]
; ***Change BG color to Orange
IfCondition2=MeasureGlucose > #HighGlucoseAlert#
IfTrueAction2=[!SetOption meterGlucose FontColor #ColorOrange#]
; ***Change BG color to Colorful-Rainbow-Gradient @100
IfCondition3=MeasureGlucose = 100
IfTrueAction3=[!SetOption meterGlucose InlineSetting "GradientColor | 180 | 255,0,0,255 ; 0.0 | 0,255,0,255 ; 0.5 | 0,0,255,255 ; 1.0"]
; ***Change BG color to White if "in-range" AND not @100
IfCondition4=((MeasureGlucose >= #LowGlucoseAlert#) && (MeasureGlucose <= #HighGlucoseAlert#) && (MeasureGlucose <> 100))
IfTrueAction4=[!SetOption meterGlucose FontColor #ColorWhite#][!SetOption meterGlucose InlineSetting ""]
OnUpdateAction=[!UpdateMeter meterGlucose][!Redraw]
; Added OnUpdateAction to make sure the colors are updated saving a [!Redraw] at every single condition;
; Added Condition4 to set color to White if "in-range", now we have 4 explicit conditions for all cases and [InlineSetting ""] clears rainbow colors!
[CalcAverageDeltaDirection]
; This is my own "trend arrow" calculation based on the sum of the last 3 delta values, using 3 threshold variables coming from UserVariables.inc settings (and Calc measures above)
Measure=Calc
Formula=#GlucoseDelta0# + #GlucoseDelta1# + #GlucoseDelta2#
IfCondition=CalcAverageDeltaDirection < (#DeltaT3d#)
IfTrueAction=[!SetOption MeterDeltaDirection Text "🡣🡣"][!SetOption MeterDeltaDirection FontColor #ColorRed#]
IfCondition2=(CalcAverageDeltaDirection >= (#DeltaT3d#)) && (CalcAverageDeltaDirection < (#DeltaT2d#))
IfTrueAction2=[!SetOption MeterDeltaDirection Text "🡣"][!SetOption MeterDeltaDirection FontColor #ColorRed#]
IfCondition3=(CalcAverageDeltaDirection >= (#DeltaT2d#)) && (CalcAverageDeltaDirection < (#DeltaT1d#))
IfTrueAction3=[!SetOption MeterDeltaDirection Text "🡦"][!SetOption MeterDeltaDirection FontColor #ColorText#]
IfCondition4=(CalcAverageDeltaDirection >= (#DeltaT1d#)) && (CalcAverageDeltaDirection <= (#DeltaT1u#))
IfTrueAction4=[!SetOption MeterDeltaDirection Text "🡢"][!SetOption MeterDeltaDirection FontColor #ColorText#]
IfCondition5=(CalcAverageDeltaDirection > (#DeltaT1u#)) && (CalcAverageDeltaDirection <= (#DeltaT2u#))
IfTrueAction5=[!SetOption MeterDeltaDirection Text "🡥"][!SetOption MeterDeltaDirection FontColor #ColorText#]
IfCondition6=(CalcAverageDeltaDirection > (#DeltaT2u#)) && (CalcAverageDeltaDirection <= (#DeltaT3u#))
IfTrueAction6=[!SetOption MeterDeltaDirection Text "🡡"][!SetOption MeterDeltaDirection FontColor #ColorOrange#]
IfCondition7=CalcAverageDeltaDirection > (#DeltaT3u#)
IfTrueAction7=[!SetOption MeterDeltaDirection Text "🡡🡡"][!SetOption MeterDeltaDirection FontColor #ColorOrange#]
OnUpdateAction=[!UpdateMeter MeterDeltaDirection][!Redraw]
DynamicVariables=1
; **Below backup code before adding user configurable variables**
;IfCondition=CalcAverageDeltaDirection < -11
;IfTrueAction=[!SetOption MeterDeltaDirection Text "🡣🡣"][!SetOption MeterDeltaDirection FontColor 255,0,0]
;IfCondition2=(CalcAverageDeltaDirection >= -11) && (CalcAverageDeltaDirection < -7)
;IfTrueAction2=[!SetOption MeterDeltaDirection Text "🡣"][!SetOption MeterDeltaDirection FontColor 255,0,0]
;IfCondition3=(CalcAverageDeltaDirection >= -7) && (CalcAverageDeltaDirection < -2)
;IfTrueAction3=[!SetOption MeterDeltaDirection Text "🡦"][!SetOption MeterDeltaDirection FontColor #ColorText#]
;IfCondition4=(CalcAverageDeltaDirection >= -2) && (CalcAverageDeltaDirection <= 2)
;IfTrueAction4=[!SetOption MeterDeltaDirection Text "🡢"][!SetOption MeterDeltaDirection FontColor #ColorText#]
;IfCondition5=(CalcAverageDeltaDirection > 2) && (CalcAverageDeltaDirection <= 7)
;IfTrueAction5=[!SetOption MeterDeltaDirection Text "🡥"][!SetOption MeterDeltaDirection FontColor #ColorText#]
;IfCondition6=(CalcAverageDeltaDirection > 7) && (CalcAverageDeltaDirection <= 11)
;IfTrueAction6=[!SetOption MeterDeltaDirection Text "🡡"][!SetOption MeterDeltaDirection FontColor 255,155,0]
;IfCondition7=CalcAverageDeltaDirection > 11
;IfTrueAction7=[!SetOption MeterDeltaDirection Text "🡡🡡"][!SetOption MeterDeltaDirection FontColor 255,155,0]
[MeasureTimeDifferenceMinutes]
; TimeDifference current server query time vs. last bg reading time in minutes, from milliseconds to minutes via /60000
Measure=Calc
Formula=Round((MeasureCurrentTime-MeasureGlucoseTime)/60000, 3)
; Checking for stale data = signal loss if above (default) 15min threshhold and indicate signal loss via Strikethrough bangs
; Added [!SetVariable GlucoseDelta0+1+2 "0"] bang to IfCondition=MeasureTimeDifferenceMinutes > #StaleGlucoseAlertMinutes# in order to delete last deltas from "before signal loss"
; Removed IOB/COB Strikethroughs, IfTrue: [!SetOption MeterIOB InlineSetting "Strikethrough"][!UpdateMeter MeterIOB][!SetOption MeterCOB InlineSetting "Strikethrough"][!UpdateMeter MeterCOB]
; Removed IOB/COB Reverting, IfFalse: [!SetOption MeterIOB InlineSetting "None"][!UpdateMeter MeterIOB][!SetOption MeterCOB InlineSetting "None"][!UpdateMeter MeterCOB]
IfCondition=MeasureTimeDifferenceMinutes > #StaleGlucoseAlertMinutes#
IfTrueAction=[!SetVariable GlucoseDelta0 "0"][!SetVariable GlucoseDelta1 "0"][!SetVariable GlucoseDelta2 "0"][!SetOption MeterGlucose FontColor #ColorText#][!SetOption MeterGlucose InlineSetting "Strikethrough"][!UpdateMeter MeterGlucose][!SetOption MeterGlucoseDelta InlineSetting "Strikethrough"][!UpdateMeter MeterGlucoseDelta][!SetOption MeterDeltaDirection InlineSetting "Strikethrough"][!UpdateMeter MeterDeltaDirection]
IfFalseAction=[!SetOption MeterGlucose InlineSetting "None"][!UpdateMeter MeterGlucose][!SetOption MeterGlucoseDelta InlineSetting "None"][!UpdateMeter MeterGlucoseDelta][!SetOption MeterDeltaDirection InlineSetting "None"][!UpdateMeter MeterDeltaDirection]
OnUpdateAction=[!UpdateMeter MeterGlucose][!UpdateMeter MeterGlucoseDelta][!UpdateMeter MeterDeltaDirection][!Redraw]
; Added Strikethrough for delta and direction meters and moved [!Redraw] to OnUpdateAction
[CalcTimeDifferenceMinutesRounded]
; Rounding MeasureTimeDifferenceMinutes to 1 digit for display in meter "X min ago"
Measure=Calc
Formula=Round(MeasureTimeDifferenceMinutes, 0)
[MeasureGlucoseDelta]
; Modified to display positive values with leading "+" in meter code at bottom and needed to introduce [CalcGlucoseDelta] to take care of the colors below
Measure=WebParser
URL=[MeasureSite]
StringIndex=5
[CalcGlucoseDelta]
; This ensures that negative/positive deltas get red/green color AND it adds the "+" for positive and "±" for zero deltas
Measure=Calc
Formula=[MeasureGlucoseDelta]
IfCondition=CalcGlucoseDelta < 0
IfTrueAction=[!SetOption MeterGlucoseDelta FontColor #ColorRed#][!SetOption MeterGlucoseDelta Text "%1"][!UpdateMeter MeterGlucoseDelta][!Redraw]
IfCondition2=CalcGlucoseDelta > 0
IfTrueAction2=[!SetOption MeterGlucoseDelta FontColor #ColorGreen#][!SetOption MeterGlucoseDelta Text "+%1"][!UpdateMeter MeterGlucoseDelta][!Redraw]
IfCondition3=CalcGlucoseDelta = 0
IfTrueAction3=[!SetOption MeterGlucoseDelta FontColor #ColorText#][!SetOption MeterGlucoseDelta Text "±%1"][!UpdateMeter MeterGlucoseDelta][!Redraw]
; Note: DynamicVariables=1 is required HERE, otherwise the leading "+" and colors are not updated!!
DynamicVariables=1
[MeasureClientCurrentTimeUTC]
; Get Client Timestamp for comparison with Server BG Time, see [MeasureClientToGlucoseTimeDelta]
; TimeZone=0 set client time to UTC (thus not +2h =120min CET time shift)
; and additionally needs DaylightSavingsTime=0 to eliminate DST +1h effect!
Measure=Time
TimeZone=0
DaylightSavingTime=0
[CalcClientToGlucoseTimeDeltaMinutes]
; Calculating the "ticking" time difference Rainmeter client time vs. last server glucose reception time, if >5.X min could be used to fire/sync Webparser
Measure=Calc
; Rounding to specific / not by full digits ==> Example: Round /0.2 * 0.2 rounds to 0.2
; Formula=(Round( (#Value#)/(#RoundTo#) )) *(#RoundTo#)
Formula=(Round( ((MeasureClientCurrentTimeUTC - 11644473600 - MeasureGlucoseTime/1000)/60) /0.1)) *0.1
; This IfCondition ensures that at initial start or Refresh (MeasureGlucoseTime=0 due to Webparser not yet finisihed and thus TimeDifference>>1000)
; the meter is hidden via the [!HideMeter] bang thus avoiding appearance of a crazy large TimeDifference number at first start (initialization issue)
IfCondition=CalcClientToGlucoseTimeDeltaMinutes > 1000
IfTrueAction=[!HideMeter MeterClientToGlucoseTimeDeltaMinutes][!HideMeter MeterGlucoseDelta][!HideMeter MeterDeltaDirection]
IfFalseAction=[!ShowMeter MeterClientToGlucoseTimeDeltaMinutes][!ShowMeter MeterGlucoseDelta][!ShowMeter MeterDeltaDirection]
DynamicVariables=1
; ######
; ###### Test Code for even-driven WebParser api call based on @SilverAzide: https://forum.rainmeter.net/viewtopic.php?t=41422&start=10 *******
; ###### Requirement: see above, needs [MeasureSite] -> "UpdateRate=-1"
; ###### Tested only 2-3 days, working mostly as designed but saw issues requiring refresh (time ticking up, no reload) - reason not 100% clear, needs further testing!
; ######
; This IfCondition ensures that at initial start or Refresh (MeasureGlucoseTime=0 due to Webparser not yet finisihed and thus TimeDifference>>1000)
; the meter is hidden via the [!HideMeter] bang thus avoiding appearance of a crazy large TimeDifference number at first start = initialization isse
;##IfCondition=CalcClientToGlucoseTimeDeltaMinutes > 1000
;##IfTrueAction=[!HideMeter meterTimeDifferenceMinutes]
;##IfFalseAction=[!ShowMeter meterTimeDifferenceMinutes][!SetOption meterTimeDifferenceMinutes FontColor #ColorText#]
; The IfCondition2 triggers a call to the web server when the time delta is greater than 5.2 min = 312 seconds !
; This magic enables synched 5 min polling shortly after bg is updated on server-side
; ###<180 because of initialization see silverazide comment tb updated
;IfCondition2=((CalcClientToGlucoseTimeDeltaMinutes > 5.3) && (CalcClientToGlucoseTimeDeltaMinutes < 180))
;IfTrueAction2=[!CommandMeasure MeasureSite "Update"]
; ###### Test Code End but see also meter section below to change ticking time meter
[CalcClientToGlucoseTimeDeltaMinTick]
; Calculating the "ticking" time difference Rainmeter client time vs. last server glucose reception time: MINs
Measure=Calc
; Floor is rounding down, thus extracting the MINs from the decimal time, e.g. "3" from 3.834
Formula=Floor((MeasureClientCurrentTimeUTC - 11644473600 - MeasureGlucoseTime/1000)/60)
DynamicVariables=1
[CalcClientToGlucoseTimeDeltaSecTick]
; Calculating the "ticking" time difference Rainmeter client time vs. last server glucose reception time: SECs
Measure=Calc
; Floor is rounding down, thus extracting the SECs from the decimal time, e.g. "50" from 3.834
; Note1: "%1" calculates the modulus of the decimal time, e.g. 0.834 from 3.834 !
; Note2: For rounding the seconds (down) to next e.g. 5 seconds use (5/60) instead of (1/60), this reduces apparent meter update frequency to e.g. 5 secs if liked better
Formula=(((Floor(((MeasureClientCurrentTimeUTC - 11644473600 - MeasureGlucoseTime/1000)/60)/(1/60)))*(1/60))%1)*60
; The following two lines are adding a leading zero to "0" -> "00" to ensure time display e.g. "4:00" instead of "4:0" !
RegExpSubstitute=1
Substitute="^(\d{1})$":"0\1"
DynamicVariables=1
[MeasureIOB]
; IOB = Insulin on Board
Measure=WebParser
URL=[MeasureSite]
StringIndex=6
[CalcIOB]
; IOB = Insulin on Board: This extra Calc measure is needed to convert the webparser string to a real number so that IfConditions work
; ### Yes, this works!! Only needs Text=%1 and MeasureName=CalcIOB in [MeterIOB]
; Disabled since dispay e.g. 10.9 still (almost) fits in meter display, ok.
Measure=Calc
Formula=[MeasureIOB]
IfCondition=(CalcIOB = 0)
IfTrueAction=[!SetOption MeterIOB Text "-"][!SetOption MeterIOB FontColor #ColorText#]
IfFalseAction=[!SetOption MeterIOB Text ""]
IfCondition2=(CalcIOB > 0) && (CalcIOB < #HighIOB#)
IfTrueAction2=[!SetOption MeterIOB NumOfDecimals "1"][!SetOption MeterIOB FontColor #ColorWhite#]
IfCondition3=(CalcIOB >= #HighIOB#)
IfTrueAction3=[!SetOption MeterIOB NumOfDecimals "1"][!SetOption MeterIOB FontColor #ColorYellow#]
OnUpdateAction=[!UpdateMeter MeterIOB][!Redraw]
DynamicVariables=1
[MeasureCOB]
; COB = Carbs on Board
Measure=WebParser
URL=[MeasureSite]
StringIndex=7
[CalcCOB]
; IOB = Carbs on Board: This extra Calc measure is needed to convert the webparser string to a real number so that IfConditions work
Measure=Calc
Formula=[MeasureCOB]
IfCondition=(CalcCOB=0)
IfTrueAction=[!SetOption MeterCOB Text "-"][!SetOption MeterCOB FontColor #ColorText#]
IfFalseAction=[!SetOption MeterCOB Text ""]
IfCondition2=(CalcCOB>0) && (CalcCOB < #HighCOB#)
IfTrueAction2=[!SetOption MeterCOB NumOfDecimals "0"][!SetOption MeterCOB FontColor #ColorText#]
IfCondition3=(CalcCOB >= #HighCOB#)
IfTrueAction3=[!SetOption MeterCOB NumOfDecimals "0"][!SetOption MeterCOB FontColor #ColorOrange#]
OnUpdateAction=[!UpdateMeter MeterCOB][!Redraw]
DynamicVariables=1
; ---------------------------------------
; STYLES are used to "centralize" options
; ---------------------------------------
[StyleGlucose]
; Glucose value right-aligned
StringAlign=Right
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
; Grey shadow without transparency
FontEffectColor=125,125,125,255
FontColor=#ColorText#
FontFace=Calibri
FontSize=28
AntiAlias=1
ClipString=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
[StyleLeftText]
; Meters using styleLeftText will be left-aligned
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
; Black shadow without transparency
FontEffectColor=0,0,0,255
FontColor=#ColorText#
FontFace=Calibri
FontSize=11
AntiAlias=1
ClipString=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
[StyleCenterText]
; Meters using styleCenterText will be center-aligned
StringAlign=Center
StringCase=None
StringStyle=Bold
StringEffect=Shadow
; Black shadow without transparency
FontEffectColor=0,0,0,255
FontColor=#ColorText#
FontFace=Calibri
FontSize=9
AntiAlias=1
ClipString=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
[StyleRightText]
; Meters using styleRightText will be right-aligned
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
; Black shadow without transparency
FontEffectColor=0,0,0,255
FontColor=#ColorText#
FontFace=Calibri
FontSize=11
AntiAlias=1
ClipString=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
; ---------------------------------------
; METERS display images, text, bars, etc.
; ---------------------------------------
[MeterBackgroundRoundedEdges]
; "Solid background2" with rounded edges, adapted from SilverAzide Gadgets 7.4.0 suite
Meter=Shape
Shape=Rectangle 0,0,(#BgWidth# * #Scale#),(#BgHeight# * #Scale#) | Fill Color #ColorBg#,1 | StrokeWidth 0
Shape2=Rectangle (4 * #Scale#),(4 * #Scale#),((#BgWidth# - 8) * #Scale#),((#BgHeight# - 8) * #Scale#),(4 * #Scale#) | Fill Color #ColorBg#,(#BgAlpha# / 2) | StrokeWidth 0
Shape3=Rectangle (5 * #Scale#),(5 * #Scale#),((#BgWidth# - 10) * #Scale#),((#BgHeight# - 10) * #Scale#),(3 * #Scale#) | Fill Color #ColorBg#,#BgAlpha# | StrokeWidth 0
[MeterError]
; Meter for error message display in case of nightscout misconfiguration or network dropout via Webparser error; see [ErrorCounter] for activation of this meter, normally Hidden=1.
Meter=String
MeterStyle=StyleCenterText
FontColor=#ColorYellow#
FontFace=Tahoma
FontWeight=999
X=(#BgWidth#/2)-1
Y=4
W=#BgWidth#
H=#BgHeight#
Text="ERROR MESSAGE"
Hidden=1
[MeterErrorMouseRegion]
; Extra MouseRegion meter needed for correctly scaled tooltips
Meter=Image
SolidColor=0,0,0,1
X=(([MeterError:X]+24) * #Scale#)
Y=(([MeterError:Y]+10) * #Scale#)
W=(([MeterError:W]-36) * #Scale#)
H=(([MeterError:H]-24) * #Scale#)
; Tooltip is shown by hovering with mouse
ToolTipTitle=NS2Win - Nightscout Blood Glucose Monitor by MK
ToolTipType=1
ToolTipIcon=ERROR
ToolTipText=Nightscout or Network ERROR#CRLF#Please check your Nightscout settings#CRLF#Click NS2Win "Settings Button"#CRLF##CRLF#Nightscout URL: #NightScoutURL##CRLF#Nightscout Token: #NightScoutToken#
DynamicVariables=1
[MeterSettingsButton]
Meter=Image
ImageName="#CURRENTPATH#Settings.png"
ImageAlpha=0
Antialias=1
X=6
Y=6
W=12
H=12
UpdateDivider=-1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
[MeterSettingsButtonMouseRegion]
; Extra MouseRegion meter needed for correctly scaled tooltips
Meter=Image
SolidColor=0,0,0,1
X=([MeterSettingsButton:X] * #Scale#)
Y=([MeterSettingsButton:Y] * #Scale#)
W=([MeterSettingsButton:W] * #Scale#)
H=([MeterSettingsButton:H] * #Scale#)
ToolTipText="NS2Win Settings"
LeftMouseUpAction=["#ROOTCONFIGPATH#\UserVariables.inc"]
UpdateDivider=-1
[MeterTimeDifferenceMinutes]
; Meter "X min ago"
Meter=String
MeterStyle=StyleRightText
; Padding +1 pixel to top
Padding=0,1,0,0
FontSize=10
MeasureName=CalcTimeDifferenceMinutesRounded
X=81
;##MeasureName=CalcClientToGlucoseTimeDeltaMinutes
Y=2
Text=[&CalcTimeDifferenceMinutesRounded] min ago
;##Text=[&CalcClientToGlucoseTimeDeltaMinutes:1] min ago
DynamicVariables=1
[MeterClientToGlucoseTimeDeltaMinutesMouseRegion]
; Extra MouseRegion meter needed for scaled tooltips
Meter=Image
SolidColor=0,0,0,1
X=([MeterClientToGlucoseTimeDeltaMinutes:X] * #Scale#)
Y=([MeterClientToGlucoseTimeDeltaMinutes:Y] * #Scale#)
W=([MeterClientToGlucoseTimeDeltaMinutes:W] * #Scale#)
H=([MeterClientToGlucoseTimeDeltaMinutes:H] * #Scale#)
; Tooltip is shown by hovering with mouse
ToolTipTitle=NS2Win - Nightscout Blood Glucose Monitor by MK
ToolTipType=1
ToolTipIcon=INFO
ToolTipText=Nightscout URL: #NightScoutURL##CRLF#Nightscout Token: #NightScoutToken##CRLF#***Last BG: [MeasureGlucose] mg/dl*** IOB: [MeasureIOB:1] units COB: [MeasureCOB:0] grams
DynamicVariables=1
[MeterClientToGlucoseTimeDeltaMinutes]
; Note: [&CalcClientToGlucoseTimeDeltaMinutes:1] is the exact "ticking" time difference last glucose on server vs. client time !
; This could be displayed in the above [MeterTimeDifferenceMinutes] instead of the server delta time if
; a) confirmed working and
; b) time synch feature with 5 min polling implemented, see above
; NEW: [&CalcClientToGlucoseTimeDeltaMinTick]:[&CalcClientToGlucoseTimeDeltaSecTick] displays the ticking "min:ss" e.g. "2:15"
Meter=String
MeterStyle=StyleRightText
FontColor=#ColorTicking#
FontSize=8
MeasureName=CalcClientToGlucoseTimeDeltaMinutes
X=(#BgWidth# - 15)
Y=6
W=35
H=12
; Adding ":1" ensures display of 1 decimal, also for X.0 otherwise giving X !
;Text=[&CalcClientToGlucoseTimeDeltaMinutes:1]
Text=[&CalcClientToGlucoseTimeDeltaMinTick]:[&CalcClientToGlucoseTimeDeltaSecTick]
DynamicVariables=1
[MeterGlucose]
; Meter "XXX" [mg/dl] last glucose value, right-aligned
Meter=String
MeterStyle=StyleGlucose
; This compresses the font width to 85% but cannot be combined with scaling functionality thus deprecated!
;TransformationMatrix=0.85;0;0;1;0;0
MeasureName=MeasureGlucose
; e.g. X=85 because of "Right" alignment to show 2 and 3-digit figures Right-aligned (e.g. BG " 80" and "180" mg/dl)
X=(#BgWidth# - 56)
Y=8
Text=[&MeasureGlucose]
;Text="168"
DynamicVariables=1
[MeterDeltaDirection]
; Meter "delta arrow indicator": calculated from sum of last 3 deltas
Meter=String
MeterStyle=StyleLeftText
FontSize=10
MeasureName=CalcAverageDeltaDirection
X=66
Y=17
; Fontweight=999 applies strongest "Bold" effect
FontWeight=999
Text="%1"
DynamicVariables=1
[MeterGlucoseDelta]
; Meter "+-XX" [mg/dl] last glucose delta
Meter=String
MeterStyle=StyleLeftText
MeasureName=MeasureGlucoseDelta
; modified to display positive values with leading "+" via Text="%1", see [CalcGlucoseDelta] above
X=66
Y=30
Text="%1"
DynamicVariables=1
[SeparatorV1]
; This is a separator line in the middle of the NS2Win skin
Meter=Image
X=94
Y=21
W=1
H=24
; Light gray and thin (W=1) bar
SolidColor=150,150,150,255
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
[MeterIOB]
; Meter "Insulin on Board"
Meter=String
MeterStyle=StyleRightText
FontSize=9
MeasureName=CalcIOB
X=(#BgWidth# - 9)
Y=20
; Adding ":1" ensures display of 1 decimal, also for X.0 otherwise giving X !
;Text=[&MeasureIOB:1]
Text=%1
DynamicVariables=1
[MeterCOB]
; Meter "Carbs on Board"
Meter=String
MeterStyle=StyleRightText
FontSize=9
MeasureName=CalcCOB
X=(#BgWidth# - 9)
Y=33
; Adding ":1" ensures display of 1 decimal, also for X.0 otherwise giving X !
;Text=[&MeasureCOB:0]
Text=%1
DynamicVariables=1