|o       experimentalerkokl@gmail.com Safe-Inferred3Delay (wait) for the given number of milli-seconds  NB. The  function is broken on Mac, see  /http://hackage.haskell.org/trac/ghc/ticket/7299  Until there'Ds a new GHC release that fixes this issue, we temporarily use system/sleep on Mac. WA simple printer that can keep track of sequence numbers. Used for debugging purposes. !Show a byte in a visible format. Show a list of bytes  Show a number as a binary value  Turn a lo/9hi encoded Arduino string constant into a Haskell string  Error out  experimentalerkokl@gmail.comNoneVSys-ex commands, see: http: firmata.orgwikiProtocol#Sysex_Message_Format 0x7F& MIDI Reserved for realtime messages 0x7E* MIDI Reserved for non-realtime messages 0x7A sampling interval 0x79* report name and version of the firmware 0x78D Configure special I2C settings such as power pins and delay times !0x77 I2C reply messages from an I/O board to a host "0x76* I2C request messages from a host to an I/O board #0x75 shiftOut config/data message (34 bits) $0x71) a string message with 14-bits per char %0x70* set max angle, minPulse, maxPulse, freq &0x6F, analog write (PWM, Servo, etc) to any pin '0x6E reply with a pin's current mode and value (0x6D ask for a pin's current mode and value )0x6C, reply with supported modes and resolution *0x6B5 ask for supported modes and resolution of all pins +0x6A reply with mapping info ,0x69+ ask for mapping of analog to pin numbers -0x00F 2nd SysEx data byte is a chip-specific command (AVR, PIC, TI, etc). .Firmata commands, see: http: firmata.orgwikiProtocol#Message_Types / 0xFF0 0xF91 0xF72 0xF43 0xF040xD0 port 50xC0 pin 60x90 port 70xE0 pin The Arduino monad. 8State of the computation 9Current debugging routine :$Serial port we are communicating on ;8The ID of the board (as identified by the Board itself) <Capabilities of the board =Current state of the board >!Incoming messages from the board ?State of the board @ Which analog pins are reporting A!Which digital pins are reporting BFor-each pin, store its data CHSemaphore list to wake-up upon receiving a digital message for this pin DData associated with a pin E2What the board is capable of and current settings FCapabilities of a pin G#Resolution, as referred to in http: firmata.orgwikiProtocol#Capability_Query I TODO: Not quite sure how this is used, so merely keep it as a Word8 now H)A response, as returned from the Arduino I*Represents messages currently unsupported JStatus of a port KAnalog pin mappings LCapabilities report MFirmware version (maj/min and indentifier NA request, as sent to Arduino O#Set the values on a port digitally P"Analog report values on pin enable/disable Q$Digital report values on port enable/disable RSet the mode on a pin S!Query the mapping of analog pins T$Query the capabilities of the board U$Query the Firmata version installed The mode for a pin. *I2C (Inter-Integrated-Circuit) connection Shift controller Servo Motor controller %PWM (Pulse-Width-Modulation) output  Analog input Digital output Digital input VA pin on the Arduino WThe pin number XA port (containing 8 pins) YThe port number *Declare a pin on the board by its number. Z2On the Arduino, pins are grouped into banks of 8. @ Given a pin, this function determines which port it belongs to [2On the Arduino, pins are grouped into banks of 8. M Given a pin, this function determines which index it belongs to in its port \2Debugging only: print the given string on stdout. ]#Which modes does this pin support? ^Current state of the pin _<Given a pin, collect the digital value corresponding to the E port it belongs to, where the new value of the current pin is given  The result is two bytes: " First lsb: pins 0-6 on the port ' * Second msb: pins 7-13 on the port HIn particular, the result is suitable to be sent with a digital message `-Keep track of listeners on a digital message a'Compute the numeric value of a command b$Convert a byte to a Firmata command c Convert a  to a byte dConvert a byte into a  eKeep track of pin-mode changes f5Depending on a mode-set call, determine what further - actions should be executed, such as enabling disabling pinport reporting c !"#$%&'()*+,-./01234567g8h9:;<=>?i@ABCDjklEmFGHIJKLMNOPQRSTUVnWXoY Z[\]^_`abcdefpqrs_ !"#$%&'()*+,-./01234567g8h9:;<=>?i@ABCDjklEmFGHIJKLMNOPQRSTUVnWXoY Z[\]^_`abcdef -,+*)('&%$#"! . 76543210/g8h9:;<=>?i@ABCDjklEmFGHMLKJINUTSRQPOVnWXoY Z[\]^_`abcdefpqrs experimentalerkokl@gmail.comNonet.Wrap a sys-ex message to be sent to the board uConstruct a non sys-ex message vAPackage a request as a sequence of bytes to be sent to the board  using the Firmata protocol. wUnpackage a SysEx response xUnpackage a Non-SysEx response tuvwyxvwxtuvwyx experimentalerkokl@gmail.comNone .Run the Haskell program to control the board: @ The file path argument should point to the device file that is " associated with the board. (COM1 on Windows,  '/dev/cu.usbmodemfd131' on Mac, etc.) ; The boolean argument controls verbosity. It should remain  z5 unless you have communication issues. The print-out D is typically less-than-useful, but it might point to the root  cause of the problem. See &System.Hardware.Arduino.Examples.Blink for a simple example. {Send down a request. |4Receive a sys-ex response. This is a blocking call. }VStart a thread to listen to the board and populate the channel with incoming queries. Y NB. This function is run in a thread; so be careful not to throw error or die otherwise  in here. ~,Initialize our board, get capabilities, etc  If !, debugging info will be printed Path to the USB port &The Haskell controller program to run {|}~ {|}~ {|}~ experimentalerkokl@gmail.comNone HRetrieve the Firmata firmware version running on the Arduino. The first I component is the major, second is the minor. The final value is a human / readable identifier for the particular board. 9Delay the computaton for a given number of milli-seconds .Set the mode on a particular pin on the board (Set or clear a digital pin on the board PRead the value of a pin in digital mode; this is a non-blocking call, returning $ the current value immediately. See ' for a version that waits for a change  in the pin first. PWait for a change in the value of the digital input pin. Returns the new value. D Note that this is a blocking call. For a non-blocking version, see , which returns the current  value of a pin immediately. 8Sleep until we receive a digital message from the board      experimentalerkokl@gmail.comNone  experimentalerkokl@gmail.comNone    experimentalerkokl@gmail.comNone=Blink the led connected to port 13 on the Arduino UNO board. E The blinking will synchronize with the printing of a dot on stdout. BDepending on your set-up, you will need to change the path to the B USB board. If you have problems, try changing the first argument  to  in the call to  , which will hopefully print  a useful diagnostic message.  experimentalerkokl@gmail.comNone<Read the value of a push-button switch (NO - normally open) ? connected to input pin 2 on the Arduino. We will continuously 4 monitor and print the value as it changes. Also, we'll turn 1 the led on pin 7 on when the switch is pressed. .The wiring diagram is fairly straightforward: 7Switch: ~10K pull-down resistor, between pin 2 and GND H Push-button NO-switch (normally open) between pin-2 and 5V 7Led : ~10K pull-down resistor between pin-7 and led+ . Led between GND and the resistor Don',t neglect the resistors to make sure you don't do a short-circuit!      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopq CJOrsPactuvwxyz{|}~~ hArduino-0.2System.Hardware.Arduino&System.Hardware.Arduino.Examples.Blink'System.Hardware.Arduino.Examples.SwitchSystem.Hardware.Arduino.UtilsSystem.Hardware.Arduino.Data System.Hardware.Arduino.ProtocolSystem.Hardware.Arduino.Comm&System.Hardware.Arduino.Firmata.BasicsSystem.Hardware.Arduino.FirmataArduinoPinModeI2CSHIFTSERVOPWMANALOGOUTPUTINPUTpin withArduino queryFirmwaredelay setPinMode digitalWrite digitalReadwaitForblinkswitchbase GHC.Conc.IO threadDelaymkDebugPrintershowByte showByteListshowBin getStringdieSysExCmdSYSEX_REALTIMESYSEX_NON_REALTIMESAMPLING_INTERVALREPORT_FIRMWARE I2C_CONFIG I2C_REPLY I2C_REQUEST SHIFT_DATA STRING_DATA SERVO_CONFIGEXTENDED_ANALOGPIN_STATE_RESPONSEPIN_STATE_QUERYCAPABILITY_RESPONSECAPABILITY_QUERYANALOG_MAPPING_RESPONSEANALOG_MAPPING_QUERYRESERVED_COMMAND FirmataCmd SYSTEM_RESETPROTOCOL_VERSION END_SYSEX SET_PIN_MODE START_SYSEXREPORT_DIGITAL_PORTREPORT_ANALOG_PINDIGITAL_MESSAGEANALOG_MESSAGE ArduinoStatemessageport firmataID capabilities boardState deviceChannel BoardStateanalogReportingPinsdigitalReportingPins pinStatesdigitalWakeUpQueuePinDataBoardCapabilitiesPinCapabilities ResolutionResponse UnimplementedDigitalMessage AnalogMapping CapabilitiesFirmwareRequestDigitalPortWrite AnalogReport DigitalReport SetPinModeAnalogMappingQueryCapabilityQuery QueryFirmwarePinpinNoPortportNopinPort pinPortIndexdebug getPinModes getPinDatacomputePortData digitalWakeUp firmataCmdVal getFirmataCmd sysExCmdValgetSysExCommandregisterPinModegetModeActionspinModepinValue$fShowBoardCapabilities$fShowResponse $fShowPin $fShowPortsysExnonSysExpackageunpackageSysExunpackageNonSysExgetCapabilitiesghc-prim GHC.TypesFalsesendrecv setupListener initializeTruesleepTillDigitalMessage