hemokit 0.6.4 → 0.6.5
raw patch · 4 files changed
+16/−17 lines, 4 filesdep −xhbdep ~robot
Dependencies removed: xhb
Dependency ranges changed: robot
Files
- apps/Dump.hs +2/−1
- apps/DumpConduit.hs +5/−3
- apps/Mouse.hs +7/−10
- hemokit.cabal +2/−3
apps/Dump.hs view
@@ -6,6 +6,7 @@ import Control.Concurrent (threadDelay) import Control.Monad import Data.Aeson (ToJSON (..), encode)+import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy.Char8 as BSL8 import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Lazy.Builder as Builder@@ -199,7 +200,7 @@ Raw -> readEmotivRaw device `withJustM` \rawBytes -> do case format of Default -> -- raw data stdout; flush so that consuming apps immediately get it- output $ BSL.fromStrict (emotivRawDataBytes rawBytes)+ BS.putStr (emotivRawDataBytes rawBytes) >> hFlush stdout _ -> -- use EmotivRawData newtype for base64 encoding output $ formatOutput rawBytes
apps/DumpConduit.hs view
@@ -175,8 +175,8 @@ Just (Websocket host port) -> websocketSink host port Just (TCP host port) -> tcpSink host port - -- Turns EmotivRawData into a lazy ByteString (no base64 encoding)- rawBytesConduit = CL.map (BSL8.fromStrict . emotivRawDataBytes)+ -- Prints raw bytes to stdout+ rawBytesSink = CL.mapM_ (putStrBsFlush . emotivRawDataBytes) throttled = if realtime then ($= throttle) else id @@ -190,12 +190,14 @@ _ -> formatConduit =$ outputSink Raw -> throttled (rawSource device) $$ case format of- Default -> rawBytesConduit =$ outputSink+ Default -> rawBytesSink _ -> formatConduit =$ outputSink -- use EmotivRawData newtype for base64 encoding Measure -> throttled (rawSource device) $= measureConduit $$ formatConduit =$ outputSink where+ putStrBsFlush bs = BS.putStr bs >> hFlush stdout+ measureConduit = do -- For --mode measure: See how long a 0-128 cycle takes timeRef <- liftIO $ newIORef =<< getCurrentTime
apps/Mouse.hs view
@@ -3,7 +3,6 @@ import Control.Concurrent (threadDelay, forkIO) import Control.Monad import Data.IORef-import Graphics.XHB.Connection (connect) import System.Environment import System.IO import Test.Robot@@ -26,17 +25,15 @@ device <- openEmotivDevice model $ case reverse devices of d:_ -> d [] -> error "no Epoc devices found" - m'xConnection <- connect+ conn <- connect xy <- newIORef (0,0) - case m'xConnection of- Nothing -> return ()- Just xc -> void . forkIO . forever $ do- (x, y) <- readIORef xy- print (x, y)- writeIORef xy (0, 0)- runRobotWithConnection (moveBy ((-x) `quot` 10) (y `quot` 10)) xc- threadDelay 10000+ void . forkIO . forever $ do+ (x, y) <- readIORef xy+ print (x, y)+ writeIORef xy (0, 0)+ runRobotWith conn (moveBy ((-x) `quot` 10) (y `quot` 10))+ threadDelay 10000 void $ untilNothing (readEmotiv device) $ \(state, _) -> do
hemokit.cabal view
@@ -1,5 +1,5 @@ name: hemokit-version: 0.6.4+version: 0.6.5 license: MIT copyright: 2013 Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com> author: Niklas Hambüchen <mail@nh2.me>, Patrick Chilton <chpatrick@gmail.com>@@ -96,8 +96,7 @@ base , hemokit , pretty-show >= 1.0- , robot >= 1.0.1.1- , xhb >= 0.5.2012.11.23+ , robot >= 1.3.0.1 ghc-options: -Wall