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

This class can create a simple plotter object. More...

#include <Shellminator-Progress.hpp>

Inheritance diagram for ShellminatorProgress:
Collaboration diagram for ShellminatorProgress:

Public Member Functions

 ShellminatorProgress ()
 
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 setText (const char *text_p)
 Set progress text. More...
 
void setFormat (const char *format_p)
 Format options. More...
 
void setPercentage (float percentage_p)
 Set current percentage. More...
 
void setStep (int current, int total)
 Set current step. More...
 
void setColor (Shellminator::textColor_t color_p)
 You can modify the color of the bar. More...
 
void start ()
 Start trigger event. 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...
 
Shellminator::textColor_t color = Shellminator::WHITE
 
float percentage = 0.0
 
const char * text = NULL
 
const char * format = NULL
 
unsigned long timerStart = 0
 

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

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 60 of file Shellminator-Progress.hpp.

Constructor & Destructor Documentation

◆ ShellminatorProgress()

ShellminatorProgress::ShellminatorProgress ( )

Definition at line 36 of file Shellminator-Progress.cpp.

Member Function Documentation

◆ draw()

void ShellminatorProgress::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 46 of file Shellminator-Progress.cpp.

Here is the call graph for this function:

◆ forceRedraw()

void ShellminatorProgress::forceRedraw ( )
overridevirtual

Reimplemented from ShellminatorScreen.

Definition at line 375 of file Shellminator-Progress.cpp.

◆ init()

void ShellminatorProgress::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 40 of file Shellminator-Progress.cpp.

◆ setColor()

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

You can modify the color of the bar.

Definition at line 367 of file Shellminator-Progress.cpp.

◆ setFormat()

void ShellminatorProgress::setFormat ( const char *  format_p)

Format options.

You can specify a custom format to add some useful informations about the progress.

Parameters
format_pFormat string.

Format string option characters: -s : Seconds since start event. -m : Minutes since start event. -t : Time since start event[ mm:ss ]. -r : Estimated remaining time[ mm:ss ].

  • : Blank space will be printed. -| : Vertical separator will be printed.

For example this format ms| r will produce this string: 0m 3s | 01:30 left

Definition at line 346 of file Shellminator-Progress.cpp.

◆ setPercentage()

void ShellminatorProgress::setPercentage ( float  percentage_p)

Set current percentage.

Parameters
percentage_pPercentage value[ 0.0 - 100.0 ].

Definition at line 351 of file Shellminator-Progress.cpp.

◆ setStep()

void ShellminatorProgress::setStep ( int  current,
int  total 
)

Set current step.

Parameters
currentCurrent step index.
totalNumber of total steps.

Definition at line 363 of file Shellminator-Progress.cpp.

◆ setText()

void ShellminatorProgress::setText ( const char *  text_p)

Set progress text.

You can give some information about the current process step.

Parameters
text_pProgress text.

Definition at line 341 of file Shellminator-Progress.cpp.

◆ start()

void ShellminatorProgress::start ( )

Start trigger event.

Start event for timings.

Note
The timing functions will not work properly if this function is not called. The best practice is to call this function right before the progress start.

Definition at line 371 of file Shellminator-Progress.cpp.

◆ update()

void ShellminatorProgress::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 316 of file Shellminator-Progress.cpp.

Member Data Documentation

◆ color

Shellminator::textColor_t ShellminatorProgress::color = Shellminator::WHITE
private

Definition at line 151 of file Shellminator-Progress.hpp.

◆ format

const char* ShellminatorProgress::format = NULL
private

Definition at line 160 of file Shellminator-Progress.hpp.

◆ percentage

float ShellminatorProgress::percentage = 0.0
private

Definition at line 154 of file Shellminator-Progress.hpp.

◆ redraw

bool ShellminatorProgress::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 148 of file Shellminator-Progress.hpp.

◆ text

const char* ShellminatorProgress::text = NULL
private

Definition at line 157 of file Shellminator-Progress.hpp.

◆ timerStart

unsigned long ShellminatorProgress::timerStart = 0
private

Definition at line 163 of file Shellminator-Progress.hpp.