Hardware
Basic diagram of all the components inside the camera :
(The Raspberry pi pin numbering reference is the one of wiring/pi4j library : http://pi4j.com/pins/model-2b-rev1.html)
And how they fit in the prototype case :
Software
There is two main external library/executable used by the Java program to achieve picture capturing and printing.
First is the program raspividyuv (in /opt/vc/bin/ of raspbian). It is launched within Java with the argument -o - in order to get the pixels data on stdout in an inputStream.
Second is the use of the Pi4J library. The Serial port is configured to send image data to the printer, a GPIO pin is used to read lines advance of the printer and another GPIO for the 'shutter' button event.
Before the Java program starts, the primary frame buffer is copied to the second frame buffer used for the PiTFT screen in order to see the camera preview on it. This is done by the fbcp program. (Credits to tasanakorn)
The Java program continuously receive the camera image and build a buffered array of pixels. Once the shutter button is pressed, the event launch two sequential process. The gray-scale image is converted in monochrome with Floyd–Steinberg dithering method. Then the printing thread is started, sending data to the printer on the serial port.
The sources and builds are here on: github. On the jar folder, there is the executable .jar file, the built fbcp program, and the config.txt file. On the last file, there is the welcome message, the header message, the printer serial speed and more configuration detailed in the 7th instruction below.
Hi,
i try to rebuild this project on an raspberry pi A+.
PolaPi starting...
/home/pi/polapi/header.txt not found, using config.txt for header text
Unable to determine hardware version. I see: Hardware : BCM2835
,
- expecting BCM2708 or BCM2709. Please report this to ...drogon.net
To solve this issue:
Downgrade the kernel to Kernel 4.4.50-v7+
sudo rpi-update 52241088c1da59a359110d39c1875cda56496764
If someone use an ILI9341 Display compile the fbcp library:
https://github.com/juj/fbcp-ili9341
Example for an Aliexpress 3,5" 320x240 Display:
cmake -DSPI_BUS_CLOCK_DIVISOR=6 -DILI9341=ON -DGPIO_TFT_DATA_CONTROL=24 -DGPIO_TFT_RESET_PIN=25 -DGPIO_TFT_BACKLIGHT=15 -DSINGLE_CORE_BOARD=ON -DARMV6Z=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 -DDISPLAY_CROPPED_INSTEAD_OF_SCALING=OFF -DDISPLAY_BREAK_ASPECT_RATIO_WHEN_SCALING=ON ..
Thanks for sharing this project.