diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2025-12-13 22:20:41 +0100 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2025-12-13 22:20:41 +0100 |
| commit | 10078d83ce910ddfee311964766c5042c38d3763 (patch) | |
| tree | 0ee519efa9050c9c5731729be72b94bb529bb3af /hsm-battery/Test | |
| parent | 459d2c5630e1296807bbf23fd4360fb4d4f5bbe7 (diff) | |
Adds battery monitoring service via INA226/I2Cbattery_monitoring
Diffstat (limited to 'hsm-battery/Test')
| -rw-r--r-- | hsm-battery/Test/Battery.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hsm-battery/Test/Battery.hs b/hsm-battery/Test/Battery.hs new file mode 100644 index 0000000..caf24a6 --- /dev/null +++ b/hsm-battery/Test/Battery.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE TemplateHaskell #-} + +import Control.Concurrent (threadDelay) +import Control.Monad (forever) +import Data.Function ((&)) +import Effectful (liftIO, runEff) +import Hsm.Battery (readBatteryState, runBattery) +import Hsm.Core.App (bootstrapApp) +import Hsm.Log (Severity (Info), logMsg, runLogsOpt) +import Hsm.Log.Options (makeLoggerOptionParser) +-- Import full module for cleaner `-ddump-splices` output +-- Avoids package/module qualifiers in generated code +import Options.Applicative + +type Logs = '["battery"] + +$(makeLoggerOptionParser @Logs "Options" "parser" 'Info) + +main :: IO () +main = + bootstrapApp parser "Launch Battery Monitoring Test Application" $ \opts -> + (forever $ liftIO (threadDelay 1000000) >> readBatteryState >>= logMsg Info . show) + & runBattery + & runLogsOpt @Options @Logs opts + & runEff |
