aboutsummaryrefslogtreecommitdiff
path: root/hsm-battery/Test/Battery.hs
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-12-17 02:26:07 +0000
committerPaul Oliver <contact@pauloliver.dev>2025-12-17 02:26:07 +0000
commitf1e95891617b705c5bbe04fb20d64b9dab9346b1 (patch)
tree0a4565c9a74005690f5cec104bebb471b7afc383 /hsm-battery/Test/Battery.hs
parent459d2c5630e1296807bbf23fd4360fb4d4f5bbe7 (diff)
Adds battery monitoring service via INA226/I2C (WIP)battery_monitoring
Diffstat (limited to 'hsm-battery/Test/Battery.hs')
-rw-r--r--hsm-battery/Test/Battery.hs25
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