Last active
August 29, 2015 13:56
-
-
Save ramirez7/8816974 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Edge = Rising | Falling | |
| newGpioEdgeEventHandler :: Int -> (Edge -> Maybe m) -> Chan m -> IO () | |
| -- The above function is a more general case of pressing or holding a button | |
| -- Holding sends messages on the Rising and Falling edges of a GPIO pin's input | |
| -- Pressing only sends messages on a Rising edge | |
| -- If you want to not send a message on an edge, just have your | |
| -- input function return Nothing | |
| -- Otherwise, return Just m | |
| -- For example, if we want to send a message to Undo every time a press is | |
| -- detected, we would the following function | |
| data Message = Undo | Legal Bool | ... | |
| f :: Edge -> Maybe Message | |
| f Rising = Just Undo | |
| f Falling = Nothing | |
| -- The following function will send a message that will be True or False | |
| -- depending on if the user wants to display legal moves | |
| g :: Edge -> Maybe Message | |
| g Rising = Just (Legal True) | |
| g Falling = Just (Legal False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment