From 7d7fa4816a1744d860c74a45003eda6cd71ec42a Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Wed, 17 Dec 2025 02:26:07 +0000 Subject: Adds battery monitoring service via INA226/I2C --- hsm-ina226/Test/INA226.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 hsm-ina226/Test/INA226.hs (limited to 'hsm-ina226/Test') diff --git a/hsm-ina226/Test/INA226.hs b/hsm-ina226/Test/INA226.hs new file mode 100644 index 0000000..71f8f45 --- /dev/null +++ b/hsm-ina226/Test/INA226.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE TemplateHaskell #-} + +import Control.Concurrent (threadDelay) +import Control.Monad (forever) +import Data.Function ((&)) +import Effectful (liftIO, runEff) +import Hsm.Core.App (bootstrapApp) +import Hsm.I2C (runI2C) +import Hsm.INA226 (readINA226State, runINA226) +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 = '["i2c", "ina226"] + +$(makeLoggerOptionParser @Logs "Options" "parser" 'Info) + +main :: IO () +main = + bootstrapApp parser "Launch INA226 Monitoring Test Application" $ \opts -> + forever (liftIO (threadDelay 1000000) >> readINA226State >>= logMsg @"ina226" Info . show) + & runINA226 + & runI2C + & runLogsOpt @Options @Logs opts + & runEff -- cgit v1.2.1