blob: 71f8f45f073aa190bde9134526143c36989253a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|