summaryrefslogtreecommitdiffstats
path: root/app/Sensor.hs
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-12 13:59:50 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2024-08-12 13:59:50 +0200
commitb28555a116278861ffbbfc43199a470e438d45f4 (patch)
tree3d1a7f9a39bfe013aeb1657c0d0d96f59cdd1c3a /app/Sensor.hs
parentf413648183c90e454ba42aa3f1c8794f1d4fa729 (diff)
feat: adjust bat icon depending on value
Diffstat (limited to 'app/Sensor.hs')
-rw-r--r--app/Sensor.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/Sensor.hs b/app/Sensor.hs
index 55d2554..2dcf6c0 100644
--- a/app/Sensor.hs
+++ b/app/Sensor.hs
@@ -4,6 +4,7 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE QuasiQuotes #-}
@@ -206,8 +207,17 @@ instance (S.MonadSensor m) => S.Aggregate m BatStat Float where
<*> (readFile (fp </> "energy_full") (pure . read))
]
-bat :: (S.MonadSensor m) => S.Sensor m () Float
-bat = S.sensor BatStat
+bat :: (S.MonadSensor m) => S.Sensor m () String
+bat = do
+ value <- S.sensor BatStat
+ return
+ ( if
+ | 0.8 < value -> "\xf240"
+ | 0.6 < value -> "\xf241"
+ | 0.4 < value -> "\xf242"
+ | 0.2 < value -> "\xf243"
+ | otherwise -> "\xf244"
+ )
choice :: a -> [IO a] -> IO a
choice def [] = pure def