As soon as I finished my previous project, I knew I could improve it…
With pictures, of course ! And also take them on the fly, like in a photo booth…
Why use Haskell to generate pictures on the printer ? Just because Functors, Applicatives and Monads are obscurely cool… 🙂
By the way, I still had to throw in there a small Python script to run the show by capturing images from the camera, displaying them on the screen and listening for clicks on the tactile display.
As much as I love Haskell, several days of struggle didn’t yield much for capturing the video stream from a webcam in general and the Pi camera in particular.
A few proof of concept libraries, not updated in years, are no match for the Python ones, which proves again that what matters is not really how “good” a programming language is, but its ecosystem !
Similarly for Arduino, it doesn’t matter if the hardware / boards themselves are better or cheaper than others, what makes it so popular is the ecosystem, including the countless libraries and easy support available online !
Anyhow, please check out (and of course contribute is you feel so inclined) the code for yourself.
The bits that took some time on this projects were:
- figuring out / reverse engineering the POS commands / protocol to send bit images to the printer
- encode the above in Haskell, including resizing and optimizing images for such a low resolution, 1 colour printer
- figure out what screen to use, initially tried a small SPI OLED but the refresh rate was too slow
- trying to read the Pi camera in Haskell, either using V4L driver or natively (as PiCamera does in Python). Failing that, wasted time trying to call Python from Haskell, but gave up and accepted the obvious reality, that everything needs Python script to glue the bits together 🙂
- figuring out that Stack is much better at managing compatible dependencies than Cabal. Once done, installing Haskell and building the project on a fresh Raspberry Pi proved straight forward (though slow…), the one exception being that it requires LLVM-3.7 precisely (see more info here)
- making the GUI/desktop manager work with the SPI screen. The provided drivers were easy to install following instructions, however it took this post to explain how to update the xorg.conf too
Comments
Please log in or sign up to comment.