Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

6.
Access to the GPIO pins
http://www.airspayce.com/mikem/bcm2835/
# tar -zxf bcm2835-1.3.tar.gz
# cd bcm2835-1.3/src
# make libbcm2835.a
# cc -shared bcm2835.o -o libbcm2835.so
• You will need to download and build the bcm2835
library on the Pi which will enable you to access
the pins
• In order to interop with .NET / Mono you must use
a shared object (so) against a statically linked
binary.
• You are now able to reference the .so file like any
normal .dll file for interop using the [<DllImport>]
attribute

7.
LCD Screen!
• Almost all these displays use the Hitachi HD44780
LCD Controller
• Can be operated in 8 bit or 4 bit mode and either
way they take up a ton of IO pins !
• After the initialization, the general usage is to shift a
bunch of bits onto the data lines that will instruct the
LCD what do to, then pulse the E line to indicate it
should look at and act on the data.
• Reading and writing data is almost identical except
you hold the RS line high between writing text in
ASCII binary

9.
LCD Screen!
• Using agents to isolate state and provide
timing. It’s a self contained async system that
can only be changed via safe messaging
• Messing about with low-level timing and bit
shifting
• Cunning use of TryReceive to provide
overrideable temporary text and text scrolling

10.
NES Pad!
• A NES pad is nothing more than a 8-bit parallel to serial shift
register!
• Simply hold LATCH low (Write/Shift in this diagram) and then each
successive pulse on the CLOCK line will shift the state of the next
button onto the DATA line (Q in this diagram)

11.
NES Pad!
• Low-Level signal manipulation
• Reading values using functional techniques such as list
folding
• Isolating state and providing safe asynchronous
operation for both manual and interval polling via
message passing
• Use of active patterns to determine internal state
• Using first-class events to trigger on patterns
• Use of active patterns to provide the consumer an
elegant way of expressing the matching of button
depressing, depress durations and history sequence

12.
Last.Fm API
• Unfortunately does not have any metadata
associated with it such as a WSDL or an Odata
endpoint which means I cannot use a type
provider ! :’( Boo, Hiss
• There are .NET libraries consisting of large
object hierarchies to access Last.Fm but I’m
only interested in small portion of the API and
don’t really want to use one of these…

13.
MPC / MPD and the “Player”
• Music Player Deamon is the linux software I
am using to play the music. It is capable of
streaming from an internet address.
• MPC is the command-line interface to the
deamon which allows control via the
command line
• The “Player” object provides access to the
user’s Last.Fm station via MPC and raises
events to show stuff that’s happening

14.
The core program…
• ServiceStack is used to host a webservice that can
provide information about what’s playing and
perform some control functions, via the Player
object
• NES / LCD /Player objects are initalized and
various events hooked up between them
• GO!! Everything at this point is async, the main
program thread just sits there doing nothing (and
more importantly, not blockng anything!)

15.
The Website!
• The website uses Funscript, which is a F# to
JavaScript compiler and a TypeScript type
provider that allows direct access to JS
libraries with F# code
• Funscript also hosts its own webserver, so I
don’t need to mess about with ASP.NET linux
equivalents