1 | scope oshi_batteryLevel_withZeroPercentFix. |
2 | |
3 | static int #last = -1; |
4 | |
5 | // We assume actual 0% never appear longer than this |
6 | static WaitForStableValue<Bool> zeroSince = new(60.0); |
7 | |
8 | static double oshi_batteryLevel_withZeroPercentFix() { |
9 | double dd = oshi_batteryLevel(); |
10 | if (isNaN(dd)) ret dd; |
11 | int d = iround(dd); |
12 | zeroSince.set(d == 0); |
13 | if (d == 0 && (last < 0 || last >= 99 || isTrue(zeroSince!))) |
14 | d = 100; |
15 | ret last = d; |
16 | } |
17 | |
18 | end scope |
Began life as a copy of #1016190
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016191 |
Snippet name: | oshi_batteryLevel_withZeroPercentFix |
Eternal ID of this version: | #1016191/5 |
Text MD5: | 3ea47ddc0268f97d99bedaf61f13594c |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-10 00:10:12 |
Source code size: | 462 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 453 / 504 |
Version history: | 4 change(s) |
Referenced in: | [show references] |