Run Processing programs on your touchscreen RPi2
Run Processing 3 on the Touchscreen
Once I worked out all the bugs on the notebook (Figure 3), the sketch was copied over to the RPi2, from the Linux notebook, using the rcp
command.
rob% cd /home/rob/ rob% rcp sketchbook/g4p_basic_slider/g4p_basic_slider.pde \ pi@192.168.1.162:/home/pi/sketchbook/g4p_basic_slider/\ g4p_basic_slider.pde
On the Pi, go to the Processing directory and start Processing. Then select File | Sketchbook and the g4p_basic_slider sketch. When the sketch appears in the edit window, hit Run to see how it works (Figure 4). If you flip the toggle, the screen background should change colors.
All this can be done from the RPi2 TFT screen using the touchscreen desktop menus, command lines, and a wireless keyboard. Making the sketch a standalone application without having to start Processing is a topic for another article.
You'll notice that there are some limits to using the touchscreen display. First, screen real estate is limited, so graphical interfaces are likely to have only a few controls. Second, on the resistive touchscreen, fingers aren't very accurate for moving the mouse pointer. Use a smooth, blunt stylus for accurate mouse positioning. And, you'll still find a keyboard useful, at least, until you get all your desktop Processing apps built.
Next Steps
This brief introduction to Processing on a Linux notebook and the RPi2 simply changed the background color and sent text messages to the console as a toggle switch was flipped and a slider was slid. The next step is to tie those screen functions to physical actions on the GPIO pins. A simple example would be to toggle an external LED on and off. Or, perhaps you could adjust an LED's brightness according to the position of the slider.
As I mentioned earlier, standalone applications would also be nice and are something I'll tackle in another story. Try out the RPi2 with a small touchscreen display, your Linux notebook, and Processing. I think you'll find some convenient uses for the technology.
Infos
- 3.5-inch color TFT touchscreen display: https://www.adafruit.com/products/2441
- Processing website: https://processing.org/
- Adafruit PiTFT image: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
- Logitech K400r keyboard/mousepad: http://www.logitech.com/en-us/product/wireless-touch-keyboard-k400r
- Processing 3 download for the Pi 2: https://processing.org/download/?processing
- G4P library for Processing 3: http://www.lagers.org.uk/g4p/
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 4
(incl. VAT)