For someone who likes to write all their IOT code in Ruby, and has a lot of really useful libraries already, it’s getting harder when you experiment in IOT. It looks like Python has taken over almost everything.
And when you buy a shield (HAT/PHAT) for a raspberry Pi the drivers are almost always delivered in Python – especially from good suppliers like Adafruit and Pimoroni.
A good example is my “Scroll Phat HD” board for the raspberry Pi Zero W – it’s a really useful and good way of displaying small amounts of data – as you can scroll the text sideways very easily with their libraries with very little additional code, if you are using Python.
A Scroll Phat HD in all it’s glory.
This was until I found pycall – giving me a easy way to use Python libraries directly from Ruby.
and it works! Here is a short code example for using the Scroll PHAT HD python library
require 'pycall/import'
include PyCall::Import
pyimport 'scrollphathd', as: 'scroll'
width = 17
puts "loaded libraries ready to call scroll"
# First clear the display
scroll.clear()
scroll.set_brightness(0.2)
streng = "This is a long string"
scroll.write_string(streng + " ", x=width, y=0)
scroll.show()
teller = 0
while teller < (streng.length) do
scroll.scroll()
scroll.show()
sleep(0.1)
end
It could not be simpler – and of course I run it all directly on the Raspberry PI. Now I can both have the best of both worlds.