Shellminator V3.0.1
Simple Terminal
Loading...
Searching...
No Matches
ShellminatorLevelMeter Class Reference

#include <Shellminator-Level-Meter.hpp>

Inheritance diagram for ShellminatorLevelMeter:
Collaboration diagram for ShellminatorLevelMeter:

Public Member Functions

 ShellminatorLevelMeter ()
 
 ShellminatorLevelMeter (const char *name_p)
 
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 setPercentage (float percentage_p)
 Set current percentage. More...
 
void setColor (Shellminator::textColor_t color_p)
 You can modify the color of the bar. More...
 
void setWarningColor (Shellminator::textColor_t color_p)
 You can modify the color of the bar. More...
 
void setErrorColor (Shellminator::textColor_t color_p)
 You can modify the color of the bar. More...
 
void setWarningPercentage (float percentage_p)
 You can set the percentage value for warning color. More...
 
void setErrorPercentage (float percentage_p)
 You can set the percentage value for error color. More...
 
- Public Member Functions inherited from ShellminatorScreen
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...
 
ShellminatorgetParent ()
 
void attachEndFunction (void(*end_func_p)(Shellminator *))
 
void removeEndFunction ()
 

Private Attributes

bool redraw = true
 This flag shows that redraw is necessary. More...
 
float percentage = 0
 
int warningPercentage = -1.0
 
int errorPercentage = -1.0
 
const char * name
 
int nameSize = 0
 
Shellminator::textColor_t color = Shellminator::WHITE
 
Shellminator::textColor_t warningColor = Shellminator::YELLOW
 
Shellminator::textColor_t errorColor = Shellminator::RED
 

Additional Inherited Members

- Public Attributes inherited from ShellminatorScreen
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...
 
ShellminatorScreennextElement = NULL
 It is used by the grid layout. More...
 
void(*)(Shellminator *) getEndFunction ()
 
- Protected Attributes inherited from ShellminatorScreen
Shellminatorparent = 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
 

Detailed Description

Definition at line 54 of file Shellminator-Level-Meter.hpp.

Constructor & Destructor Documentation

◆ ShellminatorLevelMeter() [1/2]

ShellminatorLevelMeter::ShellminatorLevelMeter ( )

Definition at line 37 of file Shellminator-Level-Meter.cpp.

◆ ShellminatorLevelMeter() [2/2]

ShellminatorLevelMeter::ShellminatorLevelMeter ( const char *  name_p)

Definition at line 41 of file Shellminator-Level-Meter.cpp.

Member Function Documentation

◆ draw()

void ShellminatorLevelMeter::draw ( bool  noClear = false)
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 103 of file Shellminator-Level-Meter.cpp.

Here is the call graph for this function:

◆ forceRedraw()

void ShellminatorLevelMeter::forceRedraw ( )
overridevirtual

Reimplemented from ShellminatorScreen.

Definition at line 289 of file Shellminator-Level-Meter.cpp.

◆ init()

void ShellminatorLevelMeter::init ( Shellminator parent_p,
Stream *  channel_p 
)
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.

Parameters
parent_pPointer to the caller terminal object.
channel_pThis is a pointer to a Stream object, which can be used to print the output data.
Note
Please use the 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 47 of file Shellminator-Level-Meter.cpp.

◆ setColor()

void ShellminatorLevelMeter::setColor ( Shellminator::textColor_t  color_p)

You can modify the color of the bar.

Definition at line 277 of file Shellminator-Level-Meter.cpp.

◆ setErrorColor()

void ShellminatorLevelMeter::setErrorColor ( Shellminator::textColor_t  color_p)

You can modify the color of the bar.

Definition at line 285 of file Shellminator-Level-Meter.cpp.

◆ setErrorPercentage()

void ShellminatorLevelMeter::setErrorPercentage ( float  percentage_p)

You can set the percentage value for error color.

Definition at line 98 of file Shellminator-Level-Meter.cpp.

◆ setPercentage()

void ShellminatorLevelMeter::setPercentage ( float  percentage_p)

Set current percentage.

Parameters
percentage_pPercentage value[ 0.0 - 100.0 ].

Definition at line 56 of file Shellminator-Level-Meter.cpp.

◆ setWarningColor()

void ShellminatorLevelMeter::setWarningColor ( Shellminator::textColor_t  color_p)

You can modify the color of the bar.

Definition at line 281 of file Shellminator-Level-Meter.cpp.

◆ setWarningPercentage()

void ShellminatorLevelMeter::setWarningPercentage ( float  percentage_p)

You can set the percentage value for warning color.

Definition at line 94 of file Shellminator-Level-Meter.cpp.

◆ update()

void ShellminatorLevelMeter::update ( int  width_p,
int  height_p 
)
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.

Parameters
width_pThe width of the screen area in characters.
height_pThe height of the screen area in characters.

Reimplemented from ShellminatorScreen.

Definition at line 69 of file Shellminator-Level-Meter.cpp.

Member Data Documentation

◆ color

Shellminator::textColor_t ShellminatorLevelMeter::color = Shellminator::WHITE
private

Definition at line 131 of file Shellminator-Level-Meter.hpp.

◆ errorColor

Shellminator::textColor_t ShellminatorLevelMeter::errorColor = Shellminator::RED
private

Definition at line 137 of file Shellminator-Level-Meter.hpp.

◆ errorPercentage

int ShellminatorLevelMeter::errorPercentage = -1.0
private

Definition at line 125 of file Shellminator-Level-Meter.hpp.

◆ name

const char* ShellminatorLevelMeter::name
private

Definition at line 127 of file Shellminator-Level-Meter.hpp.

◆ nameSize

int ShellminatorLevelMeter::nameSize = 0
private

Definition at line 128 of file Shellminator-Level-Meter.hpp.

◆ percentage

float ShellminatorLevelMeter::percentage = 0
private

Definition at line 121 of file Shellminator-Level-Meter.hpp.

◆ redraw

bool ShellminatorLevelMeter::redraw = true
private

This flag shows that redraw is necessary.

In this implementation redraw is only required when the screen is resized.

Definition at line 119 of file Shellminator-Level-Meter.hpp.

◆ warningColor

Shellminator::textColor_t ShellminatorLevelMeter::warningColor = Shellminator::YELLOW
private

Definition at line 134 of file Shellminator-Level-Meter.hpp.

◆ warningPercentage

int ShellminatorLevelMeter::warningPercentage = -1.0
private

Definition at line 123 of file Shellminator-Level-Meter.hpp.