summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-13 13:06:25 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-13 13:06:25 +0200
commit6a801ff33c56010895cb9236850081cf1751a100 (patch)
treeeec49f29adf29ce3693275546f7a500b8d78a884
parent62049f094ac0b270aa4464127a6a3ebb405b6c0c (diff)
fix: improve rendering of bat symbols
-rw-r--r--app/Sensor.hs75
1 files changed, 35 insertions, 40 deletions
diff --git a/app/Sensor.hs b/app/Sensor.hs
index b6cfba5..165a1ae 100644
--- a/app/Sensor.hs
+++ b/app/Sensor.hs
@@ -285,32 +285,17 @@ bat = do
printBatNotCharging :: Float -> P.Doc
printBatNotCharging value =
- if
- | value >= 0.95 -> P.pretty "\xf0079"
- | value >= 0.9 -> P.pretty "\xf0082"
- | value >= 0.8 -> P.pretty "\xf0081"
- | value >= 0.7 -> P.pretty "\xf0080"
- | value >= 0.6 -> P.pretty "\xf007f"
- | value >= 0.5 -> P.pretty "\xf007e"
- | value >= 0.4 -> P.pretty "\xf007d"
- | value >= 0.3 -> P.pretty "\xf007c"
- | value >= 0.2 -> P.pretty "\xf007b"
- | value >= 0.1 -> P.pretty "\xf007a"
- | otherwise -> P.pretty "\xf008e"
+ mconcat
+ [ printBatCapacity value,
+ P.pretty " "
+ ]
printBatCharging :: Float -> P.Doc
printBatCharging value =
- if
- | value >= 0.9 -> P.pretty "\xf0085"
- | value >= 0.8 -> P.pretty "\xf008b"
- | value >= 0.7 -> P.pretty "\xf008a"
- | value >= 0.6 -> P.pretty "\xf089e"
- | value >= 0.5 -> P.pretty "\xf0089"
- | value >= 0.4 -> P.pretty "\xf089d"
- | value >= 0.3 -> P.pretty "\xf0088"
- | value >= 0.2 -> P.pretty "\xf0087"
- | value >= 0.1 -> P.pretty "\xf0086"
- | otherwise -> P.pretty "\xf089c"
+ mconcat
+ [ printBatCapacity value,
+ nfOctArrowUp
+ ]
printBatDischarging :: (S.MonadSensor m) => Float -> S.Sensor m () P.Doc
printBatDischarging value =
@@ -318,25 +303,35 @@ printBatDischarging value =
then
( \b ->
if b
- then mconcat [P.pretty batValue, P.pretty "\xf433"]
- else (P.color P.Red) (mconcat [P.pretty "\xf0083", P.pretty "\xf433"])
+ then mconcat [printBatCapacity value, nfOctArrowDown]
+ else (P.color P.Red) (mconcat [P.pretty "\xf0083", nfOctArrowDown])
)
<$> 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"
+ else pure (mconcat [printBatCapacity value, nfOctArrowDown])
+
+printBatCapacity :: Float -> P.Doc
+printBatCapacity value =
+ P.pretty $
+ 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"
+
+nfOctArrowUp :: P.Doc
+nfOctArrowUp =
+ P.pretty "\xf431 "
+
+nfOctArrowDown :: P.Doc
+nfOctArrowDown =
+ P.pretty "\xf433 "
data Blink = Blink deriving (Show)