SlideShare ist ein Scribd-Unternehmen logo
1 von 23
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
Last-Fi
Last-Fi
Last-Fi
Last-Fi

Weitere ähnliche Inhalte

Was ist angesagt?

Net Scheme English Version
Net Scheme English VersionNet Scheme English Version
Net Scheme English Version
Tod Morita
 
Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)
Jyrki Pulliainen
 

Was ist angesagt? (19)

Net Scheme English Version
Net Scheme English VersionNet Scheme English Version
Net Scheme English Version
 
Installation of ns2
Installation of ns2Installation of ns2
Installation of ns2
 
Wireless openflow (english)
Wireless openflow (english)Wireless openflow (english)
Wireless openflow (english)
 
Pharo Status ESUG 2014
Pharo Status ESUG 2014Pharo Status ESUG 2014
Pharo Status ESUG 2014
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
Local development using telepresence
Local development using telepresenceLocal development using telepresence
Local development using telepresence
 
Thoughts on consistency models
Thoughts on consistency modelsThoughts on consistency models
Thoughts on consistency models
 
Pharo Status Fosdem 2015
Pharo Status Fosdem 2015Pharo Status Fosdem 2015
Pharo Status Fosdem 2015
 
MPI, Erlang and the web
MPI, Erlang and the webMPI, Erlang and the web
MPI, Erlang and the web
 
OSMC 2013 | Zabbix: A Practical Demo by Rihards Olups
OSMC 2013 | Zabbix: A Practical Demo by Rihards OlupsOSMC 2013 | Zabbix: A Practical Demo by Rihards Olups
OSMC 2013 | Zabbix: A Practical Demo by Rihards Olups
 
Continuous Performance Regression Testing with JfrUnit
Continuous Performance Regression Testing with JfrUnitContinuous Performance Regression Testing with JfrUnit
Continuous Performance Regression Testing with JfrUnit
 
Concurrent Programming in Python
Concurrent Programming in PythonConcurrent Programming in Python
Concurrent Programming in Python
 
Seastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephSeastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for Ceph
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Real-time Debugging using GDB Tracepoints and other Eclipse features
Real-time Debugging using GDB Tracepoints and other Eclipse features Real-time Debugging using GDB Tracepoints and other Eclipse features
Real-time Debugging using GDB Tracepoints and other Eclipse features
 
Advanced Tracing features using GDB and LTTng
Advanced Tracing features using GDB and LTTngAdvanced Tracing features using GDB and LTTng
Advanced Tracing features using GDB and LTTng
 
Rust Primer
Rust PrimerRust Primer
Rust Primer
 
Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)
 
Service Discovery with Consul - Arunvel Arunachalam
Service Discovery with Consul  - Arunvel Arunachalam Service Discovery with Consul  - Arunvel Arunachalam
Service Discovery with Consul - Arunvel Arunachalam
 

Ähnlich wie Last-Fi

Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Bit_Bucket_x31_Final
Bit_Bucket_x31_FinalBit_Bucket_x31_Final
Bit_Bucket_x31_Final
Sam Knutson
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
Sagiv Ofek
 

Ähnlich wie Last-Fi (20)

Pipecut - slides from presentation at MeetBSD California 2014
Pipecut - slides from presentation at MeetBSD California 2014Pipecut - slides from presentation at MeetBSD California 2014
Pipecut - slides from presentation at MeetBSD California 2014
 
Harmonic Stack for Speed
Harmonic Stack for SpeedHarmonic Stack for Speed
Harmonic Stack for Speed
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1t
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
Bit_Bucket_x31_Final
Bit_Bucket_x31_FinalBit_Bucket_x31_Final
Bit_Bucket_x31_Final
 
Experiences with Microservices at Tuenti
Experiences with Microservices at TuentiExperiences with Microservices at Tuenti
Experiences with Microservices at Tuenti
 
PROCESS WARP
PROCESS WARPPROCESS WARP
PROCESS WARP
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
 
Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lisp
 
A Science Project: Swift Serial Chat
A Science Project: Swift Serial ChatA Science Project: Swift Serial Chat
A Science Project: Swift Serial Chat
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
The linux kernel hidden inside windows 10
The linux kernel hidden inside windows 10The linux kernel hidden inside windows 10
The linux kernel hidden inside windows 10
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Autobahn primer
Autobahn primerAutobahn primer
Autobahn primer
 
Micro Services Architecture
Micro Services ArchitectureMicro Services Architecture
Micro Services Architecture
 
Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)Network Stack in Userspace (NUSE)
Network Stack in Userspace (NUSE)
 
microbit Microbit programming Microbit programming
microbit Microbit programming Microbit programmingmicrobit Microbit programming Microbit programming
microbit Microbit programming Microbit programming
 
Stream processing in python with Apache Samza and Beam
Stream processing in python with Apache Samza and BeamStream processing in python with Apache Samza and Beam
Stream processing in python with Apache Samza and Beam
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck -  Pravega: Storage Rei...
Flink Forward SF 2017: Srikanth Satya & Tom Kaitchuck - Pravega: Storage Rei...
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Last-Fi

  • 4.
  • 5.
  • 7. 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
  • 8. 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
  • 9. 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
  • 11. 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
  • 12.
  • 13.
  • 14. 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)
  • 15. 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
  • 16. 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…
  • 17. 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
  • 18. 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!)
  • 19. 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

Hinweis der Redaktion

  1. BCM2835 - 700mhz ARM chip, and VideoCore, 1080p HD Encode / Decode. 512mb.