メイン・コンテンツまでスキップ

DynamicDataGraph

touchgfx/widgets/graph/AbstractDataGraph.hpp

Abstract helper class used to implement graphs with the same distance between the x values (i.e. x is ignored).

Inherits from: AbstractDataGraph, Container, Drawable

Inherited by: GraphScrollData, GraphWrapAndClearData, GraphWrapAndOverwriteData

Public Functions

FORCE_INLINE_FUNCTION int16_taddDataPoint(float y)
Adds a new data point to the end of the graph.
FORCE_INLINE_FUNCTION int16_taddDataPoint(int y)
Adds a new data point to the end of the graph.
int16_taddDataPointScaled(int y)
Adds a new data point to the end of the graph.
DynamicDataGraph(int16_t capacity, int * values)
Initializes a new instance of the AbstractDataGraphWithY class.
virtual intgetGraphRangeXMax() const
Gets the maximum x coordinate for the graph.
virtual intgetGraphRangeXMin() const
Gets the minimum x coordinate for the graph.
virtual intgetScale() const
Gets the scaling factor previously set using setScale().
virtual floatgetXAxisFactorAsFloat() const
Get x coordinate axis factor value.
virtual intgetXAxisFactorAsInt() const
Get x coordinate axis factor value.
virtual intgetXAxisFactorScaled() const
Get x axis factor as a scaled value.
virtual floatgetXAxisOffsetAsFloat() const
Get x coordinate axis offset value.
virtual intgetXAxisOffsetAsInt() const
Get x coordinate axis offset value.
virtual intgetXAxisOffsetScaled() const
Get x axis offset as a scaled value.
virtual intindexToDataPointXScaled(int16_t index) const
Gets data point x coordinate scaled.
virtual intindexToDataPointYScaled(int16_t index) const
Gets data point y coordinate scaled.
virtual voidsetGraphRangeXAutoScaled(bool showYaxis, int margin)
Automatically adjust min and max x coordinate to show entire graph.
virtual voidsetGraphRangeYAutoScaled(bool showXaxis, int margin)
Automatic adjust min and max y coordinate to show entire graph.
virtual voidsetScale(int scale, bool updateData =false)
Sets a scaling factor to be multiplied on each added element.
virtual voidsetXAxisFactor(float factor)
Set x coordinate axis factor value.
virtual voidsetXAxisFactor(int factor)
Set x coordinate axis factor value.
virtual voidsetXAxisFactorScaled(int factor)
Set x coordinate axis factor value using a pre-scaled value.
virtual voidsetXAxisOffset(float offset)
Set x coordinate axis offset value.
virtual voidsetXAxisOffset(int offset)
Set x coordinate axis offset value.
virtual voidsetXAxisOffsetScaled(int offset)
Set x coordinate axis offset value with a pre-scaled offset value.

Protected Functions

virtual int16_taddValue(int value) =0
Adds a value to the internal data array and keeps track of when graph points, graph axis and the entire graph needs to be redrawn (invalidated).
virtual voidbeforeAddValue()
This function is called before a new value (data point) is added.
virtual int16_tdataIndex(int16_t screenIndex) const
Get the data index in the yValues array of the given screen index.
virtual intgetScaleX() const
Gets the scaling factor previously set using setScaleX().
virtual intgetScaleY() const
Gets the scaling factor previously set using setScaleY().
virtual int32_tindexToGlobalIndex(int16_t index) const
Convert an index to global index.
virtual CWRUtil::Q5indexToScreenXQ5(int16_t index) const
Gets screen x coordinate for a specific data point added to the graph.
virtual CWRUtil::Q5indexToScreenYQ5(int16_t index) const
Gets screen y coordinate for a specific data point added to the graph.
virtual intindexToXAxis(const int valueScaled, const int labelScaled) const
Convert the given valueScaled (index) to x axis value.
virtual voidsetScaleX(int scale, bool updateData =false)
Sets a scaling factor to be multiplied on each X value added.
virtual voidsetScaleY(int scale, bool updateData =false)
Sets a scaling factor to be multiplied on each Y value added.
virtual boolxScreenRangeToIndexRange(int16_t xMin, int16_t xMax, int16_t & indexMin, int16_t & indexMax) const
Gets index range for screen x coordinate range taking the current graph range into account.

Protected Attributes

uint32_tdataCounter
The data counter of how many times addDataPoint() has been called.
intxAxisFactor
The axis scale (real distance between two indices)
intxAxisOffset
The x axis offset (real value of data point at index 0)
int *yValues
The values of the graph.

Additional inherited members

Public Classes inherited from AbstractDataGraph

classGraphClickEvent
An object of this type is passed with each callback that is sent when the graph is clicked.
classGraphDragEvent
An object of this type is passed with each callback that is sent when the graph is dragged.

Public Functions inherited from AbstractDataGraph

AbstractDataGraph(int16_t capacity)
Initializes a new instance of the AbstractDataGraph class.
voidaddBottomElement(AbstractGraphDecoration & d)
Adds an element to be shown in the area below the graph.
voidaddGraphElement(AbstractGraphElement & d)
Adds a graph element which will display the graph.
voidaddLeftElement(AbstractGraphDecoration & d)
Adds an element to be shown in the area to the left of the graph.
voidaddRightElement(AbstractGraphDecoration & d)
Adds an element to be shown in the area to the right of the graph.
voidaddTopElement(AbstractGraphDecoration & d)
Adds an element to be shown in the area above the graph.
virtual voidclear()
Clears the graph to its blank/initial state.
FORCE_INLINE_FUNCTION intfloat2scaledX(float f) const
Same as float2scaled(float, int) using the graph's x scale.
FORCE_INLINE_FUNCTION intfloat2scaledY(float f) const
Same as float2scaled(float, int) using the graph's y scale.
FORCE_INLINE_FUNCTION uint8_tgetAlpha() const
Gets the current alpha value of the widget.
FORCE_INLINE_FUNCTION int16_tgetGapBeforeIndex() const
Gets gap before index as set using setGapBeforeIndex().
FORCE_INLINE_FUNCTION int16_tgetGraphAreaHeight() const
Gets graph area height.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaHeightIncludingPadding() const
Gets graph area height including padding (but not margin).
FORCE_INLINE_FUNCTION int16_tgetGraphAreaMarginBottom() const
Gets graph margin bottom.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaMarginLeft() const
Gets graph margin left.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaMarginRight() const
Gets graph margin right.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaMarginTop() const
Gets graph margin top.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaPaddingBottom() const
Gets graph area padding bottom.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaPaddingLeft() const
Gets graph area padding left.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaPaddingRight() const
Gets graph area padding right.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaPaddingTop() const
Gets graph area padding top.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaWidth() const
Gets graph area width.
FORCE_INLINE_FUNCTION int16_tgetGraphAreaWidthIncludingPadding() const
Gets graph area width including padding (but not margin).
virtual floatgetGraphRangeXMaxAsFloat() const
Gets maximum x value for the graph.
virtual intgetGraphRangeXMaxAsInt() const
Gets maximum x value for the graph.
virtual intgetGraphRangeXMaxScaled() const
Gets maximum x value for the graph.
virtual floatgetGraphRangeXMinAsFloat() const
Gets minimum x value for the graph.
virtual intgetGraphRangeXMinAsInt() const
Gets minimum x value for the graph.
virtual intgetGraphRangeXMinScaled() const
Gets minimum x value for the graph.
virtual floatgetGraphRangeYMaxAsFloat() const
Gets maximum y value for the graph.
virtual intgetGraphRangeYMaxAsInt() const
Gets maximum y value for the graph.
virtual intgetGraphRangeYMaxScaled() const
Gets maximum y value for the graph.
virtual floatgetGraphRangeYMinAsFloat() const
Gets minimum y value for the graph.
virtual intgetGraphRangeYMinAsInt() const
Gets minimum y value for the graph.
virtual intgetGraphRangeYMinScaled() const
Gets minimum y value for the graph.
FORCE_INLINE_FUNCTION int16_tgetMaxCapacity() const
Gets the capacity (max number of points) of the graph.
virtual boolgetNearestIndexForScreenX(int16_t x, int16_t & index) const
Gets graph index nearest to the given screen x value.
virtual boolgetNearestIndexForScreenXY(int16_t x, int16_t y, int16_t & index)
Gets graph index nearest to the given screen position.
FORCE_INLINE_FUNCTION int16_tgetUsedCapacity() const
Gets the number of point used by the graph.
virtual voidhandleClickEvent(const ClickEvent & event)
Defines the event handler interface for ClickEvents.
virtual voidhandleDragEvent(const DragEvent & event)
Defines the event handler interface for DragEvents.
FORCE_INLINE_FUNCTION voidindexToDataPoint(int16_t index, float & xvalue, float & yvalue) const
Gets data point as floating point values.
FORCE_INLINE_FUNCTION voidindexToDataPoint(int16_t index, int & xvalue, int & yvalue) const
Gets data point as integer values.
FORCE_INLINE_FUNCTION voidindexToDataPointScaled(int16_t index, int & xvalue, int & yvalue) const
Gets data point as raw (scaled) values.
FORCE_INLINE_FUNCTION floatindexToDataPointXAsFloat(int16_t index) const
Gets data point x coordinate as float.
FORCE_INLINE_FUNCTION intindexToDataPointXAsInt(int16_t index) const
Gets data point x coordinate as int.
FORCE_INLINE_FUNCTION floatindexToDataPointYAsFloat(int16_t index) const
Gets data point y coordinate as float.
FORCE_INLINE_FUNCTION intindexToDataPointYAsInt(int16_t index) const
Gets data point y coordinate as int.
FORCE_INLINE_FUNCTION int16_tindexToScreenX(int16_t index) const
Get the screen x coordinate for the given graph point index.
FORCE_INLINE_FUNCTION int16_tindexToScreenY(int16_t index) const
Get the screen y coordinate for the given graph point index.
FORCE_INLINE_FUNCTION intint2scaledX(int i) const
Same as int2scaled(int, int) using the graph's x scale.
FORCE_INLINE_FUNCTION intint2scaledY(int i) const
Same as int2scaled(int, int) using the graph's y scale.
virtual voidinvalidateContent() const
Invalidate content.
FORCE_INLINE_FUNCTION floatscaled2floatX(int i) const
Same as scaled2float(int, int) using the graph's x scale.
FORCE_INLINE_FUNCTION floatscaled2floatY(int i) const
Same as scaled2float(int, int) using the graph's y scale.
FORCE_INLINE_FUNCTION intscaled2intX(int i) const
Same as scaled2int(int, int) using the graph's x scale.
FORCE_INLINE_FUNCTION intscaled2intY(int i) const
Same as scaled2int(int, int) using the graph's y scale.
virtual voidsetAlpha(uint8_t newAlpha)
Sets the opacity (alpha value).
FORCE_INLINE_FUNCTION voidsetClickAction(GenericCallback< const AbstractDataGraph &, const GraphClickEvent & > & callback)
Sets an action to be executed when the graph is clicked.
FORCE_INLINE_FUNCTION voidsetDragAction(GenericCallback< const AbstractDataGraph &, const GraphDragEvent & > & callback)
Sets an action to be executed when the graph is dragged.
FORCE_INLINE_FUNCTION voidsetGapBeforeIndex(int16_t index)
Makes gap before the specified index.
voidsetGraphAreaMargin(int16_t top, int16_t left, int16_t right, int16_t bottom)
Sets graph position inside the widget by reserving a margin around the graph.
voidsetGraphAreaPadding(int16_t top, int16_t left, int16_t right, int16_t bottom)
Adds padding around the graph that will not be drawn in (apart from dots, boxes, lines etc.
FORCE_INLINE_FUNCTION voidsetGraphRange(float xMin, float xMax, float yMin, float yMax)
Sets minimum and maximum x and y coordinate ranges for the graph.
FORCE_INLINE_FUNCTION voidsetGraphRange(float xMin, float xMax, int yMin, int yMax)
Sets minimum and maximum x and y coordinate ranges for the graph.
FORCE_INLINE_FUNCTION voidsetGraphRange(int xMin, int xMax, float yMin, float yMax)
Sets minimum and maximum x and y coordinate ranges for the graph.
FORCE_INLINE_FUNCTION voidsetGraphRange(int xMin, int xMax, int yMin, int yMax)
Sets minimum and maximum x and y coordinate ranges for the graph.
FORCE_INLINE_FUNCTION voidsetGraphRangeScaled(int xMin, int xMax, int yMin, int yMax)
Same as setGraphRange(int, int, int, int) except the passed arguments are assumed scaled.
virtual voidsetGraphRangeX(float min, float max)
Sets minimum and maximum x coordinates for the graph.
virtual voidsetGraphRangeX(int min, int max)
Sets minimum and maximum x coordinates for the graph.
virtual voidsetGraphRangeXAuto(bool showYaxis, float margin)
Automatically adjust min and max x coordinate to show entire graph.
virtual voidsetGraphRangeXAuto(bool showYaxis =true, int margin =0)
Automatically adjust min and max x coordinate to show entire graph.
virtual voidsetGraphRangeXScaled(int min, int max)
Sets minimum and maximum x coordinates for the graph.
virtual voidsetGraphRangeY(float min, float max)
Sets minimum and maximum y coordinates for the graph.
virtual voidsetGraphRangeY(int min, int max)
Sets minimum and maximum y coordinates for the graph.
virtual voidsetGraphRangeYAuto(bool showXaxis, float margin)
Automatic adjust min and max y coordinate to show entire graph.
virtual voidsetGraphRangeYAuto(bool showXaxis =true, int margin =0)
Automatic adjust min and max y coordinate to show entire graph.
virtual voidsetGraphRangeYScaled(int min, int max)
Same as setGraphRangeY(int, int) except the passed arguments are assumed scaled.
virtual voidsetHeight(int16_t height)
Sets the height of this drawable.
virtual voidsetWidth(int16_t width)
Sets the width of this drawable.
intconvertToNewScale(int value, int oldScale, int newScale)
Converts a value from one scale to another scale.
FORCE_INLINE_FUNCTION intfloat2scaled(float f, int scale)
Multiply a floating point value with a constant and round the result.
FORCE_INLINE_FUNCTION intint2scaled(int i, int scale)
Multiply an integer value with a constant.
FORCE_INLINE_FUNCTION floatscaled2float(int i, int scale)
Divide a floating point number with a constant.
FORCE_INLINE_FUNCTION intscaled2int(int i, int scale)
Divide an integer with a constant and round the result.

Protected Functions inherited from AbstractDataGraph

voidinvalidateAllXAxisPoints()
Invalidate all x axis points.
FORCE_INLINE_FUNCTION voidinvalidateGraphArea() const
Invalidate entire graph area (the center of the graph).
voidinvalidateGraphPointAt(int16_t index)
Invalidate point at a given index.
voidinvalidateXAxisPointAt(int16_t index)
Invalidate x axis point at the given index.
voidupdateAreasPosition()
Updates the position of all elements in all area after a change in size of the graph area and/or label padding.
virtual CWRUtil::Q5valueToScreenXQ5(int x) const
Gets screen x coordinate for an absolute value.
virtual CWRUtil::Q5valueToScreenYQ5(int y) const
Gets screen y coordinate for an absolute value.

Protected Attributes inherited from AbstractDataGraph

uint8_talpha
The alpha of the entire graph.
ContainerbottomArea
The area below the graph.
int16_tbottomPadding
The graph area bottom padding.
GenericCallback< const AbstractDataGraph &, const GraphClickEvent & > *clickAction
The callback to be executed when this Graph is clicked.
GenericCallback< const AbstractDataGraph &, const GraphDragEvent & > *dragAction
The callback to be executed when this Graph is dragged.
int16_tgapBeforeIndex
The graph is disconnected (there is a gap) before this element index.
ContainergraphArea
The graph area (the center area)
intgraphRangeMaxX
The graph range maximum x coordinate.
intgraphRangeMaxY
The graph range maximum y coordinate.
intgraphRangeMinX
The graph range minimum x coordinate.
intgraphRangeMinY
The graph range minimum y coordinate.
ContainerleftArea
The area to the left of the graph.
int16_tleftPadding
The graph area left padding.
int16_tmaxCapacity
Maximum number of points in the graph.
ContainerrightArea
The area to the right of the graph.
int16_trightPadding
The graph area right padding.
ContainertopArea
The area above the graph.
int16_ttopPadding
The graph area top padding.
int16_tusedCapacity
The number of used points in the graph.
intxScale
The data scale for the x values.
intyScale
The data scale for the y values.

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 voidinvalidateContent() const
Tell the framework that the contents of the 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 & other)
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

addDataPoint

FORCE_INLINE_FUNCTION int16_t addDataPoint(floaty)

Adds a new data point to the end of the graph.

The part of the graph that is changed, is automatically redrawn (invalidated).

Parameters:
yThe new data point.
Returns:

The index of the just added value.

addDataPoint

FORCE_INLINE_FUNCTION int16_t addDataPoint(inty)

Adds a new data point to the end of the graph.

The part of the graph that is changed, is automatically redrawn (invalidated).

Parameters:
yThe new data point.
Returns:

The index of the just added value.

addDataPointScaled

int16_t addDataPointScaled(inty)

Adds a new data point to the end of the graph.

The part of the graph that is changed, is automatically redrawn (invalidated).

Parameters:
yThe new data point.
Returns:

The index of the just added value. The index of the added data point.

Note

The y value must already be scaled.

DynamicDataGraph

DynamicDataGraph(int16_tcapacity ,
int *values
)

Initializes a new instance of the AbstractDataGraphWithY class.

Parameters:
capacityThe capacity.
valuesAddress where to store the y values of the graph.

getGraphRangeXMax

virtual int getGraphRangeXMax()const

Gets the maximum x coordinate for the graph.

Returns:

The maximum x coordinate .

getGraphRangeXMin

virtual int getGraphRangeXMin()const

Gets the minimum x coordinate for the graph.

Returns:

The minimum x coordinate .

getScale

virtual int getScale()const

Gets the scaling factor previously set using setScale().

Returns:

The scaling factor.

See also:

getXAxisFactorAsFloat

virtual float getXAxisFactorAsFloat()const

Get x coordinate axis factor value.

This is the real x value increment between two data points added to the graph.

Returns:

The x axis factor.

getXAxisFactorAsInt

virtual int getXAxisFactorAsInt()const

Get x coordinate axis factor value.

This is the real x value increment between two data points added to the graph.

Returns:

The x axis factor.

getXAxisFactorScaled

virtual int getXAxisFactorScaled()const

Get x axis factor as a scaled value.

Returns:

The x axis factor (scaled).

See also:

getXAxisOffsetAsFloat

virtual float getXAxisOffsetAsFloat()const

Get x coordinate axis offset value.

This is the real x value of the first data point added to the graph (i.e. the data point at index 0).

Returns:

The x axis offset.

getXAxisOffsetAsInt

virtual int getXAxisOffsetAsInt()const

Get x coordinate axis offset value.

This is the real x value of the first data point added to the graph (i.e. the data point at index 0).

Returns:

The x axis offset.

getXAxisOffsetScaled

virtual int getXAxisOffsetScaled()const

Get x axis offset as a scaled value.

Returns:

The x axis offset (scaled).

See also:

indexToDataPointXScaled

virtual int indexToDataPointXScaled(int16_tindex)

Gets data point x coordinate scaled.

Parameters:
indexZero-based index of the value to fetch.
Returns:

The data point x coordinate scaled.

See also:

Reimplements: touchgfx::AbstractDataGraph::indexToDataPointXScaled

indexToDataPointYScaled

virtual int indexToDataPointYScaled(int16_tindex)

Gets data point y coordinate scaled.

Parameters:
indexZero-based index of the value to fetch.
Returns:

The data point y coordinate scaled.

See also:

Reimplements: touchgfx::AbstractDataGraph::indexToDataPointYScaled

setGraphRangeXAutoScaled

virtual void setGraphRangeXAutoScaled(boolshowYaxis ,
intmargin
)

Automatically adjust min and max x coordinate to show entire graph.

It is possible to ensure that the y axis (i.e. x=0) is included in the new range. If the graph range is changed as a consequence of calling this function, the graph is automatically redrawn (invalidated).

Parameters:
showYaxis(Optional) True to ensure that the y axis is visible (default is true).
margin(Optional) The margin to add above/below the max/min x value (default is no margin).
Note

This takes the currently visible y coordinate range into account. If data in the graph is changed, added or deleted, the graph range is not automatically recalculated. Call this function again to achieve this functionality.The arguments are assumed scaled. This means that if the scale is 1000, a value of 1 is interpreted as 0.001 (i.e. 1/1000).

See also:

Reimplements: touchgfx::AbstractDataGraph::setGraphRangeXAutoScaled

setGraphRangeYAutoScaled

virtual void setGraphRangeYAutoScaled(boolshowXaxis ,
intmargin
)

Automatic adjust min and max y coordinate to show entire graph.

It is possible to ensure that the x axis (i.e. y=0) is included in the new range. If the graph range is changed, the graph is automatically redrawn (invalidated).

Parameters:
showXaxisTrue to ensure that the x axis is visible (default is true).
marginThe margin to add above/below the max/min y value (default is no margin).
Note

This takes the current visible x coordinate range into account.

Reimplements: touchgfx::AbstractDataGraph::setGraphRangeYAutoScaled

setScale

virtual void setScale(intscale ,
boolupdateData =false
)

Sets a scaling factor to be multiplied on each added element.

Since the graph only stores integer values internally, it is possible to set a scale to e.g. 1000 and make the graph work as if there are three digits of precision. The addDataPoint() will multiply the argument with the scaling factor and store this value.

By setting the scale to 1 it is possible to simply use integer values for the graph.

Parameters:
scaleThe scaling factor.
updateData(Optional) True to update all existing y value.
Note

The current xAxisFactor, xAxisOffet and xGraphRange values are updated to reflect the new scale being set.

See also:

setXAxisFactor

virtual void setXAxisFactor(floatfactor)

Set x coordinate axis factor value.

This is the real x value increment between two data points added to the graph.

Parameters:
factorThe x axis factor.

setXAxisFactor

virtual void setXAxisFactor(intfactor)

Set x coordinate axis factor value.

This is the real x value increment between two data points added to the graph.

Parameters:
factorThe x axis factor.

setXAxisFactorScaled

virtual void setXAxisFactorScaled(intfactor)

Set x coordinate axis factor value using a pre-scaled value.

This is the real x value increment between two data points added to the graph.

Parameters:
factorThe x axis factor.
See also:

setXAxisOffset

virtual void setXAxisOffset(floatoffset)

Set x coordinate axis offset value.

This is the real x value of the first data point added to the graph (i.e. the data point at index 0).

Parameters:
offsetThe x axis offset.

setXAxisOffset

virtual void setXAxisOffset(intoffset)

Set x coordinate axis offset value.

This is the real x value of the first data point added to the graph (i.e. the data point at index 0).

Parameters:
offsetThe x axis offset.

setXAxisOffsetScaled

virtual void setXAxisOffsetScaled(intoffset)

Set x coordinate axis offset value with a pre-scaled offset value.

This is the real x value of the first data point added to the graph (i.e. the data point at index 0).

Parameters:
offsetThe x axis offset.
See also:

Protected Functions Documentation

addValue

virtual int16_t addValue(intvalue)

Adds a value to the internal data array and keeps track of when graph points, graph axis and the entire graph needs to be redrawn (invalidated).

Parameters:
valueThe value to add to the array.
Returns:

The index of the newly added value.

Reimplemented by: touchgfx::GraphScrollData::addValue, touchgfx::GraphWrapAndClearData::addValue, touchgfx::GraphWrapAndOverwriteData::addValue

beforeAddValue

virtual void beforeAddValue()

This function is called before a new value (data point) is added.

This allows for invalidation to be calculated based on the global data counter before it is increased as a result of adding the new point.

Reimplemented by: touchgfx::GraphScrollData::beforeAddValue, touchgfx::GraphWrapAndClearData::beforeAddValue, touchgfx::GraphWrapAndOverwriteData::beforeAddValue

dataIndex

virtual int16_t dataIndex(int16_tscreenIndex)

Get the data index in the yValues array of the given screen index.

Normally this is just the 'i' but e.g. GraphScrollData does not, for performance reasons.

Parameters:
screenIndexZero-based screen index.
Returns:

The index in the yValues array.

Reimplemented by: touchgfx::GraphScrollData::dataIndex

getScaleX

virtual int getScaleX()const

Gets the scaling factor previously set using setScaleX().

Returns:

The scaling factor.

See also:

Reimplements: touchgfx::AbstractDataGraph::getScaleX

getScaleY

virtual int getScaleY()const

Gets the scaling factor previously set using setScaleY().

Returns:

The scaling factor.

See also:

Reimplements: touchgfx::AbstractDataGraph::getScaleY

indexToGlobalIndex

virtual int32_t indexToGlobalIndex(int16_tindex)

Convert an index to global index.

The index is the index of any data point, The global index is a value that keeps growing whenever a new data point is added the the graph.

Parameters:
indexZero-based index of the point.
Returns:

The global index.

Reimplemented by: touchgfx::GraphScrollData::indexToGlobalIndex, touchgfx::GraphWrapAndClearData::indexToGlobalIndex, touchgfx::GraphWrapAndOverwriteData::indexToGlobalIndex

indexToScreenXQ5

virtual CWRUtil::Q5 indexToScreenXQ5(int16_tindex)

Gets screen x coordinate for a specific data point added to the graph.

Parameters:
indexThe index of the element to get the x coordinate for.
Returns:

The screen x coordinate for the specific data point.

Reimplements: touchgfx::AbstractDataGraph::indexToScreenXQ5

indexToScreenYQ5

virtual CWRUtil::Q5 indexToScreenYQ5(int16_tindex)

Gets screen y coordinate for a specific data point added to the graph.

Parameters:
indexThe index of the element to get the y coordinate for.
Returns:

The screen x coordinate for the specific data point.

Reimplements: touchgfx::AbstractDataGraph::indexToScreenYQ5

indexToXAxis

virtual int indexToXAxis(const intvalueScaled ,const
const intlabelScaledconst
)const

Convert the given valueScaled (index) to x axis value.

Parameters:
valueScaledThe value scaled.
labelScaledThe label scaled.
Returns:

The x axis value.

Reimplements: touchgfx::AbstractDataGraph::indexToXAxis

setScaleX

virtual void setScaleX(intscale ,
boolupdateData =false
)

Sets a scaling factor to be multiplied on each X value added.

Since the graph only stores integer values internally, it is possible to set a scale to e.g. 1000 and make the graph work as if there are three digits of precision. The addDataPoint() will multiply the x argument with the scaling factor and store this value. Please note the addDataPointScaled, which allows adding a value that is assumed to have already been multiplied by the scaling factor. Other functions exist in a "scaled" version where the arguments are assumed to already be scaled.

By setting the scale to 1 it is possible to simply use integer values for the graph.

Parameters:
scaleThe scaling factor.
updateData(Optional) True to update all existing x value.
See also:

Reimplements: touchgfx::AbstractDataGraph::setScaleX

setScaleY

virtual void setScaleY(intscale ,
boolupdateData =false
)

Sets a scaling factor to be multiplied on each Y value added.

Since the graph only stores integer values internally, it is possible to set a scale to e.g. 1000 and make the graph work as if there are three digits of precision. The addDataPoint() will multiply the y argument with the scaling factor and store this value. Please note the addDataPointScaled, which allows adding a value that is assumed to have already been multiplied by the scaling factor. Other functions exist in a "scaled" version where the arguments are assumed to already be scaled.

By setting the scale to 1 it is possible to simply use integer values for the graph.

Parameters:
scaleThe scaling factor.
updateData(Optional) True to update all existing y value.
See also:

Reimplements: touchgfx::AbstractDataGraph::setScaleY

xScreenRangeToIndexRange

virtual bool xScreenRangeToIndexRange(int16_txMin ,const
int16_txMax ,const
int16_t &indexMin ,const
int16_t &indexMaxconst
)const

Gets index range for screen x coordinate range taking the current graph range into account.

Parameters:
xMinThe low screen x coordinate.
xMaxThe high screen x coordinate.
indexMinThe low element index.
indexMaxThe high element index.
Returns:

True if the range from low index to high index is legal.

Note

For internal use.

Reimplements: touchgfx::AbstractDataGraph::xScreenRangeToIndexRange

Protected Attributes Documentation

dataCounter

uint32_t dataCounter

The data counter of how many times addDataPoint() has been called.

xAxisFactor

int xAxisFactor

The axis scale (real distance between two indices)

xAxisOffset

int xAxisOffset

The x axis offset (real value of data point at index 0)

yValues

int * yValues

The values of the graph.