diff options
Diffstat (limited to 'app/Sensor.hs')
-rw-r--r-- | app/Sensor.hs | 14 |
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 |