Introduction: Arduino Sketch for a Retro Analogue Meter Graphic on a Modern TFT Display
Another sketch from my collection that may be of interest...
Displaying small digital numbers of temperature and humidity etc on a tiny screen is not always the best way to show information. The old style analogue meters are better in some situations and are great for a quick visual check of a sensor reading from a distance, they are also a good way of showing trends. So here we have a retro looking analogue meter on a modern TFT display, complete with smoothly animated needle!
I've pulled together a couple of functions in a demo sketch here for digital and analogue meters. I have not got around to "parameterising" the functions, so at the moment it is not easy to draw the meters anywhere on the screen with defined size and scales, but if there is sufficient interest (and given time!) I will try to do this at some point, in which case this Instructable will be updated.
I used an UNO and 2.2" ILI9341 based 320 x 240 pixel TFT, these are available at low cost on the internet.
Step 1: Connecting Up and Libraries Needed
The UNO is connected to the TFT display as in my Instructable here.
The libraries needed are also in that Instructable too.
Step 2: The Meters
The analogue meter has a moving needle that sweeps slowly with configurable speed to show the new value of a variable. The value in this example is in the range 0 to 100 (I used it for showing humidity). Meter labels can be changed easily. The actual new digital reading is shown in the bottom left corner of the meter. Needle end stops are emulated for readings outside of the normal range! Coloured zones can be added to show comfortable ranges etc.
Tip: The needle flicker is minimal but removing the units display from the needle sweep zone will improve things (and also mean that Font 4 does not need to be loaded, saving FLASH space). Just two lines in the sketch (156 and 200) need to be commented out, use the new Arduino 1.6.0 IDE and switch on line numbering to help find them!
The digital meter uses a 7 segment font and shows a dim image of the unlit segments to try to emulate the look of a real 7 segment display! The colour could easily be changed, perhaps with the value as in my Instructable here.
Step 3: The Sketch
Here we are...
Normally I would make graphics functions like this easier to adapt, resize and relocate on the screen, but I did not need to elaborate the functions for my application. Come back for updates and any bug fixes at a future date!
Step 4: Video...
Here is a video of the analogue meter in operation (this includes some linear meters that are not part of this instructable). The needle flicker and jerky pauses in the video is due to my cheap webcam, the actual movement is much much smoother.
AndrewH356 made it!
We have a be nice policy.
Please be positive and constructive.