PropWare  3.0.0.224
C++ objects and CMake build system for Parallax Propeller
Public Member Functions | List of all members
PropWare::SynchronousPrinter Class Reference

Print formatted text to a serial terminal, an LCD, or any other device from any cog at any time with no worries about contention. More...

#include <PropWare/hmi/output/synchronousprinter.h>

Public Member Functions

 SynchronousPrinter (const Printer &printer)
 Creates a synchronous instance of a Printer that can be used from multiple cogs simultaneously. More...
 
 ~SynchronousPrinter ()
 Ensure that, when a SynchronousPrinter is no longer being used, the lock is returned.
 
bool has_lock () const
 Determine if an instance of a SynchronousPrinter successfully retrieved a lock. More...
 
bool refreshLock ()
 Retrieve a new lock. More...
 
const Printerborrow_printer ()
 Retrieve the printer and acquire the lock. Useful when a class that only supports Printer and not SynchronousPrinter needs to print. More...
 
bool return_printer (const Printer *printer)
 After calling SynchronousPrinter::borrow_printer, this method.
 
template<typename T >
void print (const T var) const
 
void println (const char string[]) const
 Print a string along with a newline at the end. More...
 
void printf (const char fmt[]) const
 
template<typename T , typename... Targs>
void printf (const char fmt[], const T first, const Targs... remaining) const
 

Detailed Description

Print formatted text to a serial terminal, an LCD, or any other device from any cog at any time with no worries about contention.

Warning
SynchronousPrinter is only software - it can not magically introduce a pull-up resistor on the TX line as is needed for synchronous printing by various Propeller boards, including the Quickstart.

Definition at line 39 of file synchronousprinter.h.

Constructor & Destructor Documentation

◆ SynchronousPrinter()

PropWare::SynchronousPrinter::SynchronousPrinter ( const Printer printer)

Creates a synchronous instance of a Printer that can be used from multiple cogs simultaneously.

Parameters
*printerAddress of an instance of a PropWare::Printer device that can be shared across multiple cogs

Definition at line 47 of file synchronousprinter.h.

Member Function Documentation

◆ borrow_printer()

const Printer* PropWare::SynchronousPrinter::borrow_printer ( )

Retrieve the printer and acquire the lock. Useful when a class that only supports Printer and not SynchronousPrinter needs to print.

Returns
Instance of the printer. The invoked instance of SynchronousPrinter will remain locked until SynchronousPrinter::return_printer() is called

Definition at line 97 of file synchronousprinter.h.

◆ has_lock()

bool PropWare::SynchronousPrinter::has_lock ( ) const

Determine if an instance of a SynchronousPrinter successfully retrieved a lock.

Returns
True when a lock has been retrieved successfully, false otherwise
Examples
SynchronousPrinter_Demo.cpp.

Definition at line 66 of file synchronousprinter.h.

+ Here is the caller graph for this function:

◆ print()

template<typename T >
void PropWare::SynchronousPrinter::print ( const T  var) const
See also
PropWare::Printer::print

Definition at line 119 of file synchronousprinter.h.

+ Here is the call graph for this function:

◆ printf() [1/2]

void PropWare::SynchronousPrinter::printf ( const char  fmt[]) const
See also
PropWare::Printer::printf(const char fmt[])
Examples
Runnable_Demo.cpp, SynchronousPrinter_Demo.cpp, and UARTRX_Demo.cpp.

Definition at line 139 of file synchronousprinter.h.

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

◆ printf() [2/2]

template<typename T , typename... Targs>
void PropWare::SynchronousPrinter::printf ( const char  fmt[],
const T  first,
const Targs...  remaining 
) const
See also
PropWare::Printer::printf(const char fmt[], const T first, Targs... remaining)

Definition at line 149 of file synchronousprinter.h.

+ Here is the call graph for this function:

◆ println()

void PropWare::SynchronousPrinter::println ( const char  string[]) const

Print a string along with a newline at the end.

Parameters
[in]string[]String to be printed

Definition at line 130 of file synchronousprinter.h.

+ Here is the call graph for this function:

◆ refreshLock()

bool PropWare::SynchronousPrinter::refreshLock ( )

Retrieve a new lock.

If this instance already has a lock, the call will block until the lock has been cleared. The lock will then be returned and a new lock will be retrieved.

Returns
True if the instance was able to successfully retrieve a new lock

Definition at line 78 of file synchronousprinter.h.

+ Here is the call graph for this function:

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