Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::Device Class Referenceabstract

Device Parent Class. More...

#include <system.hpp>

Inheritance diagram for sylib::Device:
sylib::Addrled sylib::Motor

Public Member Functions

 Device (int interval=2, int offset=0)
 Creates a Device object. More...
 
 ~Device ()
 
void resumeSubTask ()
 Resumes the device update function. More...
 
void pauseSubTask ()
 Pauses the device update function. More...
 
void killSubTask ()
 Permanently ends the device update function. More...
 
bool isSubTaskRunning ()
 Gets whether or not the device update function is running. More...
 
int getUpdateFrequency ()
 Gets the number of frames delayed between updates. More...
 
int getUpdateOffset ()
 Gets the number of frames the update function is offset by. More...
 
void setUpdateFrequency (int interval)
 Sets the number of frames to wait between updates. More...
 
void setUpdateOffset (int offset)
 Sets the number of frames to shift the excecution of the update function. More...
 
int getSubTaskID ()
 Gets the subtask ID of the device's update function. More...
 
virtual void update ()=0
 Default device update function. This is overridden by classes that inherit from Device for their own specific needs. More...
 
bool getSubTaskPaused ()
 Gets whether or not the device update function is paused. More...
 

Public Attributes

sylib::Mutex mutex
 Mutex to prevent multiple threads from performing operations on important system things at once. More...
 

Detailed Description

Device Parent Class.

Motor and Addrled objects derive from this

Constructor & Destructor Documentation

◆ Device()

sylib::Device::Device ( int  interval = 2,
int  offset = 0 
)

Creates a Device object.

Parameters
intervalThe number of frames to wait between updates. A frame is 2ms, so this value multiplied by 2 is the approximate time between updates. It can be off by +/- 1ms
offsetThe number of frames to shift the excecution of the update function

◆ ~Device()

sylib::Device::~Device ( )

Member Function Documentation

◆ getSubTaskID()

int sylib::Device::getSubTaskID ( )

Gets the subtask ID of the device's update function.

Returns
ID number

◆ getSubTaskPaused()

bool sylib::Device::getSubTaskPaused ( )

Gets whether or not the device update function is paused.

Returns
True or False

◆ getUpdateFrequency()

int sylib::Device::getUpdateFrequency ( )

Gets the number of frames delayed between updates.

Returns
Sylib frame count

◆ getUpdateOffset()

int sylib::Device::getUpdateOffset ( )

Gets the number of frames the update function is offset by.

Returns
Sylib frame count

◆ isSubTaskRunning()

bool sylib::Device::isSubTaskRunning ( )

Gets whether or not the device update function is running.

Returns
True or False

◆ killSubTask()

void sylib::Device::killSubTask ( )

Permanently ends the device update function.

◆ pauseSubTask()

void sylib::Device::pauseSubTask ( )

Pauses the device update function.

◆ resumeSubTask()

void sylib::Device::resumeSubTask ( )

Resumes the device update function.

◆ setUpdateFrequency()

void sylib::Device::setUpdateFrequency ( int  interval)

Sets the number of frames to wait between updates.

Parameters
intervalSylib frame count

◆ setUpdateOffset()

void sylib::Device::setUpdateOffset ( int  offset)

Sets the number of frames to shift the excecution of the update function.

Parameters
intervalSylib frame count

◆ update()

virtual void sylib::Device::update ( )
pure virtual

Default device update function. This is overridden by classes that inherit from Device for their own specific needs.

Implemented in sylib::Addrled, and sylib::Motor.

Member Data Documentation

◆ mutex

sylib::Mutex sylib::Device::mutex

Mutex to prevent multiple threads from performing operations on important system things at once.