From e586927bdeef9d1d59f464c0fed86977ec9fd6c4 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Wed, 26 Feb 2025 18:07:58 -0800 Subject: Adds drive service and test app --- hsm-bin/Test/Drive.hs | 22 ++++++++++++++++++++++ hsm-bin/hsm-bin.cabal | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 hsm-bin/Test/Drive.hs (limited to 'hsm-bin') diff --git a/hsm-bin/Test/Drive.hs b/hsm-bin/Test/Drive.hs new file mode 100644 index 0000000..7a58c11 --- /dev/null +++ b/hsm-bin/Test/Drive.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Control.IO.Region (region) +import Control.Monad.Loops (whileJust_) +import Hsm.Drive (DriveEnv, drive, driveEnvDefault) +import Hsm.GPIO (allocateGPIO) +import Hsm.PWM (allocatePWM) +import Hsm.Readline (allocateReadline, readline) + +newtype Env = Env + { driveEnv :: DriveEnv + } + +main :: IO () +main = + region $ \ioRegion -> do + lineRequest <- allocateGPIO ioRegion "test-status" + pwmHandle <- allocatePWM ioRegion $ const 0 + handle <- allocateReadline ioRegion + whileJust_ (readline handle) + $ drive lineRequest pwmHandle + $ Env driveEnvDefault diff --git a/hsm-bin/hsm-bin.cabal b/hsm-bin/hsm-bin.cabal index 0dc0a81..de6e1a5 100644 --- a/hsm-bin/hsm-bin.cabal +++ b/hsm-bin/hsm-bin.cabal @@ -24,3 +24,11 @@ executable test-status import: test-executable build-depends: hsm-status main-is: Test/Status.hs + +executable test-drive + import: test-executable + build-depends: + , hsm-drive + , hsm-pwm + + main-is: Test/Drive.hs -- cgit v1.2.1