AbstractDataGraphWithY
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: DataGraphScroll, DataGraphWrapAndClear, DataGraphWrapAndOverwrite
Public Functions
AbstractDataGraphWithY(int16_t capacity, int * values) | |
Initializes a new instance of the AbstractDataGraphWithY class. | |
int16_t | addDataPoint(float y) |
Adds a new data point to the end of the graph. | |
int16_t | addDataPoint(int y) |
Adds a new data point to the end of the graph. | |
virtual int | getGraphRangeXMax() const |
Gets the maximum x coordinate for the graph. | |
virtual int | getGraphRangeXMin() const |
Gets the minimum x coordinate for the graph. | |
virtual float | getGraphRangeYMaxAsFloat() const |
Gets maximum y coordinate for the graph. | |
virtual int | getGraphRangeYMaxAsInt() const |
Gets maximum y coordinate for the graph. | |
virtual float | getGraphRangeYMinAsFloat() const |
Gets minimum y coordinate for the graph. | |
virtual int | getGraphRangeYMinAsInt() const |
Gets minimum y coordinate for the graph. | |
virtual float | getXAxisOffsetAsFloat() const |
Get x coordinate axis offset value. | |
virtual int | getXAxisOffsetAsInt() const |
Get x coordinate axis offset value. | |
virtual float | getXAxisScaleAsFloat() const |
Get x coordinate axis scale value. | |
virtual int | getXAxisScaleAsInt() const |
Get x coordinate axis scale value. | |
virtual void | setGraphRangeX(int min, int max) |
Sets minimum and maximum x coordinates for the graph. | |
virtual void | setGraphRangeY(float min, float max) |
Sets minimum and maximum y coordinates for the graph. | |
virtual void | setGraphRangeY(int min, int max) |
Sets minimum and maximum y coordinates for the graph. | |
void | setGraphRangeYAuto(bool showXaxis =true, int margin =0) |
Automatic adjust min and max y coordinate to show entire graph. | |
virtual void | setScale(int scale) |
Sets a scaling factor to be multiplied on each added element. | |
virtual void | setXAxisOffset(float offset) |
Set x coordinate axis offset value. | |
virtual void | setXAxisOffset(int offset) |
Set x coordinate axis offset value. | |
virtual void | setXAxisScale(float scale) |
Set x coordinate axis scale value. | |
virtual void | setXAxisScale(int scale) |
Set x coordinate axis scale value. | |
Protected Functions
int16_t | addDataPointScaled(int y) |
Same as addDataPoint(int) except the passed argument is assumed scaled. | |
virtual int16_t | addValue(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 void | beforeAddValue() |
This function is called before a new value (data point) is added. | |
virtual int | getGraphRangeYMaxScaled() const |
Gets maximum y coordinate for the graph. | |
virtual int | getGraphRangeYMinScaled() const |
Gets minimum y coordinate for the graph. | |
virtual int | getXAxisOffsetScaled() const |
Get x axis offset as a scaled value. | |
virtual int | getXAxisScaleScaled() const |
Get x axis scale as a scaled value. | |
virtual int | indexToDataPointXScaled(int16_t index) const |
Same as indexToDataPointXAsInt(int16_t) except the returned value is left scaled. | |
virtual int | indexToDataPointYScaled(int16_t index) const |
Same as indexToDataPointYAsInt(int16_t) except the returned value is left scaled. | |
virtual CWRUtil::Q5 | indexToScreenXQ5(int16_t index) const |
Gets screen x coordinate for a specific data point added to the graph. | |
virtual CWRUtil::Q5 | indexToScreenYQ5(int16_t index) const |
Gets screen y coordinate for a specific data point added to the graph. | |
virtual int16_t | realIndex(int16_t index) const |
Get the real index in the yValues array of the given index. | |
virtual void | setGraphRangeYScaled(int min, int max) |
Same as setGraphRangeY(int,int) except the passed arguments are assumed scaled. | |
virtual void | setXAxisOffsetScaled(int offset) |
Set x coordinate axis offset value with a pre-scaled offset value. | |
virtual void | setXAxisScaleScaled(int scale) |
Set x coordinate axis scale value using a pre-scaled value. | |
virtual CWRUtil::Q5 | valueToScreenXQ5(int x) const |
Gets screen x coordinate for an absolute value. | |
virtual CWRUtil::Q5 | valueToScreenYQ5(int y) const |
Gets screen y coordinate for an absolute value. | |
virtual bool | xScreenRangeToIndexRange(int16_t xLo, int16_t xHi, int16_t & indexLow, int16_t & indexHigh) const |
Gets index range for screen x coordinate range taking the current graph range into account. | |
Protected Attributes
uint32_t | dataCounter |
The data counter of how many times addDataPoint() has been called. | |
int | xOffset |
The x axis offset (real value of data point at index 0) | |
int | xScale |
The x axis scale (increment between two data points) | |
int * | yValues |
The values of the graph. | |
Additional inherited members
Public Classes inherited from AbstractDataGraph
class | GraphClickEvent |
An object of this type is passed with each callback that is sent when the graph is clicked. | |
class | GraphDragEvent |
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. | |
void | addBottomElement(AbstractGraphDecoration & d) |
Adds an element to be shown in the area below the graph. | |
void | addGraphElement(AbstractGraphElement & d) |
Adds a graph element which will display the graph. | |
void | addLeftElement(AbstractGraphDecoration & d) |
Adds an element to be shown in the area to the left of the graph. | |
void | addRightElement(AbstractGraphDecoration & d) |
Adds an element to be shown in the area to the right of the graph. | |
void | addTopElement(AbstractGraphDecoration & d) |
Adds an element to be shown in the area above the graph. | |
virtual void | clear() |
Clears the graph to its blank/initial state. | |
uint8_t | getAlpha() const |
Gets the current alpha value of the widget. | |
int16_t | getGapBeforeIndex() const |
Gets gap before index as set using setGapBeforeIndex(). | |
int16_t | getGraphAreaHeight() const |
Gets graph area height. | |
int16_t | getGraphAreaHeightIncludingPadding() const |
Gets graph area height including padding (but not margin). | |
int16_t | getGraphAreaMarginBottom() const |
Gets graph margin bottom. | |
int16_t | getGraphAreaMarginLeft() const |
Gets graph margin left. | |
int16_t | getGraphAreaMarginRight() const |
Gets graph margin right. | |
int16_t | getGraphAreaMarginTop() const |
Gets graph margin top. | |
int16_t | getGraphAreaPaddingBottom() const |
Gets graph area padding bottom. | |
int16_t | getGraphAreaPaddingLeft() const |
Gets graph area padding left. | |
int16_t | getGraphAreaPaddingRight() const |
Gets graph area padding right. | |
int16_t | getGraphAreaPaddingTop() const |
Gets graph area padding top. | |
int16_t | getGraphAreaWidth() const |
Gets graph area width. | |
int16_t | getGraphAreaWidthIncludingPadding() const |
Gets graph area width including padding (but not margin). | |
int16_t | getMaxCapacity() const |
Gets the capacity (max number of points) of the graph. | |
virtual bool | getNearestIndexForScreenX(int16_t x, int16_t & index) const |
Gets graph index nearest to the given screen x coordinate. | |
virtual bool | getNearestIndexForScreenXY(int16_t x, int16_t y, int16_t & index) |
Gets graph index nearest to the given screen position. | |
int | getScale() const |
Gets the scaling factor previously set using setScale(). | |
int16_t | getUsedCapacity() const |
Gets the number of point used by the graph. | |
virtual void | handleClickEvent(const ClickEvent & event) |
Defines the event handler interface for ClickEvents. | |
virtual void | handleDragEvent(const DragEvent & event) |
Defines the event handler interface for DragEvents. | |
float | indexToDataPointXAsFloat(int16_t index) const |
Get the data point x value for the given graph point index. | |
int | indexToDataPointXAsInt(int16_t index) const |
Get the data point x value for the given graph point index. | |
float | indexToDataPointYAsFloat(int16_t index) const |
Get the data point y value for the given graph point index. | |
int | indexToDataPointYAsInt(int16_t index) const |
Get the data point y value for the given graph point index. | |
virtual int32_t | indexToGlobalIndex(int16_t index) const |
Convert an index to global index. | |
int16_t | indexToScreenX(int16_t index) const |
Get the screen x coordinate for the given graph point index. | |
int16_t | indexToScreenY(int16_t index) const |
Get the screen y coordinate for the given graph point index. | |
void | setAlpha(uint8_t newAlpha) |
Sets the opacity (alpha value). | |
void | setClickAction(GenericCallback< const AbstractDataGraph &, const GraphClickEvent & > & callback) |
Sets an action to be executed when the graph is clicked. | |
void | setDragAction(GenericCallback< const AbstractDataGraph &, const GraphDragEvent & > & callback) |
Sets an action to be executed when the graph is dragged. | |
void | setGapBeforeIndex(int16_t index) |
Makes gap before the specified index. | |
void | setGraphAreaMargin(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. | |
void | setGraphAreaPadding(int16_t top, int16_t left, int16_t right, int16_t bottom) |
Adds some padding around the graph that will not be drawn in (apart from dots, boxes etc. | |
void | setGraphRange(int xMin, int xMax, float yMin, float yMax) |
Sets minimum and maximum x and y coordinate ranges for the graph. | |
void | setGraphRange(int xMin, int xMax, int yMin, int yMax) |
Sets minimum and maximum x and y coordinate ranges for the graph. | |
virtual void | setHeight(int16_t height) |
Sets the height of this drawable. | |
virtual void | setWidth(int16_t width) |
Sets the width of this drawable. | |
int | float2scaled(float f, int scale) |
Multiply a floating point value with a constant and round the result. | |
int | int2scaled(int i, int scale) |
Multiply an integer value with a constant. | |
float | scaled2float(int i, int scale) |
Divide a floating point number with a constant. | |
int | scaled2int(int i, int scale) |
Divide an integer with a constant and round the result. | |
Protected Functions inherited from AbstractDataGraph
int | convertToGraphScale(int value, int scale) const |
Converts a number with one scale to a number that has the same scale as the graph. | |
int | float2scaled(float f) const |
Same as float2scaled(float,int) using the graph's scale. | |
int | int2scaled(int i) const |
Same as int2scaled(int,int) using the graph's scale. | |
void | invalidateAllXAxisPoints() |
Invalidate all x axis points. | |
void | invalidateGraphArea() |
Invalidate entire graph area (the center of the graph). | |
void | invalidateGraphPointAt(int16_t index) |
Invalidate point at a given index. | |
void | invalidateXAxisPointAt(int16_t index) |
Invalidate x axis point at the given index. | |
float | scaled2float(int i) const |
Same as scaled2float(int,int) using the graph's scale. | |
int | scaled2int(int i) const |
Same as scaled2int(int,int) using the graph's scale. | |
void | setGraphRangeScaled(int xMin, int xMax, int yMin, int yMax) |
Same as setGraphRange(int,int,int,int) except the passed arguments are assumed scaled. | |
void | updateAreasPosition() |
Updates the position of all elements in all area after a change in size of the graph area and/or label padding. | |
Protected Attributes inherited from AbstractDataGraph
uint8_t | alpha |
The alpha of the entire graph. | |
Container | bottomArea |
The area below the graph. | |
int16_t | bottomPadding |
The graph area bottom padding. | |
GenericCallback< const AbstractDataGraph &, const GraphClickEvent & > * | clickAction |
The callback to be executed when this Graph is clicked. | |
int | dataScale |
The data scale applied to all values. | |
GenericCallback< const AbstractDataGraph &, const GraphDragEvent & > * | dragAction |
The callback to be executed when this Graph is dragged. | |
int16_t | gapBeforeIndex |
The graph is disconnected (there is a gap) before this element index. | |
Container | graphArea |
The graph area (the center area) | |
Container | leftArea |
The area to the left of the graph. | |
int16_t | leftPadding |
The graph area left padding. | |
int16_t | maxCapacity |
Maximum number of points in the graph. | |
Container | rightArea |
The area to the right of the graph. | |
int16_t | rightPadding |
The graph area right padding. | |
Container | topArea |
The area above the graph. | |
int16_t | topPadding |
The graph area top padding. | |
int16_t | usedCapacity |
The number of used points in the graph. | |
Public Functions inherited from Container
virtual void | add(Drawable & d) |
Adds a Drawable instance as child to this Container. | |
Container() | |
virtual bool | contains(const Drawable & d) |
Query if a given Drawable has been added directly to this Container. | |
virtual void | draw(const Rect & invalidatedArea) const |
Draw this drawable. | |
virtual void | forEachChild(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 void | getLastChild(int16_t x, int16_t y, Drawable ** last) |
Gets the last child in the list of children in this Container. | |
virtual Rect | getSolidRect() const |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual void | insert(Drawable * previous, Drawable & d) |
Inserts a Drawable after a specific child node. | |
virtual void | remove(Drawable & d) |
Removes a Drawable from the container by removing it from the linked list of children. | |
virtual void | removeAll() |
Removes all children in the Container by resetting their parent and sibling pointers. | |
virtual void | unlink() |
Removes all children by unlinking the first child. | |
Protected Functions inherited from Container
virtual Rect | getContainedArea() const |
Gets a rectangle describing the total area covered by the children of this container. | |
virtual void | moveChildrenRelative(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
virtual void | childGeometryChanged() |
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 void | draw(const Rect & invalidatedArea) const =0 |
Draw this drawable. | |
Drawable() | |
Initializes a new instance of the Drawable class. | |
void | drawToDynamicBitmap(BitmapId id) |
Render the Drawable object into a dynamic bitmap. | |
Rect | getAbsoluteRect() 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_t | getHeight() const |
Gets the height of this Drawable. | |
virtual void | getLastChild(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 Rect | getSolidRect() const =0 |
Get (the largest possible) rectangle that is guaranteed to be solid (opaque). | |
virtual Rect | getSolidRectAbsolute() |
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates. | |
virtual void | getVisibleRect(Rect & rect) const |
Function for finding the visible part of this drawable. | |
int16_t | getWidth() const |
Gets the width of this Drawable. | |
int16_t | getX() const |
Gets the x coordinate of this Drawable, relative to its parent. | |
int16_t | getY() const |
Gets the y coordinate of this Drawable, relative to its parent. | |
virtual void | handleClickEvent(const ClickEvent & event) |
Defines the event handler interface for ClickEvents. | |
virtual void | handleDragEvent(const DragEvent & event) |
Defines the event handler interface for DragEvents. | |
virtual void | handleGestureEvent(const GestureEvent & event) |
Defines the event handler interface for GestureEvents. | |
virtual void | handleTickEvent() |
Called periodically by the framework if the Drawable instance has subscribed to timer ticks. | |
virtual void | invalidate() const |
Tell the framework that this entire Drawable needs to be redrawn. | |
virtual void | invalidateRect(Rect & invalidatedArea) const |
Request that a region of this drawable is redrawn. | |
bool | isTouchable() const |
Gets whether this Drawable receives touch events or not. | |
bool | isVisible() const |
Gets whether this Drawable is visible. | |
virtual void | moveRelative(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | moveTo(int16_t x, int16_t y) |
Moves the drawable. | |
virtual void | setHeight(int16_t height) |
Sets the height of this drawable. | |
void | setPosition(const Drawable & drawable) |
Sets the position of the Drawable to the same as the given Drawable. | |
void | setPosition(int16_t x, int16_t y, int16_t width, int16_t height) |
Sets the size and position of this Drawable, relative to its parent. | |
void | setTouchable(bool touch) |
Controls whether this Drawable receives touch events or not. | |
void | setVisible(bool vis) |
Controls whether this Drawable should be visible. | |
virtual void | setWidth(int16_t width) |
Sets the width of this drawable. | |
void | setWidthHeight(const Bitmap & bitmap) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Drawable & drawable) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(const Rect & rect) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
void | setWidthHeight(int16_t width, int16_t height) |
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates). | |
virtual void | setX(int16_t x) |
Sets the x coordinate of this Drawable, relative to its parent. | |
void | setXY(const Drawable & drawable) |
Sets the x and y coordinates of this Drawable. | |
void | setXY(int16_t x, int16_t y) |
Sets the x and y coordinates of this Drawable, relative to its parent. | |
virtual void | setY(int16_t y) |
Sets the y coordinate of this Drawable, relative to its parent. | |
virtual void | translateRectToAbsolute(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. | |
Rect | rect |
The coordinates of this Drawable, relative to its parent. | |
bool | touchable |
True if this drawable should receive touch events. | |
bool | visible |
True if this drawable should be drawn. | |
Public Functions Documentation
AbstractDataGraphWithY
AbstractDataGraphWithY | ( | int16_t | capacity , | ||
int * | values | ||||
) |
Initializes a new instance of the AbstractDataGraphWithY class.
capacity | The capacity. |
values | Address where to store the y values of the graph. |
addDataPoint
int16_t addDataPoint | ( | float | y | ) | |
Adds a new data point to the end of the graph.
The part of the graph that is changed, is automatically redrawn (invalidated).
y | The new data point. |
The index of the just added value.
addDataPoint
int16_t addDataPoint | ( | int | y | ) | |
Adds a new data point to the end of the graph.
The part of the graph that is changed, is automatically redrawn (invalidated).
y | The new data point. |
The index of the just added value.
getGraphRangeXMax
virtual int getGraphRangeXMax | ( | ) | const |
Gets the maximum x coordinate for the graph.
The maximum x coordinate .
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeXMax
getGraphRangeXMin
virtual int getGraphRangeXMin | ( | ) | const |
Gets the minimum x coordinate for the graph.
The minimum x coordinate .
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeXMin
getGraphRangeYMaxAsFloat
virtual float getGraphRangeYMaxAsFloat | ( | ) | const |
Gets maximum y coordinate for the graph.
The maximum y coordinate.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMaxAsFloat
getGraphRangeYMaxAsInt
virtual int getGraphRangeYMaxAsInt | ( | ) | const |
Gets maximum y coordinate for the graph.
The maximum y coordinate.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMaxAsInt
getGraphRangeYMinAsFloat
virtual float getGraphRangeYMinAsFloat | ( | ) | const |
Gets minimum y coordinate for the graph.
The minimum y coordinate.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMinAsFloat
getGraphRangeYMinAsInt
virtual int getGraphRangeYMinAsInt | ( | ) | const |
Gets minimum y coordinate for the graph.
The minimum y coordinate.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMinAsInt
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).
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).
The x axis offset.
getXAxisScaleAsFloat
virtual float getXAxisScaleAsFloat | ( | ) | const |
Get x coordinate axis scale value.
This is the real x value increment between two data points added to the graph.
The x axis scale.
getXAxisScaleAsInt
virtual int getXAxisScaleAsInt | ( | ) | const |
Get x coordinate axis scale value.
This is the real x value increment between two data points added to the graph.
The x axis scale.
setGraphRangeX
virtual void setGraphRangeX | ( | int | min , | ||
int | max | ||||
) |
Sets minimum and maximum x coordinates for the graph.
This can be used to zoom in or out and only show parts of the graph.
min | The minimum x coordinate. |
max | The maximum x coordinate. |
Note
The graph as well as the area above and below are automatically redrawn (invalidated).
Reimplements: touchgfx::AbstractDataGraph::setGraphRangeX
setGraphRangeY
virtual void setGraphRangeY | ( | float | min , | ||
float | max | ||||
) |
Sets minimum and maximum y coordinates for the graph.
This can be used to zoom in or out and only show parts of the graph.
min | The minimum y coordinate. |
max | The maximum y coordinate. |
Note
The graph as well as the area to the left and to the right of the graph are automatically redrawn (invalidated)
Reimplements: touchgfx::AbstractDataGraph::setGraphRangeY
setGraphRangeY
virtual void setGraphRangeY | ( | int | min , | ||
int | max | ||||
) |
Sets minimum and maximum y coordinates for the graph.
This can be used to zoom in or out and only show parts of the graph.
min | The minimum y coordinate. |
max | The maximum y coordinate. |
Note
The graph as well as the area to the left and to the right of the graph are automatically redrawn (invalidated)
Reimplements: touchgfx::AbstractDataGraph::setGraphRangeY
setGraphRangeYAuto
void setGraphRangeYAuto | ( | bool | showXaxis =true, | ||
int | margin =0 | ||||
) |
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).
showXaxis | (Optional) True to ensure that the x axis is visible (default is true). |
margin | (Optional) The 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.
setScale
virtual void setScale | ( | int | scale | ) | |
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.
scale | The scaling factor. |
Note
Calling setScale after adding points to the graph has undefined behaviour. The scale should be set as the first thing before other settings of the graph is being set.
Reimplements: touchgfx::AbstractDataGraph::setScale
setXAxisOffset
virtual void setXAxisOffset | ( | float | offset | ) | |
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).
offset | The x axis offset. |
setXAxisOffset
virtual void setXAxisOffset | ( | int | offset | ) | |
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).
offset | The x axis offset. |
setXAxisScale
virtual void setXAxisScale | ( | float | scale | ) | |
Set x coordinate axis scale value.
This is the real x value increment between two data points added to the graph.
scale | The x axis scale. |
setXAxisScale
virtual void setXAxisScale | ( | int | scale | ) | |
Set x coordinate axis scale value.
This is the real x value increment between two data points added to the graph.
scale | The x axis scale. |
Protected Functions Documentation
addDataPointScaled
int16_t addDataPointScaled | ( | int | y | ) | |
Same as addDataPoint(int) except the passed argument is assumed scaled.
Adds a data point scaled.
y | The y coordinate. |
The index of the added data point.
addValue
virtual int16_t addValue | ( | int | value | ) | |
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).
value | The value to add to the array. |
The index of the newly added value.
Reimplemented by: touchgfx::DataGraphScroll::addValue, touchgfx::DataGraphWrapAndClear::addValue, touchgfx::DataGraphWrapAndOverwrite::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::DataGraphScroll::beforeAddValue, touchgfx::DataGraphWrapAndClear::beforeAddValue, touchgfx::DataGraphWrapAndOverwrite::beforeAddValue
getGraphRangeYMaxScaled
virtual int getGraphRangeYMaxScaled | ( | ) | const |
Gets maximum y coordinate for the graph.
The maximum y coordinate.
Note
The returned value is left scaled.For internal use.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMaxScaled
getGraphRangeYMinScaled
virtual int getGraphRangeYMinScaled | ( | ) | const |
Gets minimum y coordinate for the graph.
The minimum y coordinate.
Note
The returned value is left scaled.For internal use.
Reimplements: touchgfx::AbstractDataGraph::getGraphRangeYMinScaled
getXAxisOffsetScaled
virtual int getXAxisOffsetScaled | ( | ) | const |
Get x axis offset as a scaled value.
The x axis offset (left scaled).
Note
For internal use.
Reimplements: touchgfx::AbstractDataGraph::getXAxisOffsetScaled
getXAxisScaleScaled
virtual int getXAxisScaleScaled | ( | ) | const |
Get x axis scale as a scaled value.
The x axis scale (left scaled).
Note
For internal use.
Reimplements: touchgfx::AbstractDataGraph::getXAxisScaleScaled
indexToDataPointXScaled
virtual int indexToDataPointXScaled | ( | int16_t | index | ) | |
Same as indexToDataPointXAsInt(int16_t) except the returned value is left scaled.
index | Zero-based index of the data point. |
The data point x value scaled.
Note
For internal use.
Reimplements: touchgfx::AbstractDataGraph::indexToDataPointXScaled
indexToDataPointYScaled
virtual int indexToDataPointYScaled | ( | int16_t | index | ) | |
Same as indexToDataPointYAsInt(int16_t) except the returned value is left scaled.
index | Zero-based index of the data point. |
The data point y value scaled.
Note
For internal use.
Reimplements: touchgfx::AbstractDataGraph::indexToDataPointYScaled
indexToScreenXQ5
virtual CWRUtil::Q5 indexToScreenXQ5 | ( | int16_t | index | ) | |
Gets screen x coordinate for a specific data point added to the graph.
index | The index of the element to get the x coordinate for. |
The screen x coordinate for the specific data point.
Reimplements: touchgfx::AbstractDataGraph::indexToScreenXQ5
indexToScreenYQ5
virtual CWRUtil::Q5 indexToScreenYQ5 | ( | int16_t | index | ) | |
Gets screen y coordinate for a specific data point added to the graph.
index | The index of the element to get the y coordinate for. |
The screen x coordinate for the specific data point.
Reimplements: touchgfx::AbstractDataGraph::indexToScreenYQ5
realIndex
virtual int16_t realIndex | ( | int16_t | index | ) | |
Get the real index in the yValues array of the given index.
Normally this is just the 'i' but e.g. DataGraphScroll does not, for performance reasons.
index | Zero-based index. |
The index in the yValues array.
Reimplemented by: touchgfx::DataGraphScroll::realIndex
setGraphRangeYScaled
virtual void setGraphRangeYScaled | ( | int | min , | ||
int | max | ||||
) |
Same as setGraphRangeY(int,int) except the passed arguments are assumed scaled.
min | The minimum y coordinate. |
max | The maximum y coordinate. |
Note
For internal use.
Reimplements: touchgfx::AbstractDataGraph::setGraphRangeYScaled
setXAxisOffsetScaled
virtual void setXAxisOffsetScaled | ( | int | offset | ) | |
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).
offset | The x axis offset. |
Note
For internal use.
setXAxisScaleScaled
virtual void setXAxisScaleScaled | ( | int | scale | ) | |
Set x coordinate axis scale value using a pre-scaled value.
This is the real x value increment between two data points added to the graph.
scale | The x axis scale. |
Note
For internal use.
valueToScreenXQ5
virtual CWRUtil::Q5 valueToScreenXQ5 | ( | int | x | ) | |
Gets screen x coordinate for an absolute value.
x | The x value. |
The screen x coordinate for the given value.
Reimplements: touchgfx::AbstractDataGraph::valueToScreenXQ5
valueToScreenYQ5
virtual CWRUtil::Q5 valueToScreenYQ5 | ( | int | y | ) | |
Gets screen y coordinate for an absolute value.
y | The y value. |
The screen y coordinate for the given value.
Reimplements: touchgfx::AbstractDataGraph::valueToScreenYQ5
xScreenRangeToIndexRange
virtual bool xScreenRangeToIndexRange | ( | int16_t | xLo , | const | |
int16_t | xHi , | const | |||
int16_t & | indexLow , | const | |||
int16_t & | indexHigh | const | |||
) | const |
Gets index range for screen x coordinate range taking the current graph range into account.
xLo | The low screen x coordinate. |
xHi | The high screen x coordinate. |
indexLow | The low element index. |
indexHigh | The high element index. |
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.
xOffset
int xOffset
The x axis offset (real value of data point at index 0)
xScale
int xScale
The x axis scale (increment between two data points)
yValues
int * yValues
The values of the graph.