Last active
August 29, 2015 13:55
-
-
Save ramirez7/8738600 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 Message = Mark Word8 | Load Word64 Word64 | Undo | Reset | Legal Bool | Suggest Bool | |
| newButtonPressEvent :: Int -> m -> Chan m -> IO () | |
| newButtonPressEvent pinNumber msg ch = -- forkIO blah blah blah | |
| -- Push msg into ch whenever a press occurs on pinNumber (rising edge, basically) | |
| -- Usually used partially applied :: Int -> m -> (Chan m -> IO ()) | |
| newButtonHoldEvent :: Int -> (Bool -> m) -> Chan m -> IO () | |
| newButtonHoldEvent pinNumber msg ch = -- forkIO, recursive loop with lastPressed | |
| -- Push msg into ch whenever a hold or release occurs on pinNumber (rising edge = hold, falling edge = releaseS) | |
| -- Usually used partially applied :: Int -> (Bool -> m) -> (Chan m -> IO ()) | |
| newEventHandler :: [(Chan m -> IO ()] -> IO (Chan m) | |
| newEventHandler event = | |
| -- Create single new channel. Pass it to all events to fork. | |
| -- Return channel. User can read from this channel and handle events accordingly. | |
| -- Lots of refactoring of these types could be in order to make it better. We'll see. | |
| -- Abstracting over UART will be the trickiest, but I'm sure it's doable in a nice way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment