-
Display Programming (1) - Adafruit 2.8" Resistive Touch Screen
05/23/2016 at 10:43 • 0 commentsDisplays come in all shapes and sizes. Selection can be difficult with many factors to consider; power consumption, size, readability, touch input and of course there's the actual programming of a micro-controller in order to make full use of your choice. The Adafruit 2.8" Touch screen display is driven by the ILI9341 display driver, while the resistive touch data is output on 2 digital pins and 2 analogue pins. The Adafruit site are pretty good with their documentation so there are easy to follow wiring diagrams and an Arduino library with example sketches available through their site. I'm not going to cover the basics of connecting the display, instead I'm going to discuss some of the GUI elements I've created for this project and lesson learned working with this screen over a couple of logs.
Before diving into the programming whole, the project goals need to be considered. Using the touch screen as the main input to the MyComm device makes it very similar in appearance to a smartphone. In order to achieve smartphone functionality would require a much higher level of processing than the Teensy micro-controller can handle. This can be observed when writing images to the screen. The Teensy doesn't have a large enough ram to buffer the entire screen and run other code. This means when an image is loaded from external storage, the image is written on a "line-by-line" basis. Using micro-sd as the storage device bottlenecks this method further and results in being able to see the image as it is drawn in. See the example video below:
The advantage of using a small micro-controller is power! Then Teensy at very maximum draw only uses 120mA; The raspberry pi typically draws 200-400mA depending on version. So, with the limitation of the Teensy in mind, it's much more reasonable to think of pre-smartphone era devices as the model for our interface.
Starting out with images; it's simple enough to draw some basic shapes in paint to produce a small size image to make a button or display information. A really useful example in the ILI9341 library is "pictureEmbed". This uses an image broken down into an array of bytes in order to store the image in the micro-controller program memory. This means we can utilise the Teensy's 256KB of flash storage to hold small images. The writer of the example sketch also includes a Link that will convert files for us for free! The flash stored images load much faster as it bypasses the need for the micro-sd card. And thus we have GUI icons:
From a timing/speed perspective I ran some simple draw tests for comparison. The results below:
File Name Storage Method File Size / Program Memory File Dimension Write to Screen Time Scotsat Logo SD Card 161kB 240 x 104 220mS (visually see write) Scotsat Logo Prog Memory 49.920kB (19% of prog memory)
240x104 3.65ms Envelope (small) SD Card 246B 8x8 2.2mS Envelope (small) Prog Memory 128B (0.05% prog memory) 8x8 0.057ms Envlope Large SD Card 2.74kB 30x30 29.7ms Envlope Large Prog Memory 1.8kB 30x30 0.68ms Clearly the program memory for loading images is substantially faster. I'll have to keep an eye on my memory usage to ensure I have enough room on the Teensy for the actual running code.
JW
-
Display Testing - GUI GUI, Oh Baby!
05/20/2016 at 16:09 • 0 commentsI've had a week or so to play around with the display. It's easy to use but building GUI elements takes time! I've never appreciated how much work at the basic level is being done on smart phones! Here's a video of my work so far, I'll update with details next week.
Sometime's the best way to get traction in a project is to "just try it". I tend to believe more things can be learned from mistakes than instant successes. With the "lets dive in" cap on, we purchased an Adafruit Assembled Touch TFT module; this one. Pairing with a Teensy 3.1 as the brains behind the operation was easy thanks to Paul Stoffregen's immense work on supporting libraries. The TFT screen has an ILI9341 Controller which has been used quite commonly in the Arduino world. We used a Teensy for the brains for a number of reasons; The spec/price ratio is excellent, the teensy supporting libraries are well put together and supported and, most of all, I have one sitting spare on my desk!
JW
-
Design Concepts - Worth a couple of thousand words!
05/20/2016 at 15:07 • 0 commentsWhen first talking about the project the question "What will it look like" tends to be at the top of the list. Design concepts are tricky to do in the beginning when you haven't solidified your internal hardware yet. With a rough project goal, some key design criteria, a trusty ruler, a decent CAD package and a phone to measure for comparison; I was able to put together the designs below:
For those of you paying attention; Number '8' is an Iphone 6 - included for comparison
You might be able to tell that I have a soft spot for hardware keyboards. Does anyone else remember the G1 android phone? That had an amazing keyboard, but I digress. The main criteria for the designs were as follows:
The final design '9' was settled on as the target design; Abandoning the hardware keyboard but allowing more length and a bigger screen made the design much more manageable internally with more space for components. The helical/patch antenna argument will have to be settled at a future date.
JW