diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 2 | ||||
-rw-r--r-- | app/Sensor.hs | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/app/Main.hs b/app/Main.hs index 7d499d8..caee3fb 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -193,7 +193,7 @@ createWindow args = do [pure (lit (if args.icons then "\xf1638 " else "io ")), lit <$> io], [pure (lit (if args.icons then "\xf0200 " else "net ")), lit <$> net], [pure (lit (if args.icons then "\xf028 " else "snd ")), lit <$> Sensor.snd], - [pure (lit (if args.icons then "\xf240 " else "bat ")), lit <$> bat], + [lit <$> bat], [pure (lit " "), lit <$> date, pure (lit ", "), lit <$> time], [] ] 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 |