packages feed

hArduino 0.4 → 0.5

raw patch · 6 files changed

+92/−113 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- System.Hardware.Arduino.SamplePrograms.PulseIn: pulseDemo :: IO ()
- System.Hardware.Arduino.SamplePrograms.PulseOut: pulseDemo :: IO ()
+ System.Hardware.Arduino.SamplePrograms.Pulse: pulseInDemo :: IO ()
+ System.Hardware.Arduino.SamplePrograms.Pulse: pulseOutDemo :: IO ()

Files

CHANGES.md view
@@ -1,9 +1,9 @@ * Hackage: (http://hackage.haskell.org/package/hArduino) * GitHub:  (http://leventerkok.github.com/hArduino) -* Latest Hackage released version: 0.4+* Latest Hackage released version: 0.5 -### Version 0.4, 2013-03-05+### Version 0.5, 2013-03-07    * New hardware components supported:      * Shift-registers@@ -26,13 +26,15 @@ 	   as of March 2013 does not support this functionality yet.      * time: Measure the time taken by an Arduino action      * timeOut: Run an action only for the given-time-out- * Other:-    * Bugfix: Remove spurious extra call to user program-    * Rework pin assignment logic, making use of analog/digital pins much more clearer.-    * Better exception handling-    * Remove threadDelay workaround on the Mac. NB. If you are running on OSX, then-      you need at least GHC 7.6.2! +### Version 0.4, 2013-02-05++ * Bugfix: Remove spurious extra call to user program+ * Rework pin assignment logic, making use of analog/digital pins much more clearer.+ * Better exception handling+ * Remove threadDelay workaround on the Mac. NB. If you are running on OSX, then+   you need at least GHC 7.6.2!+   ### Version 0.3, 2013-02-10   * Library
System/Hardware/Arduino.hs view
@@ -25,26 +25,19 @@   -- * Running the controller   withArduino, Arduino   -- * Programming the Arduino-  -- ** Basic handshake with the board-  , queryFirmware-  -- ** Accessing pins+  -- ** Pins   , analog, digital, pin, Pin, PinMode(..), setPinMode-  -- ** Digital I/O-  -- *** Writing digital values-  , digitalWrite-  -- *** Reading digital values-  , digitalRead,  pullUpResistor, waitFor, waitAny, waitAnyHigh, waitAnyLow-  -- *** Receiving and sending pulses, host timing-  , pulseIn_hostTiming, pulseOut_hostTiming-  -- ** Pulse trigger and measurement-  , pulse-  -- ** Analog Communication-  -- *** Setting up sampling interval-  , setAnalogSamplingInterval-  -- *** Reading analog values+  -- ** Analog input   , analogRead+  -- ** Digital I/O+  , digitalWrite, digitalRead+  -- ** Programming with triggers+  , waitFor, waitAny, waitAnyHigh, waitAnyLow+  -- ** Receiving and sending pulses+  , pulse, pulseIn_hostTiming, pulseOut_hostTiming   -- * Misc utilities-  , delay, time, timeOut+  , setAnalogSamplingInterval, pullUpResistor, delay, time, timeOut+  , queryFirmware  )  where 
+ System/Hardware/Arduino/SamplePrograms/Pulse.hs view
@@ -0,0 +1,67 @@+-------------------------------------------------------------------------------+-- |+-- Module      :  System.Hardware.Arduino.SamplePrograms.Pulse+-- Copyright   :  (c) Levent Erkok+-- License     :  BSD3+-- Maintainer  :  erkokl@gmail.com+-- Stability   :  experimental+--+-- Demonstrates 'pulseIn_hostTiming' and 'pulseOut_hostTiming' functions, sending+-- and receiving pulses to/from the board.+-------------------------------------------------------------------------------++module System.Hardware.Arduino.SamplePrograms.Pulse where++import Control.Monad       (forever)+import Control.Monad.Trans (liftIO)++import System.Hardware.Arduino++-------------------------------------------------------------------------------+-- * Detecting pulses+-------------------------------------------------------------------------------++-- | Computes the amount of time a push-button is connected to+-- input pin 2 on the Arduino. We will wait for at most 5 seconds,+-- as a further demonstration of the time-out facility. Note that the+-- timing is done on the host side, so this measurement is inherently+-- inaccurate.+--+-- The wiring is straightforward: Simply put a push-button between+-- digital input 2 and +5V, guarded by a 10K resistor:+--+--  <<http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/PulseIn.png>>+pulseInDemo :: IO ()+pulseInDemo = withArduino False "/dev/cu.usbmodemfd131" $ do+               setPinMode pb INPUT+               go+ where pb = digital 2+       go = forever $ do+              liftIO $ putStr "Ready, push-and-hold for less than 5 seconds: "+              mbDur <- pulseIn_hostTiming pb True (Just 5000000)+              liftIO $ putStrLn $ case mbDur of+                Nothing -> "Time out!"+                Just d  -> "Button stayed high for: " ++ show d ++ " micro-seconds"++-------------------------------------------------------------------------------+-- * Sending pulses+-------------------------------------------------------------------------------++-- | Send pulses on a led as requested by the user. Note that the timing is computed+-- on the host side, thus the duration of the pulse is subject to some error due to+-- the Firmata communication overhead.+--+-- Wiring: Simply a led on pin 13:+--+--  <<http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.png>>+pulseOutDemo :: IO ()+pulseOutDemo = withArduino False "/dev/cu.usbmodemfd131" $ do+              setPinMode led  OUTPUT+              digitalWrite led False+              forever trigger+ where led  = digital 13+       trigger = do liftIO $ putStr "Pulse duration? (microseconds) "+                    d <- liftIO getLine+                    case reads d of+                     [(v, "")] -> pulseOut_hostTiming led True 0 v+                     _         -> liftIO $ putStrLn "Please enter a number."
− System/Hardware/Arduino/SamplePrograms/PulseIn.hs
@@ -1,40 +0,0 @@----------------------------------------------------------------------------------- |--- Module      :  System.Hardware.Arduino.SamplePrograms.PulseIn--- Copyright   :  (c) Levent Erkok--- License     :  BSD3--- Maintainer  :  erkokl@gmail.com--- Stability   :  experimental------ Computes the time a button is held pressed, demonstrating the use of--- the 'pulseIn_hostOnly' function with a time-out.----------------------------------------------------------------------------------module System.Hardware.Arduino.SamplePrograms.PulseIn where--import Control.Monad       (forever)-import Control.Monad.Trans (liftIO)--import System.Hardware.Arduino---- | Computes the amount of time a push-button is connected to--- input pin 2 on the Arduino. We will wait for at most 5 seconds,--- as a further demonstration of the time-out facility. Note that the--- timing is done on the host side, so this measurement is inherently--- inaccurate.------ The wiring is straightforward: Simply put a push-button between--- digital input 2 and +5V, guarded by a 10K resistor:------  <<http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Pulse.png>>-pulseDemo :: IO ()-pulseDemo = withArduino False "/dev/cu.usbmodemfd131" $ do-               setPinMode pb INPUT-               go- where pb = digital 2-       go = forever $ do-              liftIO $ putStr "Ready, push-and-hold for less than 5 seconds: "-              mbDur <- pulseIn_hostTiming pb True (Just 5000000)-              liftIO $ putStrLn $ case mbDur of-                Nothing -> "Time out!"-                Just d  -> "Button stayed high for: " ++ show d ++ " micro-seconds"
− System/Hardware/Arduino/SamplePrograms/PulseOut.hs
@@ -1,36 +0,0 @@----------------------------------------------------------------------------------- |--- Module      :  System.Hardware.Arduino.SamplePrograms.PulseOut--- Copyright   :  (c) Levent Erkok--- License     :  BSD3--- Maintainer  :  erkokl@gmail.com--- Stability   :  experimental------ Demonstrates the use of pulseOut----------------------------------------------------------------------------------module System.Hardware.Arduino.SamplePrograms.PulseOut where--import Control.Monad       (forever)-import Control.Monad.Trans (liftIO)--import System.Hardware.Arduino---- | Send pulses on a led as requested by the user. Note that the timing is computed--- on the host side, thus the duration of the pulse is subject to some error due to--- the Firmata communication overhead.------ Wiring: Simply a led on pin 13:------  <<http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.png>>-pulseDemo :: IO ()-pulseDemo = withArduino False "/dev/cu.usbmodemfd131" $ do-              setPinMode led  OUTPUT-              digitalWrite led False-              forever trigger- where led  = digital 13-       trigger = do liftIO $ putStr "Pulse duration? (microseconds) "-                    d <- liftIO getLine-                    case reads d of-                     [(v, "")] -> pulseOut_hostTiming led True 0 v-                     _         -> liftIO $ putStrLn "Please enter a number."
hArduino.cabal view
@@ -1,19 +1,13 @@ Name:          hArduino-Version:       0.4+Version:       0.5 Category:      Hardware Synopsis:      Control your Arduino board from Haskell.-Description:   Control Arduino from Haskell, using the Firmata protocol.-               .-               The hArduino library allows construction of Haskell programs that control-               Arduino boards that are running the (freely available) Firmata program. Note-               that hArduino does /not/ allow you to run arbitrary Haskell code on the-               Arduino! It simply allows you to control a board from Haskell, where you-               can exchange information with the board, send/receive commands from other-               peripherals connected, etc.+Description:   hArduino library allows Haskell programs to control Arduino boards and+               peripherals, using the Firmata protocol (<http://firmata.org>).                .                A short (4m29s) video of the blinking example: <http://www.youtube.com/watch?v=PPa3im44t2g>                .-               hArduino is work-in-progress. Comments, bug-reports, and patches are welcome.+               Comments, bug-reports, and patches are welcome. Copyright:     Levent Erkok, 2013 License:       BSD3 License-file:  LICENSE@@ -46,8 +40,7 @@                   , System.Hardware.Arduino.SamplePrograms.Counter                   , System.Hardware.Arduino.SamplePrograms.Distance                   , System.Hardware.Arduino.SamplePrograms.LCD-                  , System.Hardware.Arduino.SamplePrograms.PulseIn-                  , System.Hardware.Arduino.SamplePrograms.PulseOut+                  , System.Hardware.Arduino.SamplePrograms.Pulse                   , System.Hardware.Arduino.SamplePrograms.SevenSegment                   , System.Hardware.Arduino.SamplePrograms.Servo   Other-modules   : System.Hardware.Arduino.Comm