An AnalogClock is a widget that enables the display of a classic analog watch, as opposed to the DigitalClock which displays time with text. The clock uses a background image as the clock face. The hour, minute and second hands are each using an image and rotate around a configurable center.
The AnalogClock can be found in the Miscellaneous widget group in TouchGFX Designer.
The properties for a AnalogClock in TouchGFX Designer.
|Property Group||Property Descriptions|
|Name||Name of the widget. Name is the unique identifier used in TouchGFX Designer and code.|
|Location||X and Y specify the top left corner of the widget relative to its parent.|
W and H specify the width and height of the widget.
The size of a AnalogClock is taken from the size of the associated image and cannot be altered except by changing the image.
Lock specifies if the widget should be locked in its current X, Y, W and H.
Locking the widget also disables interacting with the widget through the screen.
Visible specifies the visibility of the widget. Making the widget invisible also disables interacting with the widget through the screen.
|Style||Style specifies a predefined setup of the widget, that sets select properties to predefined values.|
These styles contain images that are free to use.
|Appearance||Image specifies the image to be used as background.|
Rotation Center X and Rotation Center Y specifies the point at which the clock hands should rotate
|Time||Use Am/Pm specifies if time should be in 12h or 24h format.|
Initial Time specifies the initial time the clock shows.
|Clock Hands||Clock Hands specifies which clock hands (Second, Minute and Hour Hand) the AnalogClock should show and the order of the hands.|
Each clock hand can set a Hand Image and their rotation point by setting Rotation Position X and Rotation Position Y.
The Minute and Hour Hand have the option to use sweeping hand motion by setting Sweeping Movement
|Animations||Animate Clock Hand Movement specifies if animation of the clock hands are enabled.|
Duration specifies how long the amination is.
Easing and Easing Option specify the easing equation used.
|Mixins||Draggable specifies if the widget is draggable at runtime.|
ClickListener specifies if the widget emits a callback when clicked.
MoveAnimator specifies if the widget can animate changes to X and Y values.
The Time property group allows the user to set the initial time of the clock widget and whether or not to use Am/Pm standard.
Choosing Am/Pm also results in a slight code generation change. Instead of using the following function in Analog Clock to initialize the time:
initializeTime24Hour(uint8_t hour, uint8_t minute, uint8_t second)
The following function is used when using 12-hour notation:
initializeTime12Hour(uint8_t hour, uint8_t minute, uint8_t second, bool am)
To update the time displayed by the clock, one of the following functions can be used.
setTime24Hour(uint8_t hour, uint8_t minute, uint8_t second)
setTime12Hour(uint8_t hour, uint8_t minute, uint8_t second, bool am)
In the Clock Hands property group, the user can define which hands to use and their z-order. The hand defined first will be rendered above the others.
Each hand needs an image and a rotation position. The rotation position determines the point at which the defined hand image should rotate around itself.
The hour and minute hands have the ability to use Sweeping Movement. When this option is enabled the hand will no longer do an instantaneous jump from one position to another.
The animation section allows the user to define more advanced hand movement. However, if the hour and minute hand have Sweeping Movement enabled, they will not animate.
In the following example the animation duration is set to '30', easing is set to 'Bounce' with 'Out' as its easing option:
The actions and triggers supported by an AnalogClock are described in the following sections.
|Standard widget actions||Description|
|Move widget||Move a widget to a new position over time.|
|Hide widget||Hides a widget (sets visibility to false).|
|Show widget||Make a hidden widget visible (sets visibility to true).|
An AnalogClock does not emit any triggers.
For more details on drawing performance, read the General UI Component Performance section.
In the generated code for the View base class we can see how TouchGFX Designer sets up an AnalogClock.
analogClock.invalidate()if you change the appearance of the widget.
The following example shows how to set up clock movement:
To further explore the AnalogClock, try creating a new application within TouchGFX Designer with one of the following UI templates: