diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-02-07 17:10:05 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-02-18 20:35:35 +0000 |
commit | ab4591cb0e074ce98c24645cdb80cb5012aed566 (patch) | |
tree | 98451fa7e042e49ea83f265866754f3f6a3b406f /hsm-bin |
Diffstat (limited to 'hsm-bin')
-rw-r--r-- | hsm-bin/Test/Drive.hs | 23 | ||||
-rw-r--r-- | hsm-bin/Test/Status.hs | 22 | ||||
-rw-r--r-- | hsm-bin/hsm-bin.cabal | 32 |
3 files changed, 77 insertions, 0 deletions
diff --git a/hsm-bin/Test/Drive.hs b/hsm-bin/Test/Drive.hs new file mode 100644 index 0000000..899964c --- /dev/null +++ b/hsm-bin/Test/Drive.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE OverloadedRecordDot #-} +{-# 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 qualified as P +import Hsm.Readline (allocateReadline, readline) + +newtype Env = Env + { driveEnv :: DriveEnv + } + +main :: IO () +main = + region $ \ioRegion -> do + lineRequest <- allocateGPIO ioRegion "test-drive" + pwmHandle <- P.allocatePWM ioRegion + handle <- allocateReadline ioRegion + whileJust_ (readline handle) + $ drive pwmHandle lineRequest + $ Env driveEnvDefault diff --git a/hsm-bin/Test/Status.hs b/hsm-bin/Test/Status.hs new file mode 100644 index 0000000..bc05eca --- /dev/null +++ b/hsm-bin/Test/Status.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Control.IO.Region (region) +import Control.Monad.Loops (whileJust_) +import Hsm.GPIO (allocateGPIO) +import Hsm.PWM qualified as P +import Hsm.Readline (allocateReadline, readline) +import Hsm.Status (StatusEnv, status, statusEnvDefault) + +newtype Env = Env + { statusEnv :: StatusEnv + } + +main :: IO () +main = + region $ \ioRegion -> do + lineRequest <- allocateGPIO ioRegion "test-status" + pwmHandle <- P.allocatePWM ioRegion + handle <- allocateReadline ioRegion + whileJust_ (readline handle) + $ status lineRequest pwmHandle + $ Env statusEnvDefault diff --git a/hsm-bin/hsm-bin.cabal b/hsm-bin/hsm-bin.cabal new file mode 100644 index 0000000..de7853f --- /dev/null +++ b/hsm-bin/hsm-bin.cabal @@ -0,0 +1,32 @@ +cabal-version: 3.4 +author: Paul Oliver +build-type: Simple +maintainer: contact@pauloliver.dev +name: hsm-bin +version: 0.1.0.0 + +common test-executable + build-depends: + , base + , hsm-gpio + , hsm-pwm + , hsm-readline + , io-region + , monad-loops + + ghc-options: -Wall -Wunused-packages + + if !arch(x86_64) + ghc-options: -optl=-mno-fix-cortex-a53-835769 + + default-language: GHC2021 + +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 + main-is: Test/Drive.hs |