HMI - Image rotation
The HMI is capable of rotating an image and here's what the example will do, presented for your viewing pleasure an an animated gif:
We suggest using this feature sparingly because it will greatly slow your controller down. The smaller the image the faster it will render.
Here's the code that displays the two images:
#HMI DrawImage( x:131px, y:26px, i:"gauge.png" ) ;draw the gauge
#HMI DrawImage( id:0, x:177px, y:100px, i:"needle_grn.png", z:65, ox:63, oy:36 );draw the dial, note the z index places the dial on top of the gauge
There are a few key elements to making this work:
- The gauge must be drawn behind the needle. The "z:65" ensures the needle will be drawn on top of the gauge.
- The needle has been given an id to allow it's parameters to be changed. To rotate or change the image, we only need refer to the id.
- The centre of the needle must be specified as rotation will be performed around this point.
And here's the code that actually rotates the needle (and in this case, chooses the yellow version):
#HMI DrawImage( id:0, i:"needle_ylw.png", ro:f(*fAngle) )
The full source code and images for this demo is available here: