From b28555a116278861ffbbfc43199a470e438d45f4 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Mon, 12 Aug 2024 13:59:50 +0200 Subject: feat: adjust bat icon depending on value --- app/Sensor.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/Sensor.hs') 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 -- cgit v1.2.3