diff options
Diffstat (limited to 'hsm-ina226/Test')
| -rw-r--r-- | hsm-ina226/Test/INA226.hs | 27 |
1 files changed, 27 insertions, 0 deletions
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 |
