Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ActivityLed Class Reference

Operates an LED to visually display some activity. More...

#include <ActivityLed.hxx>

Inheritance diagram for ActivityLed:
Timer

Public Member Functions

 ActivityLed (Service *service, const Gpio *pin, long long period=MSEC_TO_NSEC(33))
 Constructor.
 
void activity ()
 Call this function when activity happens.
 

Private Member Functions

long long timeout () override
 Clients of timer should override this function.
 
- Private Member Functions inherited from Timer
 Timer (ActiveTimers *timers)
 Constructor.
 
 ~Timer ()
 Destructor.
 
void run () override
 Callback from the executor when this timer is scheduled.
 
long long schedule_time ()
 
void start (long long period=-1)
 Starts a timer.
 
void start_absolute (long long expiry_time_nsec)
 Starts the timer with an absolute deadline.
 
void restart ()
 Restart a timer with the existing period but from the current time.
 
void trigger ()
 This will wakeup the timer prematurely, immediately.
 
void ensure_triggered ()
 Triggers the timer if it is not expired yet.
 
void cancel ()
 Dangerous, do not call.
 
bool is_triggered ()
 
void set_triggered ()
 Sets the timer as if it was woken up by a trigger(), even if it was never started.
 
void update_period (long long period)
 Updates the period, to be used after the next expiration of the timer in order to restart it.
 
- Private Member Functions inherited from Executable
void test_deletion ()
 
void notify () override
 Crashes the program – everyone who is expecting notify calls must override this function.
 
virtual void alloc_result (QMember *item)
 Return the result of an alloc_async() from a memory Pool.
 
- Private Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 

Private Attributes

const Gpiogpio_
 Output pin to blink for activity.
 
unsigned triggerCount_ {0}
 How many triggers happened since the last run of the timer.
 
- Private Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Additional Inherited Members

- Private Types inherited from Timer
enum  { NONE = 0 , RESTART = 1 , DELETE = -1 }
 Special return values from the timeout function. More...
 

Detailed Description

Operates an LED to visually display some activity.

When the activity() function is called at least once within a period, we turn the LED on for the next period, if no call was made, the LED turns off for the next period.

Definition at line 45 of file ActivityLed.hxx.

Constructor & Destructor Documentation

◆ ActivityLed()

ActivityLed::ActivityLed ( Service service,
const Gpio pin,
long long  period = MSEC_TO_NSEC(33) 
)
inline

Constructor.

Parameters
servicedefines which executor this timer should be running on.
pinthe LED of the output. Will be high for activity, low for inactivity. Use InvertedGPIO if needed.
perioddefines in nanosecond the time to spend between updates.

Definition at line 53 of file ActivityLed.hxx.

Member Function Documentation

◆ activity()

void ActivityLed::activity ( )
inline

Call this function when activity happens.

Definition at line 62 of file ActivityLed.hxx.

◆ timeout()

long long ActivityLed::timeout ( )
inlineoverrideprivatevirtual

Clients of timer should override this function.

It will be called on the executor of the timer.

Returns
the new timer period, or one of the above special values.

Implements Timer.

Definition at line 68 of file ActivityLed.hxx.

Member Data Documentation

◆ gpio_

const Gpio* ActivityLed::gpio_
private

Output pin to blink for activity.

Definition at line 83 of file ActivityLed.hxx.

◆ triggerCount_

unsigned ActivityLed::triggerCount_ {0}
private

How many triggers happened since the last run of the timer.

Definition at line 85 of file ActivityLed.hxx.


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