• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Last-Fi
 

Last-Fi

on

  • 1,018 views

Last-Fi - an F# powered Raspberry Pi internet radio

Last-Fi - an F# powered Raspberry Pi internet radio

Statistics

Views

Total Views
1,018
Views on SlideShare
1,011
Embed Views
7

Actions

Likes
0
Downloads
5
Comments
0

1 Embed 7

http://lanyrd.com 7

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • BCM2835 - 700mhz ARM chip, and VideoCore, 1080p HD Encode / Decode. 512mb.

Last-Fi Last-Fi Presentation Transcript

  • Last-FI Ross McKinlay 2013
  • Me @pezi_pink www.pinksquirrellabs.com
  • fsharp.org
  • Last-Fi!
  • Raspberry Pi & F# • You want the SOFT float version of the Raspbian Linux distro! Save yourself lots of headaches! • Fully update your Pi (apt-get update, apt-get upgrade) • Ensure the SSH server starts when your Pi boots • apt-get mono-complete • Develop your projects on another machine, and use WinSCP / PuTTY (or similar) to transfer
  • 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
  • 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
  • LCD Screen!
  • 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
  • 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)
  • 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
  • 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…
  • 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
  • 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!)
  • 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