Skip to main content
Version: 4.16


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.

AnalogClock running in the simulator (sped up footage)

Widget Group#

The AnalogClock can be found in the Miscellaneous widget group in TouchGFX Designer.

AnalogClock in TouchGFX Designer


The properties for a AnalogClock in TouchGFX Designer.

Property GroupProperty Descriptions
NameName of the widget. Name is the unique identifier used in TouchGFX Designer and code.
LocationX 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.
StyleStyle specifies a predefined setup of the widget, that sets select properties to predefined values.
These styles contain images that are free to use.
AppearanceImage 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
TimeUse Am/Pm specifies if time should be in 12h or 24h format.

Initial Time specifies the initial time the clock shows.
Clock HandsClock 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
AnimationsAnimate 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.
MixinsDraggable 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)

Clock Hands#

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.

Hour, Minute and Second Hands#

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.

Clock hand properties

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.

Sweeping movement disabled

Sweeping movement enabled


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:

Example of a clock animation


The actions and triggers supported by an AnalogClock are described in the following sections.


Standard widget actionsDescription
Move widgetMove a widget to a new position over time.
Hide widgetHides a widget (sets visibility to false).
Show widgetMake a hidden widget visible (sets visibility to true).


An AnalogClock does not emit any triggers.


An AnalogClock consists of an Image and three TextureMappers, which are MCU resource intensive components. Therefore, an AnalogClock is considered a demanding widget on most platforms.

For more details on drawing performance, read the General UI Component Performance section.


Generated Code#

In the generated code for the View base class we can see how TouchGFX Designer sets up an AnalogClock.

#include <gui_generated/main_screen/mainViewBase.hpp>
#include "BitmapDatabase.hpp"
analogClock.setXY(124, 15);
analogClock.initializeTime24Hour(10, 10, 0);
void mainViewBase::setupScreen()
You can use these functions and the others available in the AnalogClock class in user code. Remember to force a redraw by calling analogClock.invalidate() if you change the appearance of the widget.

User Code#

The following example shows how to set up clock movement:

#include <gui_generated/main_screen/mainViewBase.hpp>
#include <gui/main_screen/mainPresenter.hpp>
class mainView : public mainViewBase
virtual ~mainView() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void handleTickEvent();
int tickCounter;
int analogHours;
int analogMinutes;
int analogSeconds;
#endif // MAINVIEW_HPP
#include <gui/main_screen/mainView.hpp>
void mainView::setupScreen()
analogHours = analogClock.getCurrentHour();
analogMinutes = analogClock.getCurrentMinute();
analogSeconds = analogClock.getCurrentSecond();
void mainView::tearDownScreen()
void mainView::handleTickEvent()
if (tickCounter % 60 == 0)
if (++analogSeconds >= 60)
analogSeconds = 0;
if (++analogMinutes >= 60)
analogMinutes = 0;
if (++analogHours >= 24)
analogHours = 0;
// Update the clocks
analogClock.setTime24Hour(analogHours, analogMinutes, analogSeconds);

TouchGFX Designer Examples#

To further explore the AnalogClock, try creating a new application within TouchGFX Designer with one of the following UI templates:

Clock Example UI template in TouchGFX Designer

API Reference#