HiveMind
Public Member Functions | Private Member Functions | Private Attributes | List of all members
UserInterface Class Reference

#include <UserInterface.h>

Inheritance diagram for UserInterface:
Inheritance graph
Collaboration diagram for UserInterface:
Collaboration graph

Public Member Functions

 UserInterface (const IBSP &bsp)
 
 ~UserInterface () override=default
 
Mutex & getPrintMutex () override
 get the mutex for printing. Note that the mutex is not used in any functions, the user needs to lock and unlock this mutex More...
 
void flush () override
 Adds a newline and flushes the input to the serial port. More...
 
int print (const char *format,...) override
 Provides an interface to print to the console or serial port. The arguments and return values match the standard printf library. A flush needs to be called after this function. More...
 
int print (const char *format, va_list args) override
 Provides an interface to print to the console or serial port using an initialized va_list. The return value matches the standard printf library. A flush needs to be called after this function. More...
 
int printLine (const char *format,...) override
 Provides an interface to print a line to the console or serial port. Flushes the input and adds a newline. The arguments and return values match the standard printf library. More...
 
int printLine (const char *format, va_list args) override
 Provides an interface to print to the console or serial port using an initialized va_list. Flushes the input and adds a newline. The return value matches the standard printf library. More...
 
void setRGBLed (RgbColor color) override
 Sets the RGB LED to a given color. More...
 
void setLed (LED led, bool state) override
 Sets an LED on or off. More...
 
void setHexDisplay (uint8_t value) override
 Sets the hex display to a given 8 bit value (not available on the HiveSight) More...
 
void setButtonCallback (Button button, buttonCallbackFunction_t callback, void *context) override
 Sets the callback associated with a given button press. More...
 
- Public Member Functions inherited from IUserInterface
virtual ~IUserInterface ()=default
 

Private Member Functions

std::string uiStateToString ()
 

Private Attributes

std::array< ros::Subscriber, g_nbrLEDm_buttonSubscribers
 
const IBSPm_bsp
 
std::string m_accumulatedString
 
Mutex m_mutex
 
UIState m_uiState
 

Constructor & Destructor Documentation

◆ UserInterface()

UserInterface::UserInterface ( const IBSP bsp)

◆ ~UserInterface()

UserInterface::~UserInterface ( )
overridedefault

Member Function Documentation

◆ flush()

void UserInterface::flush ( )
overridevirtual

Adds a newline and flushes the input to the serial port.

Implements IUserInterface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPrintMutex()

Mutex & UserInterface::getPrintMutex ( )
overridevirtual

get the mutex for printing. Note that the mutex is not used in any functions, the user needs to lock and unlock this mutex

Implements IUserInterface.

◆ print() [1/2]

int UserInterface::print ( const char *  format,
va_list  args 
)
overridevirtual

Provides an interface to print to the console or serial port using an initialized va_list. The return value matches the standard printf library. A flush needs to be called after this function.

Parameters
[in]formatText to be written, can contain format specifiers that will be replaced by values specified in the additional arguments, matches the standard printf function
[in]argsPreviously initialized va_list
Returns
Matches the standard printf return. The total number of characters is returned or a negative number on error

Implements IUserInterface.

◆ print() [2/2]

int UserInterface::print ( const char *  format,
  ... 
)
overridevirtual

Provides an interface to print to the console or serial port. The arguments and return values match the standard printf library. A flush needs to be called after this function.

Parameters
[in]formatText to be written, can contain format specifiers that will be replaced by values specified in the additional arguments, matches the standard printf function
[in]...Additionnal arguments for the format parameter
Returns
Matches the standard printf return. The total number of characters is returned or a negative number on error

Implements IUserInterface.

Here is the caller graph for this function:

◆ printLine() [1/2]

int UserInterface::printLine ( const char *  format,
va_list  args 
)
overridevirtual

Provides an interface to print to the console or serial port using an initialized va_list. Flushes the input and adds a newline. The return value matches the standard printf library.

Parameters
[in]formatText to be written, can contain format specifiers that will be replaced by values specified in the additional arguments, matches the standard printf function
[in]argsPreviously initialized va_list
Returns
Matches the standard printf return. The total number of characters is returned or a negative number on error

Implements IUserInterface.

Here is the call graph for this function:

◆ printLine() [2/2]

int UserInterface::printLine ( const char *  format,
  ... 
)
overridevirtual

Provides an interface to print a line to the console or serial port. Flushes the input and adds a newline. The arguments and return values match the standard printf library.

Parameters
[in]formatText to be written, can contain format specifiers that will be replaced by values specified in the additional arguments, matches the standard printf function
[in]...Additionnal arguments for the format parameter
Returns
Matches the standard printf return. The total number of characters is returned or a negative number on error

Implements IUserInterface.

◆ setButtonCallback()

void UserInterface::setButtonCallback ( Button  button,
buttonCallbackFunction_t  callback,
void *  context 
)
overridevirtual

Sets the callback associated with a given button press.

Parameters
buttonButton to register the callback on
callbackCallback to call
contextContext to pass to the callback

Implements IUserInterface.

◆ setHexDisplay()

void UserInterface::setHexDisplay ( uint8_t  value)
overridevirtual

Sets the hex display to a given 8 bit value (not available on the HiveSight)

Parameters
valueThe value to set

Implements IUserInterface.

◆ setLed()

void UserInterface::setLed ( LED  led,
bool  state 
)
overridevirtual

Sets an LED on or off.

Parameters
ledwich led to toggle
statewhich state to put the led (on or off)

Implements IUserInterface.

◆ setRGBLed()

void UserInterface::setRGBLed ( RgbColor  color)
overridevirtual

Sets the RGB LED to a given color.

Parameters
colorThe color to set

Implements IUserInterface.

◆ uiStateToString()

std::string UserInterface::uiStateToString ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_accumulatedString

std::string UserInterface::m_accumulatedString
private

◆ m_bsp

const IBSP& UserInterface::m_bsp
private

◆ m_buttonSubscribers

std::array<ros::Subscriber, g_nbrLED> UserInterface::m_buttonSubscribers
private

◆ m_mutex

Mutex UserInterface::m_mutex
private

◆ m_uiState

UIState UserInterface::m_uiState
private

The documentation for this class was generated from the following files: