Shellminator V3.0.1
Simple Terminal
|
This class can create a simple plotter object. More...
#include <Shellminator-PlotModule.hpp>
Public Member Functions | |
ShellminatorPlot () | |
Empty constructor. More... | |
ShellminatorPlot (float *data_p, int dataSize_p, const char *name_p, int color_p=Shellminator::GREEN) | |
Constructor for user calculated float array. More... | |
void | init (Shellminator *parent_p, Stream *channel_p) override |
Init function. More... | |
void | draw (bool noClear=false) override |
Draw function. More... | |
void | update (int width_p, int height_p) override |
Update function. More... | |
void | forceRedraw () override |
void | setColor (Shellminator::textColor_t color_p) |
Set the color of the plot. More... | |
void | setName (const char *name_p) |
Set the name of the plot. More... | |
![]() | |
virtual void | draw (bool noClear=false) |
Draw function. More... | |
virtual void | init (Shellminator *parent_p, Stream *channel_p) |
Init function. More... | |
virtual void | setOrigin (int x, int y) |
Origin of the top left corner. More... | |
virtual void | update (int width_p, int height_p) |
Update function. More... | |
virtual void | forceRedraw () |
int | left () |
Return the coordinate of the left column next to the object. More... | |
int | right () |
Return the coordinate of the right column next to the object. More... | |
int | up () |
Return the coordinate of the upper row next to the object. More... | |
int | down () |
Return the coordinate of the lower row next to the object. More... | |
Shellminator * | getParent () |
void | attachEndFunction (void(*end_func_p)(Shellminator *)) |
void | removeEndFunction () |
Private Member Functions | |
virtual void | drawScale () |
Draw the scale for the plot. More... | |
virtual void | drawPlot () |
Draw the plot data. More... | |
float | lerp (float v0, float v1, float t) |
Linear interpolation. More... | |
float | mapFloat (float x, float inStart, float inStop, float outStart, float outStop) |
Floating point implementation of the map function. More... | |
Private Attributes | |
float * | data = NULL |
Pointer to the data array. More... | |
int | dataSize = 0 |
Size of the data array in elements. More... | |
bool | redraw = true |
unsigned long | plotTimerStart |
int | plotRedrawPeriod |
const char * | name = NULL |
Plot name. More... | |
int | color = Shellminator::GREEN |
Color code for the plot. More... | |
char | valueTextBuffer [15] |
This buffer holds a generated string that us used to print numbers to the scale. More... | |
int | valueTextSizeMax = 0 |
This variable holds the size of the largest element generated in the valueTextBuffer. More... | |
int | resultTextSize = 0 |
This variable holds the size of the last elements text. More... | |
float | min |
Holds the minimum value in the data array. More... | |
float | max |
Holds the maximum value in the data array. More... | |
Static Private Attributes | |
static const char | clearCell [2] = " " |
static const char | dotCell [5] = "\u2022" |
Additional Inherited Members | |
![]() | |
int | row = 1 |
It is used by the grid layout. More... | |
int | column = 1 |
It is used by the grid layout. More... | |
int | columnSpan = 1 |
It is used by the grid layout. More... | |
int | rowSpan = 1 |
It is used by the grid layout. More... | |
ShellminatorScreen * | nextElement = NULL |
It is used by the grid layout. More... | |
void(*)(Shellminator *) | getEndFunction () |
![]() | |
Shellminator * | parent = NULL |
Pointer to the caller terminal object. More... | |
Stream * | channel = NULL |
int | width = 1 |
Actual width of the object. More... | |
int | height = 1 |
Actual height of the object. More... | |
int | originX = 1 |
X coordinate of the origin. More... | |
int | originY = 1 |
Y coordinate of the origin. More... | |
void(* | end_func )(Shellminator *) = NULL |
This class can create a simple plotter object.
With this class, you can easily create a plotter object, which is capable of real time plotting. It can be attached to the main terminal with the beginScreen function.
Definition at line 63 of file Shellminator-PlotModule.hpp.
ShellminatorPlot::ShellminatorPlot | ( | ) |
Empty constructor.
Definition at line 44 of file Shellminator-PlotModule.cpp.
ShellminatorPlot::ShellminatorPlot | ( | float * | data_p, |
int | dataSize_p, | ||
const char * | name_p, | ||
int | color_p = Shellminator::GREEN |
||
) |
Constructor for user calculated float array.
With this constructor you can create a plotter object which is using a user created dataset.
data_p | Pointer to a float array, which contains the data points to be printed. |
dataSize_p | The size of the float array in elements( NOT IN BYTES! ). |
name_p | The name of the plot. |
color_p | Optionally, you can specify the color of the plot. Available colors: *Shellminator::RED *Shellminator::GREEN *Shellminator::WHITE |
Definition at line 36 of file Shellminator-PlotModule.cpp.
|
overridevirtual |
Draw function.
This function is called by the caller terminal if redraw is requested. If you need to draw your screen, the requestRedraw function must be called on the parent terminal object. The reason for this is to save some CPU time and do not waste it to draw something unnecessarily.
Reimplemented from ShellminatorScreen.
Definition at line 89 of file Shellminator-PlotModule.cpp.
|
privatevirtual |
Draw the plot data.
This function renders the data points from the data array. It can be overriden to create different kinds of plots.
Definition at line 326 of file Shellminator-PlotModule.cpp.
|
privatevirtual |
Draw the scale for the plot.
The scale is on the left side with this implementation. It can be overriden to create different kinds of plots.
Definition at line 202 of file Shellminator-PlotModule.cpp.
|
overridevirtual |
Reimplemented from ShellminatorScreen.
Definition at line 415 of file Shellminator-PlotModule.cpp.
|
overridevirtual |
Init function.
This function is called by the host terminal, when the plot object gets registered to it. You can put all the initialisation section here.
parent_p | Pointer to the caller terminal object. |
channel_p | This is a pointer to a Stream object, which can be used to print the output data. |
channel_p
object instead of parent -> channel
method. This object can be a regular channel or a buffer accelerated one. The logic behind the buffering and flushing is handled by the caller terminal. Reimplemented from ShellminatorScreen.
Definition at line 51 of file Shellminator-PlotModule.cpp.
|
private |
Linear interpolation.
Original source
v0 | First corner value. |
v1 | Second corner value. |
t | Control value between 0.0 and 1.0. |
Definition at line 315 of file Shellminator-PlotModule.cpp.
|
private |
Floating point implementation of the map function.
Definition at line 319 of file Shellminator-PlotModule.cpp.
void ShellminatorPlot::setColor | ( | Shellminator::textColor_t | color_p | ) |
Set the color of the plot.
With this function, you can set the color of the plot.
color_p | Specify a color from Shellminator::textColor_t enumeration. |
Definition at line 411 of file Shellminator-PlotModule.cpp.
void ShellminatorPlot::setName | ( | const char * | name_p | ) |
Set the name of the plot.
name_p | The name of the plot. |
Definition at line 419 of file Shellminator-PlotModule.cpp.
|
overridevirtual |
Update function.
The update function must be used to process events and not to draw the objects. It is called much frequently than, the draw function. All the event handling should be done in the update function, including key and mouse detection along with various events.
width_p | The width of the screen area in characters. |
height_p | The height of the screen area in characters. |
Reimplemented from ShellminatorScreen.
Definition at line 57 of file Shellminator-PlotModule.cpp.
|
staticprivate |
Definition at line 178 of file Shellminator-PlotModule.hpp.
|
private |
Color code for the plot.
Definition at line 146 of file Shellminator-PlotModule.hpp.
|
private |
Pointer to the data array.
Definition at line 132 of file Shellminator-PlotModule.hpp.
|
private |
Size of the data array in elements.
Definition at line 135 of file Shellminator-PlotModule.hpp.
|
staticprivate |
Definition at line 179 of file Shellminator-PlotModule.hpp.
|
private |
Holds the maximum value in the data array.
Definition at line 176 of file Shellminator-PlotModule.hpp.
|
private |
Holds the minimum value in the data array.
Definition at line 173 of file Shellminator-PlotModule.hpp.
|
private |
Plot name.
Definition at line 143 of file Shellminator-PlotModule.hpp.
|
private |
Definition at line 140 of file Shellminator-PlotModule.hpp.
|
private |
Definition at line 139 of file Shellminator-PlotModule.hpp.
|
private |
Definition at line 137 of file Shellminator-PlotModule.hpp.
|
private |
This variable holds the size of the last elements text.
Definition at line 170 of file Shellminator-PlotModule.hpp.
|
private |
This buffer holds a generated string that us used to print numbers to the scale.
Definition at line 162 of file Shellminator-PlotModule.hpp.
|
private |
This variable holds the size of the largest element generated in the valueTextBuffer.
Definition at line 166 of file Shellminator-PlotModule.hpp.