주요 내용으로 건너뛰기

AnalogClock

An analog clock. Should be supplied with images for the background, hour hand, minute hand and the optional second hand. You setup the AnalogClock by specifying the rotation point of each hand as well as the global rotation point of the clock. You can customize the behavior of the AnalogClock in respect to animations and relations between the hands e.g. if the hour hand should move gradually towards the next hour as the minute hand progresses (setHourHandMinuteCorrection())

Inherits from: AbstractClock, Container, Drawable

Public Functions

AnalogClock()
virtual uint8_tgetAlpha() const
Gets the current alpha value of the widget.
virtual uint16_tgetAnimationDuration()
Gets the animation duration.
virtual boolgetHourHandMinuteCorrection() const
Gets hour hand minute correction.
virtual boolgetMinuteHandSecondCorrection() const
Gets minute hand second correction.
virtual voidinitializeTime12Hour(uint8_t hour, uint8_t minute, uint8_t second, bool am)
Sets the time with input format as 12H.
virtual voidinitializeTime24Hour(uint8_t hour, uint8_t minute, uint8_t second)
Sets the time with input format as 24H.
virtual voidsetAlpha(uint8_t newAlpha)
Sets the opacity (alpha value).
virtual voidsetAnimation(uint16_t duration =10, EasingEquation animationProgressionEquation =EasingEquations::backEaseInOut)
Setup the clock to use animation for hand movements.
virtual voidsetBackground(const BitmapId backgroundBitmapId)
Sets the background image of the clock.
virtual voidsetBackground(const BitmapId backgroundBitmapId, int16_t rotationCenterX, int16_t rotationCenterY)
Sets the background image of the clock and the rotation center of the clock.
virtual voidsetHourHandMinuteCorrection(bool active)
Sets whether hour hand minute correction should be active.
virtual voidsetMinuteHandSecondCorrection(bool active)
Sets whether minute hand second correction should be active.
virtual voidsetRotationCenter(int16_t rotationCenterX, int16_t rotationCenterY)
Sets the rotation center of the clock.
virtual voidsetupHourHand(const BitmapId hourHandBitmapId, int16_t rotationCenterX, int16_t rotationCenterY)
Sets up the hour hand.
virtual voidsetupMinuteHand(const BitmapId minuteHandBitmapId, int16_t rotationCenterX, int16_t rotationCenterY)
Sets up the minute hand.
virtual voidsetupSecondHand(const BitmapId secondHandBitmapId, int16_t rotationCenterX, int16_t rotationCenterY)
Sets up the second hand.

Protected Functions

virtual boolanimationEnabled() const
Is animation enabled for the hands?
virtual floatconvertHandValueToAngle(uint8_t steps, uint8_t handValue, uint8_t secondHandValue =0) const
Convert hand value to angle.
virtual voidsetupHand(TextureMapper & hand, const BitmapId bitmapId, int16_t rotationCenterX, int16_t rotationCenterY)
Sets up a given the hand.
virtual voidupdateClock()
Update the visual representation of the clock on the display.

Protected Attributes

uint16_tanimationDuration
The duration of hand animations. If 0 animations are disabled.
EasingEquationanimationEquation
The easing equation used by hand animations.
Imagebackground
The background image of the AnalogClock.
int16_tclockRotationCenterX
The x coordinate of the rotation point of the hands.
int16_tclockRotationCenterY
The y coordinate of the rotation point of the hands.
AnimationTextureMapperhourHand
TextureMapper used for drawing the hourHand.
boolhourHandMinuteCorrectionActive
Is hour hand minute correction active.
uint8_tlastHour
The last know hour value.
uint8_tlastMinute
The last know minute value.
uint8_tlastSecond
The last know second value.
AnimationTextureMapperminuteHand
TextureMapper used for drawing the minuteHand.
boolminuteHandSecondCorrectionActive
Is minute hand second correction active.
AnimationTextureMappersecondHand
TextureMapper used for drawing the secondHand.

Additional inherited members

Public Functions inherited from AbstractClock

AbstractClock()
boolgetCurrentAM() const
Is the current time a.m.
uint8_tgetCurrentHour() const
Gets the current hour.
uint8_tgetCurrentHour12() const
Gets current hour 12, i.e.
uint8_tgetCurrentHour24() const
Gets current hour 24, i.e.
uint8_tgetCurrentMinute() const
Gets the current minute.
uint8_tgetCurrentSecond() const
Gets the current second.
virtual voidsetTime12Hour(uint8_t hour, uint8_t minute, uint8_t second, bool am)
Sets the time with input format as 12H.
virtual voidsetTime24Hour(uint8_t hour, uint8_t minute, uint8_t second)
Sets the time with input format as 24H.

Protected Attributes inherited from AbstractClock

uint8_tcurrentHour
Local copy of the current hour.
uint8_tcurrentMinute
Local copy of the current minute.
uint8_tcurrentSecond
Local copy of the current second.

Public Functions inherited from Container

virtual voidadd(Drawable & d)
Adds a Drawable instance as child to this Container.
Container()
virtual boolcontains(const Drawable & d)
Query if a given Drawable has been added directly to this Container.
virtual voiddraw(const Rect & invalidatedArea) const
Draw this drawable.
virtual voidforEachChild(GenericCallback< Drawable & > * function)
Executes the specified callback function for each child in the Container.
virtual Drawable *getFirstChild()
Obtain a pointer to the first child of this container.
virtual voidgetLastChild(int16_t x, int16_t y, Drawable ** last)
Gets the last child in the list of children in this Container.
virtual voidgetLastChildNear(int16_t x, int16_t y, Drawable * last, int16_t fingerAdjustmentX, int16_t * fingerAdjustmentY)
Works similar to getLastChild() but also considers the current set finger size in HAL.
virtual RectgetSolidRect() const
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
virtual voidinsert(Drawable * previous, Drawable & d)
Inserts a Drawable after a specific child node.
virtual voidremove(Drawable & d)
Removes a Drawable from the container by removing it from the linked list of children.
virtual voidremoveAll()
Removes all children in the Container by resetting their parent and sibling pointers.
virtual voidunlink()
Removes all children by unlinking the first child.

Protected Functions inherited from Container

virtual RectgetContainedArea() const
Gets a rectangle describing the total area covered by the children of this container.
virtual voidmoveChildrenRelative(int16_t deltaX, int16_t deltaY)
Calls moveRelative on all children.

Protected Attributes inherited from Container

Drawable *firstChild
Pointer to the first child of this container. Subsequent children can be found through firstChild's nextSibling.

Public Functions inherited from Drawable

voidcenter()
Centers the Drawable inside its parent.
voidcenterX()
Center the Drawable horizontally inside its parent.
voidcenterY()
Center the Drawable vertically inside its parent.
virtual voidchildGeometryChanged()
This function can be called on parent nodes to signal that the size or position of one or more of its children has changed.
virtual voiddraw(const Rect & invalidatedArea) const =0
Draw this drawable.
Drawable()
Initializes a new instance of the Drawable class.
voiddrawToDynamicBitmap(BitmapId id)
Render the Drawable object into a dynamic bitmap.
voidexpand(int margin =0)
Expands the Drawable to have the same size as its parent with a given margin around the edge.
RectgetAbsoluteRect() const
Helper function for obtaining the rectangle this Drawable covers, expressed in absolute coordinates.
virtual Drawable *getFirstChild()
Function for obtaining the first child of this drawable if any.
int16_tgetHeight() const
Gets the height of this Drawable.
virtual voidgetLastChild(int16_t x, int16_t y, Drawable ** last) =0
Function for obtaining the the last child of this drawable that intersects with the specified point.
Drawable *getNextSibling()
Gets the next sibling node.
Drawable *getParent() const
Returns the parent node.
const Rect &getRect() const
Gets the rectangle this Drawable covers, in coordinates relative to its parent.
virtual RectgetSolidRect() const =0
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
virtual RectgetSolidRectAbsolute()
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates.
virtual voidgetVisibleRect(Rect & rect) const
Function for finding the visible part of this drawable.
int16_tgetWidth() const
Gets the width of this Drawable.
int16_tgetX() const
Gets the x coordinate of this Drawable, relative to its parent.
int16_tgetY() const
Gets the y coordinate of this Drawable, relative to its parent.
virtual voidhandleClickEvent(const ClickEvent & event)
Defines the event handler interface for ClickEvents.
virtual voidhandleDragEvent(const DragEvent & event)
Defines the event handler interface for DragEvents.
virtual voidhandleGestureEvent(const GestureEvent & event)
Defines the event handler interface for GestureEvents.
virtual voidhandleTickEvent()
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
virtual voidinvalidate() const
Tell the framework that this entire Drawable needs to be redrawn.
virtual voidinvalidateRect(Rect & invalidatedArea) const
Request that a region of this drawable is redrawn.
boolisTouchable() const
Gets whether this Drawable receives touch events or not.
boolisVisible() const
Gets whether this Drawable is visible.
virtual voidmoveRelative(int16_t x, int16_t y)
Moves the drawable.
virtual voidmoveTo(int16_t x, int16_t y)
Moves the drawable.
virtual voidsetHeight(int16_t height)
Sets the height of this drawable.
voidsetPosition(const Drawable & drawable)
Sets the position of the Drawable to the same as the given Drawable.
voidsetPosition(int16_t x, int16_t y, int16_t width, int16_t height)
Sets the size and position of this Drawable, relative to its parent.
voidsetTouchable(bool touch)
Controls whether this Drawable receives touch events or not.
voidsetVisible(bool vis)
Controls whether this Drawable should be visible.
virtual voidsetWidth(int16_t width)
Sets the width of this drawable.
voidsetWidthHeight(const Bitmap & bitmap)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Drawable & drawable)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Rect & rect)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(int16_t width, int16_t height)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
virtual voidsetX(int16_t x)
Sets the x coordinate of this Drawable, relative to its parent.
voidsetXY(const Drawable & drawable)
Sets the x and y coordinates of this Drawable.
voidsetXY(int16_t x, int16_t y)
Sets the x and y coordinates of this Drawable, relative to its parent.
virtual voidsetY(int16_t y)
Sets the y coordinate of this Drawable, relative to its parent.
virtual voidtranslateRectToAbsolute(Rect & r) const
Helper function for converting a region of this Drawable to absolute coordinates.
virtual ~Drawable()
Finalizes an instance of the Drawable class.

Protected Attributes inherited from Drawable

Drawable *nextSibling
Pointer to the next Drawable.
Drawable *parent
Pointer to this drawable's parent.
Rectrect
The coordinates of this Drawable, relative to its parent.
booltouchable
True if this drawable should receive touch events.
boolvisible
True if this drawable should be drawn.

Public Functions Documentation

AnalogClock

getAlpha

virtual uint8_t getAlpha()const

Gets the current alpha value of the widget.

The alpha value is in range 255 (solid) to 0 (invisible).

Returns:

The current alpha value.

See also:

getAnimationDuration

virtual uint16_t getAnimationDuration()

Gets the animation duration.

Returns:

The animation duration.

See also:

getHourHandMinuteCorrection

virtual bool getHourHandMinuteCorrection()const

Gets hour hand minute correction.

Returns:

true if hour hand minute correction is active.

See also:

getMinuteHandSecondCorrection

virtual bool getMinuteHandSecondCorrection()const

Gets minute hand second correction.

Returns:

true if minute hand second correction is active.

See also:

initializeTime12Hour

virtual void initializeTime12Hour(uint8_thour ,
uint8_tminute ,
uint8_tsecond ,
boolam
)

Sets the time with input format as 12H.

No animations are performed regardless of the animation settings. This is often useful when setting up the AnalogClock where you do not want an initial animation.

Parameters:
hourThe hours, value should be between 1 and 12.
minuteThe minutes, value should be between 0 and 59.
secondThe seconds, value should be between 0 and 59.
amAM/PM setting. True = AM, false = PM.
Note

that this does not affect any selected presentation formats.

See also:

initializeTime24Hour

virtual void initializeTime24Hour(uint8_thour ,
uint8_tminute ,
uint8_tsecond
)

Sets the time with input format as 24H.

No animations are performed regardless of the animation settings. This is often useful when setting up the AnalogClock where you do not want an initial animation.

Parameters:
hourThe hours, value should be between 0 and 23.
minuteThe minutes, value should be between 0 and 59.
secondThe seconds, value should be between 0 and 59.
Note

that this does not affect any selected presentation formats.

See also:

setAlpha

virtual void setAlpha(uint8_tnewAlpha)

Sets the opacity (alpha value).

This can be used to fade it away by gradually decreasing the alpha value from 255 (solid) to 0 (invisible).

Parameters:
newAlphaThe new alpha value. 255=solid, 0=invisible.
Note

The user code must call invalidate() in order to update the display. The alpha value is reflected in the background image

See also:

setAnimation

virtual void setAnimation(uint16_tduration =10,
EasingEquationanimationProgressionEquation =EasingEquations::backEaseInOut
)

Setup the clock to use animation for hand movements.

Parameters:
duration(Optional) The animation duration, default is 10.
animationProgressionEquation(Optional) The animation progression equation, default is EasingEquations::backEaseInOut.

setBackground

virtual void setBackground(const BitmapIdbackgroundBitmapId)

Sets the background image of the clock.

The clock rotation center is automatically set to the background image center. The clock rotation center is the point that the clock hands rotates around. The size of the AnalocClock widget is set to the size of the bitmap.

Parameters:
backgroundBitmapIdIdentifier for the background bitmap.

setBackground

virtual void setBackground(const BitmapIdbackgroundBitmapId ,
int16_trotationCenterX ,
int16_trotationCenterY
)

Sets the background image of the clock and the rotation center of the clock.

The clock rotation center is the point that the clock hands rotates around. The size of the AnalocClock widget is set to the size of the bitmap.

Parameters:
backgroundBitmapIdIdentifier for the background bitmap.
rotationCenterXThe rotation center x coordinate.
rotationCenterYThe rotation center y coordinate.
See also:

setHourHandMinuteCorrection

virtual void setHourHandMinuteCorrection(boolactive)

Sets whether hour hand minute correction should be active.

If set to true the hour hand will be positioned between the current hour and the next depending on the minute hands position.

Parameters:
activetrue to use hour hand correction.
See also:

setMinuteHandSecondCorrection

virtual void setMinuteHandSecondCorrection(boolactive)

Sets whether minute hand second correction should be active.

If set to true the minute hand will be positioned between the current minute and the next depending on the second hands position.

Parameters:
activetrue to use.
See also:

setRotationCenter

virtual void setRotationCenter(int16_trotationCenterX ,
int16_trotationCenterY
)

Sets the rotation center of the clock.

The clock rotation center is the point that the clock hands rotates around.

Parameters:
rotationCenterXThe rotation center x coordinate.
rotationCenterYThe rotation center y coordinate.

setupHourHand

virtual void setupHourHand(const BitmapIdhourHandBitmapId ,
int16_trotationCenterX ,
int16_trotationCenterY
)

Sets up the hour hand.

The specified rotation center is the point of the hand that is to be placed on top of the clock rotation center. That is the point that the hand rotates around. The rotation point is relative to the supplied bitmap and can be placed outside of it.

Parameters:
hourHandBitmapIdIdentifier for the hour hand bitmap.
rotationCenterXThe hand rotation center x coordinate.
rotationCenterYThe hand rotation center y coordinate.
Note

If no hour hand is setup it will just be omitted.

setupMinuteHand

virtual void setupMinuteHand(const BitmapIdminuteHandBitmapId ,
int16_trotationCenterX ,
int16_trotationCenterY
)

Sets up the minute hand.

The specified rotation center is the point of the hand that is to be placed on top of the clock rotation center. That is the point that the hand rotates around. The rotation point is relative to the supplied bitmap but can be placed outside of it.

Parameters:
minuteHandBitmapIdIdentifier for the minute hand bitmap.
rotationCenterXThe hand rotation center x coordinate.
rotationCenterYThe hand rotation center y coordinate.
Note

If no minute hand is setup it will just be omitted.

setupSecondHand

virtual void setupSecondHand(const BitmapIdsecondHandBitmapId ,
int16_trotationCenterX ,
int16_trotationCenterY
)

Sets up the second hand.

The specified rotation center is the point of the hand that is to be placed on top of the clock rotation center. That is the point that the hand rotates around. The rotation point is relative to the supplied bitmap but can be placed outside of it.

Parameters:
secondHandBitmapIdIdentifier for the second hand bitmap.
rotationCenterXThe hand rotation center x coordinate.
rotationCenterYThe hand rotation center y coordinate.
Note

If no second hand is setup it will just be omitted.

Protected Functions Documentation

animationEnabled

virtual bool animationEnabled()const

Is animation enabled for the hands?

Returns:

true if animation is enabled.

convertHandValueToAngle

virtual float convertHandValueToAngle(uint8_tsteps ,const
uint8_thandValue ,const
uint8_tsecondHandValue =0const
)const

Convert hand value to angle.

Parameters:
stepsNumber of steps the primary hand value is divided into, i.e. 60 for minutes/seconds and 12 for hour.
handValueThe actual value for the hand in question (in the range [0; steps]).
secondHandValue(Optional) If the angle should be corrected for a secondary hand its value should be specified here (in the range [0; 60]). This is the case when setHourHandMinuteCorrection(true) or setMinuteHandSecondCorrection(true) is selected.
Returns:

The converted value to angle.

setupHand

virtual void setupHand(TextureMapper &hand ,
const BitmapIdbitmapId ,
int16_trotationCenterX ,
int16_trotationCenterY
)

Sets up a given the hand.

Parameters:
handReference to the hand being setup.
bitmapIdThe bitmap identifier for the given hand.
rotationCenterXThe hand rotation center x coordinate.
rotationCenterYThe hand rotation center y coordinate.

updateClock

virtual void updateClock()

Update the visual representation of the clock on the display.

Reimplements: touchgfx::AbstractClock::updateClock

Protected Attributes Documentation

animationDuration

uint16_t animationDuration

The duration of hand animations. If 0 animations are disabled.

animationEquation

EasingEquation animationEquation

The easing equation used by hand animations.

background

Image background

The background image of the AnalogClock.

clockRotationCenterX

int16_t clockRotationCenterX

The x coordinate of the rotation point of the hands.

clockRotationCenterY

int16_t clockRotationCenterY

The y coordinate of the rotation point of the hands.

hourHand

TextureMapper used for drawing the hourHand.

hourHandMinuteCorrectionActive

bool hourHandMinuteCorrectionActive

Is hour hand minute correction active.

lastHour

uint8_t lastHour

The last know hour value.

lastMinute

uint8_t lastMinute

The last know minute value.

lastSecond

uint8_t lastSecond

The last know second value.

minuteHand

TextureMapper used for drawing the minuteHand.

minuteHandSecondCorrectionActive

bool minuteHandSecondCorrectionActive

Is minute hand second correction active.

secondHand

TextureMapper used for drawing the secondHand.