summaryrefslogtreecommitdiffstats
path: root/app/Sensor.hs
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-13 12:01:53 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-13 12:01:53 +0200
commit8dae49a3e9525ed7d81844a7eafb55b197d4cc39 (patch)
tree40611e931e675c78cddfb23e400cf27ee6ad7874 /app/Sensor.hs
parent123e242f97485dc96d074cca398fca97b8b4a21b (diff)
fix: improve blinking of nearly empty discharging battery
Diffstat (limited to 'app/Sensor.hs')
-rw-r--r--app/Sensor.hs41
1 files changed, 23 insertions, 18 deletions
diff --git a/app/Sensor.hs b/app/Sensor.hs
index 21c7f09..612b2bc 100644
--- a/app/Sensor.hs
+++ b/app/Sensor.hs
@@ -294,24 +294,29 @@ printBatCharging value =
printBatDischarging :: (S.MonadSensor m) => Float -> S.Sensor m () P.Doc
printBatDischarging value =
- fmap mconcat $
- sequence
- [ if
- | value >= 0.95 -> pure (P.pretty "\xf0079")
- | value >= 0.9 -> pure (P.pretty "\xf0082")
- | value >= 0.8 -> pure (P.pretty "\xf0081")
- | value >= 0.7 -> pure (P.pretty "\xf0080")
- | value >= 0.6 -> pure (P.pretty "\xf007f")
- | value >= 0.5 -> pure (P.pretty "\xf007e")
- | value >= 0.4 -> pure (P.pretty "\xf007d")
- | value >= 0.3 -> pure (P.pretty "\xf007c")
- | value >= 0.2 -> pure (P.pretty "\xf007b")
- | value >= 0.1 -> pure (P.pretty "\xf007a")
- | otherwise ->
- (\b -> if b then P.pretty "\xf008e" else (P.color P.Red) (P.pretty "\xf0083"))
- <$> blink,
- pure (P.pretty "\xf433")
- ]
+ if value < 0.1
+ then
+ ( \b ->
+ if b
+ then mconcat [P.pretty batValue, P.pretty "\xf433"]
+ else (P.color P.Red) (mconcat [P.pretty "\xf0083", P.pretty "\xf433"])
+ )
+ <$> blink
+ else pure (mconcat [P.pretty batValue, P.pretty "\xf433"])
+ where
+ batValue =
+ if
+ | value >= 0.95 -> "\xf0079"
+ | value >= 0.9 -> "\xf0082"
+ | value >= 0.8 -> "\xf0081"
+ | value >= 0.7 -> "\xf0080"
+ | value >= 0.6 -> "\xf007f"
+ | value >= 0.5 -> "\xf007e"
+ | value >= 0.4 -> "\xf007d"
+ | value >= 0.3 -> "\xf007c"
+ | value >= 0.2 -> "\xf007b"
+ | value >= 0.1 -> "\xf007a"
+ | otherwise -> "\xf008e"
data Blink = Blink deriving (Show)